|
JSON Voorhees
Killer JSON for C++
|
A base for adapters written against the older value -based extraction interface.
More...
#include <jsonv/serialization/adapter_for.hpp>
Inheritance diagram for jsonv::value_adapter_for< T >:
Collaboration diagram for jsonv::value_adapter_for< T >:Protected Member Functions | |
| virtual std::expected< T, ast_node_type > | create (extraction_context &context, reader &from) const final override |
Create an instance of T by reading from. | |
| virtual T | create (extraction_context &context, const value &from) const =0 |
Create an instance of T from the materialised from. | |
Protected Member Functions inherited from jsonv::adapter_for< T > | |
| virtual value | to_json (const serialization_context &context, const T &from) const =0 |
Additional Inherited Members | |
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 |
A base for adapters written against the older value -based extraction interface.
The subtree under the reader is materialised with read_value and handed to the subclass, whose create runs unchanged. This costs the whole subtree in memory, which is exactly what extracting off a reader is meant to avoid – so it is a stepping stone for ports, not a destination. New adapters should derive from adapter_for and walk the reader.
Definition at line 95 of file adapter_for.hpp.
|
protectedpure virtual |
Create an instance of T from the materialised from.
| extraction_error | if from cannot be converted to a T. |
Implemented in jsonv::container_adapter< TContainer >, jsonv::enum_adapter< TEnum, FEnumComp, FValueComp >, jsonv::optional_adapter< TOptional >, jsonv::polymorphic_adapter< TPointer >, and jsonv::wrapper_adapter< TWrapper >.
|
inlinefinaloverrideprotectedvirtual |
Create an instance of T by reading from.
| context | Extra 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. |
| from | The 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. |
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 101 of file adapter_for.hpp.
Here is the call graph for this function: