JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::function_adapter< T, FExtract, FToJson > Class Template Reference
+ Inheritance diagram for jsonv::function_adapter< T, FExtract, FToJson >:
+ Collaboration diagram for jsonv::function_adapter< T, FExtract, FToJson >:

Public Member Functions

template<typename FUExtract , typename FUToJson >
 function_adapter (FUExtract &&extract_, FUToJson &&to_json_)
 
- Public Member Functions inherited from jsonv::adapter_for< T >
virtual const std::type_info & get_type () const noexcept override
 
virtual std::expected< void, ast_node_type > extract (extraction_context &context, reader &from, void *into) const override
 
virtual value to_json (const serialization_context &context, const void *from) const override
 

Protected Member Functions

virtual std::expected< T, ast_node_type > create (extraction_context &context, reader &from) const override
 Create an instance of T by reading from.
 
virtual value to_json (const serialization_context &context, const T &from) const override
 

Detailed Description

template<typename T, typename FExtract, typename FToJson>
class jsonv::function_adapter< T, FExtract, FToJson >

Definition at line 27 of file function_adapter.hpp.

Constructor & Destructor Documentation

◆ function_adapter()

template<typename T , typename FExtract , typename FToJson >
template<typename FUExtract , typename FUToJson >
jsonv::function_adapter< T, FExtract, FToJson >::function_adapter ( FUExtract &&  extract_,
FUToJson &&  to_json_ 
)
inlineexplicit

Definition at line 32 of file function_adapter.hpp.

Member Function Documentation

◆ create()

template<typename T , typename FExtract , typename FToJson >
virtual std::expected< T, ast_node_type > jsonv::function_adapter< T, FExtract, FToJson >::create ( extraction_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 extractor implementations via formats. Record any problem you encounter with extraction_context::problem.
fromThe JSON reader to extract 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< T >.

Definition at line 39 of file function_adapter.hpp.

◆ to_json()

template<typename T , typename FExtract , typename FToJson >
virtual value jsonv::function_adapter< T, FExtract, FToJson >::to_json ( const serialization_context &  context,
const T &  from 
) const
inlineoverrideprotectedvirtual

Implements jsonv::adapter_for< T >.

Definition at line 45 of file function_adapter.hpp.


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