PhoenixSerializer  3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
Loading...
Searching...
No Matches
Serializer< SerializeIter, SerializeMode::WRITE, bool > Struct Reference

How to write bool in a message. More...

#include <data_stream_message.h>

Inheritance diagram for Serializer< SerializeIter, SerializeMode::WRITE, bool >:
Collaboration diagram for Serializer< SerializeIter, SerializeMode::WRITE, bool >:

Static Public Member Functions

static bool phoenix_serialize (SerializeIter &ds, bool &data)
 Save the bool in the message.
static bool phoenix_serialize (SerializeIter &ds, bool *data, size_t nbElement)
 Save the bool in the message.

Detailed Description

How to write bool in a message.

Definition at line 21 of file data_stream_message.h.

Member Function Documentation

◆ phoenix_serialize() [1/2]

bool Serializer< SerializeIter, SerializeMode::WRITE, bool >::phoenix_serialize ( SerializeIter & ds,
bool & data )
static

Save the bool in the message.

Parameters
[out]ds: message to be written
data: data to be saved in the message
Returns
true on success, false otherwise

Definition at line 39 of file data_stream_message.cpp.

39 {
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}
Generic Serializer class.

◆ phoenix_serialize() [2/2]

bool Serializer< SerializeIter, SerializeMode::WRITE, bool >::phoenix_serialize ( SerializeIter & ds,
bool * data,
size_t nbElement )
static

Save the bool in the message.

Parameters
[out]ds: message to be written
data: data to be saved in the message
nbElement: number of element of the data
Returns
true on success, false otherwise

Definition at line 52 of file data_stream_message.cpp.

52 { // 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}

The documentation for this struct was generated from the following files: