PhoenixSerializer  3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
Loading...
Searching...
No Matches
data_stream_read_message.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_READ_MESSAGE_H__
8#define __DATA_STREAM_READ_MESSAGE_H__
9
10#include "data_stream_include.h"
11
13template <typename T>
16
20 static bool phoenix_serialize(SerializeIter & ds, T *& data) {
21 size_t pointerAddress = 0LU;
23 data = reinterpret_cast<T *>(pointerAddress); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr) the pointer address itself is serialised, only reinterpret_cast converts between pointer and integer
24 return b;
25 }
26};
27
29template <typename T>
30struct Serializer<SerializeIter, SerializeMode::READ, std::vector<T>> {
32
36 static bool phoenix_serialize(SerializeIter & ds, std::vector<T> & data) {
37 //Get the number of elements
38 size_t nbElement(0LU);
40 if(nbElement == 0LU || !b) {
41 return b;
42 } //If there is no element, quit now
43 for(size_t i(0LU); i < nbElement && b; ++i) {
44 T tmp;
46 data.push_back(tmp);
47 }
48 return b;
49 }
50};
51
53template <typename T>
54struct Serializer<SerializeIter, SerializeMode::READ, std::list<T>> {
56
60 static bool phoenix_serialize(SerializeIter & ds, std::list<T> & data) {
61 //Get the number of elements
62 size_t nbElement(0LU);
64 if(nbElement == 0LU || !b) {
65 return b;
66 } //If there is no element, quit now
67 for(size_t i(0LU); i < nbElement && b; ++i) {
68 T tmp;
70 data.push_back(tmp);
71 }
72 return b;
73 }
74};
75
77template <typename T, typename U>
78struct Serializer<SerializeIter, SerializeMode::READ, std::map<T, U>> {
80
84 static bool phoenix_serialize(SerializeIter & ds, std::map<T, U> & data) {
85 //Get the number of elements
86 size_t nbElement(0LU);
88 if(nbElement == 0LU || !b) {
89 return b;
90 } //If there is no element, quit now
91 for(size_t i(0LU); i < nbElement && b; ++i) {
92 T tmpFirst;
94 U tmpSecond;
96 data[tmpFirst] = tmpSecond; //Add data in map
97 }
98 return b;
99 }
100};
101
103template <typename T, typename U>
104struct Serializer<SerializeIter, SerializeMode::READ, std::pair<T, U>> {
106
110 static bool phoenix_serialize(SerializeIter & ds, std::pair<T, U> & data) {
111 T tmpFirst;
113 U tmpSecond;
115 data = std::pair<T, U>(tmpFirst, tmpSecond);
116 return b;
117 }
118};
119
120#endif
SerializeType * SerializeIter
static bool phoenix_serialize(SerializeIter &ds, T *&data)
READ a pointer address in a message.
static bool phoenix_serialize(SerializeIter &ds, std::list< T > &data)
Get the size of a class std::list T.
static bool phoenix_serialize(SerializeIter &ds, std::map< T, U > &data)
Get the size of a class std::list T.
static bool phoenix_serialize(SerializeIter &ds, std::pair< T, U > &data)
Get the size of a class std::list T.
static bool phoenix_serialize(SerializeIter &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.