Pothos  0.5.0-ga4964040
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:
26  OStreamArchiver(std::ostream &os);
27 
28  typedef std::true_type isSave;
29 
30  template <typename T>
31  void operator&(const T &value);
32 
33  template <typename T>
34  void operator<<(const T &value);
35 
36  void writeBytes(const void *buff, const size_t len);
37 
38 private:
39 
40  std::ostream &os;
41  unsigned int ver;
42 };
43 
48 {
49 public:
50  IStreamArchiver(std::istream &is);
51 
52  typedef std::false_type isSave;
53 
54  template <typename T>
55  void operator&(T &value);
56 
57  template <typename T>
58  void operator>>(T &value);
59 
60  void readBytes(void *buff, const size_t len);
61 
62 private:
63 
64  std::istream &is;
65  unsigned int ver;
66 };
67 
68 } //namespace Archive
69 } //namespace Pothos
70 
72 
73 template <typename T>
75 {
76  Pothos::serialization::invokeSerialize(*this, const_cast<T &>(value), ver);
77 }
78 
79 template <typename T>
81 {
82  *this & value;
83 }
84 
85 template <typename T>
87 {
88  Pothos::serialization::invokeSerialize(*this, value, ver);
89 }
90 
91 template <typename T>
93 {
94  *this & value;
95 }
#define POTHOS_API
Definition: Config.hpp:41
void operator>>(T &value)
Definition: StreamArchiver.hpp:92
void operator&(const T &value)
Definition: StreamArchiver.hpp:74
void operator&(T &value)
Definition: StreamArchiver.hpp:86
Definition: ArchiveEntry.hpp:20
Definition: StreamArchiver.hpp:47
std::enable_if<!hasSerialize< T, Archive >::value >::type invokeSerialize(Archive &ar, T &value, const unsigned int ver)
Definition: Invoke.hpp:91
std::false_type isSave
Definition: StreamArchiver.hpp:52
Definition: StreamArchiver.hpp:23
void operator<<(const T &value)
Definition: StreamArchiver.hpp:80
std::true_type isSave
Definition: StreamArchiver.hpp:28