X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fregistry%2Fhelm_registry.mli;h=e108ff01dd190e618a93a2a93abba2bafdd44ff3;hb=aca103d3c3d740efcc0bcc2932922cff77facb49;hp=62e85c5f1aaf65d9590866d2289ff03eb000baae;hpb=61c258b3e9c78cfa63dba73d0fad6759bccc4d1f;p=helm.git diff --git a/helm/ocaml/registry/helm_registry.mli b/helm/ocaml/registry/helm_registry.mli index 62e85c5f1..e108ff01d 100644 --- a/helm/ocaml/registry/helm_registry.mli +++ b/helm/ocaml/registry/helm_registry.mli @@ -29,7 +29,7 @@ * * key ::= path * path ::= component ( '.' component )* - * component ::= ( lowercase_alpha | num | '_' )+ + * component ::= ( alpha | num | '_' )+ * # with the only exception that sequences of '_' longer than 1 aren't valid * # components * @@ -51,9 +51,8 @@ * a configuration file (via "save_to" function below) . * * Mapping between keys and environment variables is as follows: - * - the whole key is uppercased * - each "." is converted to "__" - * E.g.: my.foo_ish.application -> MY__FOO_ISH__APPLICATION + * E.g.: my.Foo_iSH.Application -> my__Foo_iSH__Application * * ++ Variable interpolation ++ * @@ -103,14 +102,30 @@ exception Invalid_value of (string * string) * string (** lookup key in registry with environment variable override *) val get: string -> string val set: key:string -> value:string -> unit +val has: string -> bool (** remove a key from the current environment, next get over this key will * raise Key_not_found until the key will be redefined *) val unset: string -> unit -val fold: ('a -> string -> string -> 'a) -> 'a -> 'a -val iter: (string -> string -> unit) -> unit -val to_list: unit -> (string * string) list + (** @param interpolate defaults to true *) +val fold: + ?prefix:string -> ?interpolate:bool -> + ('a -> string -> string -> 'a) -> 'a -> 'a + + (** @param interpolate defaults to true *) +val iter: + ?prefix:string -> ?interpolate:bool -> + (string -> string -> unit) -> unit + + (** @param interpolate defaults to true *) +val to_list: + ?prefix:string -> ?interpolate:bool -> + unit -> (string * string) list + + (** @param prefix key representing the section whose contents should be listed + * @return section list * key list *) +val ls: string -> string list * string list (** {2 Typed interface} * Three basic types are supported: strings, int and strings list. Strings @@ -160,8 +175,9 @@ val get_opt_default: (* as get_opt with an additional default value *) * associated to the corresponding key are executed, if at least one of them * fails, Invalid_value exception will be raised *) -type validator_id +(* +type validator_id (** register a new validator for a given key * @param key key to which validator applies * @param validator a function applying to a value returning true if that @@ -172,7 +188,8 @@ type validator_id val add_validator: key:string -> validator:(string -> bool) -> descr:string -> validator_id -(* val remove_validator: validator_id -> unit *) +val remove_validator: validator_id -> unit +*) (** {2 Persistent configuration} * Validators aren't saved. load_from/save_to sequences don't preserve comments @@ -192,6 +209,42 @@ val save_to: string -> unit *) val load_from: ?path:string list -> string -> unit -(* DEBUGGING *) -(* val dump: unit -> unit *) +(** {2 OO interface} *) + + (** @see load_from *) +class registry: ?path: string list -> string -> + object + method get: string -> string + method set: key:string -> value:string -> unit + method has: string -> bool + method unset: string -> unit + method fold: + ?prefix:string -> ?interpolate:bool -> + ('a -> string -> string -> 'a) -> 'a -> 'a + method iter: + ?prefix:string -> ?interpolate:bool -> (string -> string -> unit) -> unit + method to_list: + ?prefix:string -> ?interpolate:bool -> unit -> (string * string) list + method ls: string -> string list * string list + method get_string: string -> string + method get_int: string -> int + method get_float: string -> float + method get_bool: string -> bool + method get_string_list: string -> string list + method set_string: key:string -> value:string -> unit + method set_int: key:string -> value:int -> unit + method set_float: key:string -> value:float -> unit + method set_bool: key:string -> value:bool -> unit + method set_string_list: key:string -> value:string list -> unit + method get_opt: + (string -> 'a) (* getter *) -> + string -> 'a option + method set_opt: + (key:string -> value:'a -> unit) (* setter *) -> + key:string -> value:'a option -> unit + method get_opt_default: + (string -> 'a) (* getter *) -> + 'a -> string -> 'a + method save_to: string -> unit + end