Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
StreamArchiver.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
13 #include <type_traits>
14 #include <iosfwd>
15 #include <cstddef> //size_t
16 
17 namespace Pothos {
18 namespace Archive {
19 
24 {
25 public:
30  OStreamArchiver(std::ostream &os);
31 
33  typedef std::true_type isSave;
34 
39  template <typename T>
40  void operator&(const T &value);
41 
46  template <typename T>
47  void operator<<(const T &value);
48 
52  void writeBytes(const void *buff, const size_t len);
53 
54 private:
55 
56  std::ostream &os;
57  unsigned int ver;
58 };
59 
64 {
65 public:
70  IStreamArchiver(std::istream &is);
71 
73  typedef std::false_type isSave;
74 
79  template <typename T>
80  void operator&(T &value);
81 
86  template <typename T>
87  void operator>>(T &value);
88 
92  void readBytes(void *buff, const size_t len);
93 
94 private:
95 
96  std::istream &is;
97  unsigned int ver;
98 };
99 
100 } //namespace Archive
101 } //namespace Pothos
102 
104 
105 #include <Pothos/Archive/Invoke.hpp>
106 
107 template <typename T>
109 {
110  Pothos::serialization::invokeSerialize(*this, const_cast<T &>(value), ver);
111 }
112 
113 template <typename T>
115 {
116  *this & value;
117 }
118 
119 template <typename T>
121 {
122  Pothos::serialization::invokeSerialize(*this, value, ver);
123 }
124 
125 template <typename T>
127 {
128  *this & value;
129 }
130 
#define POTHOS_API
Definition: Config.hpp:41
Definition: ArchiveEntry.hpp:20
Definition: StreamArchiver.hpp:63
std::enable_if<!hasSerialize< T, Archive >::value >::type invokeSerialize(Archive &ar, T &value, const unsigned int ver)
Definition: Invoke.hpp:91
void operator &(const T &value)
std::false_type isSave
Tell the invoker that this archiver loads.
Definition: StreamArchiver.hpp:73
Definition: StreamArchiver.hpp:23
void operator<<(const T &value)
std::true_type isSave
Tell the invoker that this archiver saves.
Definition: StreamArchiver.hpp:33