| 120 | } |
| 121 | |
| 122 | std::pair<bool, YAML::Node> |
| 123 | search_node(swoc::TextView variable, YAML::Node root, bool create) |
| 124 | { |
| 125 | auto const key{variable.take_prefix_at('.')}; |
| 126 | auto const key_str = std::string{key.data(), key.size()}; |
| 127 | if (variable.empty()) { |
| 128 | if (root.IsMap() && root[key_str]) { |
| 129 | return {true, root[key_str]}; |
| 130 | } else { |
| 131 | if (create) { |
| 132 | YAML::Node n; |
| 133 | root[key_str] = n; |
| 134 | return {true, n}; // new one created; |
| 135 | } else { |
| 136 | return NOT_FOUND; |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | if (!root[key_str]) { |
| 141 | if (create) { |
| 142 | YAML::Node n; |
| 143 | root[key_str] = n; |
| 144 | return search_node(variable, n, create); |
| 145 | } |
| 146 | } else { |
| 147 | return search_node(variable, root[key_str], create); |
| 148 | } |
| 149 | return NOT_FOUND; |
| 150 | } |
| 151 | } // namespace |
| 152 | |
| 153 | YAML::Node |
no test coverage detected