25 #ifndef INCLUDED_GetJSONStringFromTree_h_GUID_031FFB6A_B837_4080_4784_53730E86669E
26 #define INCLUDED_GetJSONStringFromTree_h_GUID_031FFB6A_B837_4080_4784_53730E86669E
34 #include <boost/variant.hpp>
42 struct GetStringVisitor : boost::static_visitor<std::string> {
46 template <
typename T> std::string operator()(T
const &)
const {
51 inline std::string getJSONStringAtNode(
PathNode const &node) {
52 return boost::apply_visitor(GetStringVisitor(), node.value());
54 inline std::string getJSONStringFromTree(PathTree
const &tree,
55 std::string
const &path) {
57 auto const &desiredNode = tree.getNodeByPath(path);
58 return getJSONStringAtNode(desiredNode);
59 }
catch (util::tree::NoSuchChild &) {
66 #endif // INCLUDED_GetJSONStringFromTree_h_GUID_031FFB6A_B837_4080_4784_53730E86669E
::osvr::util::TreeNode< PathElement > PathNode
The specific tree node type that contains a path element.
The element type corresponding to a string value such as a JSON string.
std::string & getString()
Get/set (if non const) the stored string.