Main MRPT website > C++ reference for MRPT 1.9.9
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
23  * algorithms. */
25 {
26  private:
28 
29  public:
31  {
32  }
33  // T can be CSerializable::Ptr, CSerializable, or any other class
34  // implementing ">>"
35  template <typename T>
36  inline void operator()(T& obj)
37  {
38  (*m_stream) >> obj;
39  }
40 };
41 
42 template <typename ptr_t>
44 {
45  private:
47 
48  public:
50  : m_stream(stream)
51  {
52  }
53  template <typename ptr2ptr_t>
54  inline void operator()(ptr2ptr_t& obj)
55  {
56  ptr_t p;
57  (*m_stream) >> p;
58  obj = p;
59  }
60 };
61 
62 /** An object for writing objects to a stream, intended for being used in STL
63  * algorithms. */
65 {
66  private:
68 
69  public:
71  {
72  }
73 
74  // T can be CSerializable::Ptr, CSerializable, or any other class
75  // implementing "<<"
76  template <typename T>
77  inline void operator()(const T& ptr)
78  {
79  (*m_stream) << ptr;
80  }
81 };
82 
83 /** @} */ // end of grouping
84 }
85 }
86 }
An object for writing objects to a stream, intended for being used in STL algorithms.
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
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:6305



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