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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020