Main MRPT website > C++ reference for MRPT 1.5.7
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 /*---------------------------------------------------------------
34  Destructor
35  ---------------------------------------------------------------*/
37 {
38 
39 }
40 
41 /*---------------------------------------------------------------
42  ReadBuffer
43  Reads bytes from the stream into Buffer
44  ---------------------------------------------------------------*/
45 size_t CStream::ReadBuffer(void *Buffer, size_t Count)
46 {
47  ASSERT_(Buffer!=NULL)
48  if (Count)
49  {
50  size_t actuallyRead = Read(Buffer,Count);
51  if ( !actuallyRead )
52  {
53  THROW_EXCEPTION("(EOF?) Cannot read requested number of bytes from stream" );
54  }
55  else
56  {
57  return actuallyRead;
58  }
59  }
60  else return 0;
61 }
62 
63 /*---------------------------------------------------------------
64  WriteBuffer
65  Writes a block of bytes to the stream.
66  ---------------------------------------------------------------*/
67 void CStream::WriteBuffer(const void *Buffer, size_t Count)
68 {
69  ASSERT_(Buffer!=NULL)
70  if (Count)
71  if ( Count != Write(Buffer,Count) )
72  THROW_EXCEPTION("Cannot write bytes to stream!" );
73 }
74 
75 
76 /*---------------------------------------------------------------
77  Writes an elemental data type to stream.
78  ---------------------------------------------------------------*/
79 #if MRPT_IS_BIG_ENDIAN
80  // Big endian system: Convert into little-endian for streaming
81  #define IMPLEMENT_CSTREAM_READ_WRITE_SIMPLE_TYPE( T ) \
82  CStream& utils::operator<<(mrpt::utils::CStream&out, const T &a) \
83  { \
84  T b; \
85  ::memcpy(&b,&a,sizeof(b)); \
86  mrpt::utils::reverseBytesInPlace(b); \
87  out.WriteBuffer( (void*)&b, sizeof(b) ); \
88  return out; \
89  } \
90  CStream& utils::operator>>(mrpt::utils::CStream&in, T &a) \
91  { \
92  T b; \
93  in.ReadBuffer( (void*)&b, sizeof(a) ); \
94  mrpt::utils::reverseBytesInPlace(b); \
95  ::memcpy(&a,&b,sizeof(b)); \
96  return in; \
97  }
98 #else
99  // Little endian system:
100  #define IMPLEMENT_CSTREAM_READ_WRITE_SIMPLE_TYPE( T ) \
101  CStream& utils::operator<<(mrpt::utils::CStream&out, const T &a) \
102  { \
103  out.WriteBuffer( (void*)&a, sizeof(a) ); \
104  return out; \
105  } \
106  CStream& utils::operator>>(mrpt::utils::CStream&in, T &a) \
107  { \
108  in.ReadBuffer( (void*)&a, sizeof(a) ); \
109  return in; \
110  }
111 #endif
112 
124 
125 #ifdef HAVE_LONG_DOUBLE
127 #endif
128 
129 
131 {
132  uint32_t l = (uint32_t)strlen(s);
133  out << l;
134  out.WriteBuffer( s, (int)l );
135  return out;
136 }
137 
138 
140 {
141  uint32_t n = (uint32_t) a.size();
142  out << n;
143  if (n)
144  {
145  vector_byte b(n);
148  for (it=a.begin(),it2=b.begin();it!=a.end();++it,++it2) *it2 = *it ? 1:0;
149  out.WriteBuffer( (void*)&b[0], (int)(sizeof(b[0])*n) );
150  }
151  return out;
152 }
153 
155 {
156  uint32_t n = (uint32_t) str.size();
157  out << n;
158  if (n)
159  out.WriteBuffer( str.c_str(), n );
160  return out;
161 }
162 
163 /*---------------------------------------------------------------
164  Writes an object to the stream.
165  ---------------------------------------------------------------*/
167 {
168  MRPT_START
169 
170 
171  int version;
172 
173  // First, the "classname".
174  const char *className;
175  if(o != NULL)
176  {
177  className = o->GetRuntimeClass()->className;
178  }
179  else
180  {
181  className = "nullptr";
182  }
183 
184  int8_t classNamLen = strlen(className);
185  int8_t classNamLen_mod = classNamLen | 0x80;
186 
187  (*this) << classNamLen_mod;
188  this->WriteBuffer( className, classNamLen);
189 
190  // Next, the version number:
191  if(o != NULL)
192  {
193  o->writeToStream(*this, &version);
194  ASSERT_(version>=0 && version<255);
195 
196  int8_t actualVersion = int8_t(version);
197  (*this) << actualVersion;
198 
199  // Next, the object data.
200  o->writeToStream(*this, NULL);
201  }
202 
203  // In MRPT 0.5.5 a end flag is introduced:
204  static const uint8_t endFlag = SERIALIZATION_END_FLAG;
205  (*this) << endFlag;
206 
207  MRPT_END
208 }
209 
210 
211 CStream& CStream::operator << (const CSerializablePtr & pObj)
212 {
213  WriteObject(pObj.pointer());
214  return *this;
215 }
216 
217 /** Write an object to a stream in the binary MRPT format. */
219 {
220  WriteObject(&obj);
221  return *this;
222 }
223 
224 CStream& CStream::operator >> (CSerializablePtr &pObj)
225 {
226  pObj = ReadObject();
227  return *this;
228 }
229 
231 {
232  ReadObject( &obj );
233  return *this;
234 }
235 
236 
237 /*---------------------------------------------------------------
238  Reads an elemental data type from the stream.
239  ---------------------------------------------------------------*/
240 
241 namespace mrpt
242 {
243  namespace utils
244  {
245  // For backward compatibility, since in MRPT<0.8.1 vector_XXX and std::vector<XXX> were exactly equivalent, now there're not.
246  namespace detail {
247  template <typename VEC> inline CStream& writeStdVectorToStream(mrpt::utils::CStream&s, const VEC &v) {
248  const uint32_t n = static_cast<uint32_t>(v.size());
249  s << n; if (n) s.WriteBufferFixEndianness( &v[0],n );
250  return s;
251  }
252  template <typename VEC> inline CStream& readStdVectorToStream(mrpt::utils::CStream&s, VEC &v) {
253  uint32_t n; s >> n;
254  v.resize(n); if (n) s.ReadBufferFixEndianness( &v[0], n );
255  return s;
256  }
257  }
258  }
259 }
260 
261 // Write:
262 CStream& utils::operator << (mrpt::utils::CStream&s, const std::vector<float> &a) { return detail::writeStdVectorToStream(s,a); }
263 CStream& utils::operator << (mrpt::utils::CStream&s, const std::vector<double> &a) { return detail::writeStdVectorToStream(s,a); }
272 {
273  const uint32_t n = static_cast<uint32_t>(v.size());
274  s << n; if (n) s.WriteBufferFixEndianness( &v[0],n );
275  return s;
276 }
278 {
279  const uint32_t n = static_cast<uint32_t>(v.size());
280  s << n; if (n) s.WriteBufferFixEndianness( &v[0],n );
281  return s;
282 }
283 
284 // Read:
295 {
296  uint32_t n; s >> n;
297  v.resize(n);
298  if (n) s.ReadBufferFixEndianness( &v[0], n );
299  return s;
300 }
302 {
303  uint32_t n; s >> n;
304  v.resize(n);
305  if (n) s.ReadBufferFixEndianness( &v[0], n );
306  return s;
307 }
308 
309 #if MRPT_WORD_SIZE!=32 // If it's 32 bit, size_t <=> uint32_t
310 CStream& utils::operator << (mrpt::utils::CStream&s, const std::vector<size_t> &a) { return detail::writeStdVectorToStream(s,a); }
312 #endif
313 
315 {
316  uint32_t n;
317  in >> n;
318  a.resize(n);
319  if (n)
320  {
321  vector_byte b(n);
322  in.ReadBuffer( (void*)&b[0], sizeof(b[0])*n);
325  for (it=a.begin(),it2=b.begin();it!=a.end();++it,++it2) *it = (*it2!=0);
326  }
327  return in;
328 }
329 
331 {
332  uint32_t n;
333  in >> n;
334  str.resize(n);
335  if (n)
336  in.ReadBuffer( (void*)&str[0], n );
337  return in;
338 }
339 
340 
342 {
343  ASSERT_(s!=NULL)
344  uint32_t l;
345  in >>l;
346  if (l)
347  in.ReadBuffer( s, l );
348  s[l]='\0';
349  return in;
350 }
351 
352 
353 //#define CSTREAM_VERBOSE 1
354 #define CSTREAM_VERBOSE 0
355 
356 template <bool EXISTING_OBJ>
357 void CStream::internal_ReadObject(CSerializablePtr &newObj,CSerializable *existingObj)
358 {
359  // Automatically register all classes when the first one is registered.
361 
362  // First, read the class name:
363  uint8_t lengthReadClassName = 255;
364  bool isOldFormat=false; // < MRPT 0.5.5
365  char readClassName[260];
366  readClassName[0] = 0;
367 
368  try
369  {
370  // First, read the class name: (exception is raised here if ZERO bytes read -> possibly an EOF)
371  if (sizeof(lengthReadClassName) != ReadBuffer( (void*)&lengthReadClassName, sizeof(lengthReadClassName) ) )
372  THROW_EXCEPTION("Cannot read object header from stream! (EOF?)");
373 
374  // Is in old format (< MRPT 0.5.5)?
375  if (! (lengthReadClassName & 0x80 ))
376  {
377  isOldFormat = true;
378  uint8_t buf[3];
379  if (3 != ReadBuffer( buf, 3 ) ) THROW_EXCEPTION("Cannot read object header from stream! (EOF?)");
380  if (buf[0] || buf[1] || buf[2]) THROW_EXCEPTION("Expecting 0x00 00 00 while parsing old streaming header (Perhaps it's a gz-compressed stream? Use a GZ-stream for reading)");
381  }
382 
383  // Remove MSB:
384  lengthReadClassName &= 0x7F;
385 
386  // Sensible class name size?
387  if (lengthReadClassName>120)
388  THROW_EXCEPTION("Class name has more than 120 chars. This probably means a corrupted binary stream.");
389 
390  if (((size_t)lengthReadClassName)!=ReadBuffer( readClassName, lengthReadClassName ))
391  THROW_EXCEPTION("Cannot read object class name from stream!");
392 
393  readClassName[lengthReadClassName]='\0';
394 
395  // Pass to string class:
396  const std::string strClassName(readClassName);
397 
398  // Next, the version number:
399  int8_t version;
400  if (isOldFormat)
401  {
402  int32_t version_old;
403  // Handle big endian right:
404  if (sizeof(version_old)!=ReadBufferFixEndianness( &version_old, 1 /*element count*/ ))
405  THROW_EXCEPTION("Cannot read object streaming version from stream!");
406  ASSERT_(version_old>=0 && version_old<255);
407  version = int8_t(version_old);
408  }
409  else if (strClassName != "nullptr" && sizeof(version)!=ReadBuffer( (void*)&version, sizeof(version) ))
410  {
411  THROW_EXCEPTION("Cannot read object streaming version from stream!");
412  }
413 
414  // In MRPT 0.5.5 an end flag was introduced:
415 #if CSTREAM_VERBOSE
416  cerr << "[CStream::ReadObject] readClassName:" << strClassName << " version: " << version << endl;
417 #endif
418 
419  CSerializable* obj = NULL;
420  if (EXISTING_OBJ)
421  { // (Existing object)
422  // Now, compare to existing class:
423  if(strClassName != "nullptr")
424  {
425  ASSERT_(existingObj)
426  const TRuntimeClassId *id = existingObj->GetRuntimeClass();
427  const TRuntimeClassId *id2 = findRegisteredClass(strClassName);
428  if (!id2) THROW_EXCEPTION_FMT("Stored object has class '%s' which is not registered!",strClassName.c_str());
429  if ( id!=id2 ) THROW_EXCEPTION(format("Stored class does not match with existing object!!:\n Stored: %s\n Expected: %s", id2->className,id->className ));
430  // It matches, OK
431  obj = existingObj;
432  }
433  }
434  else if (strClassName != "nullptr")
435  { // (New object)
436  // Get the mapping to the "TRuntimeClassId*" in the registered classes table:
437  const TRuntimeClassId *classId = findRegisteredClass( strClassName );
438  if (!classId)
439  {
440  const std::string msg = format("Class '%s' is not registered! Have you called mrpt::registerClass(CLASS)?",readClassName);
441  std::cerr << "CStream::ReadObject(): " << msg << std::endl;
442  THROW_EXCEPTION(msg)
443  }
444  obj = static_cast<CSerializable*>(classId->createObject());
445  newObj = CSerializablePtr(obj);
446  }
447 
448  if(strClassName != "nullptr")
449  {
450  // Go on, read it:
451  obj->readFromStream( *this, (int)version );
452  }
453  // Check end flag (introduced in MRPT 0.5.5)
454  if (!isOldFormat)
455  {
456  uint8_t endFlag;
457  if (sizeof(endFlag)!=ReadBuffer( (void*)&endFlag, sizeof(endFlag) )) THROW_EXCEPTION("Cannot read object streaming version from stream!");
458  if (endFlag!=SERIALIZATION_END_FLAG) THROW_EXCEPTION_FMT("end-flag missing: There is a bug in the deserialization method of class: '%s'",strClassName.c_str());
459  }
460  ASSERT_(!EXISTING_OBJ || strClassName != "nullptr");
461  }
462  catch (std::bad_alloc &)
463  {
464  throw;
465  }
466  catch(std::exception &e)
467  {
468  if (lengthReadClassName==255) {
469  THROW_TYPED_EXCEPTION("Cannot read object due to EOF", CExceptionEOF);
470  }
471  else {
472  THROW_STACKED_EXCEPTION_CUSTOM_MSG2(e,"Exception while parsing typed object '%s' from stream!\n",readClassName);
473  }
474  }
475  catch (...) {
476  THROW_EXCEPTION("Unexpected runtime error!");
477  }
478 } // end method
479 
480 
481 /*---------------------------------------------------------------
482  Reads an object from stream, where its class is determined
483  at runtime.
484  exception std::exception On I/O error or undefined class.
485  ---------------------------------------------------------------*/
486 CSerializablePtr CStream::ReadObject()
487 {
488  CSerializablePtr ret;
489  internal_ReadObject<false>(ret, NULL);
490  return ret;
491 }
492 
493 /*---------------------------------------------------------------
494  Reads an object from stream, where its class is determined
495  by an existing object
496  exception std::exception On I/O error or undefined class.
497  ---------------------------------------------------------------*/
499 {
500  CSerializablePtr dummy;
501  internal_ReadObject<true>(dummy,existingObj);
502 }
503 
504 /*---------------------------------------------------------------
505  Writes an elemental data type to stream.
506  ---------------------------------------------------------------*/
507 int CStream::printf(const char *fmt, ... )
508 {
509  MRPT_START
510 
511  if (!fmt) throw std::runtime_error("fmt in CStream::printf cannot be NULL");
512 
513  int result = -1, length = 1024;
514  vector<char> buffer;
515  while (result == -1)
516  {
517  buffer.resize(length + 10);
518 
519  va_list args; // This must be done WITHIN the loop
520  va_start(args,fmt);
521  result = os::vsnprintf(&buffer[0], length, fmt, args);
522  va_end(args);
523 
524  // Truncated?
525  if (result>=length) result=-1;
526  length*=2;
527  }
528 
529  size_t l = strlen(&buffer[0]);
530  WriteBuffer( &buffer[0], (int)l );
531 
532  return result;
533 
534  MRPT_END
535 }
536 
537 CStream &utils::operator<<(mrpt::utils::CStream &s,const std::vector<std::string> &vec) {
538  uint32_t N=static_cast<uint32_t>(vec.size());
539  s<<N;
540  for (size_t i=0;i<N;i++) s<<vec[i];
541  return s;
542 }
543 
544 CStream &utils::operator>>(mrpt::utils::CStream &s,std::vector<std::string> &vec) {
545  uint32_t N;
546  s>>N;
547  vec.resize(N);
548  for (size_t i=0;i<N;i++) s>>vec[i];
549  return s;
550 }
551 
552 
553 /*-------------------------------------------------------------
554  sendMessage
555 -------------------------------------------------------------*/
557 {
558  MRPT_START
559 
560  unsigned char buf[0x10100];
561  unsigned int nBytesTx = 0;
562 
563  const bool msg_format_is_tiny = msg.content.size() < 256;
564 
565  // Build frame -------------------------------------
566  buf[nBytesTx++] = msg_format_is_tiny ? 0x69 : 0x79;
567  buf[nBytesTx++] = (unsigned char)(msg.type);
568 
569  if (msg_format_is_tiny) {
570  buf[nBytesTx++] = (unsigned char)msg.content.size();
571  } else {
572  buf[nBytesTx++] = msg.content.size() & 0xff; // lo
573  buf[nBytesTx++] = (msg.content.size()>>8) & 0xff; // hi
574  }
575 
576  if (!msg.content.empty())
577  memcpy( buf+nBytesTx, &msg.content[0], msg.content.size() );
578  nBytesTx += (unsigned char)msg.content.size();
579  buf[nBytesTx++] = 0x96;
580 
581  // Send buffer -------------------------------------
582  WriteBuffer(buf,nBytesTx); // Exceptions will be raised on errors here
583 
584  MRPT_END
585 }
586 
587 /*-------------------------------------------------------------
588  receiveMessage
589 -------------------------------------------------------------*/
591 {
592  MRPT_START
593  std::vector<unsigned char> buf(66000);
594  unsigned int nBytesInFrame=0;
595  unsigned long nBytesToRx=0;
596  unsigned char tries = 2;
597  unsigned int payload_len = 0;
598  unsigned int expectedLen = 0;
599 
600  for (;;)
601  {
602  if (nBytesInFrame<4)
603  nBytesToRx = 1;
604  else
605  {
606  if (buf[0] == 0x69)
607  {
608  payload_len = buf[2];
609  expectedLen = payload_len + 4;
610  }
611  else if( buf[0] == 0x79 )
612  {
613  payload_len = MAKEWORD16B(buf[3] /*low*/, buf[2] /*hi*/); // Length of the content
614  expectedLen = payload_len + 5;
615  }
616  nBytesToRx = expectedLen - nBytesInFrame;
617  } // end else
618 
619  unsigned long nBytesRx = 0;
620  try {
621  nBytesRx = ReadBufferImmediate(&buf[nBytesInFrame], nBytesToRx);
622  }
623  catch (...) {
624  }
625 
626  // No more data! (read timeout is already included in the call to "Read")
627  if (!nBytesRx)
628  return false;
629 
630  if (!nBytesInFrame && buf[0]!=0x69 && buf[0]!=0x79 )
631  {
632  // Start flag is invalid:
633  if (!tries--) return false;
634  }
635  else
636  {
637  // Is a new byte for the frame:
638  nBytesInFrame += nBytesRx;
639 
640  if (nBytesInFrame == expectedLen )
641  {
642  // Frame complete
643  // check for frame be ok:
644 
645  // End flag?
646  if (buf[nBytesInFrame-1]!=0x96)
647  {
648  // Error in frame!
649  nBytesInFrame=0;
650  return false;
651  }
652  else
653  {
654  // copy out data:
655  msg.type = buf[1];
656  if( buf[0] == 0x69 )
657  {
658  msg.content.resize(payload_len);
659  if (!msg.content.empty())
660  memcpy( &msg.content[0], &buf[3], payload_len);
661  } // end if
662  if ( buf[0] == 0x79 )
663  {
664  msg.content.resize(payload_len);
665  if (!msg.content.empty())
666  memcpy( &msg.content[0], &buf[4], payload_len);
667  } // end if
668  return true;
669  }
670  }
671  }
672  }
673  MRPT_END
674 }
675 
676 /*-------------------------------------------------------------
677 Reads from the stream until a '\n' character is found ('\r' characters are ignored).
678 return false on EOF or any other read error.
679 -------------------------------------------------------------*/
681 {
682  out_str.clear();
683  try
684  {
685  for (;;)
686  {
687  size_t N = out_str.size();
688  out_str.resize(N+1);
689  if (! Read(&out_str[N], 1) )
690  return false;
691 
692  // New char read:
693  if (out_str[N]=='\r')
694  {
695  out_str.resize(N); // Ignore.
696  }
697  else if (out_str[N]=='\n')
698  {
699  out_str.resize(N); // End of line!
700  return true; // Ok.
701  }
702  }
703  }
704  catch(...)
705  { // Any read error:
706  return false;
707  }
708 }
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
Definition: os.cpp:358
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
Definition: CStream.cpp:45
CSerializablePtr ReadObject()
Reads an object from stream, its class determined at runtime, and returns a smart pointer to the obje...
Definition: CStream.cpp:486
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
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:680
unsigned __int16 uint16_t
Definition: rptypes.h:46
std::vector< uint32_t > vector_uint
Definition: types_simple.h:28
std::vector< uint8_t > vector_byte
Definition: types_simple.h:26
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:29
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
void BASE_IMPEXP registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
GLuint buffer
Definition: glext.h:3775
#define THROW_STACKED_EXCEPTION_CUSTOM_MSG2(e, stuff, param1)
#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:4618
Scalar * iterator
Definition: eigen_plugins.h:23
CStream & readStdVectorToStream(mrpt::utils::CStream &s, VEC &v)
Definition: CStream.cpp:252
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
Definition: CStream.cpp:67
CStream & operator<<(const CSerializablePtr &pObj)
Write an object to a stream in the binary MRPT format.
Definition: CStream.cpp:211
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:35
signed char int8_t
Definition: rptypes.h:42
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:24
GLdouble s
Definition: glext.h:3602
CStream & writeStdVectorToStream(mrpt::utils::CStream &s, const VEC &v)
Definition: CStream.cpp:247
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
std::vector< int8_t > vector_signed_byte
Definition: types_simple.h:21
#define IMPLEMENT_CSTREAM_READ_WRITE_SIMPLE_TYPE(T)
Definition: CStream.cpp:100
void internal_ReadObject(CSerializablePtr &newObj, CSerializable *existingObj=NULL)
A common template code for both versions of CStream::ReadObject()
Definition: CStream.cpp:357
std::vector< bool > vector_bool
A type for passing a vector of bools.
Definition: types_simple.h:29
unsigned char uint8_t
Definition: rptypes.h:43
std::vector< int64_t > vector_long
Definition: types_simple.h:24
::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CImagePtr &pObj)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
mrpt::utils::CObject * createObject() const
Definition: CObject.cpp:88
__int16 int16_t
Definition: rptypes.h:45
#define MRPT_END
__int64 int64_t
Definition: rptypes.h:51
const TRuntimeClassId BASE_IMPEXP * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or NULL if the class is not registered.
#define vsnprintf
Definition: zutil.h:204
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
GLubyte GLubyte b
Definition: glext.h:5575
#define THROW_TYPED_EXCEPTION(msg, exceptionClass)
Defines a unified way of reporting exceptions of type different than "std::exception".
int version
Definition: mrpt_jpeglib.h:898
void WriteObject(const CSerializable *o)
Writes an object to the stream.
Definition: CStream.cpp:166
CStream BASE_IMPEXP & operator<<(mrpt::utils::CStream &s, const char *a)
Definition: CStream.cpp:130
GLsizei const GLchar ** string
Definition: glext.h:3919
Used in mrpt::utils::CStream.
Definition: exceptions.h:38
#define SERIALIZATION_END_FLAG
Definition: CStream.cpp:25
#define MRPT_START
__int32 int32_t
Definition: rptypes.h:48
unsigned __int64 uint64_t
Definition: rptypes.h:52
const GLdouble * v
Definition: glext.h:3603
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:590
CStream & operator>>(CSerializablePtr &pObj)
Definition: CStream.cpp:224
std::vector< uint16_t > vector_word
Definition: types_simple.h:27
GLuint id
Definition: glext.h:3770
std::vector< int16_t > vector_signed_word
Definition: types_simple.h:22
GLuint GLsizei GLsizei * length
Definition: glext.h:3900
GLuint in
Definition: glext.h:6301
#define ASSERT_(f)
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const
Returns information about the class of an object in runtime.
void sendMessage(const utils::CMessage &msg)
Send a message to the device.
Definition: CStream.cpp:556
std::vector< uint8_t > content
The contents of the message (memory is automatically handled by the std::vector object) ...
Definition: CMessage.h:33
std::vector< int32_t > vector_int
Definition: types_simple.h:23
virtual ~CStream()
Definition: CStream.cpp:36
A structure that holds runtime class type information.
Definition: CObject.h:36
const char * className
Definition: CObject.h:38
unsigned __int32 uint32_t
Definition: rptypes.h:49
GLubyte GLubyte GLubyte a
Definition: glext.h:5575
#define MAKEWORD16B(__LOBYTE, __HILOBYTE)
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
Definition: CMessage.h:29
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Definition: CStream.cpp:507
uint32_t type
An identifier of the message type (only the least-sig byte is typically sent)
Definition: CMessage.h:32



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019