PhoenixSerializer
3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
Toggle main menu visibility
Loading...
Searching...
No Matches
data_stream_size.h
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : LGPL-3.0-only
5
****************************************/
6
7
#ifndef __DATA_STREAM_SIZE_H__
8
#define __DATA_STREAM_SIZE_H__
9
10
#include "
data_stream_include.h
"
11
13
template
<
typename
T>
14
struct
Serializer
<size_t,
SerializeMode
::WRITE, T *> {
16
20
static
bool
phoenix_serialize
(
size_t
& ds, T *& data) {
21
ds +=
sizeof
(T *);
22
return
true
;
23
}
24
};
25
27
template
<
typename
T>
28
struct
Serializer
<size_t,
SerializeMode
::WRITE, std::vector<T>> {
30
34
static
bool
phoenix_serialize
(
size_t
& ds, std::vector<T> & data) {
35
ds +=
sizeof
(size_t);
36
for
(
typename
std::vector<T>::iterator it(data.begin()); it != data.end(); ++it) {
37
Serializer<size_t, SerializeMode::WRITE, T>::phoenix_serialize
(ds, *it);
38
}
39
return
true
;
40
}
41
};
42
44
template
<
typename
T>
45
struct
Serializer
<size_t,
SerializeMode
::WRITE, std::list<T>> {
47
51
static
bool
phoenix_serialize
(
size_t
& ds, std::list<T> & data) {
52
ds +=
sizeof
(size_t);
53
for
(
typename
std::list<T>::iterator it(data.begin()); it != data.end(); ++it) {
54
Serializer<size_t, SerializeMode::WRITE, T>::phoenix_serialize
(ds, *it);
55
}
56
return
true
;
57
}
58
};
59
61
template
<
typename
T,
typename
U>
62
struct
Serializer
<size_t,
SerializeMode
::WRITE, std::map<T, U>> {
64
68
static
bool
phoenix_serialize
(
size_t
& ds, std::map<T, U> & data) {
69
ds +=
sizeof
(size_t);
70
for
(
typename
std::map<T, U>::iterator it(data.begin()); it != data.end(); ++it) {
71
Serializer<size_t, SerializeMode::WRITE, T>::phoenix_serialize
(ds, (T &)it->first);
// NOLINT(modernize-avoid-c-style-cast) WRITE never modifies data, but Serializer takes T & to share one function with READ
72
Serializer<size_t, SerializeMode::WRITE, U>::phoenix_serialize
(ds, it->second);
73
}
74
return
true
;
75
}
76
};
77
79
template
<
typename
T,
typename
U>
80
struct
Serializer
<size_t,
SerializeMode
::WRITE, std::pair<T, U>> {
82
86
static
bool
phoenix_serialize
(
size_t
& ds, std::pair<T, U> & data) {
87
Serializer<size_t, SerializeMode::WRITE, T>::phoenix_serialize
(ds, (T &)data.first);
// NOLINT(modernize-avoid-c-style-cast) WRITE never modifies data, but Serializer takes T & to share one function with READ
88
Serializer<size_t, SerializeMode::WRITE, U>::phoenix_serialize
(ds, data.second);
89
return
true
;
90
}
91
};
92
94
template
<>
95
struct
Serializer
<size_t,
SerializeMode
::WRITE, bool> {
96
static
bool
phoenix_serialize
(
size_t
& ds,
bool
& data);
97
static
bool
phoenix_serialize
(
size_t
& ds,
bool
* data,
size_t
nbElement);
98
};
99
101
template
<>
102
struct
Serializer
<size_t,
SerializeMode
::WRITE, std::string> {
103
static
bool
phoenix_serialize
(
size_t
& ds, std::string & data);
104
};
105
106
#endif
data_stream_include.h
SerializeMode
Definition
data_stream_include.h:18
Serializer< size_t, SerializeMode::WRITE, T * >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, T *&data)
Get the size of a class T*.
Definition
data_stream_size.h:20
Serializer< size_t, SerializeMode::WRITE, bool >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, bool &data)
Get the size of a type bool.
Definition
data_stream_size.cpp:14
Serializer< size_t, SerializeMode::WRITE, std::list< T > >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, std::list< T > &data)
Get the size of a class std::list T.
Definition
data_stream_size.h:51
Serializer< size_t, SerializeMode::WRITE, std::map< T, U > >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, std::map< T, U > &data)
Get the size of a class std::list T.
Definition
data_stream_size.h:68
Serializer< size_t, SerializeMode::WRITE, std::pair< T, U > >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, std::pair< T, U > &data)
Get the size of a class std::list T.
Definition
data_stream_size.h:86
Serializer< size_t, SerializeMode::WRITE, std::string >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, std::string &data)
Get the size of a std::string.
Definition
data_stream_size.cpp:35
Serializer< size_t, SerializeMode::WRITE, std::vector< T > >::phoenix_serialize
static bool phoenix_serialize(size_t &ds, std::vector< T > &data)
Get the size of a class std::vector T.
Definition
data_stream_size.h:34
Serializer
Generic Serializer class.
Definition
data_stream_include.h:32
Serializer::phoenix_serialize
static bool phoenix_serialize(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.
Definition
data_stream_include.h:37
src
data_stream_size.h
Generated by
1.18.0