GCC Code Coverage Report


Directory: ./
File: src/iguana/services/YAMLReader.cc
Date: 2025-11-25 17:57:04
Coverage Exec Excl Total
Lines: 70.5% 98 0 139
Functions: 100.0% 20 0 20
Branches: 52.6% 153 0 291

Line Branch Exec Source
1 #include "YAMLReader.h"
2
3 namespace iguana {
4
5 47 void YAMLReader::LoadFiles()
6 {
7 47 m_log->Debug("YAMLReader::LoadFiles():");
8
2/2
✓ Branch 23 → 4 taken 53 times.
✓ Branch 23 → 24 taken 47 times.
100 for(auto const& file : m_files) {
9 try {
10
2/6
✓ Branch 8 → 9 taken 53 times.
✗ Branch 8 → 25 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 12 taken 53 times.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 28 not taken.
53 m_log->Debug(" - load: {}", file);
11
2/4
✓ Branch 14 → 15 taken 53 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 53 times.
✗ Branch 15 → 33 not taken.
106 m_configs.push_back({YAML::LoadFile(file), file}); // m_config must be the same ordering as m_files, so `push_back`
12 }
13 catch(YAML::Exception const& e) {
14 m_log->Error(" - YAML Exception: {}", e.what());
15 }
16 catch(std::exception const& e) {
17 m_log->Error(" - Exception: {}", e.what());
18 }
19 }
20 47 }
21
22 ///////////////////////////////////////////////////////////////////////////////
23
24 template <typename SCALAR>
25
3/6
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 2 → 3 taken 90 times.
✗ Branch 2 → 15 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(YAML::Node):
✓ Branch 2 → 3 taken 22 times.
✗ Branch 2 → 9 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(YAML::Node):
✓ Branch 2 → 3 taken 27 times.
✗ Branch 2 → 9 not taken.
139 std::optional<SCALAR> YAMLReader::GetScalar(YAML::Node node)
26 {
27
6/12
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 4 → 5 taken 90 times.
✗ Branch 4 → 15 not taken.
✓ Branch 6 → 7 taken 90 times.
✗ Branch 6 → 15 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(YAML::Node):
✓ Branch 4 → 5 taken 22 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 22 times.
✗ Branch 6 → 9 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(YAML::Node):
✓ Branch 4 → 5 taken 27 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 27 times.
✗ Branch 6 → 9 not taken.
278 if(node.IsDefined() && !node.IsNull()) {
28 try {
29
3/6
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 7 → 8 taken 90 times.
✗ Branch 7 → 17 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(YAML::Node):
✓ Branch 7 → 8 taken 22 times.
✗ Branch 7 → 11 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(YAML::Node):
✓ Branch 7 → 8 taken 27 times.
✗ Branch 7 → 11 not taken.
229 return node.as<SCALAR>();
30 }
31 catch(YAML::Exception const& e) {
32 m_log->Error("YAML Parsing Exception: {}", e.what());
33 }
34 catch(std::exception const& e) {
35 m_log->Error("YAML Misc. Exception: {}", e.what());
36 }
37 }
38 return std::nullopt;
39 }
40 template std::optional<int> YAMLReader::GetScalar(YAML::Node node);
41 template std::optional<double> YAMLReader::GetScalar(YAML::Node node);
42 template std::optional<std::string> YAMLReader::GetScalar(YAML::Node node);
43
44 ///////////////////////////////////////////////////////////////////////////////
45
46 template <typename SCALAR>
47 164 std::optional<SCALAR> YAMLReader::GetScalar(node_path_t node_path)
48 {
49
5/6
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 22 → 3 taken 115 times.
✓ Branch 22 → 23 taken 22 times.
std::optional<double> iguana::YAMLReader::GetScalar<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 22 → 3 taken 25 times.
✗ Branch 22 → 23 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 22 → 3 taken 35 times.
✓ Branch 22 → 23 taken 2 times.
234 for(auto const& [config, filename] : m_configs) {
50
10/18
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 4 → 5 taken 115 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 115 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 115 times.
✗ Branch 8 → 13 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 4 → 5 taken 25 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 25 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 25 times.
✗ Branch 8 → 13 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 4 → 5 taken 35 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 34 times.
✓ Branch 5 → 25 taken 1 time.
✓ Branch 8 → 9 taken 34 times.
✗ Branch 8 → 13 not taken.
176 auto node = FindNode(config, node_path);
51
9/12
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 10 → 11 taken 90 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 25 times.
✓ Branch 12 → 15 taken 90 times.
std::optional<double> iguana::YAMLReader::GetScalar<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 10 → 11 taken 22 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 3 times.
✓ Branch 12 → 15 taken 22 times.
std::optional<int> iguana::YAMLReader::GetScalar<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 10 → 11 taken 28 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 7 times.
✓ Branch 12 → 15 taken 27 times.
314 if(node.IsDefined() && !node.IsNull())
52
6/12
std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > iguana::YAMLReader::GetScalar<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 15 → 16 taken 90 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 90 times.
✗ Branch 16 → 29 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 15 → 16 taken 22 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 22 times.
✗ Branch 16 → 29 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 15 → 16 taken 27 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 27 times.
✗ Branch 16 → 29 not taken.
139 return GetScalar<SCALAR>(node);
53 }
54 24 return std::nullopt;
55 }
56 template std::optional<int> YAMLReader::GetScalar(node_path_t node_path);
57 template std::optional<double> YAMLReader::GetScalar(node_path_t node_path);
58 template std::optional<std::string> YAMLReader::GetScalar(node_path_t node_path);
59
60 ///////////////////////////////////////////////////////////////////////////////
61
62 template <typename SCALAR>
63
3/6
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 2 → 3 taken 5 times.
✗ Branch 2 → 33 not taken.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(YAML::Node):
✓ Branch 2 → 3 taken 42 times.
✗ Branch 2 → 27 not taken.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(YAML::Node):
✓ Branch 2 → 3 taken 57 times.
✗ Branch 2 → 27 not taken.
104 std::optional<std::vector<SCALAR>> YAMLReader::GetVector(YAML::Node node)
64 {
65
9/18
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 4 → 5 taken 5 times.
✗ Branch 4 → 33 not taken.
✓ Branch 6 → 7 taken 5 times.
✗ Branch 6 → 33 not taken.
✓ Branch 8 → 9 taken 5 times.
✗ Branch 8 → 33 not taken.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(YAML::Node):
✓ Branch 4 → 5 taken 42 times.
✗ Branch 4 → 27 not taken.
✓ Branch 6 → 7 taken 42 times.
✗ Branch 6 → 27 not taken.
✓ Branch 8 → 9 taken 42 times.
✗ Branch 8 → 27 not taken.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(YAML::Node):
✓ Branch 4 → 5 taken 57 times.
✗ Branch 4 → 27 not taken.
✓ Branch 6 → 7 taken 57 times.
✗ Branch 6 → 27 not taken.
✓ Branch 8 → 9 taken 57 times.
✗ Branch 8 → 27 not taken.
312 if(node.IsDefined() && !node.IsNull() && node.IsSequence()) {
66 try {
67 std::vector<SCALAR> result;
68
15/24
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 9 → 10 taken 5 times.
✗ Branch 9 → 49 not taken.
✓ Branch 10 → 22 taken 5 times.
✗ Branch 10 → 46 not taken.
✓ Branch 11 → 12 taken 12 times.
✗ Branch 11 → 43 not taken.
✓ Branch 26 → 11 taken 12 times.
✓ Branch 26 → 27 taken 5 times.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(YAML::Node):
✓ Branch 9 → 10 taken 42 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 17 taken 42 times.
✗ Branch 10 → 34 not taken.
✓ Branch 11 → 12 taken 126 times.
✗ Branch 11 → 31 not taken.
✓ Branch 21 → 11 taken 126 times.
✓ Branch 21 → 22 taken 42 times.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(YAML::Node):
✓ Branch 9 → 10 taken 57 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 17 taken 57 times.
✗ Branch 10 → 34 not taken.
✓ Branch 11 → 12 taken 124 times.
✗ Branch 11 → 31 not taken.
✓ Branch 21 → 11 taken 124 times.
✓ Branch 21 → 22 taken 57 times.
470 for(auto const& element : node)
69
5/10
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(YAML::Node):
✓ Branch 12 → 13 taken 12 times.
✗ Branch 12 → 41 not taken.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(YAML::Node):
✓ Branch 12 → 13 taken 126 times.
✗ Branch 12 → 29 not taken.
✓ Branch 13 → 14 taken 126 times.
✗ Branch 13 → 29 not taken.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(YAML::Node):
✓ Branch 12 → 13 taken 124 times.
✗ Branch 12 → 29 not taken.
✓ Branch 13 → 14 taken 124 times.
✗ Branch 13 → 29 not taken.
274 result.push_back(element.as<SCALAR>());
70 return result;
71 5 }
72 catch(YAML::Exception const& e) {
73 m_log->Error("YAML Parsing Exception: {}", e.what());
74 }
75 catch(std::exception const& e) {
76 m_log->Error("YAML Misc. Exception: {}", e.what());
77 }
78 }
79 return std::nullopt;
80 }
81 template std::optional<std::vector<int>> YAMLReader::GetVector(YAML::Node node);
82 template std::optional<std::vector<double>> YAMLReader::GetVector(YAML::Node node);
83 template std::optional<std::vector<std::string>> YAMLReader::GetVector(YAML::Node node);
84
85 ///////////////////////////////////////////////////////////////////////////////
86
87 template <typename SCALAR>
88 45 std::optional<std::vector<SCALAR>> YAMLReader::GetVector(node_path_t node_path)
89 {
90
4/6
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 22 → 3 taken 5 times.
✗ Branch 22 → 23 not taken.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 22 → 3 taken 28 times.
✗ Branch 22 → 23 not taken.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 22 → 3 taken 16 times.
✓ Branch 22 → 23 taken 4 times.
61 for(auto const& [config, filename] : m_configs) {
91
9/18
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 4 → 5 taken 5 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 5 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 5 times.
✗ Branch 8 → 13 not taken.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 4 → 5 taken 28 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 28 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 28 times.
✗ Branch 8 → 13 not taken.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 4 → 5 taken 16 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 16 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 16 times.
✗ Branch 8 → 13 not taken.
49 auto node = FindNode(config, node_path);
92
7/12
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 10 → 11 taken 5 times.
✗ Branch 10 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 15 taken 5 times.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 10 → 11 taken 28 times.
✗ Branch 10 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 15 taken 28 times.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 10 → 11 taken 10 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 8 times.
✓ Branch 12 → 15 taken 8 times.
92 if(node.IsDefined() && !node.IsNull())
93
6/12
std::optional<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > iguana::YAMLReader::GetVector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 15 → 16 taken 5 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 5 times.
✗ Branch 16 → 29 not taken.
std::optional<std::vector<double, std::allocator<double> > > iguana::YAMLReader::GetVector<double>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 15 → 16 taken 28 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 28 times.
✗ Branch 16 → 29 not taken.
std::optional<std::vector<int, std::allocator<int> > > iguana::YAMLReader::GetVector<int>(std::deque<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> >, std::allocator<std::variant<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<YAML::Node (YAML::Node)> > > >):
✓ Branch 15 → 16 taken 8 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 8 times.
✗ Branch 16 → 29 not taken.
41 return GetVector<SCALAR>(node);
94 }
95 4 return std::nullopt;
96 }
97 template std::optional<std::vector<int>> YAMLReader::GetVector(node_path_t node_path);
98 template std::optional<std::vector<double>> YAMLReader::GetVector(node_path_t node_path);
99 template std::optional<std::vector<std::string>> YAMLReader::GetVector(node_path_t node_path);
100
101 ///////////////////////////////////////////////////////////////////////////////
102
103 template <typename SCALAR>
104 42 YAMLReader::node_finder_t YAMLReader::InRange(std::string const& key, SCALAR val)
105 {
106
3/6
std::function<YAML::Node (YAML::Node)> iguana::YAMLReader::InRange<double>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double):
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 8 times.
std::function<YAML::Node (YAML::Node)> iguana::YAMLReader::InRange<int>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int):
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 34 times.
None:
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 258 times.
858 return [this, key, val](YAML::Node node) -> YAML::Node {
107
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 8 taken 42 times.
42 if(!node.IsSequence()) {
108 m_log->Error("YAML node path expected a sequence at current node");
109 throw std::runtime_error("Failed `InRange`");
110 }
111 // search each sub-node for one with `val` with in the range at `key`
112
4/6
✓ Branch 9 → 44 taken 42 times.
✗ Branch 9 → 107 not taken.
✓ Branch 10 → 11 taken 90 times.
✗ Branch 10 → 104 not taken.
✓ Branch 48 → 10 taken 90 times.
✓ Branch 48 → 49 taken 24 times.
246 for(auto const& sub_node : node) {
113
1/2
✓ Branch 11 → 12 taken 90 times.
✗ Branch 11 → 102 not taken.
90 auto bounds_node = sub_node[key];
114
1/2
✓ Branch 14 → 15 taken 63 times.
✗ Branch 14 → 40 not taken.
63 if(bounds_node.IsDefined()) {
115
3/6
✓ Branch 15 → 16 taken 63 times.
✗ Branch 15 → 100 not taken.
✓ Branch 16 → 17 taken 63 times.
✗ Branch 16 → 96 not taken.
✓ Branch 18 → 19 taken 63 times.
✗ Branch 18 → 20 not taken.
63 auto bounds = GetVector<SCALAR>(bounds_node);
116
5/6
✓ Branch 22 → 23 taken 63 times.
✗ Branch 22 → 29 not taken.
✓ Branch 25 → 26 taken 57 times.
✓ Branch 25 → 29 taken 6 times.
✓ Branch 28 → 29 taken 39 times.
✓ Branch 28 → 31 taken 18 times.
183 if(bounds.value().size() == 2 && bounds.value()[0] <= val && bounds.value()[1] >= val)
117
1/2
✓ Branch 31 → 32 taken 18 times.
✗ Branch 31 → 98 not taken.
18 return sub_node;
118 }
119 }
120 // fallback to the default node
121
4/6
✓ Branch 54 → 72 taken 24 times.
✗ Branch 54 → 115 not taken.
✓ Branch 55 → 56 taken 36 times.
✗ Branch 55 → 112 not taken.
✓ Branch 76 → 55 taken 36 times.
✓ Branch 76 → 77 taken 1 time.
97 for(auto const& sub_node : node) {
122
3/4
✓ Branch 56 → 57 taken 36 times.
✗ Branch 56 → 110 not taken.
✓ Branch 61 → 62 taken 23 times.
✓ Branch 61 → 63 taken 13 times.
72 if(sub_node["default"].IsDefined())
123
1/2
✓ Branch 62 → 65 taken 23 times.
✗ Branch 62 → 110 not taken.
23 return sub_node;
124 }
125 // if no default found, return empty
126
3/8
✗ Branch 81 → 82 not taken.
✓ Branch 81 → 83 taken 1 time.
✓ Branch 84 → 85 taken 1 time.
✗ Branch 84 → 118 not taken.
✓ Branch 85 → 86 taken 1 time.
✗ Branch 85 → 88 not taken.
✗ Branch 118 → 119 not taken.
✗ Branch 118 → 121 not taken.
2 m_log->Error("No default node for `InRange('{}',{})`", key, val);
127
1/2
✓ Branch 91 → 92 taken 1 time.
✗ Branch 91 → 124 not taken.
1 throw std::runtime_error("Failed `InRange`");
128
2/4
std::function<YAML::Node (YAML::Node)> iguana::YAMLReader::InRange<double>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double):
✓ Branch 5 → 6 taken 8 times.
✗ Branch 5 → 12 not taken.
std::function<YAML::Node (YAML::Node)> iguana::YAMLReader::InRange<int>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int):
✓ Branch 5 → 6 taken 34 times.
✗ Branch 5 → 12 not taken.
84 };
129 }
130 template YAMLReader::node_finder_t YAMLReader::InRange(std::string const& key, int val);
131 template YAMLReader::node_finder_t YAMLReader::InRange(std::string const& key, double val);
132
133 ///////////////////////////////////////////////////////////////////////////////
134
135
2/2
✓ Branch 2 → 3 taken 183 times.
✓ Branch 2 → 5 taken 585 times.
768 YAML::Node YAMLReader::FindNode(YAML::Node node, node_path_t node_path)
136 {
137
138 // if `node_path` is empty, we are likely at the end of the node path; end recursion and return `node`
139
2/2
✓ Branch 2 → 3 taken 183 times.
✓ Branch 2 → 5 taken 585 times.
768 if(node_path.empty()) {
140 183 m_log->Trace("... found");
141 183 return node;
142 }
143
144 // find the next node using the first `node_id_t` in `node_path`
145 1170 auto node_id_visitor = [&node, &m_log = this->m_log](auto&& arg) -> YAML::Node {
146 using arg_t = std::decay_t<decltype(arg)>;
147 // find a node by key name
148 if constexpr(std::is_same_v<arg_t, std::string>) {
149
4/8
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 543 times.
✓ Branch 5 → 6 taken 543 times.
✗ Branch 5 → 13 not taken.
✓ Branch 6 → 7 taken 293 times.
✓ Branch 6 → 9 taken 250 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 16 not taken.
1086 m_log->Trace("... by key '{}'", arg);
150 543 return node[arg];
151 }
152 // find a node using a `node_finder_t`
153 else {
154 42 m_log->Trace("... by node finder function");
155 84 return arg(node);
156 }
157 585 };
158 auto result = std::visit(node_id_visitor, node_path.front());
159
160 // if the resulting node is not defined, return an empty node; callers must check the result
161
2/2
✓ Branch 8 → 9 taken 40 times.
✓ Branch 8 → 10 taken 544 times.
584 if(!result.IsDefined())
162 return {};
163
164 // recurse to the next element of `node_path`
165 544 node_path.pop_front();
166
4/6
✓ Branch 11 → 12 taken 544 times.
✗ Branch 11 → 23 not taken.
✓ Branch 12 → 13 taken 544 times.
✗ Branch 12 → 21 not taken.
✓ Branch 13 → 14 taken 542 times.
✓ Branch 13 → 19 taken 2 times.
546 return FindNode(result, node_path);
167 584 }
168
169 }
170