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

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 TOptional create (const extraction_context &context, const value &from) const override
 
virtual value to_json (const serialization_context &context, const TOptional &from) const override
 

Additional Inherited Members

- Public Member Functions inherited from jsonv::adapter_for< TOptional >
virtual const std::type_info & get_type () const override
 Get the run-time type this extractor knows how to extract.
 
virtual void extract (const extraction_context &context, const value &from, void *into) const override
 Extract a the type from a value into a region of memory.
 
virtual value to_json (const serialization_context &context, const void *from) const override
 Create a value from the value in the given region of memory.
 

Detailed Description

template<typename TOptional>
class jsonv::optional_adapter< TOptional >

An adapter for optional-like types.

This is for convenience of creating an adapter for things like std::optional or boost::optional.

Template Parameters
TOptionalThe 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 32 of file optional_adapter.hpp.

Member Function Documentation

◆ create()

template<typename TOptional >
virtual TOptional jsonv::optional_adapter< TOptional >::create ( const extraction_context context,
const value from 
) const
inlineoverrideprotectedvirtual

Implements jsonv::adapter_for< TOptional >.

Definition at line 38 of file optional_adapter.hpp.

◆ to_json()

template<typename TOptional >
virtual value jsonv::optional_adapter< TOptional >::to_json ( const serialization_context context,
const TOptional from 
) const
inlineoverrideprotectedvirtual

Implements jsonv::adapter_for< TOptional >.

Definition at line 46 of file optional_adapter.hpp.


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