diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-09-21 08:48:25 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-09-21 08:48:25 +0600 |
commit | f9fcc768e41d5ea0338dfcc9670734cd283e5939 (patch) | |
tree | 1388e78bafc52722cd3cc6409f3f2d8a7f9802a3 /src | |
parent | a13e17bbbb81e848be72749bec4fb41155aa7514 (diff) | |
download | vyconf-f9fcc768e41d5ea0338dfcc9670734cd283e5939.tar.gz vyconf-f9fcc768e41d5ea0338dfcc9670734cd283e5939.zip |
Fix multilevel insert logic.
Diffstat (limited to 'src')
-rw-r--r-- | src/config_tree.ml | 8 | ||||
-rw-r--r-- | src/config_tree.mli | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/config_tree.ml b/src/config_tree.ml index cd2eafd..b70a8bb 100644 --- a/src/config_tree.ml +++ b/src/config_tree.ml @@ -36,9 +36,11 @@ let set_value node path value behaviour = | AddValue -> add_value node path value | ReplaceValue -> replace_value node path value -let set node path value position behaviour = - if Vytree.exists node path then set_value node path value behaviour - else Vytree.insert ~position:position node path {default_data with values=[value]} +let set node path value behaviour = + if Vytree.exists node path then set_value node path value behaviour else + let path_existing = Vytree.get_existent_path node path in + let path_remaining = Vylist.complement path path_existing in + Vytree.insert_multi_level default_data node path_existing path_remaining {default_data with values=[value]} let get_values node path = let node' = Vytree.get node path in diff --git a/src/config_tree.mli b/src/config_tree.mli index 1a807c2..7ce505c 100644 --- a/src/config_tree.mli +++ b/src/config_tree.mli @@ -14,7 +14,7 @@ val default_data : config_node_data val make : string -> t -val set : t -> string list -> string -> Vytree.position -> value_behaviour -> t +val set : t -> string list -> string -> value_behaviour -> t val get_values : t -> string list -> string list |