PhoenixSerializer  3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
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
13template <typename T>
14struct 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
27template <typename T>
28struct 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) {
38 }
39 return true;
40 }
41};
42
44template <typename T>
45struct 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) {
55 }
56 return true;
57 }
58};
59
61template <typename T, typename U>
62struct 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
73 }
74 return true;
75 }
76};
77
79template <typename T, typename U>
80struct 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
89 return true;
90 }
91};
92
94template <>
95struct 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
101template <>
102struct Serializer<size_t, SerializeMode::WRITE, std::string> {
103 static bool phoenix_serialize(size_t & ds, std::string & data);
104};
105
106#endif
static bool phoenix_serialize(size_t &ds, T *&data)
Get the size of a class T*.
static bool phoenix_serialize(size_t &ds, bool &data)
Get the size of a type bool.
static bool phoenix_serialize(size_t &ds, std::list< T > &data)
Get the size of a class std::list T.
static bool phoenix_serialize(size_t &ds, std::map< T, U > &data)
Get the size of a class std::list T.
static bool phoenix_serialize(size_t &ds, std::pair< T, U > &data)
Get the size of a class std::list T.
static bool phoenix_serialize(size_t &ds, std::string &data)
Get the size of a std::string.
static bool phoenix_serialize(size_t &ds, std::vector< T > &data)
Get the size of a class std::vector T.
Generic Serializer class.
static bool phoenix_serialize(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.