Flow123d
release_2.1.0-84-g6a13a75
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
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 "yaml-cpp/yaml.h"
23
#include "
input/path_base.hh
"
24
25
26
namespace
Input
{
27
28
29
30
/**
31
* @brief Class used by ReaderToStorage class to iterate over the YAML tree provided by yaml-cpp library.
32
*
33
* This class keeps whole path from the root of the YAML tree to the current node. We store nodes along path in \p nodes_
34
* and address of the node in \p path_.
35
*
36
* The class also contains methods for processing of special tags for 'TYPE' key. Class doesn't need special methods
37
* for work with references. YAML tree used own native references.
38
*/
39
class
PathYAML
:
public
PathBase
{
40
public
:
41
/// Definition of YAML-cpp node.
42
typedef
YAML::Node
Node
;
43
44
/// Constructor.
45
PathYAML
(std::istream &in);
46
47
/**
48
* @brief Destructor.
49
*
50
* Clean nodes_.
51
*/
52
~PathYAML
()
override
;
53
54
/**
55
* @brief Returns level of actual path.
56
*
57
* Root has level == 0.
58
*/
59
inline
int
level
()
const
60
{
return
nodes_
.size() - 1; }
61
62
/**
63
* @brief Dive into yaml-cpp hierarchy.
64
*
65
* Implements @p PathBase::down(unsigned int)
66
*/
67
bool
down
(
unsigned
int
index)
override
;
68
69
/**
70
* @brief Dive into yaml-cpp hierarchy.
71
*
72
* Implements @p PathBase::down(const std::string&)
73
*/
74
bool
down
(
const
std::string& key)
override
;
75
76
/// Return one level up in the hierarchy.
77
void
up
()
override
;
78
79
// These methods are derived from PathBase
80
bool
is_null_type
()
const override
;
///< Implements @p PathBase::is_null_type
81
bool
get_bool_value
()
const override
;
///< Implements @p PathBase::get_bool_value
82
std::int64_t
get_int_value
()
const override
;
///< Implements @p PathBase::get_int_value
83
double
get_double_value
()
const override
;
///< Implements @p PathBase::get_double_value
84
std::string
get_string_value
()
const override
;
///< Implements @p PathBase::get_string_value
85
unsigned
int
get_node_type_index
()
const override
;
///< Implements @p PathBase::get_node_type_index
86
bool
get_record_key_set
(std::set<std::string> &)
const override
;
///< Implements @p PathBase::get_record_key_set
87
bool
is_effectively_null
()
const override
;
///< Implements @p PathBase::is_effectively_null
88
int
get_array_size
()
const override
;
///< Implements @p PathBase::get_array_size
89
bool
is_record_type
()
const override
;
///< Implements @p PathBase::is_record_type
90
bool
is_array_type
()
const override
;
///< Implements @p PathBase::is_array_type
91
PathYAML
*
clone
()
const override
;
///< Implements @p PathBase::clone
92
93
/// Implements reading of reference keys, and check of cyclic references.
94
PathBase
*
find_ref_node
()
override
;
95
96
/// Implements @p PathBase::get_record_name
97
std::string
get_record_name
()
const override
;
98
99
protected
:
100
101
102
/// Pointer to YAML Value object at current path.
103
inline
const
Node &
head
()
const
104
{
return
nodes_
.back(); }
105
106
// Pointers to all nodes from the root up to the current path.
107
std::vector<Node>
nodes_
;
108
};
109
110
111
/**
112
* @brief Output operator for PathYAML.
113
*
114
* Mainly for debugging purposes and error messages.
115
*/
116
std::ostream&
operator<<
(std::ostream& stream,
const
PathYAML
& path);
117
118
119
120
}
// namespace Input
121
122
123
124
#endif
/* PATH_YAML_HH_ */
Input::PathYAML::get_node_type_index
unsigned int get_node_type_index() const override
Implements PathBase::get_node_type_index.
Definition:
path_yaml.cc:144
Input::PathYAML
Class used by ReaderToStorage class to iterate over the YAML tree provided by yaml-cpp library...
Definition:
path_yaml.hh:39
Input::PathYAML::Node
YAML::Node Node
Definition of YAML-cpp node.
Definition:
path_yaml.hh:42
Input::PathYAML::get_array_size
int get_array_size() const override
Implements PathBase::get_array_size.
Definition:
path_yaml.cc:167
Input::operator<<
std::ostream & operator<<(std::ostream &stream, const Address &address)
Definition:
accessors.hh:247
Input::PathBase
Base abstract class used by ReaderToStorage class to iterate over the input tree. ...
Definition:
path_base.hh:39
Input
Definition:
equation.hh:37
Input::PathYAML::get_int_value
std::int64_t get_int_value() const override
Implements PathBase::get_int_value.
Definition:
path_yaml.cc:102
Input::PathYAML::is_null_type
bool is_null_type() const override
Implements PathBase::is_null_type.
Definition:
path_yaml.cc:83
Input::PathYAML::find_ref_node
PathBase * find_ref_node() override
Implements reading of reference keys, and check of cyclic references.
Definition:
path_yaml.cc:190
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:155
std::vector< Node >
Input::PathYAML::get_record_name
std::string get_record_name() const override
Implements PathBase::get_record_name.
Definition:
path_yaml.cc:197
Input::PathYAML::is_array_type
bool is_array_type() const override
Implements PathBase::is_array_type.
Definition:
path_yaml.cc:180
Input::PathYAML::PathYAML
PathYAML(std::istream &in)
Constructor.
Definition:
path_yaml.cc:29
Input::PathYAML::~PathYAML
~PathYAML() override
Destructor.
Definition:
path_yaml.cc:45
Input::PathYAML::head
const Node & head() const
Pointer to YAML Value object at current path.
Definition:
path_yaml.hh:103
Input::PathYAML::nodes_
std::vector< Node > nodes_
Definition:
path_yaml.hh:107
Input::PathYAML::is_effectively_null
bool is_effectively_null() const override
Implements PathBase::is_effectively_null.
Definition:
path_yaml.cc:208
Input::PathYAML::is_record_type
bool is_record_type() const override
Implements PathBase::is_record_type.
Definition:
path_yaml.cc:175
Input::PathYAML::clone
PathYAML * clone() const override
Implements PathBase::clone.
Definition:
path_yaml.cc:185
Input::PathYAML::level
int level() const
Returns level of actual path.
Definition:
path_yaml.hh:59
Input::PathYAML::get_double_value
double get_double_value() const override
Implements PathBase::get_double_value.
Definition:
path_yaml.cc:116
path_base.hh
Input::PathYAML::get_bool_value
bool get_bool_value() const override
Implements PathBase::get_bool_value.
Definition:
path_yaml.cc:88
Input::PathYAML::down
bool down(unsigned int index) override
Dive into yaml-cpp hierarchy.
Definition:
path_yaml.cc:51
Input::PathYAML::get_string_value
std::string get_string_value() const override
Implements PathBase::get_string_value.
Definition:
path_yaml.cc:130
Input::PathYAML::up
void up() override
Return one level up in the hierarchy.
Definition:
path_yaml.cc:75
Generated by
1.8.11