jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
5.09k stars 1.83k forks source link

Accessing the name of a node? #1162

Closed GalladeGuy closed 1 year ago

GalladeGuy commented 1 year ago

Let's say you have something like this:

map:
    a: 1
    b: 2
    c: 3

If you only had YAML::Node pointing to, for example, that "b" node, is there any way to get "b" back as a string from it? I know you could get it if you had the root node, but it would simplify things if there was a name method or similar on the node itself.

jbeder commented 1 year ago

No, since (because of aliases) a node can have multiple "parents".