parse.cpp 483 Bytes
Newer Older
1
2
3
4
5
6
#include "yaml.h"
#include <fstream>
#include <iostream>

int main(int argc, char **argv)
{
7
8
9
10
11
	std::ifstream fin;
	if(argc > 1)
		fin.open(argv[1]);
	
	std::istream& input = (argc > 1 ? fin : std::cin);
12
	try {
13
14
15
16
		YAML::Parser parser(input);
		while(parser) {
			YAML::Node doc;
			parser.GetNextDocument(doc);
17
18
19
			YAML::Emitter emitter;
			emitter << doc;
			std::cout << emitter.c_str() << "\n";
20
		}
21
	} catch(const YAML::Exception& e) {
22
		std::cerr << e.what() << "\n";
23
24
25
	}
	return 0;
}