Cbeam
Loading...
Searching...
No Matches
cbeam::serialization::traits< container::xpod::type > Struct Reference

Specialization of traits for cbeam::container::xpod::type. More...

#include <xpod.hpp>

Static Public Member Functions

static void serialize (const container::xpod::type &val, container::buffer &stream)
 Serialize the given xpod::type variant into the buffer stream.
 
static void deserialize (serialized_object &it, container::xpod::type &val)
 Deserialize an xpod::type variant from the buffer pointed to by it.
 
static void serialize (const container::xpod::type &val, container::buffer &stream)
 Required to serialize an object of type T into a shared_buffer stream.
 
static void deserialize (serialized_object &it, container::xpod::type &val)
 Required to deserialize an object of type T from a serialized memory block, incrementing the iterator it.
 

Detailed Description

Specialization of traits for cbeam::container::xpod::type.

The variant can hold: long long, double, bool, memory::pointer, or std::string. During serialization, we first store the variant index (1 byte), then the corresponding data in a type-dependent format.

Member Function Documentation

◆ deserialize() [1/2]

static void cbeam::serialization::traits< container::xpod::type >::deserialize ( serialized_object & it,
container::xpod::type & val )
inlinestatic

Required to deserialize an object of type T from a serialized memory block, incrementing the iterator it.

Parameters
itA reference to a pointer to the serialized memory block.
valA reference to the object of type T, where the deserialized data will be stored.

This method should deserialize an object of type T from a serialized memory block, incrementing the iterator it to point to the next part of the serialized data. It should handle different types of data, managing memory and type conversion as needed.

◆ deserialize() [2/2]

static void cbeam::serialization::traits< container::xpod::type >::deserialize ( serialized_object & it,
container::xpod::type & val )
inlinestatic

Deserialize an xpod::type variant from the buffer pointed to by it.

Reads a single byte to determine the active index, then reads the corresponding data into val. Advances it to point past the consumed data.

Parameters
itThe iterator (raw pointer) position in the serialized data.
valThe xpod::type variant to populate.
Exceptions
cbeam::error::runtime_errorif the variant index is invalid.

◆ serialize() [1/2]

static void cbeam::serialization::traits< container::xpod::type >::serialize ( const container::xpod::type & val,
container::buffer & stream )
inlinestatic

Required to serialize an object of type T into a shared_buffer stream.

Parameters
valThe object to serialize.
streamThe shared_buffer stream into which the object is serialized.

This method should take an object of type T and serialize it into a container::buffer stream. by using its append method.

◆ serialize() [2/2]

static void cbeam::serialization::traits< container::xpod::type >::serialize ( const container::xpod::type & val,
container::buffer & stream )
inlinestatic

Serialize the given xpod::type variant into the buffer stream.

The serialization stores: 1) A single byte (valIndex) representing which type is active. 2) The associated data for that type.

Parameters
valThe variant to serialize.
streamThe buffer to which data is appended.

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