Iguana
1.0.0
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
template
<
typename
SCALAR>
43
std::optional<SCALAR>
GetScalar
(YAML::Node node);
44
48
template
<
typename
SCALAR>
49
std::optional<SCALAR>
GetScalar
(
node_path_t
node_path);
50
54
template
<
typename
SCALAR>
55
std::optional<std::vector<SCALAR>>
GetVector
(YAML::Node node);
56
60
template
<
typename
SCALAR>
61
std::optional<std::vector<SCALAR>>
GetVector
(
node_path_t
node_path);
62
68
template
<
typename
SCALAR>
69
node_finder_t
InRange
(std::string
const
& key, SCALAR val);
70
71
private
:
72
77
YAML::Node FindNode(YAML::Node node,
node_path_t
node_path);
78
80
std::deque<std::pair<YAML::Node, std::string>> m_configs;
81
};
82
}
iguana::ConfigFileReader::ConfigFileReader
ConfigFileReader(std::string_view name="config")
iguana::YAMLReader
A YAMLReader based on yaml-cpp.
Definition
YAMLReader.h:15
iguana::YAMLReader::GetScalar
std::optional< SCALAR > GetScalar(node_path_t node_path)
iguana::YAMLReader::InRange
node_finder_t InRange(std::string const &key, SCALAR val)
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)
iguana::YAMLReader::GetVector
std::optional< std::vector< SCALAR > > GetVector(node_path_t node_path)
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)
iguana::YAMLReader::YAMLReader
YAMLReader(std::string_view name="config")
Definition
YAMLReader.h:31
iguana_v1.0.0
src
iguana
services
YAMLReader.h
Generated by
1.18.0