JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::adapter_for< T > Class Template Referenceabstract

An adapter for the type T. More...

#include <jsonv/serialization/adapter_for.hpp>

+ Inheritance diagram for jsonv::adapter_for< T >:
+ Collaboration diagram for jsonv::adapter_for< T >:

Public Member Functions

virtual const std::type_info & get_type () const noexcept override
 
virtual std::expected< void, ast_node_type > deserialize (deserialization_context &context, reader &from, void *into) const override
 
virtual void serialize (const serialization_context &context, const void *from, writer &to) const override
 

Protected Member Functions

virtual std::expected< T, ast_node_type > create (deserialization_context &context, reader &from) const =0
 Create an instance of T by reading from.
 
virtual void serialize (const serialization_context &context, const T &from, writer &to) const =0
 Write from into to.
 

Detailed Description

template<typename T>
class jsonv::adapter_for< T >

An adapter for the type T.

This is a utility class which converts the void*s used in the deserializer and serializer interfaces into the more-friendly T.

See also
deserializer_for
serializer_for
value_adapter_for

Definition at line 34 of file adapter_for.hpp.

Member Function Documentation

◆ create()

template<typename T >
virtual std::expected< T, ast_node_type > jsonv::adapter_for< T >::create ( deserialization_context &  context,
reader &  from 
) const
protectedpure virtual

Create an instance of T by reading from.

Parameters
contextExtra information to help you decode sub-objects, such as looking up other deserializer implementations via formats. Record any problem you encounter with deserialization_context::problem.
fromThe JSON reader to deserialize from. On a successful return it should sit one position past the value which was read, as reader::next_value would have left it.
Returns
The created instance; otherwise a std::unexpected carrying the ast_node_type actually found when the failure was a type mismatch, or ast_node_type::error otherwise.

Implemented in jsonv::value_adapter_for< T >, jsonv::container_adapter< TContainer >, jsonv::enum_adapter< TEnum, FEnumComp, FValueComp >, jsonv::function_adapter< T, FDeserialize, FSerialize >, jsonv::optional_adapter< TOptional >, jsonv::polymorphic_adapter< TPointer >, and jsonv::wrapper_adapter< TWrapper >.

◆ deserialize()

template<typename T >
virtual std::expected< void, ast_node_type > jsonv::adapter_for< T >::deserialize ( deserialization_context &  context,
reader &  from,
void *  into 
) const
inlineoverridevirtual
See also
deserializer::deserialize

Implements jsonv::deserializer.

Definition at line 49 of file adapter_for.hpp.

+ Here is the call graph for this function:

◆ get_type()

template<typename T >
virtual const std::type_info & jsonv::adapter_for< T >::get_type ( ) const
inlineoverridevirtualnoexcept
See also
deserializer::get_type
serializer::get_type

Implements jsonv::deserializer.

Definition at line 41 of file adapter_for.hpp.

◆ serialize() [1/2]

◆ serialize() [2/2]

template<typename T >
virtual void jsonv::adapter_for< T >::serialize ( const serialization_context &  context,
const void *  from,
writer &  to 
) const
inlineoverridevirtual
See also
serializer::serialize

Implements jsonv::serializer.

Definition at line 74 of file adapter_for.hpp.

+ Here is the call graph for this function:

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