Ariles
Loading...
Searching...
No Matches
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
28namespace 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:
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
::rapidjson::Document document_
instance of the parser
Definition common.h:40
t_Node & getRawNode(const std::size_t depth)
Get current node.
Definition common.h:49
Copied from a newer version of RapidJSON to add this functionality to older versions.
#define ARILES2_LOCAL
Definition visibility.h:47