MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / parse_flattened_document

Function parse_flattened_document

src/framework/io/yaml.cpp:226–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226FlattenedDocument parse_flattened_document(std::string_view text) {
227 require_single_document(text);
228 Parser parser(text);
229 yaml_document_t & document = parser.load_primary();
230
231 yaml_node_t * root = yaml_document_get_root_node(&document);
232 if (root == nullptr) {
233 return {};
234 }
235 if (root->type != YAML_MAPPING_NODE) {
236 throw std::runtime_error("yaml config root must be a mapping");
237 }
238
239 FlattenedDocument flattened;
240 for (yaml_node_pair_t * pair = root->data.mapping.pairs.start;
241 pair != root->data.mapping.pairs.top;
242 ++pair) {
243 const std::string key = require_scalar_value(document, pair->key, "mapping key");
244 if (key.empty()) {
245 continue;
246 }
247 flatten_node(document, pair->value, key, flattened);
248 }
249 return flattened;
250}
251
252bool parse_bool_scalar(const std::string & value, const std::string & key) {
253 if (value == "true") {

Callers 2

parse_flattened_yamlMethod · 0.85
parse_configFunction · 0.85

Calls 5

require_single_documentFunction · 0.85
require_scalar_valueFunction · 0.85
flatten_nodeFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected