MRPT  2.0.4
metaprogramming_serialization.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 
14 {
15 /** \addtogroup stlext_grp
16  * @{ */
17 
18 /** An object for reading objects from a stream, intended for being used in STL
19  * algorithms. */
21 {
22  private:
24 
25  public:
27  : m_stream(stream)
28  {
29  }
30  // T can be CSerializable::Ptr, CSerializable, or any other class
31  // implementing ">>"
32  template <typename T>
33  inline void operator()(T& obj)
34  {
35  (*m_stream) >> obj;
36  }
37 };
38 
39 template <typename ptr_t>
41 {
42  private:
44 
45  public:
47  : m_stream(stream)
48  {
49  }
50  template <typename ptr2ptr_t>
51  inline void operator()(ptr2ptr_t& obj)
52  {
53  ptr_t p;
54  (*m_stream) >> p;
55  obj = p;
56  }
57 };
58 
59 /** An object for writing objects to a stream, intended for being used in STL
60  * algorithms. */
62 {
63  private:
65 
66  public:
68  : m_stream(stream)
69  {
70  }
71 
72  // T can be CSerializable::Ptr, CSerializable, or any other class
73  // implementing "<<"
74  template <typename T>
75  inline void operator()(const T& ptr)
76  {
77  (*m_stream) << ptr;
78  }
79 };
80 
81 /** @} */ // end of grouping
82 } // namespace mrpt::serialization::metaprogramming
An object for reading objects from a stream, intended for being used in STL algorithms.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
An object for writing objects to a stream, intended for being used in STL algorithms.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020