Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Forstner, Matyas | |
11 | * Kovacs, Ferenc | |
12 | * Raduly, Csaba | |
13 | * Szabo, Janos Zoltan – initial implementation | |
14 | * | |
15 | ******************************************************************************/ | |
970ed795 EL |
16 | #ifndef TEXTBUF_HH |
17 | #define TEXTBUF_HH | |
18 | ||
19 | #include "Types.h" | |
20 | #include "RInt.hh" | |
21 | ||
22 | class Text_Buf { | |
23 | private: | |
24 | int buf_size; ///< amount of allocated memory | |
25 | int buf_begin; ///< number of reserved bytes | |
26 | int buf_pos; ///< read position into the payload | |
27 | int buf_len; ///< number of payload bytes | |
28 | void *data_ptr; | |
29 | ||
30 | void Allocate(int size); | |
31 | void Reallocate(int size); | |
32 | ||
33 | boolean safe_pull_int(int_val_t& value); | |
34 | /// Copy constructor disabled | |
35 | Text_Buf(const Text_Buf&); | |
36 | /// Assignment disabled | |
37 | Text_Buf& operator=(const Text_Buf&); | |
38 | public: | |
39 | Text_Buf(); | |
40 | ~Text_Buf(); | |
41 | ||
42 | void reset(); | |
43 | inline void rewind() { buf_pos = buf_begin; } | |
44 | ||
45 | inline int get_len() const { return buf_len; } | |
46 | inline int get_pos() const { return buf_pos - buf_begin; } | |
47 | inline void buf_seek(int new_pos) { buf_pos = buf_begin + new_pos; } | |
48 | inline const char *get_data() const | |
49 | { return (const char*)data_ptr + buf_begin; } | |
50 | ||
51 | void push_int(const int_val_t& value); | |
52 | void push_int(const RInt& value); | |
53 | const int_val_t pull_int(); | |
54 | ||
55 | void push_double(double value); | |
56 | double pull_double(); | |
57 | ||
58 | void push_raw(int len, const void *data); | |
016a1a93 | 59 | void push_raw_front(int len, const void *data); |
970ed795 EL |
60 | void pull_raw(int len, void *data); |
61 | ||
62 | void push_string(const char *string_ptr); | |
63 | char *pull_string(); | |
64 | ||
65 | void push_qualified_name(const qualified_name& name); | |
66 | void pull_qualified_name(qualified_name& name); | |
67 | ||
68 | void calculate_length(); | |
69 | ||
70 | void get_end(char*& end_ptr, int& end_len); | |
71 | void increase_length(int add_len); | |
72 | boolean is_message(); | |
73 | void cut_message(); | |
74 | ||
75 | }; | |
76 | ||
77 | #endif |