GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 71.2% 104 / 0 / 146
Functions: 100.0% 21 / 0 / 21
Branches: 52.8% 158 / 0 / 299

src/iguana/services/YAMLReader.cc
Line Branch Exec Source
1 #include "YAMLReader.h"
2
3 namespace iguana {
4
5 104 void YAMLReader::LoadFiles()
6 {
7 104 m_log->Debug("YAMLReader::LoadFiles():");
8
2/2
✓ Branch 23 → 4 taken 64 times.
✓ Branch 23 → 24 taken 104 times.
168 for(auto const& file : m_files) {
9 try {
10
2/6
✓ Branch 8 → 9 taken 64 times.
✗ Branch 8 → 25 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 12 taken 64 times.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 28 not taken.
64 m_log->Debug(" - load: {}", file);
11
2/4
✓ Branch 14 → 15 taken 64 times.
✗ Branch 14 → 35 not taken.
✓ Branch 15 → 16 taken 64 times.
✗ Branch 15 → 33 not taken.
128 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 104 }
21
22 ///////////////////////////////////////////////////////////////////////////////
23
24
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 312 times.
312 std::string YAMLReader::NodePath2String(node_path_t const& node_path)
25 {
26
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 312 times.
312 if(node_path.empty())
27 return "";
28 std::vector<std::string> tokens;
29
2/2
✓ Branch 12 → 6 taken 450 times.
✓ Branch 12 → 13 taken 312 times.
762 for(auto const& node : node_path) {
30 if(auto const* str = std::get_if<std::string>(&node)) {
31
1/2
✓ Branch 8 → 9 taken 408 times.
✗ Branch 8 → 16 not taken.
408 tokens.push_back(*str);
32 }
33 }
34 312 return fmt::format("{}", fmt::join(tokens, "/"));
35 312 }
36
37 ///////////////////////////////////////////////////////////////////////////////
38
39 template <typename SCALAR>
40
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 102 times.
✗ Branch 2 → 15 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(YAML::Node):
✓ Branch 2 → 3 taken 30 times.
✗ Branch 2 → 9 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(YAML::Node):
✓ Branch 2 → 3 taken 29 times.
✗ Branch 2 → 9 not taken.
161 std::optional<SCALAR> YAMLReader::GetScalar(YAML::Node node)
41 {
42
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 102 times.
✗ Branch 4 → 15 not taken.
✓ Branch 6 → 7 taken 102 times.
✗ Branch 6 → 15 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(YAML::Node):
✓ Branch 4 → 5 taken 30 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 30 times.
✗ Branch 6 → 9 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(YAML::Node):
✓ Branch 4 → 5 taken 29 times.
✗ Branch 4 → 9 not taken.
✓ Branch 6 → 7 taken 29 times.
✗ Branch 6 → 9 not taken.
322 if(node.IsDefined() && !node.IsNull()) {
43 try {
44
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 102 times.
✗ Branch 7 → 17 not taken.
std::optional<double> iguana::YAMLReader::GetScalar<double>(YAML::Node):
✓ Branch 7 → 8 taken 30 times.
✗ Branch 7 → 11 not taken.
std::optional<int> iguana::YAMLReader::GetScalar<int>(YAML::Node):
✓ Branch 7 → 8 taken 29 times.
✗ Branch 7 → 11 not taken.
263 return node.as<SCALAR>();
45 }
46 catch(YAML::Exception const& e) {
47 m_log->Error("YAML Parsing Exception: {}", e.what());
48 }
49 catch(std::exception const& e) {
50 m_log->Error("YAML Misc. Exception: {}", e.what());
51 }
52 }
53 return std::nullopt;
54 }
55 template std::optional<int> YAMLReader::GetScalar(YAML::Node node);
56 template std::optional<double> YAMLReader::GetScalar(YAML::Node node);
57 template std::optional<std::string> YAMLReader::GetScalar(YAML::Node node);
58
59 ///////////////////////////////////////////////////////////////////////////////
60
61 template <typename SCALAR>
62 256 std::optional<SCALAR> YAMLReader::GetScalar(node_path_t node_path)
63 {
64
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 157 times.
✓ Branch 22 → 23 taken 92 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 33 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 37 times.
✓ Branch 22 → 23 taken 2 times.
386 for(auto const& [config, filename] : m_configs) {
65
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 157 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 157 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 157 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 33 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 33 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 33 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 37 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 36 times.
✓ Branch 5 → 25 taken 1 time.
✓ Branch 8 → 9 taken 36 times.
✗ Branch 8 → 13 not taken.
228 auto node = FindNode(config, node_path);
66
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 102 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 55 times.
✓ Branch 12 → 15 taken 102 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 30 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 3 times.
✓ Branch 12 → 15 taken 30 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 30 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 7 times.
✓ Branch 12 → 15 taken 29 times.
388 if(node.IsDefined() && !node.IsNull())
67
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 102 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 102 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 30 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 30 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 29 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 29 times.
✗ Branch 16 → 29 not taken.
161 return GetScalar<SCALAR>(node);
68 }
69 94 return std::nullopt;
70 }
71 template std::optional<int> YAMLReader::GetScalar(node_path_t node_path);
72 template std::optional<double> YAMLReader::GetScalar(node_path_t node_path);
73 template std::optional<std::string> YAMLReader::GetScalar(node_path_t node_path);
74
75 ///////////////////////////////////////////////////////////////////////////////
76
77 template <typename SCALAR>
78
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 4 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 60 times.
✗ Branch 2 → 27 not taken.
106 std::optional<std::vector<SCALAR>> YAMLReader::GetVector(YAML::Node node)
79 {
80
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 4 times.
✗ Branch 4 → 33 not taken.
✓ Branch 6 → 7 taken 4 times.
✗ Branch 6 → 33 not taken.
✓ Branch 8 → 9 taken 4 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 60 times.
✗ Branch 4 → 27 not taken.
✓ Branch 6 → 7 taken 60 times.
✗ Branch 6 → 27 not taken.
✓ Branch 8 → 9 taken 60 times.
✗ Branch 8 → 27 not taken.
318 if(node.IsDefined() && !node.IsNull() && node.IsSequence()) {
81 try {
82 std::vector<SCALAR> result;
83
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 4 times.
✗ Branch 9 → 49 not taken.
✓ Branch 10 → 22 taken 4 times.
✗ Branch 10 → 46 not taken.
✓ Branch 11 → 12 taken 11 times.
✗ Branch 11 → 43 not taken.
✓ Branch 26 → 11 taken 11 times.
✓ Branch 26 → 27 taken 4 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 60 times.
✗ Branch 9 → 37 not taken.
✓ Branch 10 → 17 taken 60 times.
✗ Branch 10 → 34 not taken.
✓ Branch 11 → 12 taken 136 times.
✗ Branch 11 → 31 not taken.
✓ Branch 21 → 11 taken 136 times.
✓ Branch 21 → 22 taken 60 times.
485 for(auto const& element : node)
84
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 11 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 136 times.
✗ Branch 12 → 29 not taken.
✓ Branch 13 → 14 taken 136 times.
✗ Branch 13 → 29 not taken.
284 result.push_back(element.as<SCALAR>());
85 return result;
86 4 }
87 catch(YAML::Exception const& e) {
88 m_log->Error("YAML Parsing Exception: {}", e.what());
89 }
90 catch(std::exception const& e) {
91 m_log->Error("YAML Misc. Exception: {}", e.what());
92 }
93 }
94 return std::nullopt;
95 }
96 template std::optional<std::vector<int>> YAMLReader::GetVector(YAML::Node node);
97 template std::optional<std::vector<double>> YAMLReader::GetVector(YAML::Node node);
98 template std::optional<std::vector<std::string>> YAMLReader::GetVector(YAML::Node node);
99
100 ///////////////////////////////////////////////////////////////////////////////
101
102 template <typename SCALAR>
103 47 std::optional<std::vector<SCALAR>> YAMLReader::GetVector(node_path_t node_path)
104 {
105
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 4 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 19 times.
✓ Branch 22 → 23 taken 4 times.
63 for(auto const& [config, filename] : m_configs) {
106
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 4 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 4 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 4 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 19 times.
✗ Branch 4 → 27 not taken.
✓ Branch 5 → 6 taken 19 times.
✗ Branch 5 → 25 not taken.
✓ Branch 8 → 9 taken 19 times.
✗ Branch 8 → 13 not taken.
51 auto node = FindNode(config, node_path);
107
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 4 times.
✗ Branch 10 → 13 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 15 taken 4 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 13 times.
✗ Branch 10 → 13 not taken.
✓ Branch 12 → 13 taken 8 times.
✓ Branch 12 → 15 taken 11 times.
96 if(node.IsDefined() && !node.IsNull())
108
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 4 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 4 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 11 times.
✗ Branch 15 → 31 not taken.
✓ Branch 16 → 17 taken 11 times.
✗ Branch 16 → 29 not taken.
43 return GetVector<SCALAR>(node);
109 }
110 4 return std::nullopt;
111 }
112 template std::optional<std::vector<int>> YAMLReader::GetVector(node_path_t node_path);
113 template std::optional<std::vector<double>> YAMLReader::GetVector(node_path_t node_path);
114 template std::optional<std::vector<std::string>> YAMLReader::GetVector(node_path_t node_path);
115
116 ///////////////////////////////////////////////////////////////////////////////
117
118 template <typename SCALAR>
119 42 YAMLReader::node_finder_t YAMLReader::InRange(std::string const& key, SCALAR val)
120 {
121
3/6
None:
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 258 times.
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.
858 return [this, key, val](YAML::Node node) -> YAML::Node {
122
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 8 taken 42 times.
42 if(!node.IsSequence()) {
123 m_log->Error("YAML node path expected a sequence at current node");
124 throw std::runtime_error("Failed `InRange`");
125 }
126 // search each sub-node for one with `val` with in the range at `key`
127
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) {
128
1/2
✓ Branch 11 → 12 taken 90 times.
✗ Branch 11 → 102 not taken.
90 auto bounds_node = sub_node[key];
129
1/2
✓ Branch 14 → 15 taken 63 times.
✗ Branch 14 → 40 not taken.
63 if(bounds_node.IsDefined()) {
130
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);
131
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)
132
1/2
✓ Branch 31 → 32 taken 18 times.
✗ Branch 31 → 98 not taken.
18 return sub_node;
133 }
134 }
135 // fallback to the default node
136
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) {
137
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())
138
1/2
✓ Branch 62 → 65 taken 23 times.
✗ Branch 62 → 110 not taken.
23 return sub_node;
139 }
140 // if no default found, return empty
141
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);
142
1/2
✓ Branch 91 → 92 taken 1 time.
✗ Branch 91 → 124 not taken.
1 throw std::runtime_error("Failed `InRange`");
143
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 };
144 }
145 template YAMLReader::node_finder_t YAMLReader::InRange(std::string const& key, int val);
146 template YAMLReader::node_finder_t YAMLReader::InRange(std::string const& key, double val);
147
148 ///////////////////////////////////////////////////////////////////////////////
149
150
2/2
✓ Branch 2 → 3 taken 207 times.
✓ Branch 2 → 5 taken 693 times.
900 YAML::Node YAMLReader::FindNode(YAML::Node node, node_path_t node_path)
151 {
152
153 // if `node_path` is empty, we are likely at the end of the node path; end recursion and return `node`
154
2/2
✓ Branch 2 → 3 taken 207 times.
✓ Branch 2 → 5 taken 693 times.
900 if(node_path.empty()) {
155 207 m_log->Trace("... found");
156 207 return node;
157 }
158
159 // find the next node using the first `node_id_t` in `node_path`
160 1386 auto node_id_visitor = [&node, &m_log = this->m_log](auto&& arg) -> YAML::Node {
161 using arg_t = std::decay_t<decltype(arg)>;
162 // find a node by key name
163 if constexpr(std::is_same_v<arg_t, std::string>) {
164
4/8
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 651 times.
✓ Branch 5 → 6 taken 651 times.
✗ Branch 5 → 13 not taken.
✓ Branch 6 → 7 taken 336 times.
✓ Branch 6 → 9 taken 315 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 16 not taken.
1302 m_log->Trace("... by key '{}'", arg);
165 651 return node[arg];
166 }
167 // find a node using a `node_finder_t`
168 else {
169 42 m_log->Trace("... by node finder function");
170 84 return arg(node);
171 }
172 693 };
173 auto result = std::visit(node_id_visitor, node_path.front());
174
175 // if the resulting node is not defined, return an empty node; callers must check the result
176
2/2
✓ Branch 8 → 9 taken 70 times.
✓ Branch 8 → 10 taken 622 times.
692 if(!result.IsDefined())
177 return {};
178
179 // recurse to the next element of `node_path`
180 622 node_path.pop_front();
181
4/6
✓ Branch 11 → 12 taken 622 times.
✗ Branch 11 → 23 not taken.
✓ Branch 12 → 13 taken 622 times.
✗ Branch 12 → 21 not taken.
✓ Branch 13 → 14 taken 620 times.
✓ Branch 13 → 19 taken 2 times.
624 return FindNode(result, node_path);
182 692 }
183
184 }
185