majintao0131 / yaml-cpp

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

Incomplete error messages and zero documentation #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What's this suppose to mean ??!!

terminate called after throwing an instance of 'YAML::BadDereference'
  what():  yaml-cpp: error at line 0, column 0: bad dereference

I've been going through the tutorial. And nothing works ??!! And the kind of 
error message like the one shown above is not really helping. What was 
derefrenced in this piece of code :

<code>
    std::ifstream fin(argv[x]);
    YAML::Parser parser(fin);

    YAML::Node doc;
    while (parser.GetNextDocument(doc)){
      for(YAML::Iterator it=doc.begin();it!=doc.end();++it) {
        string scalar;
        *it >> scalar;
        cout << "Found scalar: " << scalar << endl;
      }   
    }   
</code>

This is the content of the YAML file:
canonical: 12345
decimal: +12345
octal: 0o14
hexadecimal: 0xC
oleans: [ true, false ]
string: '012345'

This seems promising, but without proper documentation it's unusable... I'd 
gladly help you on this issue. But the code is uncommented as well.

Original issue reported on code.google.com by uk8...@gmail.com on 22 Dec 2012 at 2:20

GoogleCodeExporter commented 9 years ago
You're absolutely right, that's a pretty bad error message.  What's happening 
is that you're trying to dereference a map iterator as if it were a sequence.

The proper way to do it is:

it.first() >> key;
it.second() >> value;

I'll definitely try to improve the error message here - thanks for the note!

As for general documentation - I have some decent overviews, I think, but no 
per-function docs. Unfortunately, I don't have the time to write it, but I'd be 
happy to accept patches :)

Original comment by jbe...@gmail.com on 23 Dec 2012 at 5:39

GoogleCodeExporter commented 9 years ago
Fixed, ra270fc2221f3.

Original comment by jbe...@gmail.com on 29 Dec 2012 at 12:57

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 29 Dec 2012 at 12:57