summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-06-03 15:56:48 +0600
committerDaniil Baturin <daniil@baturin.org>2015-06-03 15:56:48 +0600
commit8caa65f953642cd8fe12ca6493b25a463093f30b (patch)
treea8ffe2ee7a871b38c61dc8b9900e5b05c75f629f /src
parent74132f616269e0de282354dec602d494455da4dc (diff)
downloadvyconf-8caa65f953642cd8fe12ca6493b25a463093f30b.tar.gz
vyconf-8caa65f953642cd8fe12ca6493b25a463093f30b.zip
Add get_data function, a shortcut for getting a data of node at specified path.
Mainly for quickly getting data from a reference tree.
Diffstat (limited to 'src')
-rw-r--r--src/vytree.ml2
-rw-r--r--src/vytree.mli2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/vytree.ml b/src/vytree.ml
index 93d3d71..b5dcba6 100644
--- a/src/vytree.ml
+++ b/src/vytree.ml
@@ -97,6 +97,8 @@ let rec get node path =
| [name] -> find_or_fail node name
| name :: names -> get (find_or_fail node name) names
+let get_data node path = data_of_node @@ get node path
+
let exists node path =
try ignore (get node path); true
with Nonexistent_path -> false
diff --git a/src/vytree.mli b/src/vytree.mli
index e912922..6a7eda1 100644
--- a/src/vytree.mli
+++ b/src/vytree.mli
@@ -31,4 +31,6 @@ val get : 'a t -> string list -> 'a t
val get_existent_path : 'a t -> string list -> string list
+val get_data : 'a t -> string list -> 'a
+
val exists : 'a t -> string list -> bool