]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/libucl/examples/ucl_cpp.cc
Update libucl to latest git snapshot (20151027)
[FreeBSD/FreeBSD.git] / contrib / libucl / examples / ucl_cpp.cc
1 #include <iostream>
2 #include <string>
3 #include "ucl++.h"
4
5 int main(int argc, char **argv)
6 {
7         std::string input, err;
8
9         input.assign((std::istreambuf_iterator<char>(std::cin)),
10                 std::istreambuf_iterator<char>());
11
12         auto obj = ucl::Ucl::parse(input, err);
13
14         if (obj) {
15                 std::cout << obj.dump(UCL_EMIT_CONFIG) << std::endl;
16
17                 for (const auto &o : obj) {
18                         std::cout << o.dump(UCL_EMIT_CONFIG) << std::endl;
19                 }
20         }
21         else {
22                 std::cerr << "Error: " << err << std::endl;
23
24                 return 1;
25         }
26 }