character_buffer.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_DEVICES_BUFFER_HPP_
13 #define ECL_DEVICES_BUFFER_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <cstring>
20 
21 /*****************************************************************************
22 ** Namespaces
23 *****************************************************************************/
24 
25 namespace ecl {
26 namespace devices {
27 
28 /*****************************************************************************
29 ** Interface [CharBuffer]
30 *****************************************************************************/
39 class CharBuffer {
40 public:
41  /*********************
42  ** Static Variables
43  **********************/
44  static const unsigned int buffer_size = 4096;
45 
46  /*********************
47  ** C&D
48  **********************/
50  virtual ~CharBuffer() {}
51 
52  unsigned int remaining() { return ( buffer_size - fill_point_marker); }
53  unsigned int size() const { return fill_point_marker; }
54  bool full() const;
55  long append(const char &c);
56  long append(const char* s, unsigned long n);
57  void clear();
58  char* c_ptr() { return contents; }
59 
60 private:
61  /*********************
62  ** Variables
63  **********************/
64  unsigned int fill_point_marker; // Index pointing to where you would write the next char
66 };
67 
68 /*****************************************************************************
69 ** Interface [CharStringBuffer]
70 *****************************************************************************/
80 public:
81  /*********************
82  ** Static Variables
83  **********************/
84  static const unsigned int buffer_size = 4095; // Array is actually this + 1
85 
86  /*********************
87  ** C&D
88  **********************/
90  contents[buffer_size] = '\0';
91  }
92 
93  virtual ~CharStringBuffer() {}
94 
95  unsigned int remaining() { return ( buffer_size - fill_point_marker); }
96  bool full() const;
97  long append(const char &c);
98  long append(const char* s, unsigned long n);
99  const char* c_str();
100  void clear();
101 
102 private:
103  /*********************
104  ** Variables
105  **********************/
106  unsigned int fill_point_marker; // Index pointing to where you would write the next char
107  char contents[buffer_size+1];
108 };
109 
110 } // namespace devices
111 } // namespace ecl
112 
113 
114 #endif /* ECL_DEVICES_BUFFER_HPP_ */
unsigned int size() const
Embedded control libraries.
static const unsigned int buffer_size
char contents[buffer_size]
Simple char string buffer class for use internally by the devices.
Simple char string buffer class for use internally by the devices.
long append(const char &c)


ecl_devices
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:45