Main MRPT website > C++ reference for MRPT 1.5.6
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 
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer On any error, or if ZERO bytes are read...
Definition: CStream.cpp:45
GLvoid *typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1745
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
GLuint in
Definition: glew.h:7146
void resize(uint64_t newSize)
Resizes the internal buffer size.
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...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
int version
Definition: mrpt_jpeglib.h:898
A memory buffer (implements CStream) which can be itself serialized.
Definition: CMemoryChunk.h:27
unsigned __int64 uint64_t
Definition: rptypes.h:52
#define ASSERT_(f)
void_ptr_noncopy m_memory
Internal data.
Definition: CMemoryStream.h:33



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018