|
rapidyaml 0.15.2
parse and emit YAML, and do it fast
|
Functions | |
| void | sample_anchors_and_aliases () |
| deal with YAML anchors and aliases | |
| void | sample_anchors_and_aliases_create () |
| how to create YAML anchors and aliases | |
| void sample_anchors_and_aliases | ( | ) |
deal with YAML anchors and aliases
demonstrates usage with anchors and alias references.
Note that dereferencing is opt-in; after parsing, you have to call c4::yml::Tree::resolve() explicitly if you want resolved references in the tree. This method will resolve all references and substitute the anchored values in place of the reference.
The c4::yml::Tree::resolve() method first does a full traversal of the tree to gather all anchors and references in a separate collection, then it goes through that collection to locate the names, which it does by obeying the YAML standard diktat that
> an alias node refers to the most recent node in > the serialization having the specified anchor
So, depending on the number of anchor/alias nodes, this is a potentially expensive operation, with a best-case linear complexity (from the initial traversal) and a worst-case quadratic complexity (if every node has an alias/anchor). This potential cost is the reason for requiring an explicit call to c4::yml::Tree::resolve()
Definition at line 5830 of file quickstart.cpp.
Referenced by main().
| void sample_anchors_and_aliases_create | ( | ) |
how to create YAML anchors and aliases
demonstrates how to use the API to programatically create anchors and aliases
Definition at line 5907 of file quickstart.cpp.
Referenced by main().