Function resolve


#include <src/c4/yml/tree.hpp>

void resolve()


Resolve references (aliases <- anchors) in the tree.

Dereferencing is opt-in; after parsing, Tree::resolve() has to be called explicitly for obtaining resolved references in the tree. This method will resolve all references and substitute the anchored values in place of the reference.

This 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). This potential cost is the reason for requiring an explicit call.


Line 733 in src/c4/yml/tree.hpp.

Add Discussion as Guest

Log in