exception Cyclic_definition of string
exception Type_error of string (* expected type, value, msg *)
exception Parse_error of string * int * int * string (* file, line, col, msg *)
-exception Invalid_value of (string * string) * string (* key, value, descr *)
(* root XML tag: used by save_to, ignored by load_from *)
let root_tag = "helm_registry"
List.map unmarshaller (get registry key)
with Key_not_found _ -> []
+let get_pair registry unmarshaller key =
+ let v = singleton (get registry key) in
+ match Str.split spaces_rex v with
+ | [fst; snd] -> unmarshaller fst, unmarshaller snd
+ | _ -> raise (Type_error "not a pair")
+
let set_list registry marshaller ~key ~value =
List.iter (fun v -> set registry ~key ~value:(marshaller v)) value
let get_opt unmarshaller = get_opt default_registry unmarshaller
let get_opt_default unmarshaller = get_opt_default default_registry unmarshaller
let get_list unmarshaller = get_list default_registry unmarshaller
+let get_pair unmarshaller = get_pair default_registry unmarshaller
let set_typed marshaller = set_typed default_registry marshaller
let set_opt unmarshaller = set_opt default_registry unmarshaller
let set_list marshaller = set_list default_registry marshaller
*)
exception Parse_error of string * int * int * string
- (** raised when a given <key,value> pair fails validity test(s)
- * @param pair <key,value> pair
- * @param descr description of the failed test *)
-exception Invalid_value of (string * string) * string
-
(** {2 Generic untyped interface}
* Using the functions below this module could be used as a repository of
* key/value pairs *)
(** 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
+
(** {4 Shorthands} *)
val get_string: string -> string