|
JSON Voorhees
Killer JSON for C++
|
A serializer holds the method for converting an arbitrary C++ type into JSON, written token by token into a writer.
More...
#include <jsonv/serialization/serializer.hpp>
Inheritance diagram for jsonv::serializer:Public Member Functions | |
| virtual const std::type_info & | get_type () const noexcept=0 |
Get the run-time type this serializer knows how to serialize. | |
| virtual void | serialize (const serialization_context &context, const void *from, writer &to) const =0 |
| Write the value in the given region of memory from into to. | |
A serializer holds the method for converting an arbitrary C++ type into JSON, written token by token into a writer.
Definition at line 26 of file serializer.hpp.
|
pure virtualnoexcept |
Get the run-time type this serializer knows how to serialize.
Once this serializer is registered with a formats, it is not allowed to change.
Implemented in jsonv::adapter_for< T >, jsonv::adapter_for< TContainer >, jsonv::adapter_for< TEnum >, jsonv::adapter_for< TOptional >, jsonv::adapter_for< TPointer >, jsonv::adapter_for< TWrapper >, and jsonv::serializer_for< T >.
|
pure virtual |
Write the value in the given region of memory from into to.
| context | Extra information to help you serialize sub-objects for your type, such as the ability to find other serializer implementations via formats. Serialize each part of your type through serialization_context::serialize: anything thrown while doing so comes out of it as a serialization_error naming the type and the position in the document, as writer::current_path reports it. |
| from | The region of memory that represents the C++ value to convert to JSON. The pointer comes as the result of a static_cast<const void*>, so performing a static_cast back to your type is okay. |
| to | The writer to write into, positioned where the value goes: at the root, as the next element of an open array, or as the value of the key just written. Write exactly one value – a scalar, or a structure you open and close – and nothing else. To refuse, throw: to.current_path() is where you are. |
Implemented in jsonv::adapter_for< T >, jsonv::adapter_for< TContainer >, jsonv::adapter_for< TEnum >, jsonv::adapter_for< TOptional >, jsonv::adapter_for< TPointer >, jsonv::adapter_for< TWrapper >, and jsonv::serializer_for< T >.