|
JSON Voorhees
Killer JSON for C++
|
An adapter which calls one function to deserialize and another to serialize.
More...
#include <jsonv/serialization/function_adapter.hpp>
Inheritance diagram for jsonv::function_adapter< T, FDeserialize, FSerialize >:
Collaboration diagram for jsonv::function_adapter< T, FDeserialize, FSerialize >:Public Member Functions | |
| template<typename FUDeserialize , typename FUSerialize > | |
| function_adapter (FUDeserialize &&deserialize_, FUSerialize &&serialize_) | |
| Create an adapter which deserializes by calling deserialize_ and serializes by calling serialize_. | |
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 > | 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 override |
Create an instance of T by reading from. | |
| virtual void | serialize (const serialization_context &context, const T &from, writer &to) const override |
| Write from into to. | |
An adapter which calls one function to deserialize and another to serialize.
The functions may take any of the shapes detail::invoke_deserialize and detail::invoke_serialize accept.
Definition at line 31 of file function_adapter.hpp.
|
inlineexplicit |
Create an adapter which deserializes by calling deserialize_ and serializes by calling serialize_.
Definition at line 37 of file function_adapter.hpp.
|
inlineoverrideprotectedvirtual |
Create an instance of T by reading from.
| context | Extra 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. |
| from | The 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. |
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 44 of file function_adapter.hpp.
|
inlineoverrideprotectedvirtual |
Write from into to.
Implements jsonv::adapter_for< T >.
Definition at line 49 of file function_adapter.hpp.