From: Stefano Zacchiroli Date: Tue, 28 Jun 2005 08:22:38 +0000 (+0000) Subject: changed get_pair interface, now supports different unmarshallers X-Git-Tag: INDEXING_NO_PROOFS~31 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=bae55b6a8409d2a5b852544c26283a926ba01abf;p=helm.git changed get_pair interface, now supports different unmarshallers --- 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