Main MRPT website > C++ reference for MRPT 1.9.9
CStream.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CSTREAM_H
10 #define CSTREAM_H
11 
12 #include <mrpt/utils/core_defs.h>
14 #include <mrpt/utils/exceptions.h>
15 #include <mrpt/utils/bits.h> // reverseBytesInPlace()
17 #include <mrpt/utils/variant.h>
18 
19 #include <mrpt/otherlibs/mapbox/variant.hpp>
20 #include <vector>
21 #include <type_traits> // remove_reference_t
22 
23 namespace mrpt
24 {
25 namespace utils
26 {
27 class CSerializable;
28 class CMessage;
29 
30 /** This base class is used to provide a unified interface to
31  * files,memory buffers,..Please see the derived classes. This class is
32  * largely inspired by Borland VCL "TStream" class. <br><br>
33  * Apart of the "VCL like" methods, operators ">>" and "<<" have been
34  * defined so that simple types (int,bool,char,float,char *,std::string,...)
35  * can be directly written and read to and from any CStream easily.
36  * Please, it is recomendable to read CSerializable documentation also.
37  *
38  * \ingroup mrpt_base_grp
39  * \sa CFileStream, CMemoryStream,CSerializable
40  */
41 class CStream
42 {
43  public:
44  /** Used in CStream::Seek */
46  {
50  };
51 
52  protected:
53  /** Introduces a pure virtual method responsible for reading from the
54  * stream. */
55  virtual size_t Read(void* Buffer, size_t Count) = 0;
56 
57  /** Introduces a pure virtual method responsible for writing to the stream.
58  * Write attempts to write up to Count bytes to Buffer, and returns the
59  * number of bytes actually written. */
60  virtual size_t Write(const void* Buffer, size_t Count) = 0;
61 
62  /** Read the object */
64  CSerializable* newObj, const std::string& className, bool isOldFormat,
65  int8_t version);
66 
67  /** Read the object Header*/
69  std::string& className, bool& isOldFormat, int8_t& version);
70 
71  public:
72  /* Constructor
73  */
74  CStream() {}
75  /* Destructor
76  */
77  virtual ~CStream();
78 
79  /** Reads a block of bytes from the stream into Buffer
80  * \exception std::exception On any error, or if ZERO bytes are read.
81  * \return The amound of bytes actually read.
82  * \note This method is endianness-dependent.
83  * \sa ReadBufferImmediate ; Important, see: ReadBufferFixEndianness,
84  */
85  size_t ReadBuffer(void* Buffer, size_t Count);
86 
87  /** Reads a sequence of elemental datatypes, taking care of reordering their
88  *bytes from the MRPT stream standard (little endianness) to the format of
89  *the running architecture.
90  * \param ElementCount The number of elements (not bytes) to read.
91  * \param ptr A pointer to the first output element in an array (or
92  *std::vector<>, etc...).
93  * \return The amound of *bytes* (not elements) actually read (under error
94  *situations, the last element may be invalid if the data stream abruptly
95  *ends).
96  * Example of usage:
97  * \code
98  * uint32_t N;
99  * s >> N;
100  * vector<float> vec(N);
101  * if (N)
102  * s.ReadBufferFixEndianness<float>(&vec[0],N);
103  * \endcode
104  * \exception std::exception On any error, or if ZERO bytes are read.
105  * \sa ReadBufferFixEndianness, ReadBuffer
106  */
107  template <typename T>
108  size_t ReadBufferFixEndianness(T* ptr, size_t ElementCount)
109  {
110 #if !MRPT_IS_BIG_ENDIAN
111  // little endian: no conversion needed.
112  return ReadBuffer(ptr, ElementCount * sizeof(T));
113 #else
114  // big endian: convert.
115  const size_t nread = ReadBuffer(ptr, ElementCount * sizeof(T));
116  for (size_t i = 0; i < ElementCount; i++)
118  return nread;
119 #endif
120  }
121 
122  /** Reads a block of bytes from the stream into Buffer, and returns the
123  *amound of bytes actually read, without waiting for more extra bytes to
124  *arrive (just those already enqued in the stream).
125  * Note that this method will fallback to ReadBuffer() in most CStream
126  *classes but in some hardware-related classes.
127  * \exception std::exception On any error, or if ZERO bytes are read.
128  */
129  virtual size_t ReadBufferImmediate(void* Buffer, size_t Count)
130  {
131  return ReadBuffer(Buffer, Count);
132  }
133 
134  /** Writes a block of bytes to the stream from Buffer.
135  * \exception std::exception On any error
136  * \sa Important, see: WriteBufferFixEndianness
137  * \note This method is endianness-dependent.
138  */
139  void WriteBuffer(const void* Buffer, size_t Count);
140 
141  /** Writes a sequence of elemental datatypes, taking care of reordering
142  * their bytes from the running architecture to MRPT stream standard (little
143  * endianness).
144  * \param ElementCount The number of elements (not bytes) to write.
145  * \param ptr A pointer to the first input element in an array (or
146  * std::vector<>, etc...).
147  * Example of usage:
148  * \code
149  * vector<float> vec = ...
150  * uint32_t N = vec.size();
151  * s << N
152  * if (N)
153  * s.WriteBufferFixEndianness<float>(&vec[0],N);
154  * \endcode
155  * \exception std::exception On any error
156  * \sa WriteBuffer
157  */
158  template <typename T>
159  void WriteBufferFixEndianness(const T* ptr, size_t ElementCount)
160  {
161 #if !MRPT_IS_BIG_ENDIAN
162  // little endian: no conversion needed.
163  return WriteBuffer(ptr, ElementCount * sizeof(T));
164 #else
165  // big endian: the individual "<<" functions already convert endiannes
166  for (size_t i = 0; i < ElementCount; i++) (*this) << ptr[i];
167 #endif
168  }
169 
170  /** Introduces a pure virtual method for moving to a specified position in
171  *the streamed resource.
172  * he Origin parameter indicates how to interpret the Offset parameter.
173  *Origin should be one of the following values:
174  * - sFromBeginning (Default) Offset is from the beginning of the
175  *resource. Seek moves to the position Offset. Offset must be >= 0.
176  * - sFromCurrent Offset is from the current position in the resource.
177  *Seek moves to Position + Offset.
178  * - sFromEnd Offset is from the end of the resource. Offset must
179  *be
180  *<= 0 to indicate a number of bytes before the end of the file.
181  * \return Seek returns the new value of the Position property.
182  */
183  virtual uint64_t Seek(
184  uint64_t Offset, CStream::TSeekOrigin Origin = sFromBeginning) = 0;
185 
186  /** Returns the total amount of bytes in the stream.
187  */
188  virtual uint64_t getTotalBytesCount() = 0;
189 
190  /** Method for getting the current cursor position, where 0 is the first
191  * byte and TotalBytesCount-1 the last one.
192  */
193  virtual uint64_t getPosition() = 0;
194 
195  /** Writes an object to the stream.
196  */
197  void WriteObject(const CSerializable* o);
198  void WriteObject(const CSerializable& o) { WriteObject(&o); }
199  /** Reads an object from stream, its class determined at runtime, and
200  * returns a smart pointer to the object.
201  * \exception std::exception On I/O error or undefined class.
202  * \exception mrpt::utils::CExceptionEOF On an End-Of-File condition found
203  * at a correct place: an EOF that abruptly finishes in the middle of one
204  * object raises a plain std::exception instead.
205  */
206 
207  CSerializable::Ptr ReadObject() { return ReadObject<CSerializable>(); }
208  /** Reads an object from stream, its class determined at runtime, and
209  * returns a smart pointer to the object. This version is similar to
210  * mrpt::make_aligned_shared<T>.
211  * \exception std::exception On I/O error or undefined class.
212  * \exception mrpt::utils::CExceptionEOF On an End-Of-File condition found
213  * at a correct place: an EOF that abruptly finishes in the middle of one
214  * object raises a plain std::exception instead.
215  */
216  template <typename T>
217  typename T::Ptr ReadObject()
218  {
220  std::string strClassName;
221  bool isOldFormat;
222  int8_t version;
223  internal_ReadObjectHeader(strClassName, isOldFormat, version);
224  if (strClassName != "nullptr")
225  {
226  const TRuntimeClassId* classId = findRegisteredClass(strClassName);
227  obj.reset(dynamic_cast<CSerializable*>(classId->createObject()));
228  }
230  obj.get() /* may be nullptr */, strClassName, isOldFormat,
231  version); // must be called to read the END FLAG byte
232  if (!obj)
233  {
234  return typename T::Ptr();
235  }
236  else
237  {
238  return std::dynamic_pointer_cast<T>(obj);
239  }
240  }
241 
242  private:
243  template <typename RET>
245  {
246  THROW_EXCEPTION("Can't match variant type");
247  return RET();
248  }
249 
250  template <typename RET, typename T, typename... R>
252  CSerializable::Ptr& ptr,
253  std::enable_if_t<is_shared_ptr<T>::value>* = nullptr)
254  {
255  if (IS_CLASS(ptr, typename T::element_type))
256  return std::dynamic_pointer_cast<typename T::element_type>(ptr);
257  return ReadVariant_helper<RET, R...>(ptr);
258  }
259 
260  template <typename RET, typename T, typename... R>
262  CSerializable::Ptr& ptr,
263  std::enable_if_t<!is_shared_ptr<T>::value>* = nullptr)
264  {
265  if (IS_CLASS(ptr, T)) return dynamic_cast<T&>(*ptr);
266  return ReadVariant_helper<RET, R...>(ptr);
267  }
268 
269  public:
270  /** Reads a variant from stream, its class determined at runtime, and
271  * returns a variant to the object.
272  * To be compatible with the current polymorphic system this support smart
273  * pointer types.
274  * For pointer types, This will bind to the first possible pointer type.
275  * variant<CSerializable::Ptr, CRenderizable::Ptr>
276  * \exception std::exception On I/O error or undefined class.
277  * \exception mrpt::utils::CExceptionEOF On an End-Of-File condition found
278  * at a correct place: an EOF that abruptly finishes in the middle of one
279  * object raises a plain std::exception instead.
280  */
281  template <typename... T>
283  {
285  std::string strClassName;
286  bool isOldFormat;
287  int8_t version;
288  internal_ReadObjectHeader(strClassName, isOldFormat, version);
289  const TRuntimeClassId* classId = findRegisteredClass(strClassName);
290  if (!classId)
292  "Stored object has class '%s' which is not registered!",
293  strClassName.c_str())
294  if (strClassName != "nullptr")
295  {
296  obj.reset(dynamic_cast<CSerializable*>(classId->createObject()));
297  }
298  internal_ReadObject(obj.get(), strClassName, isOldFormat, version);
299  if (!obj)
300  {
301  return mrpt::utils::variant<T...>();
302  }
303  else
304  {
305  return ReadVariant_helper<mrpt::utils::variant<T...>, T...>(obj);
306  }
307  }
308 
309  /** Writes a Variant to the stream.
310  */
311  template <typename T>
312  void WriteVariant(T t)
313  {
314  t.match([&](auto& o) { this->WriteObject(o); });
315  }
316 
317  /** Reads a simple POD type and returns by value. Useful when `stream >>
318  * var;`
319  * cannot be used becuase of errors of misaligned reference binding.
320  * Use with macro `MRPT_READ_POD` to avoid typing the type T yourself.
321  * \note [New in MRPT 2.0.0]
322  * \note Write operator `s << var;` is safe for misaligned variables.
323  */
324  template <typename T>
326  {
327  T ret;
328  ReadBufferFixEndianness(&ret, 1);
329  return ret;
330  }
331 
332  /** Reads an object from stream, where its class must be the same
333  * as the supplied object, where the loaded object will be stored in.
334  * \exception std::exception On I/O error or different class found.
335  * \exception mrpt::utils::CExceptionEOF On an End-Of-File condition found
336  * at a correct place: an EOF that abruptly finishes in the middle of one
337  * object raises a plain std::exception instead.
338  */
339  void ReadObject(CSerializable* existingObj);
340 
341  /** Write an object to a stream in the binary MRPT format. */
342  CStream& operator<<(const CSerializable::Ptr& pObj);
343  /** Write an object to a stream in the binary MRPT format. */
345 
348 
349  /** Read a value from a stream stored in a type different of the target
350  * variable, making the conversion via static_cast. Useful for coding
351  * backwards compatible de-serialization blocks */
352  template <typename STORED_TYPE, typename CAST_TO_TYPE>
353  void ReadAsAndCastTo(CAST_TO_TYPE& read_here)
354  {
355  STORED_TYPE var;
356  (*this) >> var;
357  read_here = static_cast<CAST_TO_TYPE>(var);
358  }
359 
360  /** Writes a string to the stream in a textual form.
361  * \sa CStdOutStream
362  */
363  virtual int printf(const char* fmt, ...)
364  MRPT_printf_format_check(2, 3); // The first argument (1) is "this" !!!
365 
366  /** Prints a vector in the format [A,B,C,...] using CStream::printf, and the
367  * fmt string for <b>each</b> vector element `T`.
368  * \tparam CONTAINER_TYPE can be any vector<T>, deque<T> or alike. */
369  template <typename CONTAINER_TYPE>
371  const char* fmt, const CONTAINER_TYPE& V, char separator = ',')
372  {
373  this->printf("[");
374  const size_t N = V.size();
375  for (size_t i = 0; i < N; i++)
376  {
377  this->printf(fmt, V[i]);
378  if (i != (N - 1)) this->printf("%c", separator);
379  }
380  this->printf("]");
381  }
382 
383  /** Send a message to the device.
384  * Note that only the low byte from the "type" field will be used.
385  *
386  * For frames of size < 255 the frame format is an array of bytes in this
387  * order:
388  * \code
389  * <START_FLAG> <HEADER> <LENGTH> <BODY> <END_FLAG>
390  * <START_FLAG> = 0x69
391  * <HEADER> = A header byte
392  * <LENGHT> = Number of bytes of BODY
393  * <BODY> = N x bytes
394  * <END_FLAG> = 0X96
395  * Total length = <LENGTH> + 4
396  * \endcode
397  *
398  * For frames of size > 255 the frame format is an array of bytes in this
399  * order:
400  * \code
401  * <START_FLAG> <HEADER> <HIBYTE(LENGTH)> <LOBYTE(LENGTH)> <BODY>
402  * <END_FLAG>
403  * <START_FLAG> = 0x79
404  * <HEADER> = A header byte
405  * <LENGHT> = Number of bytes of BODY
406  * <BODY> = N x bytes
407  * <END_FLAG> = 0X96
408  * Total length = <LENGTH> + 5
409  * \endcode
410  *
411  * \exception std::exception On communication errors
412  */
413  void sendMessage(const utils::CMessage& msg);
414 
415  /** Tries to receive a message from the device.
416  * \exception std::exception On communication errors
417  * \returns True if successful, false if there is no new data from the
418  * device (but communications seem to work fine)
419  * \sa The frame format is described in sendMessage()
420  */
421  bool receiveMessage(utils::CMessage& msg);
422 
423  /** Reads from the stream until a '\n' character is found ('\r' characters
424  * are ignored).
425  * \return false on EOF or any other read error.
426  */
427  bool getline(std::string& out_str);
428 
429 }; // End of class def.
430 
431 // Note: write op accepts parameters by value on purpose, to avoid misaligned
432 // reference binding errors.
433 #define DECLARE_CSTREAM_READ_WRITE_SIMPLE_TYPE(T) \
434  CStream& operator<<(mrpt::utils::CStream& out, const T a); \
435  CStream& operator>>(mrpt::utils::CStream& in, T& a);
436 
437 // Definitions:
449 #ifdef HAVE_LONG_DOUBLE
451 #endif
452 
453 #define MRPT_READ_POD(_STREAM, _VARIABLE) \
454  do \
455  { \
456  const std::remove_cv_t<std::remove_reference_t<decltype(_VARIABLE)>> \
457  val = _STREAM.ReadPOD<std::remove_cv_t< \
458  std::remove_reference_t<decltype(_VARIABLE)>>>(); \
459  ::memcpy(&_VARIABLE, &val, sizeof(val)); \
460  } while (0)
461 
462 // Why this shouldn't be templatized?: There's a more modern system
463 // in MRPT that serializes any kind of vector<T>, deque<T>, etc... but
464 // to keep COMPATIBILITY with old serialized objects we must preserve
465 // the ones listed here:
466 
467 // Write --------------------
468 CStream& operator<<(mrpt::utils::CStream& s, const char* a);
469 CStream& operator<<(mrpt::utils::CStream& s, const std::string& str);
470 
471 CStream& operator<<(mrpt::utils::CStream&, const vector_int& a);
472 CStream& operator<<(mrpt::utils::CStream&, const vector_uint& a);
473 CStream& operator<<(mrpt::utils::CStream&, const vector_word& a);
475 CStream& operator<<(mrpt::utils::CStream&, const vector_long& a);
476 CStream& operator<<(mrpt::utils::CStream&, const vector_byte& a);
478 
479 CStream& operator<<(mrpt::utils::CStream&, const vector_bool& a);
480 CStream& operator<<(mrpt::utils::CStream&, const std::vector<std::string>&);
481 
482 #if MRPT_WORD_SIZE != 32 // If it's 32 bit, size_t <=> uint32_t
483 CStream& operator<<(mrpt::utils::CStream&, const std::vector<size_t>& a);
484 #endif
485 
486 // Read --------------------
487 CStream& operator>>(mrpt::utils::CStream& in, char* a);
489 
498 
499 CStream& operator>>(mrpt::utils::CStream& in, std::vector<std::string>& a);
500 
501 // For backward compatibility, since in MRPT<0.8.1 vector_XXX and
502 // std::vector<XXX> were exactly equivalent, now there're not.
503 CStream& operator>>(mrpt::utils::CStream& s, std::vector<float>& a);
504 CStream& operator>>(mrpt::utils::CStream& s, std::vector<double>& a);
505 CStream& operator<<(mrpt::utils::CStream& s, const std::vector<float>& a);
506 CStream& operator<<(mrpt::utils::CStream& s, const std::vector<double>& a);
507 
508 #if MRPT_WORD_SIZE != 32 // If it's 32 bit, size_t <=> uint32_t
509 CStream& operator>>(mrpt::utils::CStream& s, std::vector<size_t>& a);
510 #endif
511 //
512 template <typename T, std::enable_if_t<std::is_base_of<
513  mrpt::utils::CSerializable, T>::value>* = nullptr>
515  mrpt::utils::CStream& in, typename std::shared_ptr<T>& pObj)
516 {
517  pObj = in.ReadObject<T>();
518  return in;
519 }
520 
521 template <typename... T>
524 {
525  pObj = in.ReadVariant<T...>();
526  return in;
527 }
528 
529 template <typename... T>
531  mrpt::utils::CStream& out, const typename mrpt::utils::variant<T...>& pObj)
532 {
533  pObj.match([&](auto& t) { out << t; });
534  return out;
535 }
536 
537 } // End of namespace
538 } // End of namespace
539 
540 #endif
virtual uint64_t getPosition()=0
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
void WriteObject(const CSerializable &o)
Definition: CStream.h:198
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
Definition: CStream.cpp:40
GLdouble GLdouble t
Definition: glext.h:3689
virtual size_t Read(void *Buffer, size_t Count)=0
Introduces a pure virtual method responsible for reading from the stream.
bool getline(std::string &out_str)
Reads from the stream until a &#39; &#39; character is found (&#39;&#39; characters are ignored). ...
Definition: CStream.cpp:780
unsigned __int16 uint16_t
Definition: rptypes.h:44
std::vector< uint32_t > vector_uint
Definition: types_simple.h:29
virtual size_t ReadBufferImmediate(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer, and returns the amound of bytes actually read...
Definition: CStream.h:129
std::vector< uint8_t > vector_byte
Definition: types_simple.h:27
TSeekOrigin
Used in CStream::Seek.
Definition: CStream.h:45
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
CStream & operator>>(CSerializable::Ptr &pObj)
Definition: CStream.cpp:214
void internal_ReadObjectHeader(std::string &className, bool &isOldFormat, int8_t &version)
Read the object Header.
Definition: CStream.cpp:420
#define THROW_EXCEPTION(msg)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CStream.cpp:64
T ReadPOD()
Reads a simple POD type and returns by value.
Definition: CStream.h:325
signed char int8_t
Definition: rptypes.h:40
mrpt::utils::variant< T... > ReadVariant()
Reads a variant from stream, its class determined at runtime, and returns a variant to the object...
Definition: CStream.h:282
GLdouble s
Definition: glext.h:3676
RET ReadVariant_helper(CSerializable::Ptr &ptr)
Definition: CStream.h:244
T::Ptr ReadObject()
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the obje...
Definition: CStream.h:217
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
std::vector< int8_t > vector_signed_byte
Definition: types_simple.h:22
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
std::vector< bool > vector_bool
A type for passing a vector of bools.
Definition: types_simple.h:31
unsigned char uint8_t
Definition: rptypes.h:41
std::vector< int64_t > vector_long
Definition: types_simple.h:25
virtual size_t Write(const void *Buffer, size_t Count)=0
Introduces a pure virtual method responsible for writing to the stream.
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
Definition: CStream.h:159
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
CSerializable::Ptr ReadObject()
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the obje...
Definition: CStream.h:207
mrpt::utils::CObject * createObject() const
Definition: CObject.cpp:93
__int16 int16_t
Definition: rptypes.h:43
#define DECLARE_CSTREAM_READ_WRITE_SIMPLE_TYPE(T)
Definition: CStream.h:433
virtual int void printf_vector(const char *fmt, const CONTAINER_TYPE &V, char separator=',')
Prints a vector in the format [A,B,C,...] using CStream::printf, and the fmt string for each vector e...
Definition: CStream.h:370
__int64 int64_t
Definition: rptypes.h:49
virtual uint64_t getTotalBytesCount()=0
Returns the total amount of bytes in the stream.
mapbox::util::variant< T... > variant
Definition: variant.h:18
void WriteObject(const CSerializable *o)
Writes an object to the stream.
Definition: CStream.cpp:158
CStream & operator<<(mrpt::utils::CStream &s, const char *a)
Definition: CStream.cpp:123
GLsizei const GLchar ** string
Definition: glext.h:4101
RET ReadVariant_helper(CSerializable::Ptr &ptr, std::enable_if_t<!is_shared_ptr< T >::value > *=nullptr)
Definition: CStream.h:261
std::shared_ptr< CSerializable > Ptr
Definition: CSerializable.h:47
const TRuntimeClassId * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or nullptr if the class is not registered.
__int32 int32_t
Definition: rptypes.h:46
unsigned __int64 uint64_t
Definition: rptypes.h:50
void ReadAsAndCastTo(CAST_TO_TYPE &read_here)
Read a value from a stream stored in a type different of the target variable, making the conversion v...
Definition: CStream.h:353
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool receiveMessage(utils::CMessage &msg)
Tries to receive a message from the device.
Definition: CStream.cpp:686
size_t ReadBufferFixEndianness(T *ptr, size_t ElementCount)
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream s...
Definition: CStream.h:108
const float R
void internal_ReadObject(CSerializable *newObj, const std::string &className, bool isOldFormat, int8_t version)
Read the object.
Definition: CStream.cpp:523
std::vector< uint16_t > vector_word
Definition: types_simple.h:28
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
Definition: CObject.h:103
std::vector< int16_t > vector_signed_word
Definition: types_simple.h:23
GLuint in
Definition: glext.h:7274
CStream & operator<<(const CSerializable::Ptr &pObj)
Write an object to a stream in the binary MRPT format.
Definition: CStream.cpp:201
void WriteVariant(T t)
Writes a Variant to the stream.
Definition: CStream.h:312
void sendMessage(const utils::CMessage &msg)
Send a message to the device.
Definition: CStream.cpp:649
This is useful for checking ::Ptr types.
Definition: CObject.h:125
RET ReadVariant_helper(CSerializable::Ptr &ptr, std::enable_if_t< is_shared_ptr< T >::value > *=nullptr)
Definition: CStream.h:251
std::vector< int32_t > vector_int
Definition: types_simple.h:24
GLsizei const GLfloat * value
Definition: glext.h:4117
CStream & operator>>(mrpt::utils::CStream &in, char *a)
Definition: CStream.cpp:407
virtual ~CStream()
Definition: CStream.cpp:35
A structure that holds runtime class type information.
Definition: CObject.h:31
void reverseBytesInPlace(bool &v_in_out)
Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) ...
unsigned __int32 uint32_t
Definition: rptypes.h:47
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
Definition: CMessage.h:31
virtual uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning)=0
Introduces a pure virtual method for moving to a specified position in the streamed resource...
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Definition: CStream.cpp:597



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019