|
JSON Voorhees
Killer JSON for C++
|
An adapter for optional-like types. More...
#include <jsonv/serialization/optional_adapter.hpp>
Inheritance diagram for jsonv::optional_adapter< TOptional >:
Collaboration diagram for jsonv::optional_adapter< TOptional >:Protected Member Functions | |
| virtual std::expected< TOptional, 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 TOptional &from, writer &to) const override |
| Write from into to. | |
Additional Inherited Members | |
Public Member Functions inherited from jsonv::adapter_for< TOptional > | |
| 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 |
An adapter for optional-like types.
This is for convenience of creating an adapter for things like std::optional or boost::optional.
| TOptional | The optional container type. It must have a member type named value_type which holds the actual type. It must default-construct to the "none" type and have a single-argument constructor which takes a TOptional::value_type. It must support a boolean conversion operator for checking if the value is none and a unary operator* for getting the underlying value. Both std::optional and boost::optional possess all of these properties. |
Definition at line 39 of file optional_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< TOptional >.
Definition at line 47 of file optional_adapter.hpp.
Here is the call graph for this function:
|
inlineoverrideprotectedvirtual |
Write from into to.
Implements jsonv::adapter_for< TOptional >.
Definition at line 82 of file optional_adapter.hpp.
Here is the call graph for this function: