From bae55b6a8409d2a5b852544c26283a926ba01abf Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 28 Jun 2005 08:22:38 +0000 Subject: [PATCH] changed get_pair interface, now supports different unmarshallers --- helm/ocaml/registry/helm_registry.ml | 4 ++-- helm/ocaml/registry/helm_registry.mli | 4 ++-- helm/ocaml/registry/tests/sample.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helm/ocaml/registry/helm_registry.ml b/helm/ocaml/registry/helm_registry.ml index 0b54116cb..a845cb576 100644 --- a/helm/ocaml/registry/helm_registry.ml +++ b/helm/ocaml/registry/helm_registry.ml @@ -194,10 +194,10 @@ let get_list registry unmarshaller key = List.map unmarshaller (get registry key) with Key_not_found _ -> [] -let get_pair registry unmarshaller key = +let get_pair registry fst_unmarshaller snd_unmarshaller key = let v = singleton (get registry key) in match Str.split spaces_rex v with - | [fst; snd] -> unmarshaller fst, unmarshaller snd + | [fst; snd] -> fst_unmarshaller fst, snd_unmarshaller snd | _ -> raise (Type_error "not a pair") let set_list registry marshaller ~key ~value = diff --git a/helm/ocaml/registry/helm_registry.mli b/helm/ocaml/registry/helm_registry.mli index 7dd2a68d4..1f7fd0b56 100644 --- a/helm/ocaml/registry/helm_registry.mli +++ b/helm/ocaml/registry/helm_registry.mli @@ -146,8 +146,8 @@ val get_opt_default: (string -> 'a) -> default:'a -> string -> 'a (** never fails with Key_not_found, instead return the empty list *) val get_list: (string -> 'a) -> string -> 'a list - (** same as get_list, but assumes list length to be 2 *) -val get_pair: (string -> 'a) -> string -> 'a * 'a + (** decode values which are blank separated list of values, of length 2 *) +val get_pair: (string -> 'a) -> (string -> 'b) -> string -> 'a * 'b (** {4 Shorthands} *) diff --git a/helm/ocaml/registry/tests/sample.xml b/helm/ocaml/registry/tests/sample.xml index d08ce5644..33e1c6589 100644 --- a/helm/ocaml/registry/tests/sample.xml +++ b/helm/ocaml/registry/tests/sample.xml @@ -17,7 +17,7 @@ 13 17 19 - 19 23 + 19 23.2
-- 2.39.2