Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
Vector.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
15 #include <utility> //move
16 #include <vector>
17 
18 namespace Pothos {
19 namespace serialization {
20 
21 //------------ boolean vectors use a special internal type --------------//
22 template <typename Archive, typename Allocator>
23 void save(Archive &ar, const std::vector<bool, Allocator> &t, const unsigned int)
24 {
25  ar << unsigned(t.size());
26  for (const bool elem : t)
27  {
28  ar << elem;
29  }
30 }
31 
32 template <typename Archive, typename Allocator>
33 void load(Archive &ar, std::vector<bool, Allocator> &t, const unsigned int)
34 {
35  unsigned size(0);
36  ar >> size;
37  t.resize(size);
38  for (size_t i = 0; i < size_t(size); i++)
39  {
40  bool elem;
41  ar >> elem;
42  t[i] = elem;
43  }
44 }
45 
46 //------------ a vector of any type --------------//
47 template<typename Archive, typename T, typename Allocator>
48 void save(Archive &ar, const std::vector<T, Allocator> &t, const unsigned int)
49 {
50  ar << unsigned(t.size());
51  for (const auto &elem : t)
52  {
53  ar << elem;
54  }
55 }
56 
57 template<typename Archive, typename T, typename Allocator>
58 void load(Archive &ar, std::vector<T, Allocator> &t, const unsigned int)
59 {
60  unsigned size(0);
61  ar >> size;
62  t.resize(size);
63  for (size_t i = 0; i < size_t(size); i++)
64  {
65  T elem;
66  ar >> elem;
67  t[i] = std::move(elem);
68  }
69 }
70 
71 template <typename Archive, typename T, typename Allocator>
72 void serialize(Archive &ar, std::vector<T, Allocator> &t, const unsigned int ver)
73 {
75 }
76 
77 }}
Definition: ArchiveEntry.hpp:20
std::enable_if< Archive::isSave::value >::type invokeSplit(Archive &ar, T &value, const unsigned int ver)
Definition: Invoke.hpp:69
void save(Archive &ar, const std::complex< T > &t, const unsigned int)
Definition: Complex.hpp:20
void serialize(Archive &ar, std::complex< T > &t, const unsigned int ver)
Definition: Complex.hpp:37
void load(Archive &ar, std::complex< T > &t, const unsigned int)
Definition: Complex.hpp:27