69 assert(val.index() >= 0 && val.index() <= 0xff);
71 char valIndex = (char)val.index();
73 stream.
append(&valIndex, 1);
79 const auto intValue = std::get<container::xpod::type_index::integer>(val);
80 stream.
append(
reinterpret_cast<const char*
>(&intValue),
sizeof(intValue));
85 const auto doubleValue = std::get<container::xpod::type_index::number>(val);
86 stream.
append(
reinterpret_cast<const char*
>(&doubleValue),
sizeof(doubleValue));
91 const auto boolValue = std::get<container::xpod::type_index::boolean>(val);
92 stream.
append(
reinterpret_cast<const char*
>(&boolValue),
sizeof(boolValue));
98 const auto strValue = (std::string)std::get<container::xpod::type_index::pointer>(val);
99 const auto strLen = strValue.size();
100 stream.
append(
reinterpret_cast<const char*
>(&strLen),
sizeof(strLen));
101 stream.
append(strValue.data(), strLen);
106 const auto strValue = std::get<container::xpod::type_index::string>(val);
107 const auto strLen = strValue.size();
108 stream.
append(
reinterpret_cast<const char*
>(&strLen),
sizeof(strLen));
109 stream.
append(strValue.data(), strLen);
129 uint8_t* localIt = (uint8_t*)it;
131 const unsigned long valIndex = *localIt++;
137 std::memcpy(&intValue, localIt,
sizeof(intValue));
139 localIt +=
sizeof(intValue);
145 std::memcpy(&doubleValue, localIt,
sizeof(doubleValue));
147 localIt +=
sizeof(doubleValue);
153 std::memcpy(&boolValue, localIt,
sizeof(boolValue));
155 localIt +=
sizeof(boolValue);
161 std::memcpy(&strLen, localIt,
sizeof(strLen));
162 localIt +=
sizeof(strLen);
170 std::memcpy(&strLen, localIt,
sizeof(strLen));
171 localIt +=
sizeof(strLen);
172 val = std::string(localIt, localIt + strLen);
Manages memory a byte buffer, offering dynamic appending. This class is designed for scenarios where ...
Definition buffer.hpp:50
virtual void append(const void *buffer_to_append, const std::size_t length_of_buffer)
append the given buffer to the end of the current buffer. If there is no current buffer yet,...
Definition buffer.hpp:96
A Cbeam-specific runtime error that also acts like std::runtime_error.
Definition runtime_error.hpp:46
The pointer class is one of the types supported by container::xpod::type.
Definition pointer.hpp:46
constexpr std::size_t number
Definition xpod.hpp:51
constexpr std::size_t boolean
Definition xpod.hpp:52
constexpr std::size_t pointer
Definition xpod.hpp:53
constexpr std::size_t string
Definition xpod.hpp:54
constexpr std::size_t integer
Definition xpod.hpp:50
std::variant< long long, double, bool, memory::pointer, std::string > type
A variant designed for basic data types. memory::pointer is used in place of void* to provide additio...
Definition xpod.hpp:46
Offers advanced container types with unique approaches to stability and interprocess sharing....
Definition buffer.hpp:44
Implements traits-based serialization for complex data types, including standard containers and custo...
Definition direct.hpp:38
void * serialized_object
Represents a serialized value in memory.
Definition traits.hpp:42
static void deserialize(serialized_object &it, container::xpod::type &val)
Deserialize an xpod::type variant from the buffer pointed to by it.
Definition xpod.hpp:127
static void serialize(const container::xpod::type &val, container::buffer &stream)
Serialize the given xpod::type variant into the buffer stream.
Definition xpod.hpp:67
Defines the traits required for serializing and deserializing objects of type T.
Definition traits.hpp:52