39#ifndef POSITION_DATA_H
40#define POSITION_DATA_H
43#if BYTE_ORDER == BIG_ENDIAN
44#error Big endian detected! Serialization expects little endian system!
67 constexpr size_t size()
const {
return sizeof(
x) +
sizeof(
y) +
sizeof(
z); }
74 int serialize(
char* buffer,
size_t buffer_size)
const
77 if (buffer_size <
size()) {
78 return -((int)
size());
80 std::memcpy(buffer + idx, &
x,
sizeof(
x)); idx +=
sizeof(
x);
81 std::memcpy(buffer + idx, &
y,
sizeof(
x)); idx +=
sizeof(
y);
82 std::memcpy(buffer + idx, &
z,
sizeof(
x)); idx +=
sizeof(
z);
93 if (buffer_size <
size())
95 std::memcpy(&
x, buffer + idx,
sizeof(
x)); idx +=
sizeof(
x);
96 std::memcpy(&
y, buffer + idx,
sizeof(
y)); idx +=
sizeof(
y);
97 std::memcpy(&
z, buffer + idx,
sizeof(
z)); idx +=
sizeof(
z);
Position data structure for submitting node positions to DESERT in ENU coordinates.
int serialize(char *buffer, size_t buffer_size) const
Serialize the position data to buffer.
constexpr size_t size() const
Compute required buffer size for (de-)serialization.
bool deserialize(char *buffer, size_t buffer_size)
Deserialize the position data from the buffer.