JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::deserializer Class Referenceabstract

A deserializer holds the method for converting JSON source into an arbitrary C++ type. More...

#include <jsonv/serialization/deserialize.hpp>

+ Inheritance diagram for jsonv::deserializer:

Public Member Functions

virtual const std::type_info & get_type () const noexcept=0
 Get the run-time type this deserializer knows how to deserialize.
 
virtual std::expected< void, ast_node_type > deserialize (deserialization_context &context, reader &from, void *into) const =0
 Deserialize the type from a reader into a region of memory.
 

Detailed Description

A deserializer holds the method for converting JSON source into an arbitrary C++ type.

Definition at line 346 of file deserialize.hpp.

Member Function Documentation

◆ deserialize()

virtual std::expected< void, ast_node_type > jsonv::deserializer::deserialize ( deserialization_context &  context,
reader &  from,
void *  into 
) const
pure virtual

Deserialize the type from a reader into a region of memory.

Parameters
contextExtra information to help you decode sub-objects, such as looking up other deserializer implementations via formats. It is also where a deserialization_context::problem is recorded and where the path a problem is reported at comes from.
fromThe JSON reader to deserialize something from. On entry, reader::current is the first node of the value to deserialize – never ast_node_type::document_start, which the entry points step over before any deserializer runs. On a successful return it should be one position past that value, as reader::next_value would leave it.
intoThe region of memory to create the deserialized object in. There will always be enough room to create your object and the alignment of the pointer should be correct (assuming a working alignof implementation).
Returns
A success result if the object was created in into; otherwise a std::unexpected carrying the ast_node_type actually found when the failure was a type mismatch, or ast_node_type::error as a sentinel for everything else. In the failure case nothing has been constructed in into and deserialization_context::problems describes what went wrong.
See also
deserializer_for
adapter_for
value_adapter_for

Implemented in jsonv::adapter_for< T >, jsonv::adapter_for< TContainer >, jsonv::adapter_for< TEnum >, jsonv::adapter_for< TOptional >, jsonv::adapter_for< TPointer >, jsonv::adapter_for< TWrapper >, jsonv::deserializer_construction< T >, and jsonv::deserializer_for< T >.

◆ get_type()

virtual const std::type_info & jsonv::deserializer::get_type ( ) const
pure virtualnoexcept

Get the run-time type this deserializer knows how to deserialize.

Once this deserializer is registered with a formats, it is not allowed to change.

Implemented in jsonv::adapter_for< T >, jsonv::adapter_for< TContainer >, jsonv::adapter_for< TEnum >, jsonv::adapter_for< TOptional >, jsonv::adapter_for< TPointer >, jsonv::adapter_for< TWrapper >, jsonv::deserializer_construction< T >, and jsonv::deserializer_for< T >.


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