StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
StormByte::Serializable< T > Class Template Reference

The class to serialize and deserialize data. More...

#include <serializable.hxx>

Public Member Functions

 Serializable (const DecayedT &data) noexcept
 The constructor of the Serializable class.
 
 Serializable (const Serializable &other) noexcept=delete
 The copy constructor of the Serializable class.
 
 Serializable (Serializable &&other) noexcept=delete
 The move constructor of the Serializable class.
 
 ~Serializable () noexcept=default
 The destructor of the Serializable class.
 
Serializableoperator= (const Serializable &other) noexcept=delete
 The assignment operator of the Serializable class.
 
Serializableoperator= (Serializable &&other) noexcept=delete
 The move assignment operator of the Serializable class.
 
std::vector< std::byte > Serialize () const noexcept
 Serializes the data into a byte vector.
 

Static Public Member Functions

static StormByte::Expected< T, DeserializeErrorDeserialize (std::span< const std::byte > data) noexcept
 Deserializes data from a byte span.
 
static StormByte::Expected< T, DeserializeErrorDeserialize (const std::vector< std::byte > &data) noexcept
 Deserializes data from a byte vector.
 
static std::size_t Size (const DecayedT &data) noexcept
 Calculates the serialized size of the data.
 

Detailed Description

template<typename T>
class StormByte::Serializable< T >

The class to serialize and deserialize data.

Template Parameters
TThe type of the data to serialize and deserialize.

Constructor & Destructor Documentation

◆ Serializable() [1/3]

template<typename T >
StormByte::Serializable< T >::Serializable ( const DecayedT &  data)
inlinenoexcept

The constructor of the Serializable class.

Parameters
dataThe data to serialize.

◆ Serializable() [2/3]

template<typename T >
StormByte::Serializable< T >::Serializable ( const Serializable< T > &  other)
deletenoexcept

The copy constructor of the Serializable class.

Parameters
otherThe other Serializable to copy.

◆ Serializable() [3/3]

template<typename T >
StormByte::Serializable< T >::Serializable ( Serializable< T > &&  other)
deletenoexcept

The move constructor of the Serializable class.

Parameters
otherThe other Serializable to move.

Member Function Documentation

◆ Deserialize() [1/2]

template<typename T >
static StormByte::Expected< T, DeserializeError > StormByte::Serializable< T >::Deserialize ( const std::vector< std::byte > &  data)
inlinestaticnoexcept

Deserializes data from a byte vector.

This function automatically selects the appropriate deserialization method based on the type of data: trivial types, containers, pairs, optionals, or complex types.

Parameters
dataThe byte vector containing the serialized data.
Returns
An Expected object containing the deserialized data on success, or a DeserializeError on failure.

◆ Deserialize() [2/2]

template<typename T >
static StormByte::Expected< T, DeserializeError > StormByte::Serializable< T >::Deserialize ( std::span< const std::byte >  data)
inlinestaticnoexcept

Deserializes data from a byte span.

This function is a convenience overload that accepts a std::span of bytes and forwards it to the vector-based Deserialize function.

Parameters
dataThe byte span containing the serialized data.
Returns
An Expected object containing the deserialized data on success, or a DeserializeError on failure.

◆ operator=() [1/2]

template<typename T >
Serializable & StormByte::Serializable< T >::operator= ( const Serializable< T > &  other)
deletenoexcept

The assignment operator of the Serializable class.

Parameters
otherThe other Serializable to assign.
Returns
The reference to the assigned Serializable.

◆ operator=() [2/2]

template<typename T >
Serializable & StormByte::Serializable< T >::operator= ( Serializable< T > &&  other)
deletenoexcept

The move assignment operator of the Serializable class.

Parameters
otherThe other Serializable to assign.
Returns
The reference to the assigned Serializable.

◆ Serialize()

template<typename T >
std::vector< std::byte > StormByte::Serializable< T >::Serialize ( ) const
inlinenoexcept

Serializes the data into a byte vector.

This function automatically selects the appropriate serialization method based on the type of data: trivial types, containers, pairs, optionals, or complex types.

Returns
A vector of bytes containing the serialized data.

◆ Size()

template<typename T >
static std::size_t StormByte::Serializable< T >::Size ( const DecayedT &  data)
inlinestaticnoexcept

Calculates the serialized size of the data.

This function computes the size in bytes that the serialized data will occupy.

Parameters
dataThe data to calculate the size for.
Returns
The size in bytes of the serialized data.

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