summaryrefslogtreecommitdiff
path: root/examples/ucl_cpp.cc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ucl_cpp.cc')
-rw-r--r--examples/ucl_cpp.cc26
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;
+ }
+}