12 #ifndef THRILL_DATA_SERIALIZATION_HEADER 13 #define THRILL_DATA_SERIALIZATION_HEADER 22 #include <type_traits> 34 template <
typename Archive,
typename T>
36 typename
std::enable_if<
39 && !std::is_pointer<T>::value
42 ar.template PutRaw<T>(
x);
45 return ar.template GetRaw<T>();
47 static constexpr
bool is_fixed_size =
true;
48 static constexpr
size_t fixed_size =
sizeof(
T);
53 template <
typename Archive>
59 return ar.GetString();
61 static constexpr
bool is_fixed_size =
false;
62 static constexpr
size_t fixed_size = 0;
67 template <
typename Archive,
typename U,
typename V>
69 static void Serialize(
const std::pair<U, V>&
x, Archive& ar) {
76 return std::pair<U, V>(std::move(u), std::move(v));
78 static constexpr
bool is_fixed_size =
81 static constexpr
size_t fixed_size =
98 template <
typename Archive,
size_t RevIndex,
typename... Args>
101 static constexpr
size_t Index =
sizeof ... (Args) - RevIndex;
104 typename std::tuple_element<Index, std::tuple<Args...> >::type;
106 static void Serialize(
const std::tuple<Args...>&
x, Archive& ar) {
113 static constexpr
bool is_fixed_size
117 static constexpr
size_t fixed_size =
123 template <
typename Archive,
typename... Args>
125 static void Serialize(
const std::tuple<Args...>&, Archive&) {
128 static constexpr
bool is_fixed_size =
true;
129 static constexpr
size_t fixed_size = 0;
133 template <
typename Archive,
int RevIndex,
typename T,
typename... Args>
139 template <
typename Archive,
int RevIndex,
typename T,
typename... Args>
145 return std::tuple_cat(
147 Archive, RevIndex - 1, std::tuple<Args...> >::Deserialize(ar));
152 template <
typename Archive>
155 return std::make_tuple();
164 template <
typename Archive,
typename... Args>
166 static void Serialize(
const std::tuple<Args...>&
x, Archive& ar) {
168 Archive,
sizeof ... (Args), Args...>::Serialize(x, ar);
172 Archive,
sizeof ... (Args), std::tuple<Args...> >::Deserialize(ar);
176 Archive,
sizeof ... (Args), Args...>::is_fixed_size;
178 Archive, sizeof ... (Args), Args...>::fixed_size;
183 template <
typename Archive,
typename T>
185 static void Serialize(
const std::vector<T>&
x, Archive& ar) {
186 ar.PutVarint(x.size());
187 for (
typename std::vector<T>::const_iterator it = x.begin();
192 size_t size = ar.GetVarint();
195 for (
size_t i = 0; i != size; ++i)
199 static constexpr
bool is_fixed_size =
false;
200 static constexpr
size_t fixed_size = 0;
205 template <
typename Archive,
typename T,
size_t N>
207 typename std::enable_if<
209 !std::is_pod<std::array<T, N> >::value
212 static void Serialize(
const std::array<T, N>&
x, Archive& ar) {
213 for (
typename std::array<T, N>::const_iterator it = x.begin();
218 std::array<T, N> out;
219 for (
size_t i = 0; i !=
N; ++i)
231 template <
typename Archive,
typename T>
233 typename
std::enable_if<
234 has_member_thrill_is_fixed_size<T>::value
238 x.ThrillSerialize(ar);
241 return T::ThrillDeserialize(ar);
243 static constexpr
bool is_fixed_size = T::thrill_is_fixed_size;
244 static constexpr
size_t fixed_size = T::thrill_fixed_size;
252 #endif // !THRILL_DATA_SERIALIZATION_HEADER static std::array< T, N > Deserialize(Archive &ar)
static T Deserialize(Archive &ar)
static std::string Deserialize(Archive &ar)
TLX_MAKE_HAS_MEMBER(thrill_is_fixed_size)
typename std::tuple_element< Index, std::tuple< Args... > >::type ThisElemType
static std::tuple Deserialize(Archive &)
static std::tuple< Args... > Deserialize(Archive &ar)
static std::pair< U, V > Deserialize(Archive &ar)
static void Serialize(const std::vector< T > &x, Archive &ar)
static void Serialize(const std::pair< U, V > &x, Archive &ar)
static void Serialize(const T &x, Archive &ar)
static std::vector< T > Deserialize(Archive &ar)
static void Serialize(const std::tuple< Args... > &x, Archive &ar)
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
std::vector< T, Allocator< T > > vector
vector with Manager tracking
static void Serialize(const std::array< T, N > &x, Archive &ar)
static std::tuple< T, Args... > Deserialize(Archive &ar)
static void Serialize(const T &x, Archive &ar)
static void Serialize(const std::tuple< Args... > &, Archive &)
static void Serialize(const std::tuple< Args... > &x, Archive &ar)
static T Deserialize(Archive &ar)
static void Serialize(const std::string &x, Archive &ar)