Iros
 
Loading...
Searching...
No Matches
di::serialization::BinarySerializer< Writer > Class Template Reference

A serializer for a simple binary format. More...

#include <di/serialization/binary_serializer.h>

Public Types

using SerializationFormat = BinaryFormat
 

Public Member Functions

template<concepts::NotDecaysTo< BinarySerializer > T>
requires (ConstructibleFrom<Writer, T>)
constexpr BinarySerializer (T &&writer)
 
template<typename T, concepts::InstanceOf< reflection::Fields > M>
constexpr auto serialize (T &&value, M)
 
constexpr auto serialize (concepts::TupleLike auto &&value)
 
constexpr auto serialize (concepts::VariantLike auto &&value) -> meta::WriterResult< void, Writer >
 
template<concepts::IntegralOrEnum T>
constexpr auto serialize (T value)
 
template<typename T, concepts::InstanceOf< reflection::Atom > M>
requires (M::is_string())
constexpr auto serialize (T &&value, M)
 
template<concepts::SizedContainer T>
requires (concepts::Serializable<meta::ContainerReference<T>, BinarySerializer>)
constexpr auto serialize (T &&value) -> meta::WriterResult< void, Writer >
 
constexpr auto writer () &-> Writer &
 
constexpr auto writer () const &-> Writer const &
 
constexpr auto writer () &&-> Writer &&
 

Detailed Description

template<Impl< io::Writer > Writer>
class di::serialization::BinarySerializer< Writer >

A serializer for a simple binary format.

Template Parameters
WriterThe type of the writer to write to.

The binary format is a simple format. Integral and enum types are written as-is, but are converted to little endian first. Structure types are serialized by calling serialize on each field. Tuple types are serialized by calling serialize on each element. Variant types are serialized by writing the index of the active alternative and then calling serialize on the active alternative. Container types are serialized by writing the size of the container and then calling serialize on each element. Strings are just specializations of containers.

The format is not self-describing, so the deserializer must know the format of the data it is deserializing. This also means that it is not possible to add new fields to a structure without breaking backwards compatibility. If this is needed, the structure should be wrapped in a variant, which allows the variant index to act as the version number. Including a verson number directly in a structure is not enough since the size of the structure may change.

Member Typedef Documentation

◆ SerializationFormat

template<Impl< io::Writer > Writer>
using di::serialization::BinarySerializer< Writer >::SerializationFormat = BinaryFormat

Constructor & Destructor Documentation

◆ BinarySerializer()

template<Impl< io::Writer > Writer>
template<concepts::NotDecaysTo< BinarySerializer > T>
requires (ConstructibleFrom<Writer, T>)
di::serialization::BinarySerializer< Writer >::BinarySerializer ( T && writer)
inlineexplicitconstexpr

Member Function Documentation

◆ serialize() [1/6]

template<Impl< io::Writer > Writer>
auto di::serialization::BinarySerializer< Writer >::serialize ( concepts::TupleLike auto && value)
inlineconstexpr

◆ serialize() [2/6]

template<Impl< io::Writer > Writer>
auto di::serialization::BinarySerializer< Writer >::serialize ( concepts::VariantLike auto && value) -> meta::WriterResult<void, Writer>
inlineconstexpr

◆ serialize() [3/6]

template<Impl< io::Writer > Writer>
template<concepts::SizedContainer T>
requires (concepts::Serializable<meta::ContainerReference<T>, BinarySerializer>)
auto di::serialization::BinarySerializer< Writer >::serialize ( T && value) -> meta::WriterResult<void, Writer>
inlineconstexpr

◆ serialize() [4/6]

template<Impl< io::Writer > Writer>
template<typename T, concepts::InstanceOf< reflection::Fields > M>
auto di::serialization::BinarySerializer< Writer >::serialize ( T && value,
M  )
inlineconstexpr

◆ serialize() [5/6]

template<Impl< io::Writer > Writer>
template<typename T, concepts::InstanceOf< reflection::Atom > M>
requires (M::is_string())
auto di::serialization::BinarySerializer< Writer >::serialize ( T && value,
M  )
inlineconstexpr

◆ serialize() [6/6]

template<Impl< io::Writer > Writer>
template<concepts::IntegralOrEnum T>
auto di::serialization::BinarySerializer< Writer >::serialize ( T value)
inlineconstexpr

◆ writer() [1/3]

template<Impl< io::Writer > Writer>
auto di::serialization::BinarySerializer< Writer >::writer ( ) && -> Writer&&
inlineconstexpr

◆ writer() [2/3]

template<Impl< io::Writer > Writer>
auto di::serialization::BinarySerializer< Writer >::writer ( ) & -> Writer&
inlineconstexpr

◆ writer() [3/3]

template<Impl< io::Writer > Writer>
auto di::serialization::BinarySerializer< Writer >::writer ( ) const & -> Writer const&
inlineconstexpr

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