Sync with 5.4.0
[deliverable/titan.core.git] / core / Textbuf.hh
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 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 #ifndef TEXTBUF_HH
9 #define TEXTBUF_HH
10
11 #include "Types.h"
12 #include "RInt.hh"
13
14 class Text_Buf {
15 private:
16 int buf_size; ///< amount of allocated memory
17 int buf_begin; ///< number of reserved bytes
18 int buf_pos; ///< read position into the payload
19 int buf_len; ///< number of payload bytes
20 void *data_ptr;
21
22 void Allocate(int size);
23 void Reallocate(int size);
24
25 boolean safe_pull_int(int_val_t& value);
26 /// Copy constructor disabled
27 Text_Buf(const Text_Buf&);
28 /// Assignment disabled
29 Text_Buf& operator=(const Text_Buf&);
30 public:
31 Text_Buf();
32 ~Text_Buf();
33
34 void reset();
35 inline void rewind() { buf_pos = buf_begin; }
36
37 inline int get_len() const { return buf_len; }
38 inline int get_pos() const { return buf_pos - buf_begin; }
39 inline void buf_seek(int new_pos) { buf_pos = buf_begin + new_pos; }
40 inline const char *get_data() const
41 { return (const char*)data_ptr + buf_begin; }
42
43 void push_int(const int_val_t& value);
44 void push_int(const RInt& value);
45 const int_val_t pull_int();
46
47 void push_double(double value);
48 double pull_double();
49
50 void push_raw(int len, const void *data);
51 void pull_raw(int len, void *data);
52
53 void push_string(const char *string_ptr);
54 char *pull_string();
55
56 void push_qualified_name(const qualified_name& name);
57 void pull_qualified_name(qualified_name& name);
58
59 void calculate_length();
60
61 void get_end(char*& end_ptr, int& end_len);
62 void increase_length(int add_len);
63 boolean is_message();
64 void cut_message();
65
66 };
67
68 #endif
This page took 0.039494 seconds and 5 git commands to generate.