Ariles
Loading...
Searching...
No Matches
extra_visitors
rapidjson
src
common.h
Go to the documentation of this file.
1
/**
2
@file
3
@author Alexander Sherikov
4
5
@copyright 2018-2020 Alexander Sherikov, Licensed under the Apache License, Version 2.0.
6
(see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7
8
@brief
9
*/
10
11
#pragma once
12
13
14
// In old versions of RapidJSON it is impossible to specify flags
15
// as template parameter of PrettyWriter, so this is the only way
16
// to change them.
17
#define RAPIDJSON_WRITE_DEFAULT_FLAGS ::rapidjson::kWriteNanAndInfFlag
18
#define RAPIDJSON_PARSE_DEFAULT_FLAGS ::rapidjson::kParseNanAndInfFlag
19
20
21
#include <boost/lexical_cast.hpp>
22
23
#include <rapidjson/document.h>
24
25
#include "
istreamwrapper.h
"
26
27
28
namespace
ariles2
29
{
30
namespace
ns_rapidjson
31
{
32
template
<
class
t_Node>
33
class
ARILES2_LOCAL
ImplBase
:
public
serialization::NodeStackBase
<serialization::Node<t_Node *>>
34
{
35
public
:
36
using
serialization::NodeStackBase
<
serialization::Node<t_Node *>
>::node_stack_;
37
38
public
:
39
/// instance of the parser
40
::rapidjson::Document
document_
;
41
42
43
public
:
44
/**
45
* @brief Get current node
46
*
47
* @return pointer to the current node
48
*/
49
t_Node &
getRawNode
(
const
std::size_t depth)
50
{
51
if
(node_stack_[depth].isArray())
52
{
53
return
(getRawNode(depth - 1)[node_stack_[depth].index_]);
54
}
55
56
return
(*node_stack_[depth].node_);
57
}
58
59
60
t_Node &
getRawNode
()
61
{
62
if
(node_stack_.empty())
63
{
64
return
(document_);
65
}
66
67
return
(getRawNode(node_stack_.size() - 1));
68
}
69
};
70
}
// namespace ns_rapidjson
71
}
// namespace ariles2
ariles2::ns_rapidjson::ImplBase
Definition
common.h:34
ariles2::ns_rapidjson::ImplBase::document_
::rapidjson::Document document_
instance of the parser
Definition
common.h:40
ariles2::ns_rapidjson::ImplBase::getRawNode
t_Node & getRawNode(const std::size_t depth)
Get current node.
Definition
common.h:49
ariles2::ns_rapidjson::ImplBase::getRawNode
t_Node & getRawNode()
Definition
common.h:60
ariles2::serialization::NodeStackBase
Definition
serialization.h:126
ariles2::serialization::Node
Definition
serialization.h:54
istreamwrapper.h
Copied from a newer version of RapidJSON to add this functionality to older versions.
ariles2
Definition
basic.h:17
ARILES2_LOCAL
#define ARILES2_LOCAL
Definition
visibility.h:47
Generated by
1.9.8