Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A Google Code Search (now defunct) for "yaml load lang:c++" gave this as the first link: <a href="https://github.com/wilhelmtell/libyamlpp/blob/master/demo/begin/demo.cc" rel="nofollow noreferrer">demo.cc</a>:</p> <pre><code>#include &lt;iyaml++.hh&gt; #include &lt;tr1/memory&gt; #include &lt;iostream&gt; #include &lt;stdexcept&gt; using namespace std; // What should libyaml++ do when a YAML entity is parsed? // NOTE: if any of the event handlers is not defined, a respective default // no-op handler will be used. For example, not defining on_eos() is // equivalent to defining void on_eos() { }. class my_handler : public yaml::event_handler { void on_string(const std::string&amp; s) { cout &lt;&lt; "parsed string: " &lt;&lt; s &lt;&lt; endl; } void on_integer(const std::string&amp; s) { cout &lt;&lt; "parsed integer: " &lt;&lt; s &lt;&lt; endl; } void on_sequence_begin() { cout &lt;&lt; "parsed sequence-begin." &lt;&lt; endl; } void on_mapping_begin() { cout &lt;&lt; "parsed mapping-begin." &lt;&lt; endl; } void on_sequence_end() { cout &lt;&lt; "parsed sequence-end." &lt;&lt; endl; } void on_mapping_end() { cout &lt;&lt; "parsed mapping-end." &lt;&lt; endl; } void on_document() { cout &lt;&lt; "parsed document." &lt;&lt; endl; } void on_pair() { cout &lt;&lt; "parsed pair." &lt;&lt; endl; } void on_eos() { cout &lt;&lt; "parsed eos." &lt;&lt; endl; } }; // ok then, now that i know how to behave on each YAML entity encountered, just // give me a stream to parse! int main(int argc, char* argv[]) { tr1::shared_ptr&lt;my_handler&gt; handler(new my_handler()); while( cin ) { try { yaml::load(cin, handler); } // throws on syntax error catch( const runtime_error&amp; e ) { cerr &lt;&lt; e.what() &lt;&lt; endl; } } return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload