JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::wrapper_adapter< TWrapper > Class Template Reference

An adapter for "wrapper" types. More...

#include <jsonv/serialization/wrapper_adapter.hpp>

+ Inheritance diagram for jsonv::wrapper_adapter< TWrapper >:
+ Collaboration diagram for jsonv::wrapper_adapter< TWrapper >:

Protected Member Functions

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

Additional Inherited Members

- Public Member Functions inherited from jsonv::adapter_for< TWrapper >
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
 

Detailed Description

template<typename TWrapper>
class jsonv::wrapper_adapter< TWrapper >

An adapter for "wrapper" types.

Template Parameters
TWrapperA wrapper type with a member value_type which represents the underlying wrapped type. This must be explicitly convertible to and from the value_type.

Definition at line 33 of file wrapper_adapter.hpp.

Member Function Documentation

◆ create()

template<typename TWrapper >
virtual std::expected< TWrapper, ast_node_type > jsonv::wrapper_adapter< TWrapper >::create ( deserialization_context &  context,
reader &  from 
) const
inlineoverrideprotectedvirtual

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.

Implements jsonv::adapter_for< TWrapper >.

Definition at line 40 of file wrapper_adapter.hpp.

◆ serialize()

template<typename TWrapper >
virtual void jsonv::wrapper_adapter< TWrapper >::serialize ( const serialization_context &  context,
const TWrapper &  from,
writer &  to 
) const
inlineoverrideprotectedvirtual

Write from into to.

See also
serializer::serialize

Implements jsonv::adapter_for< TWrapper >.

Definition at line 63 of file wrapper_adapter.hpp.


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