diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-10-29 09:19:02 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-11-03 08:07:56 -0600 |
| commit | 6ced0e36b3f98675d82007f8c77193e2836c4b60 (patch) | |
| tree | 4181f3259c50b4dbdbf957344bb4df0ce2077fcf /src | |
| parent | 80e28b1e191fe6f518f7b1ee3d77e672f7397159 (diff) | |
| download | vyos1x-config-6ced0e36b3f98675d82007f8c77193e2836c4b60.tar.gz vyos1x-config-6ced0e36b3f98675d82007f8c77193e2836c4b60.zip | |
T7969: add boolean test value_exists
Diffstat (limited to 'src')
| -rw-r--r-- | src/config_tree.ml | 6 | ||||
| -rw-r--r-- | src/config_tree.mli | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/config_tree.ml b/src/config_tree.ml index 84cfe43..8c9e783 100644 --- a/src/config_tree.ml +++ b/src/config_tree.ml @@ -85,6 +85,12 @@ let get_value node path = | [] -> raise Node_has_no_value | x :: _ -> x +let value_exists node path value = + if not (Vytree.exists node path) then false + else let node' = Vytree.get node path in + let data = Vytree.data_of_node node' in + Vylist.in_list data.values value + let delete node path value = match value with | Some v -> diff --git a/src/config_tree.mli b/src/config_tree.mli index fe1085c..5d3db3c 100644 --- a/src/config_tree.mli +++ b/src/config_tree.mli @@ -33,6 +33,8 @@ val get_values : t -> string list -> string list val get_value : t -> string list -> string +val value_exists : t -> string list -> string -> bool + val set_comment : t -> string list -> string option -> t val get_comment : t -> string list -> string option |
