test.cc

Go to the documentation of this file.
00001 #include <fstream>
00002 #include <string>
00003 #include <iostream>
00004 #include "yaml.h"
00005 
00006 using namespace std;
00007 
00008 int main()
00009 {
00010   ifstream io("test.yaml");
00011   YAML::Parser parser(io);
00012 
00013   YAML::Node doc;
00014   parser.GetNextDocument(doc);
00015   cout << "---------------------" << doc << "---------------------" << endl;
00016 
00017   const YAML::Node& things = doc["things"];
00018   string s;
00019   for (YAML::Iterator it = things.begin(); it != things.end(); ++it) {
00020     *it >> s;
00021     cout << "&&& " << s << " &&&" << endl;
00022   }
00023 
00024   const YAML::Node& stuff = doc["stuff"];
00025   int a;
00026   for (YAML::Iterator it = stuff.begin(); it != stuff.end(); ++it) {
00027     *it >> a;
00028     cout << "%%% " << a << " %%%" << endl;
00029   }
00030 
00031   const YAML::Node& desc = doc["desc"];
00032   string d;
00033   desc >> d;
00034   cout << "*** " << d << " ***" << endl;
00035 
00036   parser.GetNextDocument(doc);
00037   cout << "---------------------" << doc << "---------------------" << endl;
00038 
00039   return 0;
00040 }