Main MRPT website > C++ reference for MRPT 1.9.9
CStream.cpp
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 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/utils/CStream.h>
13 #include <mrpt/system/os.h>
14 #include <mrpt/system/os.h>
16 #include <mrpt/utils/types_math.h> // CVector* types
17 
18 #include <map>
19 #include <iostream>
20 #include <cstdarg>
21 
23 
24 // 8 bits:
25 #define SERIALIZATION_END_FLAG 0x88
26 
27 using namespace mrpt;
28 using namespace mrpt::utils;
29 using namespace mrpt::system;
30 using namespace std;
31 
32 /*---------------------------------------------------------------
33  Destructor
34  ---------------------------------------------------------------*/
36 /*---------------------------------------------------------------
37  ReadBuffer
38  Reads bytes from the stream into Buffer
39  ---------------------------------------------------------------*/
40 size_t CStream::ReadBuffer(void* Buffer, size_t Count)
41 {
42  ASSERT_(Buffer != nullptr)
43  if (Count)
44  {
45  size_t actuallyRead = Read(Buffer, Count);
46  if (!actuallyRead)
47  {
49  "(EOF?) Cannot read requested number of bytes from stream");
50  }
51  else
52  {
53  return actuallyRead;
54  }
55  }
56  else
57  return 0;
58 }
59 
60 /*---------------------------------------------------------------
61  WriteBuffer
62  Writes a block of bytes to the stream.
63  ---------------------------------------------------------------*/
64 void CStream::WriteBuffer(const void* Buffer, size_t Count)
65 {
66  ASSERT_(Buffer != nullptr)
67  if (Count)
68  if (Count != Write(Buffer, Count))
69  THROW_EXCEPTION("Cannot write bytes to stream!");
70 }
71 
72 /*---------------------------------------------------------------
73  Writes an elemental data type to stream.
74  ---------------------------------------------------------------*/
75 #if MRPT_IS_BIG_ENDIAN
76 // Big endian system: Convert into little-endian for streaming
77 #define IMPLEMENT_CSTREAM_READ_WRITE_SIMPLE_TYPE(T) \
78  CStream& utils::operator<<(mrpt::utils::CStream& out, const T a) \
79  { \
80  mrpt::utils::reverseBytesInPlace(a); \
81  out.WriteBuffer((void*)&a, sizeof(a)); \
82  return out; \
83  } \
84  CStream& utils::operator>>(mrpt::utils::CStream& in, T& a) \
85  { \
86  T b; \
87  in.ReadBuffer((void*)&b, sizeof(a)); \
88  mrpt::utils::reverseBytesInPlace(b); \
89  ::memcpy(&a, &b, sizeof(b)); \
90  return in; \
91  }
92 #else
93 // Little endian system:
94 #define IMPLEMENT_CSTREAM_READ_WRITE_SIMPLE_TYPE(T) \
95  CStream& utils::operator<<(mrpt::utils::CStream& out, const T a) \
96  { \
97  out.WriteBuffer((void*)&a, sizeof(a)); \
98  return out; \
99  } \
100  CStream& utils::operator>>(mrpt::utils::CStream& in, T& a) \
101  { \
102  in.ReadBuffer((void*)&a, sizeof(a)); \
103  return in; \
104  }
105 #endif
106 
118 
119 #ifdef HAVE_LONG_DOUBLE
121 #endif
122 
124 {
125  uint32_t l = (uint32_t)strlen(s);
126  out << l;
127  out.WriteBuffer(s, (int)l);
128  return out;
129 }
130 
132 {
133  uint32_t n = (uint32_t)a.size();
134  out << n;
135  if (n)
136  {
137  vector_byte b(n);
140  for (it = a.begin(), it2 = b.begin(); it != a.end(); ++it, ++it2)
141  *it2 = *it ? 1 : 0;
142  out.WriteBuffer((void*)&b[0], (int)(sizeof(b[0]) * n));
143  }
144  return out;
145 }
146 
148 {
149  uint32_t n = (uint32_t)str.size();
150  out << n;
151  if (n) out.WriteBuffer(str.c_str(), n);
152  return out;
153 }
154 
155 /*---------------------------------------------------------------
156  Writes an object to the stream.
157  ---------------------------------------------------------------*/
159 {
160  MRPT_START
161 
162  int version;
163 
164  // First, the "classname".
165  const char* className;
166  if (o != nullptr)
167  {
168  className = o->GetRuntimeClass()->className;
169  }
170  else
171  {
172  className = "nullptr";
173  }
174 
175  int8_t classNamLen = strlen(className);
176  int8_t classNamLen_mod = classNamLen | 0x80;
177 
178  (*this) << classNamLen_mod;
179  this->WriteBuffer(className, classNamLen);
180 
181  // Next, the version number:
182  if (o != nullptr)
183  {
184  o->writeToStream(*this, &version);
185  ASSERT_(version >= 0 && version < 255);
186 
187  int8_t actualVersion = int8_t(version);
188  (*this) << actualVersion;
189 
190  // Next, the object data.
191  o->writeToStream(*this, nullptr);
192  }
193 
194  // In MRPT 0.5.5 a end flag is introduced:
195  static const uint8_t endFlag = SERIALIZATION_END_FLAG;
196  (*this) << endFlag;
197 
198  MRPT_END
199 }
200 
202 {
203  WriteObject(pObj.get());
204  return *this;
205 }
206 
207 /** Write an object to a stream in the binary MRPT format. */
209 {
210  WriteObject(&obj);
211  return *this;
212 }
213 
215 {
216  pObj = ReadObject();
217  return *this;
218 }
219 
221 {
222  ReadObject(&obj);
223  return *this;
224 }
225 
226 /*---------------------------------------------------------------
227  Reads an elemental data type from the stream.
228  ---------------------------------------------------------------*/
229 
230 namespace mrpt
231 {
232 namespace utils
233 {
234 // For backward compatibility, since in MRPT<0.8.1 vector_XXX and
235 // std::vector<XXX> were exactly equivalent, now there're not.
236 namespace detail
237 {
238 template <typename VEC>
240 {
241  const uint32_t n = static_cast<uint32_t>(v.size());
242  s << n;
243  if (n) s.WriteBufferFixEndianness(&v[0], n);
244  return s;
245 }
246 template <typename VEC>
248 {
249  uint32_t n;
250  s >> n;
251  v.resize(n);
252  if (n) s.ReadBufferFixEndianness(&v[0], n);
253  return s;
254 }
255 }
256 }
257 }
258 
259 // Write:
260 CStream& utils::operator<<(mrpt::utils::CStream& s, const std::vector<float>& a)
261 {
263 }
265  mrpt::utils::CStream& s, const std::vector<double>& a)
266 {
268 }
270 {
272 }
274 {
276 }
278 {
280 }
282 {
284 }
286 {
288 }
290 {
292 }
294 {
296 }
299 {
300  const uint32_t n = static_cast<uint32_t>(v.size());
301  s << n;
302  if (n) s.WriteBufferFixEndianness(&v[0], n);
303  return s;
304 }
307 {
308  const uint32_t n = static_cast<uint32_t>(v.size());
309  s << n;
310  if (n) s.WriteBufferFixEndianness(&v[0], n);
311  return s;
312 }
313 
314 // Read:
316 {
318 }
320 {
322 }
324 {
326 }
328 {
330 }
332 {
334 }
336 {
338 }
340 {
342 }
344 {
346 }
348 {
350 }
352 {
353  uint32_t n;
354  s >> n;
355  v.resize(n);
356  if (n) s.ReadBufferFixEndianness(&v[0], n);
357  return s;
358 }
361 {
362  uint32_t n;
363  s >> n;
364  v.resize(n);
365  if (n) s.ReadBufferFixEndianness(&v[0], n);
366  return s;
367 }
368 
369 #if MRPT_WORD_SIZE != 32 // If it's 32 bit, size_t <=> uint32_t
371  mrpt::utils::CStream& s, const std::vector<size_t>& a)
372 {
374 }
376 {
378 }
379 #endif
380 
382 {
383  uint32_t n;
384  in >> n;
385  a.resize(n);
386  if (n)
387  {
388  vector_byte b(n);
389  in.ReadBuffer((void*)&b[0], sizeof(b[0]) * n);
392  for (it = a.begin(), it2 = b.begin(); it != a.end(); ++it, ++it2)
393  *it = (*it2 != 0);
394  }
395  return in;
396 }
397 
399 {
400  uint32_t n;
401  in >> n;
402  str.resize(n);
403  if (n) in.ReadBuffer((void*)&str[0], n);
404  return in;
405 }
406 
408 {
409  ASSERT_(s != nullptr)
410  uint32_t l;
411  in >> l;
412  if (l) in.ReadBuffer(s, l);
413  s[l] = '\0';
414  return in;
415 }
416 
417 //#define CSTREAM_VERBOSE 1
418 #define CSTREAM_VERBOSE 0
419 
421  std::string& strClassName, bool& isOldFormat, int8_t& version)
422 {
423  uint8_t lengthReadClassName = 255;
424  char readClassName[260];
425  readClassName[0] = 0;
426 
427  try
428  {
429  // First, read the class name: (exception is raised here if ZERO bytes
430  // read -> possibly an EOF)
431  if (sizeof(lengthReadClassName) !=
432  ReadBuffer(
433  (void*)&lengthReadClassName, sizeof(lengthReadClassName)))
434  THROW_EXCEPTION("Cannot read object header from stream! (EOF?)");
435 
436  // Is in old format (< MRPT 0.5.5)?
437  if (!(lengthReadClassName & 0x80))
438  {
439  isOldFormat = true;
440  uint8_t buf[3];
441  if (3 != ReadBuffer(buf, 3))
443  "Cannot read object header from stream! (EOF?)");
444  if (buf[0] || buf[1] || buf[2])
446  "Expecting 0x00 00 00 while parsing old streaming header "
447  "(Perhaps it's a gz-compressed stream? Use a GZ-stream for "
448  "reading)");
449  }
450  else
451  {
452  isOldFormat = false;
453  }
454 
455  // Remove MSB:
456  lengthReadClassName &= 0x7F;
457 
458  // Sensible class name size?
459  if (lengthReadClassName > 120)
461  "Class name has more than 120 chars. This probably means a "
462  "corrupted binary stream.");
463 
464  if (((size_t)lengthReadClassName) !=
465  ReadBuffer(readClassName, lengthReadClassName))
466  THROW_EXCEPTION("Cannot read object class name from stream!");
467 
468  readClassName[lengthReadClassName] = '\0';
469 
470  // Pass to string class:
471  strClassName = readClassName;
472 
473  // Next, the version number:
474  if (isOldFormat)
475  {
476  int32_t version_old;
477  // Handle big endian right:
478  if (sizeof(version_old) !=
479  ReadBufferFixEndianness(&version_old, 1 /*element count*/))
481  "Cannot read object streaming version from stream!");
482  ASSERT_(version_old >= 0 && version_old < 255);
483  version = int8_t(version_old);
484  }
485  else if (
486  strClassName != "nullptr" &&
487  sizeof(version) != ReadBuffer((void*)&version, sizeof(version)))
488  {
490  "Cannot read object streaming version from stream!");
491  }
492 
493 // In MRPT 0.5.5 an end flag was introduced:
494 #if CSTREAM_VERBOSE
495  cerr << "[CStream::ReadObject] readClassName:" << strClassName
496  << " version: " << version << endl;
497 #endif
498  }
499  catch (std::bad_alloc&)
500  {
501  throw;
502  }
503  catch (std::exception& e)
504  {
505  if (lengthReadClassName == 255)
506  {
508  "Cannot read object due to EOF", CExceptionEOF);
509  }
510  else
511  {
513  e, "Exception while parsing typed object '%s' from stream!\n",
514  readClassName);
515  }
516  }
517  catch (...)
518  {
519  THROW_EXCEPTION("Unexpected runtime error!");
520  }
521 } // end method
522 
524  CSerializable* obj, const std::string& strClassName, bool isOldFormat,
525  int8_t version)
526 {
527  try
528  {
529  if (obj)
530  {
531  // Not de-serializing an "nullptr":
532  obj->readFromStream(*this, (int)version);
533  }
534  if (!isOldFormat)
535  {
536  uint8_t endFlag;
537  if (sizeof(endFlag) != ReadBuffer((void*)&endFlag, sizeof(endFlag)))
539  "Cannot read object streaming version from stream!");
540  if (endFlag != SERIALIZATION_END_FLAG)
542  "end-flag missing: There is a bug in the deserialization "
543  "method of class: '%s'",
544  strClassName.c_str());
545  }
546  }
547  catch (std::bad_alloc&)
548  {
549  throw;
550  }
551  catch (std::exception&)
552  {
553  THROW_TYPED_EXCEPTION("Cannot read object due to EOF", CExceptionEOF);
554  }
555  catch (...)
556  {
557  THROW_EXCEPTION("Unexpected runtime error!");
558  }
559 }
560 
561 /*---------------------------------------------------------------
562  Reads an object from stream, where its class is determined
563  by an existing object
564  exception std::exception On I/O error or undefined class.
565  ---------------------------------------------------------------*/
567 {
568  std::string strClassName;
569  bool isOldFormat;
570  int8_t version;
571 
572  internal_ReadObjectHeader(strClassName, isOldFormat, version);
573 
574  ASSERT_(existingObj && strClassName != "nullptr");
575  ASSERT_(strClassName != "nullptr");
576 
577  const TRuntimeClassId* id = existingObj->GetRuntimeClass();
578  const TRuntimeClassId* id2 = findRegisteredClass(strClassName);
579 
580  if (!id2)
582  "Stored object has class '%s' which is not registered!",
583  strClassName.c_str());
584  if (id != id2)
586  format(
587  "Stored class does not match with existing object!!:\n Stored: "
588  "%s\n Expected: %s",
589  id2->className, id->className));
590 
591  internal_ReadObject(existingObj, strClassName, isOldFormat, version);
592 }
593 
594 /*---------------------------------------------------------------
595  Writes an elemental data type to stream.
596  ---------------------------------------------------------------*/
597 int CStream::printf(const char* fmt, ...)
598 {
599  MRPT_START
600 
601  if (!fmt) throw std::runtime_error("fmt in CStream::printf cannot be NULL");
602 
603  int result = -1, length = 1024;
604  vector<char> buffer;
605  while (result == -1)
606  {
607  buffer.resize(length + 10);
608 
609  va_list args; // This must be done WITHIN the loop
610  va_start(args, fmt);
611  result = os::vsnprintf(&buffer[0], length, fmt, args);
612  va_end(args);
613 
614  // Truncated?
615  if (result >= length) result = -1;
616  length *= 2;
617  }
618 
619  size_t l = strlen(&buffer[0]);
620  WriteBuffer(&buffer[0], (int)l);
621 
622  return result;
623 
624  MRPT_END
625 }
626 
628  mrpt::utils::CStream& s, const std::vector<std::string>& vec)
629 {
630  uint32_t N = static_cast<uint32_t>(vec.size());
631  s << N;
632  for (size_t i = 0; i < N; i++) s << vec[i];
633  return s;
634 }
635 
637  mrpt::utils::CStream& s, std::vector<std::string>& vec)
638 {
639  uint32_t N;
640  s >> N;
641  vec.resize(N);
642  for (size_t i = 0; i < N; i++) s >> vec[i];
643  return s;
644 }
645 
646 /*-------------------------------------------------------------
647  sendMessage
648 -------------------------------------------------------------*/
650 {
651  MRPT_START
652 
653  unsigned char buf[0x10100];
654  unsigned int nBytesTx = 0;
655 
656  const bool msg_format_is_tiny = msg.content.size() < 256;
657 
658  // Build frame -------------------------------------
659  buf[nBytesTx++] = msg_format_is_tiny ? 0x69 : 0x79;
660  buf[nBytesTx++] = (unsigned char)(msg.type);
661 
662  if (msg_format_is_tiny)
663  {
664  buf[nBytesTx++] = (unsigned char)msg.content.size();
665  }
666  else
667  {
668  buf[nBytesTx++] = msg.content.size() & 0xff; // lo
669  buf[nBytesTx++] = (msg.content.size() >> 8) & 0xff; // hi
670  }
671 
672  if (!msg.content.empty())
673  memcpy(buf + nBytesTx, &msg.content[0], msg.content.size());
674  nBytesTx += (unsigned char)msg.content.size();
675  buf[nBytesTx++] = 0x96;
676 
677  // Send buffer -------------------------------------
678  WriteBuffer(buf, nBytesTx); // Exceptions will be raised on errors here
679 
680  MRPT_END
681 }
682 
683 /*-------------------------------------------------------------
684  receiveMessage
685 -------------------------------------------------------------*/
687 {
688  MRPT_START
689  std::vector<unsigned char> buf(66000);
690  unsigned int nBytesInFrame = 0;
691  unsigned long nBytesToRx = 0;
692  unsigned char tries = 2;
693  unsigned int payload_len = 0;
694  unsigned int expectedLen = 0;
695 
696  for (;;)
697  {
698  if (nBytesInFrame < 4)
699  nBytesToRx = 1;
700  else
701  {
702  if (buf[0] == 0x69)
703  {
704  payload_len = buf[2];
705  expectedLen = payload_len + 4;
706  }
707  else if (buf[0] == 0x79)
708  {
709  payload_len = MAKEWORD16B(
710  buf[3] /*low*/, buf[2] /*hi*/); // Length of the content
711  expectedLen = payload_len + 5;
712  }
713  nBytesToRx = expectedLen - nBytesInFrame;
714  } // end else
715 
716  unsigned long nBytesRx = 0;
717  try
718  {
719  nBytesRx = ReadBufferImmediate(&buf[nBytesInFrame], nBytesToRx);
720  }
721  catch (...)
722  {
723  }
724 
725  // No more data! (read timeout is already included in the call to
726  // "Read")
727  if (!nBytesRx) return false;
728 
729  if (!nBytesInFrame && buf[0] != 0x69 && buf[0] != 0x79)
730  {
731  // Start flag is invalid:
732  if (!tries--) return false;
733  }
734  else
735  {
736  // Is a new byte for the frame:
737  nBytesInFrame += nBytesRx;
738 
739  if (nBytesInFrame == expectedLen)
740  {
741  // Frame complete
742  // check for frame be ok:
743 
744  // End flag?
745  if (buf[nBytesInFrame - 1] != 0x96)
746  {
747  // Error in frame!
748  nBytesInFrame = 0;
749  return false;
750  }
751  else
752  {
753  // copy out data:
754  msg.type = buf[1];
755  if (buf[0] == 0x69)
756  {
757  msg.content.resize(payload_len);
758  if (!msg.content.empty())
759  memcpy(&msg.content[0], &buf[3], payload_len);
760  } // end if
761  if (buf[0] == 0x79)
762  {
763  msg.content.resize(payload_len);
764  if (!msg.content.empty())
765  memcpy(&msg.content[0], &buf[4], payload_len);
766  } // end if
767  return true;
768  }
769  }
770  }
771  }
772  MRPT_END
773 }
774 
775 /*-------------------------------------------------------------
776 Reads from the stream until a '\n' character is found ('\r' characters are
777 ignored).
778 return false on EOF or any other read error.
779 -------------------------------------------------------------*/
781 {
782  out_str.clear();
783  try
784  {
785  for (;;)
786  {
787  size_t N = out_str.size();
788  out_str.resize(N + 1);
789  if (!Read(&out_str[N], 1)) return false;
790 
791  // New char read:
792  if (out_str[N] == '\r')
793  {
794  out_str.resize(N); // Ignore.
795  }
796  else if (out_str[N] == '\n')
797  {
798  out_str.resize(N); // End of line!
799  return true; // Ok.
800  }
801  }
802  }
803  catch (...)
804  { // Any read error:
805  return false;
806  }
807 }
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
Definition: CStream.cpp:40
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
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
std::vector< uint8_t > vector_byte
Definition: types_simple.h:27
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
GLuint buffer
Definition: glext.h:3917
CStream & operator>>(CSerializable::Ptr &pObj)
Definition: CStream.cpp:214
#define THROW_STACKED_EXCEPTION_CUSTOM_MSG2(e, stuff, param1)
void internal_ReadObjectHeader(std::string &className, bool &isOldFormat, int8_t &version)
Read the object Header.
Definition: CStream.cpp:420
#define THROW_EXCEPTION(msg)
virtual void writeToStream(mrpt::utils::CStream &out, int *getVersion) const =0
Introduces a pure virtual method responsible for writing to a CStream.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
GLenum GLsizei n
Definition: glext.h:5074
Scalar * iterator
Definition: eigen_plugins.h:26
CStream & readStdVectorToStream(mrpt::utils::CStream &s, VEC &v)
Definition: CStream.cpp:247
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CStream.cpp:64
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
signed char int8_t
Definition: rptypes.h:40
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
GLdouble s
Definition: glext.h:3676
CStream & writeStdVectorToStream(mrpt::utils::CStream &s, const VEC &v)
Definition: CStream.cpp:239
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
std::vector< int8_t > vector_signed_byte
Definition: types_simple.h:22
#define IMPLEMENT_CSTREAM_READ_WRITE_SIMPLE_TYPE(T)
Definition: CStream.cpp:94
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
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
__int16 int16_t
Definition: rptypes.h:43
#define MRPT_END
__int64 int64_t
Definition: rptypes.h:49
#define vsnprintf
Definition: zutil.h:203
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
GLubyte GLubyte b
Definition: glext.h:6279
#define THROW_TYPED_EXCEPTION(msg, exceptionClass)
Defines a unified way of reporting exceptions of type different than "std::exception".
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
Used in mrpt::utils::CStream.
Definition: exceptions.h:39
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.
#define SERIALIZATION_END_FLAG
Definition: CStream.cpp:25
#define MRPT_START
__int32 int32_t
Definition: rptypes.h:46
unsigned __int64 uint64_t
Definition: rptypes.h:50
const GLdouble * v
Definition: glext.h:3678
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
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
GLuint id
Definition: glext.h:3909
std::vector< int16_t > vector_signed_word
Definition: types_simple.h:23
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
CStream & operator<<(const CSerializable::Ptr &pObj)
Write an object to a stream in the binary MRPT format.
Definition: CStream.cpp:201
void sendMessage(const utils::CMessage &msg)
Send a message to the device.
Definition: CStream.cpp:649
std::vector< uint8_t > content
The contents of the message (memory is automatically handled by the std::vector object) ...
Definition: CMessage.h:39
std::vector< int32_t > vector_int
Definition: types_simple.h:24
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
const char * className
Definition: CObject.h:34
unsigned __int32 uint32_t
Definition: rptypes.h:47
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
Definition: CMessage.h:31
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
uint32_t type
An identifier of the message type (only the least-sig byte is typically sent)
Definition: CMessage.h:36
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
Definition: os.cpp:355



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