devices/string.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_DEVICES_STRING_HPP_
13 #define ECL_DEVICES_STRING_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <string>
20 #include "traits.hpp"
21 #include "macros.hpp"
22 
23 /*****************************************************************************
24 ** Namespaces
25 *****************************************************************************/
26 
27 namespace ecl {
28 
29 /*****************************************************************************
30 ** Interface [String]
31 *****************************************************************************/
49 class ecl_devices_PUBLIC String {
50 public:
59  explicit String(const char* str = "");
65  virtual ~String();
66 
67  /*********************
68  ** String Interface
69  **********************/
78  const char* c_str();
87  std::string str();
94  void clear();
95 
96  /******************************************
97  ** Device Source Interface
98  *******************************************/
107  long read(char &c);
116  long read(char* s, unsigned long n);
125  unsigned long remaining();
126 
127  /******************************************
128  ** Device Sink Interface
129  *******************************************/
139  long write(char c);
151  long write(const char* s, unsigned long n);
152 
153  /******************************************
154  ** Device Seekable Interface
155  *******************************************/
165  unsigned long size();
172  void flush() {};
173 
174  /*********************
175  ** Device Interface
176  **********************/
185  bool open() { return true; };
194  bool isOpen() { return true; };
196 private:
197  unsigned long buffer_length; // Actual reserved memory is this +1
198  char *buffer;
199  char* buffer_cur_write;
200  char* buffer_cur_read;
210  void grow(int no_bytes = 256);
211 
212 };
213 
214 /*****************************************************************************
215 ** Traits
216 *****************************************************************************/
217 
223 template <>
224 class is_sink<String> : public True {};
225 
231 template <>
232 class is_source<String> : public True {};
233 
239 template <>
240 class is_sourcesink<String> : public True {};
241 
242 } // namespace ecl
243 
244 
245 #endif /* ECL_DEVICES_STRING_HPP_ */
#define ecl_devices_PUBLIC
Bool< true > True
ecl_geometry_PUBLIC int size(const Trajectory2D &trajectory)


xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:38