PhoenixSerializer  3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
Loading...
Searching...
No Matches
data_stream_message.cpp
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
8
10
15 char * srcByte = reinterpret_cast<char *>(&data); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) the data is read or written as raw bytes
16 memcpy(srcByte, ds, sizeof(bool));
17 ds += sizeof(bool); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the message iterator moves forward after each read or write, the message is allocated with data_size
18 return true;
19}
20
22
28 char * srcByte = reinterpret_cast<char *>(data); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) the data is read or written as raw bytes
29 memcpy(srcByte, ds, sizeof(bool) * nbElement);
30 ds += sizeof(bool) * nbElement; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the message iterator moves forward after each read or write, the message is allocated with data_size
31 return true;
32}
33
35
40 const char * srcByte = reinterpret_cast<const char *>(&data); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) the data is read or written as raw bytes
41 memcpy(ds, srcByte, sizeof(bool));
42 ds += sizeof(bool); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the message iterator moves forward after each read or write, the message is allocated with data_size
43 return true;
44}
45
47
52bool Serializer<SerializeIter, SerializeMode::WRITE, bool>::phoenix_serialize(SerializeIter & ds, bool * data, size_t nbElement) { // NOLINT(readability-non-const-parameter) : adding const will break the design for user types
53 const char * srcByte = reinterpret_cast<const char *>(data); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) the data is read or written as raw bytes
54 memcpy(ds, srcByte, sizeof(bool) * nbElement);
55 ds += sizeof(bool) * nbElement; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the message iterator moves forward after each read or write, the message is allocated with data_size
56 return true;
57}
58
60
65 size_t nbElement(0LU);
67 if(nbElement == 0LU || !b) {
68 return b;
69 }
70 data.resize(nbElement);
71 memcpy(reinterpret_cast<SerializeIter>(data.data()), ds, nbElement); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) the data is read or written as raw bytes
72 ds += nbElement; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the message iterator moves forward after each read or write, the message is allocated with data_size
73 return b;
74}
75
77
82 size_t nbElement(data.size());
84 if(nbElement == 0LU || !b) {
85 return b;
86 }
87 memcpy(ds, reinterpret_cast<const SerializeIter>(data.data()), nbElement); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) the data is read or written as raw bytes
88 ds += nbElement; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) the message iterator moves forward after each read or write, the message is allocated with data_size
89 return b;
90}
SerializeType * SerializeIter
static bool phoenix_serialize(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.