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-2026 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#include <boost/lexical_cast.hpp>
15#include <nlohmann/json.hpp>
16
17namespace ariles2
18{
19 namespace ns_nlohmann_json
20 {
21 template <class t_Node>
22 class ARILES2_LOCAL ImplBase : public serialization::NodeStackBase<serialization::Node<t_Node *>>
23 {
24 public:
26
27 public:
28 /// instance of the JSON value
29 ::nlohmann::ordered_json document_;
30
31
32 public:
33 /**
34 * @brief Get current node
35 *
36 * @return reference to the current node
37 */
38 t_Node &getRawNode(const std::size_t depth)
39 {
40 if (node_stack_[depth].isArray())
41 {
42 return (getRawNode(depth - 1)[node_stack_[depth].index_]);
43 }
44
45 return (*node_stack_[depth].node_);
46 }
47
48
49 const t_Node &getRawNode() const
50 {
51 if (node_stack_.empty())
52 {
53 return (document_);
54 }
55
56 // Non-recursive implementation for const version
57 const t_Node *current = node_stack_[0].node_;
58 for (std::size_t i = 1; i < node_stack_.size(); ++i)
59 {
60 if (node_stack_[i].isArray())
61 {
62 current = &((*current)[node_stack_[i].index_]);
63 }
64 else
65 {
66 current = node_stack_[i].node_;
67 }
68 }
69 return *current;
70 }
71
72 t_Node &getRawNode()
73 {
74 if (node_stack_.empty())
75 {
76 return (document_);
77 }
78
79 return (getRawNode(node_stack_.size() - 1));
80 }
81 };
82 } // namespace ns_nlohmann_json
83} // namespace ariles2
const t_Node & getRawNode() const
Definition common.h:49
::nlohmann::ordered_json document_
instance of the JSON value
Definition common.h:29
t_Node & getRawNode(const std::size_t depth)
Get current node.
Definition common.h:38
#define ARILES2_LOCAL
Definition visibility.h:47