Cbeam
Loading...
Searching...
No Matches
cbeam::serialization::traits< std::string > Struct Reference

Specialization of traits for std::string, providing both serialization and deserialization. More...

#include <string.hpp>

Static Public Member Functions

static void serialize (const std::string &str, container::buffer &stream)
 Serializes a std::string into a binary buffer.
 
static void deserialize (serialized_object &it, std::string &str)
 Deserializes a std::string from a binary buffer.
 
static void serialize (const std::string &val, container::buffer &stream)
 Required to serialize an object of type T into a shared_buffer stream.
 
static void deserialize (serialized_object &it, std::string &val)
 Required to deserialize an object of type T from a serialized memory block, incrementing the iterator it.
 

Detailed Description

Specialization of traits for std::string, providing both serialization and deserialization.

The serialization format stores the string length (std::size_t) followed by the character data.

Member Function Documentation

◆ deserialize() [1/2]

static void cbeam::serialization::traits< std::string >::deserialize ( serialized_object & it,
std::string & str )
inlinestatic

Deserializes a std::string from a binary buffer.

Reads the string length first, then reads that many characters. The iterator it is advanced accordingly.

Parameters
itA reference to the current position in the serialized data.
strThe string to populate with deserialized content.

◆ deserialize() [2/2]

static void cbeam::serialization::traits< std::string >::deserialize ( serialized_object & it,
std::string & 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.

◆ serialize() [1/2]

static void cbeam::serialization::traits< std::string >::serialize ( const std::string & str,
container::buffer & stream )
inlinestatic

Serializes a std::string into a binary buffer.

First appends the length of the string (as std::size_t), then each character in the string.

Parameters
strThe string to serialize.
streamThe buffer to which serialized data is appended.

◆ serialize() [2/2]

static void cbeam::serialization::traits< std::string >::serialize ( const std::string & 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.


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