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
65  char contents[buffer_size];
66 };
67 
68 /*****************************************************************************
69 ** Interface [CharStringBuffer]
70 *****************************************************************************/
79 class CharStringBuffer {
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
108 };
109 
110 } // namespace devices
111 } // namespace ecl
112 
113 
114 #endif /* ECL_DEVICES_BUFFER_HPP_ */
ecl::devices::CharStringBuffer::remaining
unsigned int remaining()
Definition: character_buffer.hpp:109
ecl::devices::CharStringBuffer::~CharStringBuffer
virtual ~CharStringBuffer()
Definition: character_buffer.hpp:107
ecl::devices::CharStringBuffer
Simple char string buffer class for use internally by the devices.
Definition: character_buffer.hpp:91
ecl::devices::CharBuffer::fill_point_marker
unsigned int fill_point_marker
Definition: character_buffer.hpp:84
ecl::devices::CharStringBuffer::contents
char contents[buffer_size+1]
Definition: character_buffer.hpp:121
ecl::devices::CharBuffer::~CharBuffer
virtual ~CharBuffer()
Definition: character_buffer.hpp:70
ecl::devices::CharStringBuffer::fill_point_marker
unsigned int fill_point_marker
Definition: character_buffer.hpp:120
ecl::devices::CharBuffer::size
unsigned int size() const
Definition: character_buffer.hpp:73
ecl::devices::CharBuffer::c_ptr
char * c_ptr()
Definition: character_buffer.hpp:78
ecl::devices::CharBuffer::buffer_size
static const unsigned int buffer_size
Definition: character_buffer.hpp:64
ecl::devices::CharBuffer::clear
void clear()
Definition: character_buffer.cpp:67
ecl::devices::CharBuffer::full
bool full() const
Definition: character_buffer.cpp:34
ecl::devices::CharStringBuffer::full
bool full() const
Definition: character_buffer.cpp:76
ecl::devices::CharBuffer::CharBuffer
CharBuffer()
Definition: character_buffer.hpp:69
ecl::devices::CharBuffer::append
long append(const char &c)
Definition: character_buffer.cpp:42
ecl::devices::CharStringBuffer::c_str
const char * c_str()
Definition: character_buffer.cpp:113
ecl::devices::CharStringBuffer::CharStringBuffer
CharStringBuffer()
Definition: character_buffer.hpp:103
ecl::devices::CharStringBuffer::clear
void clear()
Definition: character_buffer.cpp:109
ecl::devices::CharStringBuffer::buffer_size
static const unsigned int buffer_size
Definition: character_buffer.hpp:98
ecl::devices::CharStringBuffer::append
long append(const char &c)
Definition: character_buffer.cpp:84
ecl::devices::CharBuffer::contents
char contents[buffer_size]
Definition: character_buffer.hpp:85
ecl
Embedded control libraries.
ecl::devices::CharBuffer::remaining
unsigned int remaining()
Definition: character_buffer.hpp:72


ecl_devices
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:45