【发布时间】:2020-08-24 19:48:43
【问题描述】:
我在迭代YAML::Node 时构建了一个树结构。到目前为止,我能够在层次结构向下时构建树。但如果层次结构发生变化,我将无法获取父节点。
batman:
type: super hero
entity: ""
natural: yes
attributes:
powers:
whip:
x: ""
y: ""
batmobile:
x: ""
y: ""
基于以上结构,如何获取batmobile的父节点?
假设,我这样迭代:
for (YAML::const_iterator it = node.begin(); it != node.end(); ++it)
{
std::cout << it->first.as<std::string>() << std::endl; // prints batmobile
// how to get the parent node of batmobile?
}
【问题讨论】: