| 151 | } // namespace |
| 152 | |
| 153 | YAML::Node |
| 154 | FlatYAMLAccessor::find_or_create_node(swoc::TextView variable, bool search_all) |
| 155 | { |
| 156 | if (!search_all) { |
| 157 | if (_docs.size() == 0) { |
| 158 | // If nothing in it. Add one, it'll be the new node. |
| 159 | _docs.emplace_back(YAML::NodeType::Map); |
| 160 | } |
| 161 | } else { |
| 162 | for (auto iter = _docs.rbegin(); iter != _docs.rend(); ++iter) { |
| 163 | if (auto [found, node] = search_node(variable, *iter, DO_NOT_CREATE_IF_NOT_EXIST); found) { |
| 164 | return node; |
| 165 | } |
| 166 | } |
| 167 | // We haven't found the node, so we will create a new field in the latest doc. |
| 168 | if (_docs.size() == 0) { |
| 169 | // if nothing in it. Add one, it'll be the new node. |
| 170 | _docs.emplace_back(YAML::NodeType::Map); |
| 171 | } |
| 172 | // Use the last doc. |
| 173 | } |
| 174 | |
| 175 | return search_node(variable, _docs.back(), CREATE_IF_NOT_EXIST).second; |
| 176 | } |
| 177 | |
| 178 | std::pair<bool, YAML::Node> |
| 179 | FlatYAMLAccessor::find_node(swoc::TextView variable) |
nothing calls this directly
no test coverage detected