Iguana
1.2.1
Implementation Guardian of Analysis Algorithms
Toggle main menu visibility
Loading...
Searching...
No Matches
YAMLReader.h
1
#pragma once
2
3
#include <optional>
4
#include <variant>
5
#include <vector>
6
7
#include <yaml-cpp/yaml.h>
8
9
#include "ConfigFileReader.h"
10
11
namespace
iguana {
12
14
class
YAMLReader
:
public
ConfigFileReader
15
{
16
17
public
:
18
20
using
node_finder_t
= std::function<YAML::Node(YAML::Node
const
)>;
21
25
using
node_id_t
= std::variant<std::string, node_finder_t>;
26
28
using
node_path_t
= std::deque<node_id_t>;
29
31
YAMLReader
(std::string_view name =
"config"
)
32
:
ConfigFileReader
(name)
33
{}
34
~YAMLReader
() {}
35
37
void
LoadFiles
();
38
42
std::optional<YAML::Node>
GetNode
(
node_path_t
node_path);
43
51
static
std::string
NodePath2String
(
node_path_t
const
& node_path);
52
56
template
<
typename
SCALAR>
57
std::optional<SCALAR>
GetScalar
(YAML::Node node);
58
62
template
<
typename
SCALAR>
63
std::optional<SCALAR>
GetScalar
(
node_path_t
node_path);
64
68
template
<
typename
SCALAR>
69
std::optional<std::vector<SCALAR>>
GetVector
(YAML::Node node);
70
74
template
<
typename
SCALAR>
75
std::optional<std::vector<SCALAR>>
GetVector
(
node_path_t
node_path);
76
81
template
<
typename
SCALAR>
82
node_finder_t
InRange
(std::string
const
& key, SCALAR val);
83
84
private
:
85
90
YAML::Node FindNode(YAML::Node node,
node_path_t
node_path);
91
93
std::deque<std::pair<YAML::Node, std::string>> m_configs;
94
};
95
}
iguana::ConfigFileReader::ConfigFileReader
ConfigFileReader(std::string_view name="config", bool set_default_dirs=true)
iguana::YAMLReader
A YAMLReader based on yaml-cpp.
Definition
YAMLReader.h:15
iguana::YAMLReader::NodePath2String
static std::string NodePath2String(node_path_t const &node_path)
Convert a YAML::Node path to a string.
iguana::YAMLReader::GetScalar
std::optional< SCALAR > GetScalar(node_path_t node_path)
Read a scalar value from a YAML::Node path; searches all currently loaded config files.
iguana::YAMLReader::InRange
node_finder_t InRange(std::string const &key, SCALAR val)
Create a function to search a YAML::Node for a sub-YAML::Node such that the scalar val is within a ra...
iguana::YAMLReader::GetNode
std::optional< YAML::Node > GetNode(node_path_t node_path)
iguana::YAMLReader::node_path_t
std::deque< node_id_t > node_path_t
Representation of a path of YAML::Nodes in a YAML::Node tree, e.g., in a YAML file.
Definition
YAMLReader.h:28
iguana::YAMLReader::node_id_t
std::variant< std::string, node_finder_t > node_id_t
Definition
YAMLReader.h:25
iguana::YAMLReader::LoadFiles
void LoadFiles()
Parse the YAML files added by ConfigFileReader::AddFile.
iguana::YAMLReader::GetVector
std::optional< std::vector< SCALAR > > GetVector(YAML::Node node)
Read a vector value from a YAML::Node.
iguana::YAMLReader::GetVector
std::optional< std::vector< SCALAR > > GetVector(node_path_t node_path)
Read a vector value from a YAML::Node path; searches all currently loaded config files.
iguana::YAMLReader::node_finder_t
std::function< YAML::Node(YAML::Node const)> node_finder_t
A function f : Node A -> Node B which searches YAML::Node A for a specific YAML::Node B,...
Definition
YAMLReader.h:20
iguana::YAMLReader::GetScalar
std::optional< SCALAR > GetScalar(YAML::Node node)
Read a scalar value from a YAML::Node.
iguana::YAMLReader::YAMLReader
YAMLReader(std::string_view name="config")
Definition
YAMLReader.h:31
iguana_v1.2.1
src
iguana
services
YAMLReader.h
Generated by
1.18.0