When parsing yaml file, normally we get root node from parser.
And I'm wondering if I can reference the root node after parsing process. Like below.
YAML::Node* globalRoot;
void ParseDocument(filename)
{
YAML::Parser parser(fin)
parser.GetNextDocument(*globalRoot);
}
void myFunction()
{
ParseDocument("myYAML.yml");
// After the method above, we lose the parser instance since it's a local variable.
// But if all child data is copied, below code should be safe.
// If globalRoot is just pointing inside the parser, this could be dangerous.
std::string stringKey;
(*globalRoot)["myKey"] >> stringKey;
}
Can I use like code above??