Flow123d
DF_patch_fe_data_tables-956a7bc
src
input
path_yaml.hh
Go to the documentation of this file.
1
/*!
2
*
3
* Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4
*
5
* This program is free software; you can redistribute it and/or modify it under
6
* the terms of the GNU General Public License version 3 as published by the
7
* Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
*
13
*
14
* @file path_yaml.hh
15
* @brief
16
*/
17
18
#ifndef PATH_YAML_HH_
19
#define PATH_YAML_HH_
20
21
22
#include <stdint.h>
// for int64_t
23
#include <iosfwd>
// for ostream, istream
24
#include <set>
// for set
25
#include <string>
// for string
26
#include <vector>
// for vector
27
#include "yaml-cpp/node/impl.h"
// for Node::Node, Node::operat...
28
#include "yaml-cpp/node/node.h"
// for Node
29
30
#include "
input/path_base.hh
"
31
32
33
namespace
Input
{
34
35
36
37
/**
38
* @brief Class used by ReaderToStorage class to iterate over the YAML tree provided by yaml-cpp library.
39
*
40
* This class keeps whole path from the root of the YAML tree to the current node. We store nodes along path in \p nodes_
41
* and address of the node in \p path_.
42
*
43
* The class also contains methods for processing of special tags for 'TYPE' key. Class doesn't need special methods
44
* for work with references. YAML tree used own native references.
45
*/
46
class
PathYAML
:
public
PathBase
{
47
public
:
48
/// Definition of YAML-cpp node.
49
typedef
YAML::Node
Node
;
50
51
/// Constructor.
52
PathYAML
(std::istream &in);
53
54
/**
55
* @brief Destructor.
56
*
57
* Clean nodes_.
58
*/
59
~PathYAML
()
override
;
60
61
/**
62
* @brief Returns level of actual path.
63
*
64
* Root has level == 0.
65
*/
66
inline
int
level
()
const
67
{
return
nodes_
.size() - 1; }
68
69
/**
70
* @brief Dive into yaml-cpp hierarchy.
71
*
72
* Implements @p PathBase::down(unsigned int)
73
*/
74
bool
down
(
unsigned
int
index)
override
;
75
76
/**
77
* @brief Dive into yaml-cpp hierarchy.
78
*
79
* Implements @p PathBase::down(const std::string&)
80
*/
81
bool
down
(
const
std::string& key,
int
index = -1)
override
;
82
83
/// Return one level up in the hierarchy.
84
void
up
()
override
;
85
86
// These methods are derived from PathBase
87
bool
is_null_type
()
const override
;
///< Implements @p PathBase::is_null_type
88
bool
get_bool_value
()
const override
;
///< Implements @p PathBase::get_bool_value
89
std::int64_t
get_int_value
()
const override
;
///< Implements @p PathBase::get_int_value
90
double
get_double_value
()
const override
;
///< Implements @p PathBase::get_double_value
91
std::string
get_string_value
()
const override
;
///< Implements @p PathBase::get_string_value
92
unsigned
int
get_node_type_index
()
const override
;
///< Implements @p PathBase::get_node_type_index
93
bool
get_record_key_set
(std::set<std::string> &)
const override
;
///< Implements @p PathBase::get_record_key_set
94
bool
is_effectively_null
()
const override
;
///< Implements @p PathBase::is_effectively_null
95
int
get_array_size
()
const override
;
///< Implements @p PathBase::get_array_size
96
bool
is_record_type
()
const override
;
///< Implements @p PathBase::is_record_type
97
bool
is_array_type
()
const override
;
///< Implements @p PathBase::is_array_type
98
PathYAML
*
clone
()
const override
;
///< Implements @p PathBase::clone
99
100
/// Implements reading of reference keys, and check of cyclic references.
101
PathBase
*
find_ref_node
()
override
;
102
103
/// Implements @p PathBase::get_record_tag
104
std::string
get_record_tag
()
const override
;
105
106
protected
:
107
108
109
/// Pointer to YAML Value object at current path.
110
inline
const
Node
&
head
()
const
111
{
return
nodes_
.back(); }
112
113
// Pointers to all nodes from the root up to the current path.
114
std::vector<Node>
nodes_
;
115
};
116
117
118
/**
119
* @brief Output operator for PathYAML.
120
*
121
* Mainly for debugging purposes and error messages.
122
*/
123
std::ostream&
operator<<
(std::ostream& stream,
const
PathYAML
& path);
124
125
126
127
}
// namespace Input
128
129
130
131
#endif
/* PATH_YAML_HH_ */
Input::PathBase
Base abstract class used by ReaderToStorage class to iterate over the input tree.
Definition:
path_base.hh:41
Input::PathYAML
Class used by ReaderToStorage class to iterate over the YAML tree provided by yaml-cpp library.
Definition:
path_yaml.hh:46
Input::PathYAML::~PathYAML
~PathYAML() override
Destructor.
Definition:
path_yaml.cc:46
Input::PathYAML::is_null_type
bool is_null_type() const override
Implements PathBase::is_null_type.
Definition:
path_yaml.cc:88
Input::PathYAML::get_array_size
int get_array_size() const override
Implements PathBase::get_array_size.
Definition:
path_yaml.cc:179
Input::PathYAML::get_string_value
std::string get_string_value() const override
Implements PathBase::get_string_value.
Definition:
path_yaml.cc:135
Input::PathYAML::down
bool down(unsigned int index) override
Dive into yaml-cpp hierarchy.
Definition:
path_yaml.cc:52
Input::PathYAML::Node
YAML::Node Node
Definition of YAML-cpp node.
Definition:
path_yaml.hh:49
Input::PathYAML::head
const Node & head() const
Pointer to YAML Value object at current path.
Definition:
path_yaml.hh:110
Input::PathYAML::down
bool down(const std::string &key, int index=-1) override
Dive into yaml-cpp hierarchy.
Input::PathYAML::get_double_value
double get_double_value() const override
Implements PathBase::get_double_value.
Definition:
path_yaml.cc:121
Input::PathYAML::get_int_value
std::int64_t get_int_value() const override
Implements PathBase::get_int_value.
Definition:
path_yaml.cc:107
Input::PathYAML::up
void up() override
Return one level up in the hierarchy.
Definition:
path_yaml.cc:80
Input::PathYAML::find_ref_node
PathBase * find_ref_node() override
Implements reading of reference keys, and check of cyclic references.
Definition:
path_yaml.cc:202
Input::PathYAML::is_effectively_null
bool is_effectively_null() const override
Implements PathBase::is_effectively_null.
Definition:
path_yaml.cc:220
Input::PathYAML::get_record_key_set
bool get_record_key_set(std::set< std::string > &) const override
Implements PathBase::get_record_key_set.
Definition:
path_yaml.cc:160
Input::PathYAML::get_bool_value
bool get_bool_value() const override
Implements PathBase::get_bool_value.
Definition:
path_yaml.cc:93
Input::PathYAML::is_record_type
bool is_record_type() const override
Implements PathBase::is_record_type.
Definition:
path_yaml.cc:187
Input::PathYAML::PathYAML
PathYAML(std::istream &in)
Constructor.
Definition:
path_yaml.cc:30
Input::PathYAML::is_array_type
bool is_array_type() const override
Implements PathBase::is_array_type.
Definition:
path_yaml.cc:192
Input::PathYAML::level
int level() const
Returns level of actual path.
Definition:
path_yaml.hh:66
Input::PathYAML::clone
PathYAML * clone() const override
Implements PathBase::clone.
Definition:
path_yaml.cc:197
Input::PathYAML::get_record_tag
std::string get_record_tag() const override
Implements PathBase::get_record_tag.
Definition:
path_yaml.cc:209
Input::PathYAML::get_node_type_index
unsigned int get_node_type_index() const override
Implements PathBase::get_node_type_index.
Definition:
path_yaml.cc:149
Input::PathYAML::nodes_
std::vector< Node > nodes_
Definition:
path_yaml.hh:114
std::vector< Node >
Input
Abstract linear system class.
Definition:
balance.hh:40
Input::operator<<
std::ostream & operator<<(std::ostream &stream, const Address &address)
Definition:
accessors.hh:252
path_base.hh
Generated by
1.9.1