Main MRPT website > C++ reference for MRPT 1.9.9
CArchive.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-2018, 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 #pragma once
10 
11 #include <cstdint>
12 #include <mrpt/config.h> // MRPT_IS_BIG_ENDIAN
16 #include <vector>
17 #include <string>
18 #include <type_traits> // remove_reference_t, is_polymorphic
19 #include <stdexcept>
21 
22 #include <variant>
23 namespace mrpt
24 {
25 namespace serialization
26 {
27 class CMessage;
28 
29 /** Used in mrpt::serialization::CArchive */
30 class CExceptionEOF : public std::runtime_error
31 {
32  public:
33  CExceptionEOF(const std::string& s) : std::runtime_error(s) {}
34 };
35 
36 /** Virtual base class for "archives": classes abstracting I/O streams.
37  * This class separates the implementation details of serialization (in
38  * CSerializable) and data storage (CArchive children: files, sockets,...).
39  *
40  * Two main sets of implementations are provided:
41  * - archiveFrom: for MRPT mrpt::io::CArchive objects, and
42  * - CArchiveStdIStream and CArchiveStdOStream: for std::istream and
43  * std::ostream, respectively.
44  *
45  * \sa mrpt::io::CArchive, mrpt::serialization::CSerializable
46  * \ingroup mrpt_serialization_grp
47  */
48 class CArchive
49 {
50  public:
51  CArchive() {}
52  virtual ~CArchive() {}
53  /** @name Serialization API for generic "archives" I/O streams
54  * @{ */
55  /** Reads a block of bytes from the stream into Buffer
56  * \exception std::exception On any error, or if ZERO bytes are read.
57  * \return The amound of bytes actually read.
58  * \note This method is endianness-dependent.
59  * \sa ReadBufferImmediate ; Important, see: ReadBufferFixEndianness,
60  */
61  size_t ReadBuffer(void* Buffer, size_t Count);
62 
63  /** Reads a sequence of elemental datatypes, taking care of reordering their
64  *bytes from the MRPT stream standard (little endianness) to the format of
65  *the running architecture.
66  * \param ElementCount The number of elements (not bytes) to read.
67  * \param ptr A pointer to the first output element in an array (or
68  *std::vector<>, etc...).
69  * \return The amound of *bytes* (not elements) actually read (under error
70  *situations, the last element may be invalid if the data stream abruptly
71  *ends).
72  * Example of usage:
73  * \code
74  * uint32_t N;
75  * s >> N;
76  * vector<float> vec(N);
77  * if (N)
78  * s.ReadBufferFixEndianness<float>(&vec[0],N);
79  * \endcode
80  * \exception std::exception On any error, or if ZERO bytes are read.
81  * \sa ReadBufferFixEndianness, ReadBuffer
82  */
83  template <typename T>
84  size_t ReadBufferFixEndianness(T* ptr, size_t ElementCount)
85  {
86 #if !MRPT_IS_BIG_ENDIAN
87  // little endian: no conversion needed.
88  return ReadBuffer(ptr, ElementCount * sizeof(T));
89 #else
90  // big endian: convert.
91  const size_t nread = ReadBuffer(ptr, ElementCount * sizeof(T));
92  for (size_t i = 0; i < ElementCount; i++)
94  return nread;
95 #endif
96  }
97 
98  /** Writes a block of bytes to the stream from Buffer.
99  * \exception std::exception On any error
100  * \sa Important, see: WriteBufferFixEndianness
101  * \note This method is endianness-dependent.
102  */
103  void WriteBuffer(const void* Buffer, size_t Count);
104 
105  /** Writes a sequence of elemental datatypes, taking care of reordering
106  * their bytes from the running architecture to MRPT stream standard (little
107  * endianness).
108  * \param ElementCount The number of elements (not bytes) to write.
109  * \param ptr A pointer to the first input element in an array (or
110  * std::vector<>, etc...).
111  * Example of usage:
112  * \code
113  * vector<float> vec = ...
114  * uint32_t N = vec.size();
115  * s << N
116  * if (N)
117  * s.WriteBufferFixEndianness<float>(&vec[0],N);
118  * \endcode
119  * \exception std::exception On any error
120  * \sa WriteBuffer
121  */
122  template <typename T>
123  void WriteBufferFixEndianness(const T* ptr, size_t ElementCount)
124  {
125 #if !MRPT_IS_BIG_ENDIAN
126  // little endian: no conversion needed.
127  return WriteBuffer(ptr, ElementCount * sizeof(T));
128 #else
129  // big endian: the individual "<<" functions already convert endiannes
130  for (size_t i = 0; i < ElementCount; i++) (*this) << ptr[i];
131 #endif
132  }
133  /** Read a value from a stream stored in a type different of the target
134  * variable, making the conversion via static_cast. Useful for coding
135  * backwards compatible de-serialization blocks */
136  template <typename STORED_TYPE, typename CAST_TO_TYPE>
137  void ReadAsAndCastTo(CAST_TO_TYPE& read_here)
138  {
139  STORED_TYPE var;
140  (*this) >> var;
141  read_here = static_cast<CAST_TO_TYPE>(var);
142  }
143  /** De-serialize a variable and returns it by value. */
144  template <typename STORED_TYPE>
145  STORED_TYPE ReadAs()
146  {
147  STORED_TYPE var;
148  (*this) >> var;
149  return var;
150  }
151  template <typename TYPE_TO_STORE, typename TYPE_FROM_ACTUAL>
152  void WriteAs(const TYPE_FROM_ACTUAL& value)
153  {
154  (*this) << static_cast<TYPE_TO_STORE>(value);
155  }
156  /** Writes an object to the stream.
157  */
158  void WriteObject(const CSerializable* o);
159  void WriteObject(const CSerializable& o) { WriteObject(&o); }
160  /** Reads an object from stream, its class determined at runtime, and
161  * returns a smart pointer to the object.
162  * \exception std::exception On I/O error or undefined class.
163  * \exception CExceptionEOF On an End-Of-File condition found
164  * at a correct place: an EOF that abruptly finishes in the middle of one
165  * object raises a plain std::exception instead.
166  */
167  CSerializable::Ptr ReadObject() { return ReadObject<CSerializable>(); }
168  /** Reads an object from stream, its class determined at runtime, and
169  * returns a smart pointer to the object. This version is similar to
170  * mrpt::make_aligned_shared<T>.
171  * \exception std::exception On I/O error or undefined class.
172  * \exception CExceptionEOF On an End-Of-File condition found
173  * at a correct place: an EOF that abruptly finishes in the middle of one
174  * object raises a plain std::exception instead.
175  */
176  template <typename T>
177  typename T::Ptr ReadObject()
178  {
180  std::string strClassName;
181  bool isOldFormat;
182  int8_t version;
183  internal_ReadObjectHeader(strClassName, isOldFormat, version);
184  if (strClassName != "nullptr")
185  {
186  const mrpt::rtti::TRuntimeClassId* classId =
187  mrpt::rtti::findRegisteredClass(strClassName);
188  if (!classId)
190  "Stored object has class '%s' which is not registered!",
191  strClassName.c_str());
192  obj.reset(dynamic_cast<CSerializable*>(classId->createObject()));
193  }
195  obj.get() /* may be nullptr */, strClassName, isOldFormat,
196  version); // must be called to read the END FLAG byte
197  if (!obj)
198  {
199  return typename T::Ptr();
200  }
201  else
202  {
203  return std::dynamic_pointer_cast<T>(obj);
204  }
205  }
206 
207  private:
208  template <typename RET>
210  {
211  throw std::runtime_error("Can't match variant type");
212  return RET();
213  }
214 
215  template <typename RET, typename T, typename... R>
217  CSerializable::Ptr& ptr,
218  std::enable_if_t<mrpt::is_shared_ptr<T>::value>* = nullptr)
219  {
220  if (IS_CLASS(ptr, typename T::element_type))
221  return std::dynamic_pointer_cast<typename T::element_type>(ptr);
222  return ReadVariant_helper<RET, R...>(ptr);
223  }
224 
225  template <typename RET, typename T, typename... R>
227  CSerializable::Ptr& ptr,
228  std::enable_if_t<!mrpt::is_shared_ptr<T>::value>* = nullptr)
229  {
230  if (IS_CLASS(ptr, T)) return dynamic_cast<T&>(*ptr);
231  return ReadVariant_helper<RET, R...>(ptr);
232  }
233 
234  public:
235  template <typename T, typename T2, typename ... REST>
236  const mrpt::rtti::TRuntimeClassId* findRegisteredClassInList(std::string_view strClassName)
237  {
238  return T::GetRuntimeClassIdStatic().className == strClassName || T::GetRuntimeClassIdStatic().altName == strClassName ?
239  &T::GetRuntimeClassIdStatic() : findRegisteredClassInList<T2, REST...>(strClassName);
240  }
241 
242  template <typename T>
243  const mrpt::rtti::TRuntimeClassId* findRegisteredClassInList(std::string_view strClassName)
244  {
245  return T::GetRuntimeClassIdStatic().className == strClassName || T::GetRuntimeClassIdStatic().altName == strClassName ?
246  &T::GetRuntimeClassIdStatic() : nullptr;
247  }
248 
249  /** Reads a variant from stream, its class determined at runtime, and
250  * returns a variant to the object.
251  * To be compatible with the current polymorphic system this support smart
252  * pointer types.
253  * For pointer types, This will bind to the first possible pointer type.
254  * variant<CSerializable::Ptr, CRenderizable::Ptr>
255  * \exception std::exception On I/O error or undefined class.
256  * \exception CExceptionEOF On an End-Of-File condition found
257  * at a correct place: an EOF that abruptly finishes in the middle of one
258  * object raises a plain std::exception instead.
259  */
260  template <typename... T>
261  typename std::variant<T...> ReadVariant()
262  {
264  std::string strClassName;
265  bool isOldFormat;
266  int8_t version;
267  internal_ReadObjectHeader(strClassName, isOldFormat, version);
268  const mrpt::rtti::TRuntimeClassId* classId =
269  findRegisteredClassInList<T...>(strClassName);
270  if (!classId)
272  "Stored object has class '%s' which is not registered!",
273  strClassName.c_str());
274  if (strClassName != "nullptr")
275  {
276  obj.reset(dynamic_cast<CSerializable*>(classId->createObject()));
277  }
278  internal_ReadObject(obj.get(), strClassName, isOldFormat, version);
279  if (!obj)
280  {
281  return std::variant<T...>();
282  }
283  else
284  {
285  return ReadVariant_helper<std::variant<T...>, T...>(obj);
286  }
287  }
288 
289  /** Writes a Variant to the stream.
290  */
291  template <typename T>
292  void WriteVariant(T t)
293  {
294  t.match([&](auto& o) { this->WriteObject(o); });
295  }
296 
297  /** Reads a simple POD type and returns by value. Useful when `stream >>
298  * var;`
299  * cannot be used becuase of errors of misaligned reference binding.
300  * Use with macro `MRPT_READ_POD` to avoid typing the type T yourself.
301  * \note [New in MRPT 2.0.0]
302  * \note Write operator `s << var;` is safe for misaligned variables.
303  */
304  template <typename T>
306  {
307  T ret;
308  ReadBufferFixEndianness(&ret, 1);
309  return ret;
310  }
311 
312  /** Reads an object from stream, where its class must be the same
313  * as the supplied object, where the loaded object will be stored in.
314  * \exception std::exception On I/O error or different class found.
315  * \exception CExceptionEOF On an End-Of-File condition found
316  * at a correct place: an EOF that abruptly finishes in the middle of one
317  * object raises a plain std::exception instead.
318  */
319  void ReadObject(CSerializable* existingObj);
320 
321  /** Send a message to the device.
322  * Note that only the low byte from the "type" field will be used.
323  *
324  * For frames of size < 255 the frame format is an array of bytes in this
325  * order:
326  * \code
327  * <START_FLAG> <HEADER> <LENGTH> <BODY> <END_FLAG>
328  * <START_FLAG> = 0x69
329  * <HEADER> = A header byte
330  * <LENGHT> = Number of bytes of BODY
331  * <BODY> = N x bytes
332  * <END_FLAG> = 0X96
333  * Total length = <LENGTH> + 4
334  * \endcode
335  *
336  * For frames of size > 255 the frame format is an array of bytes in this
337  * order:
338  * \code
339  * <START_FLAG> <HEADER> <HIBYTE(LENGTH)> <LOBYTE(LENGTH)> <BODY>
340  * <END_FLAG>
341  * <START_FLAG> = 0x79
342  * <HEADER> = A header byte
343  * <LENGHT> = Number of bytes of BODY
344  * <BODY> = N x bytes
345  * <END_FLAG> = 0X96
346  * Total length = <LENGTH> + 5
347  * \endcode
348  *
349  * \exception std::exception On communication errors
350  */
351  void sendMessage(const CMessage& msg);
352 
353  /** Tries to receive a message from the device.
354  * \exception std::exception On communication errors
355  * \returns True if successful, false if there is no new data from the
356  * device (but communications seem to work fine)
357  * \sa The frame format is described in sendMessage()
358  */
359  bool receiveMessage(CMessage& msg);
360 
361  /** Write a CSerializable object to a stream in the binary MRPT format */
363  /** \overload */
364  CArchive& operator<<(const CSerializable::Ptr& pObj);
365  /** Reads a CSerializable object from the stream */
367  /** \overload */
369 
370  /** @} */
371 
372  protected:
373  /** @name Virtual methods of the CArchive interface
374  * @{ */
375  /** Writes a block of bytes.
376  * \exception std::exception On any error
377  * \return Number of bytes actually written.
378  */
379  virtual size_t write(const void* buf, size_t len) = 0;
380  /** Reads a block of bytes.
381  * \exception std::exception On any error, or if ZERO bytes are read.
382  * \return Number of bytes actually read if >0.
383  */
384  virtual size_t read(void* buf, size_t len) = 0;
385  /** @} */
386 
387  /** Read the object */
388  void internal_ReadObject(
389  CSerializable* newObj, const std::string& className, bool isOldFormat,
390  int8_t version);
391 
392  /** Read the object Header*/
394  std::string& className, bool& isOldFormat, int8_t& version);
395 };
396 
397 // Note: write op accepts parameters by value on purpose, to avoid misaligned
398 // reference binding errors.
399 #define DECLARE_CArchive_READ_WRITE_SIMPLE_TYPE(T) \
400  CArchive& operator<<(CArchive& out, const T a); \
401  CArchive& operator>>(CArchive& in, T& a)
402 
403 // Definitions:
416 
417 #define MRPT_READ_POD(_STREAM, _VARIABLE) \
418  do \
419  { \
420  const std::remove_cv_t<std::remove_reference_t<decltype(_VARIABLE)>> \
421  val = _STREAM.ReadPOD<std::remove_cv_t< \
422  std::remove_reference_t<decltype(_VARIABLE)>>>(); \
423  ::memcpy(&_VARIABLE, &val, sizeof(val)); \
424  } while (0)
425 
426 // Why this shouldn't be templatized?: There's a more modern system
427 // in MRPT that serializes any kind of vector<T>, deque<T>, etc... but
428 // to keep COMPATIBILITY with old serialized objects we must preserve
429 // the ones listed here:
430 
431 // Write --------------------
432 CArchive& operator<<(CArchive& s, const char* a);
433 CArchive& operator<<(CArchive& s, const std::string& str);
434 
435 CArchive& operator<<(CArchive&, const std::vector<int32_t>& a);
436 CArchive& operator<<(CArchive&, const std::vector<uint32_t>& a);
437 CArchive& operator<<(CArchive&, const std::vector<uint16_t>& a);
438 CArchive& operator<<(CArchive&, const std::vector<int16_t>& a);
439 CArchive& operator<<(CArchive&, const std::vector<uint32_t>& a);
440 CArchive& operator<<(CArchive&, const std::vector<int64_t>& a);
441 CArchive& operator<<(CArchive&, const std::vector<uint8_t>& a);
442 CArchive& operator<<(CArchive&, const std::vector<int8_t>& a);
443 
444 CArchive& operator<<(CArchive&, const std::vector<bool>& a);
445 CArchive& operator<<(CArchive&, const std::vector<std::string>&);
446 
447 #if MRPT_WORD_SIZE != 32 // If it's 32 bit, size_t <=> uint32_t
448 CArchive& operator<<(CArchive&, const std::vector<size_t>& a);
449 #endif
450 
451 // Read --------------------
452 CArchive& operator>>(CArchive& in, char* a);
453 CArchive& operator>>(CArchive& in, std::string& str);
454 
455 CArchive& operator>>(CArchive& in, std::vector<int32_t>& a);
456 CArchive& operator>>(CArchive& in, std::vector<uint32_t>& a);
457 CArchive& operator>>(CArchive& in, std::vector<uint16_t>& a);
458 CArchive& operator>>(CArchive& in, std::vector<int16_t>& a);
459 CArchive& operator>>(CArchive& in, std::vector<int64_t>& a);
460 CArchive& operator>>(CArchive& in, std::vector<uint8_t>& a);
461 CArchive& operator>>(CArchive& in, std::vector<int8_t>& a);
462 CArchive& operator>>(CArchive& in, std::vector<bool>& a);
463 
464 CArchive& operator>>(CArchive& in, std::vector<std::string>& a);
465 
466 // For backward compatibility, since in MRPT<0.8.1 vector_XXX and
467 // std::vector<XXX> were exactly equivalent, now there're not.
468 CArchive& operator>>(CArchive& s, std::vector<float>& a);
469 CArchive& operator>>(CArchive& s, std::vector<double>& a);
470 CArchive& operator<<(CArchive& s, const std::vector<float>& a);
471 CArchive& operator<<(CArchive& s, const std::vector<double>& a);
472 
473 #if MRPT_WORD_SIZE != 32 // If it's 32 bit, size_t <=> uint32_t
474 CArchive& operator>>(CArchive& s, std::vector<size_t>& a);
475 #endif
476 //
477 
478 template <
479  typename T, std::enable_if_t<std::is_base_of<
482 {
483  pObj = in.ReadObject<T>();
484  return in;
485 }
486 
487 template <typename... T>
488 CArchive& operator>>(CArchive& in, typename std::variant<T...>& pObj)
489 {
490  pObj = in.ReadVariant<T...>();
491  return in;
492 }
493 
494 template <typename... T>
496  CArchive& out, const typename std::variant<T...>& pObj)
497 {
498  pObj.match([&](auto& t) { out << t; });
499  return out;
500 }
501 
502 /** Write a shared_ptr to a non-CSerializable object */
503 template <
504  class T, std::enable_if_t<!std::is_base_of<
506 CArchive& operator<<(CArchive& out, const std::shared_ptr<T>& pObj)
507 {
508  if (pObj)
509  {
510  out << mrpt::typemeta::TTypeName<T>::get();
511  out << *pObj;
512  }
513  else
514  {
515  out << std::string("nullptr");
516  }
517  return out;
518 }
519 
520 /** Read a smart pointer to a non-CSerializable (POD,...) data type*/
521 template <
522  class T, std::enable_if_t<!std::is_base_of<
524 CArchive& operator>>(CArchive& in, std::shared_ptr<T>& pObj)
525 {
526  std::string stored_name;
527  in >> stored_name;
528  const std::string expected_name =
530  if (stored_name == std::string("nullptr"))
531  {
532  pObj.reset();
533  }
534  else
535  {
536  ASSERT_EQUAL_(expected_name, stored_name);
537  pObj.reset(new T);
538  in >> *pObj;
539  }
540  return in;
541 }
542 
543 /** CArchive for mrpt::io::CStream classes (use as template argument).
544  * \sa Easier to use via function archiveFrom() */
545 template <class STREAM>
547 {
548  STREAM& m_s;
549 
550  public:
551  CArchiveStreamBase(STREAM& s) : m_s(s) {}
552 
553  protected:
554  size_t write(const void* d, size_t n) override { return m_s.Write(d, n); }
555  size_t read(void* d, size_t n) override { return m_s.Read(d, n); }
556 };
557 
558 /** Helper function to create a templatized wrapper CArchive object for a:
559  * MRPT's `CStream`, `std::istream`, `std::ostream`, `std::stringstream` */
560 template <class STREAM>
562 {
564 }
565 
566 } // namespace serialization
567 } // namespace mrpt
T ReadPOD()
Reads a simple POD type and returns by value.
Definition: CArchive.h:305
CExceptionEOF(const std::string &s)
Definition: CArchive.h:33
GLdouble GLdouble t
Definition: glext.h:3689
const mrpt::rtti::TRuntimeClassId * findRegisteredClassInList(std::string_view strClassName)
Definition: CArchive.h:236
unsigned __int16 uint16_t
Definition: rptypes.h:44
size_t read(void *d, size_t n) override
Reads a block of bytes.
Definition: CArchive.h:555
GLenum GLsizei n
Definition: glext.h:5074
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: CArchive.h:123
A structure that holds runtime class type information.
Definition: CObject.h:30
void WriteObject(const CSerializable &o)
Definition: CArchive.h:159
signed char int8_t
Definition: rptypes.h:40
STL namespace.
void WriteAs(const TYPE_FROM_ACTUAL &value)
Definition: CArchive.h:152
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CArchive.cpp:48
RET ReadVariant_helper(CSerializable::Ptr &ptr, std::enable_if_t<!mrpt::is_shared_ptr< T >::value > *=nullptr)
Definition: CArchive.h:226
void sendMessage(const CMessage &msg)
Send a message to the device.
Definition: CArchive.cpp:569
GLdouble s
Definition: glext.h:3676
GLenum GLsizei len
Definition: glext.h:4712
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
virtual size_t read(void *buf, size_t len)=0
Reads a block of bytes.
CArchive & operator>>(CSerializable &obj)
Reads a CSerializable object from the stream.
Definition: CArchive.cpp:199
This is useful for checking ::Ptr types.
Definition: is_shared_ptr.h:20
unsigned char uint8_t
Definition: rptypes.h:41
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT&#39;s CStream, std::istream, std::ostream, std::stringstream
Definition: CArchive.h:561
void internal_ReadObjectHeader(std::string &className, bool &isOldFormat, int8_t &version)
Read the object Header.
Definition: CArchive.cpp:380
DECLARE_CArchive_READ_WRITE_SIMPLE_TYPE(bool)
void WriteVariant(T t)
Writes a Variant to the stream.
Definition: CArchive.h:292
__int16 int16_t
Definition: rptypes.h:43
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: CArchive.h:137
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:153
__int64 int64_t
Definition: rptypes.h:49
const char * className
Definition: CObject.h:33
STORED_TYPE ReadAs()
De-serialize a variable and returns it by value.
Definition: CArchive.h:145
size_t write(const void *d, size_t n) override
Writes a block of bytes.
Definition: CArchive.h:554
CArchive & operator<<(const CSerializable &obj)
Write a CSerializable object to a stream in the binary MRPT format.
Definition: CArchive.cpp:187
T::Ptr ReadObject()
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the obje...
Definition: CArchive.h:177
GLsizei const GLchar ** string
Definition: glext.h:4101
bool receiveMessage(CMessage &msg)
Tries to receive a message from the device.
Definition: CArchive.cpp:603
virtual size_t write(const void *buf, size_t len)=0
Writes a block of bytes.
const TRuntimeClassId * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or nullptr if the class is not registered.
CArchive for mrpt::io::CStream classes (use as template argument).
Definition: CArchive.h:546
CArchive & operator>>(CArchive &s, mrpt::aligned_std_vector< float > &a)
Definition: CArchive.cpp:291
__int32 int32_t
Definition: rptypes.h:46
unsigned __int64 uint64_t
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
Definition: CMessage.h:29
void internal_ReadObject(CSerializable *newObj, const std::string &className, bool isOldFormat, int8_t version)
Read the object.
Definition: CArchive.cpp:483
const float R
void reverseBytesInPlace(bool &v_in_out)
Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) ...
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
Definition: CObject.h:103
RET ReadVariant_helper(CSerializable::Ptr &ptr)
Definition: CArchive.h:209
RET ReadVariant_helper(CSerializable::Ptr &ptr, std::enable_if_t< mrpt::is_shared_ptr< T >::value > *=nullptr)
Definition: CArchive.h:216
GLuint in
Definition: glext.h:7274
CSerializable::Ptr ReadObject()
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the obje...
Definition: CArchive.h:167
CArchive & operator<<(CArchive &s, const mrpt::aligned_std_vector< float > &a)
Definition: CArchive.cpp:240
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
Definition: CArchive.cpp:24
void WriteObject(const CSerializable *o)
Writes an object to the stream.
Definition: CArchive.cpp:142
GLsizei const GLfloat * value
Definition: glext.h:4117
mrpt::rtti::CObject * createObject() const
Definition: CObject.cpp:79
const mrpt::rtti::TRuntimeClassId * findRegisteredClassInList(std::string_view strClassName)
Definition: CArchive.h:243
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
Definition: exceptions.h:43
unsigned __int32 uint32_t
Definition: rptypes.h:47
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: CArchive.h:84
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
std::variant< T... > ReadVariant()
Reads a variant from stream, its class determined at runtime, and returns a variant to the object...
Definition: CArchive.h:261
static constexpr auto get()
Definition: TTypeName.h:67
Used in mrpt::serialization::CArchive.
Definition: CArchive.h:30



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019