JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
serializer.hpp
Go to the documentation of this file.
1
/// \file jsonv/serialization/serializer.hpp
2
///
3
/// Copyright (c) 2015-2020 by Travis Gockel. All rights reserved.
4
///
5
/// This program is free software: you can redistribute it and/or modify it under the terms of the Apache License
6
/// as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later
7
/// version.
8
///
9
/// \author Travis Gockel (travis@gockelhut.com)
10
#pragma once
11
12
#include <
jsonv/config.hpp
>
13
#include <
jsonv/forward.hpp
>
14
#include <
jsonv/value.hpp
>
15
16
#include <typeinfo>
17
18
namespace
jsonv
19
{
20
21
/// \addtogroup Serialization
22
/// \{
23
24
/// A \c serializer holds the method for converting an arbitrary C++ type into a \c value.
25
class
JSONV_PUBLIC
serializer
26
{
27
public
:
28
virtual
~serializer
()
noexcept
;
29
30
/// Get the run-time type this \c serialize knows how to encode. Once this \c serializer is registered with a
31
/// \c formats, it is not allowed to change.
32
JSONV_NODISCARD
33
virtual
const
std::type_info&
get_type
()
const
= 0;
34
35
/// Create a \c value \a from the value in the given region of memory.
36
///
37
/// \param context Extra information to help you encode sub-objects for your type, such as the ability to find other
38
/// \c formats. It also tracks the progression of types in the encoding heirarchy, so any exceptions
39
/// thrown will have \c type information in the error message.
40
/// \param from The region of memory that represents the C++ value to convert to JSON. The pointer comes as the
41
/// result of a <tt>static_cast<void*></tt>, so performing a \c static_cast back to your type is
42
/// okay.
43
JSONV_NODISCARD
44
virtual
value
to_json
(
const
serialization_context
&
context
,
45
const
void
*
from
46
)
const
= 0;
47
};
48
49
/// \}
50
51
}
jsonv::context
Provides extra information to routines used for extraction and serialization.
Definition
context.hpp:26
jsonv::enum_adapter
An adapter for enumeration types.
Definition
enum_adapter.hpp:41
jsonv::serialization_context
Definition
serialization.hpp:34
jsonv::serializer
A serializer holds the method for converting an arbitrary C++ type into a value.
Definition
serializer.hpp:26
jsonv::serializer::to_json
virtual value to_json(const serialization_context &context, const void *from) const =0
Create a value from the value in the given region of memory.
jsonv::serializer::get_type
virtual const std::type_info & get_type() const =0
Get the run-time type this serialize knows how to encode.
jsonv::value
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly diff...
Definition
value.hpp:113
config.hpp
Copyright (c) 2014-2020 by Travis Gockel.
JSONV_NODISCARD
#define JSONV_NODISCARD
Warn if the caller discards the result of this function.
Definition
config.hpp:121
JSONV_PUBLIC
#define JSONV_PUBLIC
This function or class is part of the public API for JSON Voorhees.
Definition
config.hpp:102
forward.hpp
Copyright (c) 2012-2020 by Travis Gockel.
value.hpp
Copyright (c) 2012-2020 by Travis Gockel.
jsonv
serialization
serializer.hpp
Generated by
1.9.8