Main MRPT website > C++ reference for MRPT 1.5.7
metaprogramming_serialization.h
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 #pragma once
10 
11 namespace mrpt
12 {
13  namespace utils
14  {
15  class CStream;
16 
17  namespace metaprogramming
18  {
19  /** \addtogroup stlext_grp
20  * @{ */
21 
22  /** An object for reading objects from a stream, intended for being used in STL algorithms. */
24  {
25  private:
27  public:
28  inline ObjectReadFromStream(mrpt::utils::CStream *stream) : m_stream(stream) { }
29  // T can be CSerializablePtr, CSerializable, or any other class implementing ">>"
30  template <typename T>
31  inline void operator()(T &obj) {
32  (*m_stream) >> obj;
33  }
34  };
35 
36  template <typename ptr_t>
38  {
39  private:
41  public:
43  template <typename ptr2ptr_t>
44  inline void operator()(ptr2ptr_t &obj) {
45  ptr_t p;
46  (*m_stream) >> p;
47  obj = p;
48  }
49  };
50 
51  /** An object for writing objects to a stream, intended for being used in STL algorithms. */
53  {
54  private:
56  public:
57  inline ObjectWriteToStream(mrpt::utils::CStream *stream) : m_stream(stream) { }
58 
59  // T can be CSerializablePtr, CSerializable, or any other class implementing "<<"
60  template <typename T>
61  inline void operator()(const T &ptr) {
62  (*m_stream) << ptr;
63  }
64  };
65 
66  /** @} */ // end of grouping
67  }
68  }
69 }
70 
An object for writing objects to a stream, intended for being used in STL algorithms.
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
An object for reading objects from a stream, intended for being used in STL algorithms.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLfloat GLfloat p
Definition: glext.h:5587



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