JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
serializer_for.hpp
Go to the documentation of this file.
1
/// \file jsonv/serialization/serializer_for.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/serialization.hpp
>
14
15
namespace
jsonv
16
{
17
18
/// \addtogroup Serialization
19
/// \{
20
21
template
<
typename
T>
22
class
serializer_for
:
23
public
serializer
24
{
25
public
:
26
JSONV_NODISCARD
27
virtual
const
std::type_info&
get_type
()
const override
28
{
29
return
typeid
(T);
30
}
31
32
JSONV_NODISCARD
33
virtual
value
to_json
(
const
serialization_context
&
context
,
34
const
void
* from
35
)
const override
36
{
37
return
to_json
(
context
, *
static_cast<
const
T*
>
(from));
38
}
39
40
protected
:
41
JSONV_NODISCARD
42
virtual
value
to_json
(
const
serialization_context
&
context
,
43
const
T& from
44
)
const
= 0;
45
};
46
47
/// \}
48
49
}
jsonv::context
Provides extra information to routines used for extraction and serialization.
Definition
context.hpp:26
jsonv::serialization_context
Definition
serialization.hpp:34
jsonv::serializer_for
Definition
serializer_for.hpp:24
jsonv::serializer_for::to_json
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.
Definition
serializer_for.hpp:33
jsonv::serializer_for::get_type
virtual const std::type_info & get_type() const override
Get the run-time type this serialize knows how to encode.
Definition
serializer_for.hpp:27
jsonv::serializer
A serializer holds the method for converting an arbitrary C++ type into a value.
Definition
serializer.hpp:26
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:132
serialization.hpp
Conversion between C++ types and JSON values.
jsonv
serialization
serializer_for.hpp
Generated by
1.9.8