Main MRPT website > C++ reference for MRPT 1.9.9
CMemoryChunk.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 
13 
14 using namespace mrpt::utils;
15 
16 // This must be added to any CSerializable class implementation file.
18 
19 /*---------------------------------------------------------------
20  writeToStream
21  ---------------------------------------------------------------*/
22 void CMemoryChunk::writeToStream(
23  mrpt::utils::CStream& out, int* out_Version) const
24 {
25  if (out_Version)
26  *out_Version = 0;
27  else
28  {
29  out << static_cast<uint64_t>(m_bytesWritten);
30  if (m_bytesWritten)
31  {
32  ASSERT_(m_memory.get())
33  out.WriteBuffer(m_memory.get(), m_bytesWritten);
34  }
35  }
36 }
37 
38 /*---------------------------------------------------------------
39  readFromStream
40  ---------------------------------------------------------------*/
42 {
43  switch (version)
44  {
45  case 0:
46  {
47  uint64_t N;
48  in >> N;
49  resize(N);
50 
51  m_bytesWritten = N;
52  m_position = 0;
53  if (N) in.ReadBuffer(m_memory.get(), N);
54  }
55  break;
56  default:
58  };
59 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void resize(uint64_t newSize)
Resizes the internal buffer size.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
A memory buffer (implements CStream) which can be itself serialized.
Definition: CMemoryChunk.h:24
unsigned __int64 uint64_t
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void_ptr_noncopy m_memory
Internal data.
Definition: CMemoryStream.h:34



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