kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

New API. Querying Keys. #130

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
This doesn't work for me.
            YAML::Node test = node["test"]; <- works
            bool ab = node["test"]; <- does not work

I don't see a bool operator[] in the header. What's the Default way to query in 
the new API.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by m...@riedel-privat.de on 13 Nov 2011 at 7:17

GoogleCodeExporter commented 8 years ago
Ok, Should I use isNull? Like

YAML::Node test = node["test"];
if (!test.isNull()) {
// do something with test?
}

Original comment by m...@riedel-privat.de on 13 Nov 2011 at 8:21

GoogleCodeExporter commented 8 years ago
Whoops! This was just a mistake - I seem to have forgotten to implement this. I 
added it, r68cecbc525f9.

The proper way to use it is

   YAML::Node test = ...
    if(test) ...

the check test.IsNull() does something else (a node can be defined but null). 
For example:

    YAML::Node doc = YAML::Load("test: ~");
    assert(doc["test"]);
    assert(doc["test"].IsNull());

Nice catch!

Original comment by jbe...@gmail.com on 13 Nov 2011 at 10:08

GoogleCodeExporter commented 8 years ago
Awesome. Thanks for the quick help.

Original comment by m...@riedel-privat.de on 13 Nov 2011 at 10:31