JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
extractor_for.hpp
Go to the documentation of this file.
1
/// \file jsonv/serialization/extractor_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
/// An \c extractor for the type \c T.
22
template
<
typename
T>
23
class
extractor_for
:
24
public
extractor
25
{
26
public
:
27
virtual
const
std::type_info&
get_type
()
const override
28
{
29
return
typeid
(T);
30
}
31
32
virtual
void
extract
(
const
extraction_context
&
context
,
33
const
value
&
from
,
34
void
*
into
35
)
const override
36
{
37
new
(
into
) T(create(
context
,
from
));
38
}
39
40
protected
:
41
virtual
T create(
const
extraction_context
&
context
,
const
value
&
from
)
const
= 0;
42
};
43
44
45
/// \}
46
47
}
jsonv::enum_adapter
An adapter for enumeration types.
Definition
enum_adapter.hpp:41
jsonv::extraction_context
Definition
serialization.hpp:603
jsonv::extractor_for
An extractor for the type T.
Definition
extractor_for.hpp:25
jsonv::extractor_for::get_type
virtual const std::type_info & get_type() const override
Get the run-time type this extractor knows how to extract.
Definition
extractor_for.hpp:27
jsonv::extractor_for::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.
Definition
extractor_for.hpp:32
jsonv::extractor
An extractor holds the method for converting JSON source into an arbitrary C++ type.
Definition
serialization.hpp:272
jsonv::value
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly diff...
Definition
value.hpp:107
config.hpp
Copyright (c) 2014-2020 by Travis Gockel.
serialization.hpp
Conversion between C++ types and JSON values.
jsonv
serialization
extractor_for.hpp
Generated by
1.9.8