Main MRPT website > C++ reference for MRPT 1.5.6
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.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
GLhandleARB obj
Definition: glew.h:3276
An object for reading objects from a stream, intended for being used in STL algorithms.
GLfloat GLfloat p
Definition: glew.h:10113



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