maat::serial::Deserializer class

Class that deserializes a serializable class from a stream

A 'Deserializer' instance is intended to be used only once, then deleted. The deserialize() method allows to deserialize an object that was serialized by the 'Serializer'. There are different signatures for deserialize(): deserialize(Serializable&): loads object content in place deserialize(<pointer to Serializable>): loads content in a newly allocated object

Objects content can be read from the serialization stream using the '>>' operator. The deserializer accepts either objects that inherit from the 'Serializable' class, or raw bits.

'Serializable' objects are loaded automatically using their load() method. Operator '>>' seemlessly supports smart pointers, containers, std::optional, raw pointers, and maps of 'Serializable' objects.

In order to deserialize raw bits (primitive types, buffers, etc), one needs to wrap the variable(s) with the same functions mentioned in the 'Serializer' documentation.

❱   Public types

class Factory
Helper class to reconstruct dynamic objects from serialized data.

class Stream
Stream to read serialized data from.

❱   Constructors, destructors, conversion operators


❱   Public functions

template<typename T>
void deserialize(std::unique_ptr<T>& dest)
Deserialize object.

template<typename T>
void deserialize(std::shared_ptr<T>& dest)
Deserialize object into a shared pointer.

void deserialize(Serializable& dest)
Deserialize object into an object reference.

template<typename T>
auto operator>>(Bits<T&> obj) -> Deserializer&
Load primitive type by reference.

template<typename T>
auto operator>>(OptionalBits<T&> obj) -> Deserializer&
Load std::optional primitive type by reference.

template<template<typename...> class Map, typename K, typename V>
auto operator>>(Map<K, V>& map) -> Deserializer&
Dump map non-primitive type.

template<typename T>
auto operator>>(Buffer<T> obj) -> Deserializer&
Load raw buffer.

auto operator>>(Empty& obj) -> Deserializer&
Load empty object.

auto operator>>(std::string& str) -> Deserializer&
Load string.

template<typename T>
auto operator>>(std::shared_ptr<T>& s) -> std::enable_if<std::is_base_of<Serializable, T>::value, Deserializer&>::type
Load shared_ptr of serializable.

template<typename T>
auto operator>>(T*& s) -> std::enable_if<std::is_base_of<Serializable, T>::value, Deserializer&>::type
Load ptr of serializable.

template<typename T>
auto operator>>(ContainerBits<T> container) -> Deserializer&
Load standard container of primitive type.

template<typename T, template<typename ELEM, typename ALLOC=std::allocator<ELEM>> class C>
auto operator>>(C<T>& container) -> Deserializer&
Load standard container.

template<typename T>
auto operator>>(std::optional<T>& opt) -> Deserializer&
Load optional of non-primitive type.