Library
Module
Module type
Parameter
Class
Class type
Reading and writing configuration values in RDF graphs.
To represent option names from root.
type path = path_elt list
type error =
| Invalid_value of Rdf.Term.term
Unexpected term
*)| Invalid_path of path
Invalid path used (empty list)
*)| Path_conflict of path
When adding an option, an option path cannot be the prefix of another one.
*)| Error_at_path of path * error
Error while reading the option at the given path.
*)| Exn_at_path of path * exn
Exception raised while reading the option at the given path
*)exception Error of error
val string_of_error : error -> string
Error
val invalid_value : Rdf.Term.term -> 'a
val invalid_path : path -> 'a
val path_conflict : path -> 'a
val exn_at_path : path -> exn -> 'a
A wrapper is a pair of functions to read and write values of some type from and to graph.
module Wrapper : sig ... end
type 'a wrapper = 'a Wrapper.t
An option with a value of type 'a
. When the option is found in a graph (see Reading options), the value is modified in place. Use get
to retrieve the option value.
val option :
?doc:string ->
?cb:('a -> unit) ->
'a wrapper ->
'a ->
'a conf_option
option wrapper v
creates an option with initial value v
and using the given wrapper
to read and write from and to graph. Optional argument doc
is a description for the option. Optional argument cb
is a function to call each time the option is read.
val get : 'a conf_option -> 'a
get option
returns the value of the given option.
val set : 'a conf_option -> 'a -> unit
set option value
sets the value of the given option and calls the associated callback if any.
A group is used to group options and other groups. An `Open
group is a group in which other options and groups can be added. Nothing can be added to a `Closed
group.
val group : [ `Open ] group
Create a new empty open group.
val add : [ `Open ] group -> path -> 'a conf_option -> [ `Open ] group
add group path option
adds the given option
to group
at path
.
add_group group path g
adds the group g
to group
at path
.
val int : ?doc:string -> ?cb:(int -> unit) -> int -> int conf_option
val float : ?doc:string -> ?cb:(float -> unit) -> float -> float conf_option
val bool : ?doc:string -> ?cb:(bool -> unit) -> bool -> bool conf_option
val string :
?doc:string ->
?cb:(string -> unit) ->
string ->
string conf_option
val iri : ?doc:string -> ?cb:(Iri.t -> unit) -> Iri.t -> Iri.t conf_option
val list :
?doc:string ->
?cb:('a list -> unit) ->
'a wrapper ->
'a list ->
'a list conf_option
val option_ :
?doc:string ->
?cb:('a option -> unit) ->
'a wrapper ->
'a option ->
'a option conf_option
val pair :
?doc:string ->
?cb:(('a * 'b) -> unit) ->
'a wrapper ->
'b wrapper ->
('a * 'b) ->
('a * 'b) conf_option
val triple :
?doc:string ->
?cb:(('a * 'b * 'c) -> unit) ->
'a wrapper ->
'b wrapper ->
'c wrapper ->
('a * 'b * 'c) ->
('a * 'b * 'c) conf_option
val from_graph : 'a group -> ?root:Rdf.Term.term -> Rdf.Graph.graph -> unit
from_graph group g
reads option values described by group
from graph g
. root
indicates the IRI to start reading option values from. Default root is the graph name.
val to_graph : ?with_doc:bool -> 'a group -> Iri.t -> Rdf.Graph.graph
to_graph group iri
outputs the current state of the group, i.e. the options it contains with their current value, to a new graph. The with_doc
optional argument indicates whether to output doc associated to options. Default is true
.