diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-10-27 21:19:11 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-10-27 21:19:11 +0000 |
commit | 4e2fa78ea36ec2cf6583bc025b4127c5ea238fd2 (patch) | |
tree | 776471e6ddbb557aac5a48779cb813f63c28b4d5 /examples/ucl_cpp.cc | |
parent | 15b8b407ee0ee485e82a9de35932da2053f2c390 (diff) |
Notes
Diffstat (limited to 'examples/ucl_cpp.cc')
-rw-r--r-- | examples/ucl_cpp.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/ucl_cpp.cc b/examples/ucl_cpp.cc new file mode 100644 index 0000000000000..2d15d84a6c8d3 --- /dev/null +++ b/examples/ucl_cpp.cc @@ -0,0 +1,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; + } +} |