freebsd-skq/contrib/libucl/examples/ucl_cpp.cc
2015-10-27 21:24:09 +00:00

27 lines
487 B
C++

#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;
}
}