]> matita.cs.unibo.it Git - helm.git/commitdiff
changed get_pair interface, now supports different unmarshallers
authorStefano Zacchiroli <zack@upsilon.cc>
Tue, 28 Jun 2005 08:22:38 +0000 (08:22 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Tue, 28 Jun 2005 08:22:38 +0000 (08:22 +0000)
helm/ocaml/registry/helm_registry.ml
helm/ocaml/registry/helm_registry.mli
helm/ocaml/registry/tests/sample.xml

index 0b54116cb9bb3d43698b8cc5aff2a5f8d717c08f..a845cb576e2017083a18230e66de0ce766295a93 100644 (file)
@@ -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 =
index 7dd2a68d436126fd710f43949625c692aa4ea3b0..1f7fd0b56dcb70ab8e8dd0c82ee292abb920588a 100644 (file)
@@ -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} *)
 
index d08ce5644a9267e25e07075fe7d12e70f7e12655..33e1c65897449adb68669726985f15f027b8e3e7 100644 (file)
@@ -17,7 +17,7 @@
     <key name="int_list">13</key>
     <key name="int_list">17</key>
     <key name="int_list">19</key>
-    <key name="int_pair">19 23</key>
+    <key name="int_float_pair">19 23.2</key>
   </section>
   <section name="triciclo">
     <section name="foo1">