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

An adapter for container types. More...

#include <jsonv/serialization/container_adapter.hpp>

+ Inheritance diagram for jsonv::container_adapter< TContainer >:
+ Collaboration diagram for jsonv::container_adapter< TContainer >:

Protected Member Functions

virtual std::expected< TContainer, 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 TContainer &from, writer &to) const override
 Write from into to.
 

Additional Inherited Members

- Public Member Functions inherited from jsonv::adapter_for< TContainer >
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
 

Detailed Description

template<typename TContainer>
class jsonv::container_adapter< TContainer >

An adapter for container types.

This is for convenience of creating an adapter for things like std::vector, std::set and such.

Template Parameters
TContaineris the container to create and encode. It must have a member type value_type, support iteration and an insert operation.

Definition at line 37 of file container_adapter.hpp.

Member Function Documentation

◆ create()

template<typename TContainer >
virtual std::expected< TContainer, ast_node_type > jsonv::container_adapter< TContainer >::create ( deserialization_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 deserializer implementations via formats. Record any problem you encounter with deserialization_context::problem.
fromThe 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.
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< TContainer >.

Definition at line 45 of file container_adapter.hpp.

+ Here is the call graph for this function:

◆ serialize()

template<typename TContainer >
virtual void jsonv::container_adapter< TContainer >::serialize ( const serialization_context &  context,
const TContainer &  from,
writer &  to 
) const
inlineoverrideprotectedvirtual

Write from into to.

See also
serializer::serialize

Implements jsonv::adapter_for< TContainer >.

Definition at line 169 of file container_adapter.hpp.

+ Here is the call graph for this function:

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