ucl_cpp.cc 487 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>
#include "ucl++.h"

int main(int argc, char **argv)
{
	std::string input, err;

	input.assign((std::istreambuf_iterator<char>(std::cin)),
		std::istreambuf_iterator<char>());

	auto obj = ucl::Ucl::parse(input, err);

	if (obj) {
		std::cout << obj.dump(UCL_EMIT_CONFIG) << std::endl;

		for (const auto &o : obj) {
			std::cout << o.dump(UCL_EMIT_CONFIG) << std::endl;
		}
	}
	else {
		std::cerr << "Error: " << err << std::endl;

		return 1;
	}
}