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



Page generated by Doxygen 1.9.1 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at mar 26 may 2026 13:12:03 CEST