Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
#include <iostream>
#include <memory>
auto main(main_ctx& ctx) -> int {
auto& log = ctx.log();
return basic_string_path(str,
EAGINE_TAG(split_by),
"/");
};
auto visitor = [&ctx](
valtree::compound& c,
const valtree::attribute& a,
const basic_string_path& p) {
auto ca{c / a};
ctx.log()
.info("visit")
.arg(
EAGINE_ID(canonType), ca.canonical_type())
.arg(
EAGINE_ID(path), p.as_string(
"/", ca.nested_count() > 0))
const auto s{ca.value_count()};
if(s <= 256) {
std::array<byte, 256> temp{};
auto content{ca.fetch_blob(
cover(temp))};
ctx.log().info("content").arg(
}
if(ca.value_count() == 1) {
std::array<char, 64> temp{};
auto content{ca.fetch_values(
cover(temp))};
ctx.log().info("content").arg(
}
}
return true;
};
"attribA" : {
"attribB": 123
},
"attribC" : [
45, "six", 78.9, {"zero": false}
],
"attribD" : "VGhpcyBpcyBhIGJhc2U2NC1lbmNvZGVkIEJMT0IK"
})");
std::array<byte, 64> temp{};
log.info("parsed from json")
.arg(
json_tree.get<int>(path("attribA/attribB")),
n_a)
.arg(
json_tree.get<int>(path("attribC/0")),
n_a)
.arg(
json_tree.get<std::string>(path("attribC/1")),
n_a)
.arg(
json_tree.get<float>(path("attribC/2")),
n_a)
.arg(
json_tree.get<bool>(path("attribC/3/zero")),
n_a)
.arg(
view(json_tree.fetch_blob(path(
"attribD"),
cover(temp))));
json_tree.traverse(
}
"attribA:\n"
" attribB: 123\n"
"attribC: [45, six, 78.9, zero: false]\n");
log.info("parsed from yaml")
.arg(
yaml_tree.get<int>(path("attribA/attribB")),
n_a)
.arg(
yaml_tree.get<int>(path("attribC/0")),
n_a)
.arg(
yaml_tree.get<std::string>(path("attribC/1")),
n_a)
.arg(
yaml_tree.get<float>(path("attribC/2")),
n_a)
.arg(
yaml_tree.get<bool>(path("attribC/3/zero")),
n_a);
yaml_tree.traverse(
}
if(auto path_arg{ctx.args().find("--fs-tree").next()}) {
log.info("opening ${root} filesystem tree")
fs_tree.traverse(
}
}
return 0;
}
}