yaml-cpp/main.cpp

36 lines
707 B
C++
Raw Normal View History

#include "parser.h"
#include "node.h"
#include "exceptions.h"
2008-06-30 10:51:22 +04:00
#include <fstream>
#include <iostream>
2008-06-26 02:45:08 +04:00
int main()
{
2008-06-30 10:51:22 +04:00
std::ifstream fin("test.yaml");
try {
YAML::Parser parser(fin);
if(!parser)
return 0;
YAML::Document doc;
parser.GetNextDocument(doc);
const YAML::Node& root = doc.GetRoot();
for(YAML::Node::Iterator it=root.begin();it!=root.end();++it) {
2008-07-02 05:32:19 +04:00
std::cout << "Sequence:";
for(YAML::Node::Iterator jt=it->begin();jt!=it->end();++jt) {
int value;
*jt >> value;
std::cout << " " << value;
}
std::cout << std::endl;
}
} catch(YAML::Exception& e) {
std::cout << "Error parsing the yaml!\n";
}
getchar();
2008-06-26 02:45:08 +04:00
return 0;
}