package dtools

  1. Overview
  2. Docs

Module Dtools.ConfSource

Configuration management module.

Type for links between keys

Sourcetype path = link list

Type for paths between keys

Sourcetype ut = < kind : string option ; descr : string ; comments : string list ; plug : link -> ut -> unit ; subs : link list ; path : path -> ut ; routes : ut -> path list ; ut : ut >

Type for untyped keys (or keys with unknown type)

  • kind: a string describing the type of this key
  • descr: a key description/title
  • comments: some comments on the key purposes
  • plug: a way to plug subkeys
  • subs: the list of link names to subkeys
  • path: a way to access subkeys
  • routes: a way to find paths to an other key
Sourcetype 'a t = < kind : string option ; alias : ?comments:string list -> ?descr:string -> (ut -> unit) -> 'a t ; descr : string ; comments : string list ; plug : link -> ut -> unit ; subs : link list ; path : path -> ut ; routes : ut -> path list ; ut : ut ; set_d : 'a option -> unit ; get_d : 'a option ; set : 'a -> unit ; get : 'a ; validate : ('a -> bool) -> unit ; on_change : ('a -> unit) -> unit >

Type for 'a keys

  • ut: cast to un untyped key
  • set_d: set the default value associated to the key
  • get_d: get the default value associated to the key
  • set: set the key value according to a user demmand
  • get: retrieve the resulting key value

A set of connections to others keys

Sourceexception Undefined of ut

Raised on access to an undefined key (without default value)

Sourceexception Invalid of string

Raised when an invalid link has been specified

Sourceexception Unbound of ut * string

Raised when a specified link does not exist

Sourceexception Bound of ut * string

Raised when a specified link already exist

Sourceexception Mismatch of ut

Raised on access to a key with a mismatching type

Sourceexception Cyclic of ut * ut

Raised on cyclic plug

Sourceexception Invalid_Value of ut

Raised on invalid value set

Sourceexception Wrong_Conf of string * string

Raised when bad configuration assignations are encountered

Sourceexception File_Wrong_Conf of string * int * string

Raised when bad configuration assignations are encountered inside configuration files

Sourcetype 'a builder = ?d:'a -> ?p:(ut -> unit) -> ?l:links -> ?comments:string list -> string -> 'a t

Receipt to build a 'a key

Sourceval unit : unit builder
Sourceval int : int builder
Sourceval float : float builder
Sourceval bool : bool builder
Sourceval string : string builder
Sourceval list : string list builder

Some key builders

Sourceval void : ?p:(ut -> unit) -> ?l:links -> ?comments:string list -> string -> ut

A structural key builder

Sourceval as_unit : ut -> unit t
Sourceval as_int : ut -> int t
Sourceval as_float : ut -> float t
Sourceval as_bool : ut -> bool t
Sourceval as_string : ut -> string t
Sourceval as_list : ut -> string list t

Casts to specificaly typed keys. Raises Mismatch on mismatching cast.

Sourceval path_of_string : string -> path

Convert a dot separated string to a path

Sourceval string_of_path : path -> string

Convert a path to a dot separated string

Sourceval descr : ?prefix:path -> ut -> string

Generate a description table of a (sub)key

Sourceval dump : ?prefix:path -> ut -> string

Dump the configuration table for a (sub)key

Sourceval conf_set : ut -> string -> unit

Add a value to the configuration keys, according to the given correctly formated string: "type key :value" Raises Wrong_Conf in badly formated cases.

Sourceval conf_file : ut -> string -> unit

Read configuration values from the file associated with the given filename. Raises File_Wrong_Conf with filename line and and error message in case of a bad configuration file.

Sourceval args : ut -> (string list * Arg.spec * string) list

A set of command line options to be used with the Arg module.

OCaml

Innovation. Community. Security.