Is there a way to get the name of a node? For example:
Fruits:
- apple
- orange
- pear
Run Code Online (Sandbox Code Playgroud)
and in C++:
YAML::Node fruit = parser["Fruits"];
cout << fruit.name() << endl; // should print "Fruits"
Run Code Online (Sandbox Code Playgroud)
is there something like YAML::Node::name()? I don't see anything in Node.h that fits the bill.
If there isn't, any suggestions on a simple way to modify the code to record this information?
Thanks!
您真正要寻找的是与映射中的值关联的键。你是对的,没有从值到它的键的链接,但是当你首先导航节点时,你可以存储一个链接。
如果所有键都是字符串键,那么每当您将值传递给某个函数时,也只需传递字符串键:
// Instead of:
doSomething(node[key]);
// Call:
doSomething(key, node[key]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1148 次 |
| 最近记录: |