Up

module PropList

: sig

Property list

Author Sylvain Le Gall

Types and exceptions

#
type name = string
#
exception Not_set of name * string option

The field of name is not set with optional explanation.

#
exception No_printer of name

Can retrieve the field value, but no printer can convert. it to string.

#
exception Unknown_field of name * name

Unknown_field (fld, schm) Unknown field fld in schema schm.

Modules

#
module Data : sig

This module stores heterogeneous data defined in Schema and Field.

#
type t
#
val create : unit -> t

Create a data storage.

#
val clear : t -> unit

Clear a data storage.

#
val elements : t -> string list

List field set, not exported

#
val odn_of_t : t -> ODN.t

Dump Data.t to ODN, not exported.

end
#
module Schema : sig

This module is a set of fields (Field.t and FieldRO.t) that can be addressed by their name (as string). Value can be set and retrieved as string only. However, the value itself is stored in its native type.

#
type ('a, 'b) value

A value.

#
type ('a, 'b) t

A schema.

#
val create : ?case_insensitive:bool -> name -> ('a, 'b) t

Create a schema.

#
val mem : ('a, 'b) t -> name -> bool

Check that the given field name exists.

#
val get : ('a, 'b) t -> Data.t -> name -> string

get t data nm Retrieve the string value of field nm from schema t stores in data.

#
val set : ('a, 'b) t -> Data.t -> name -> ?context:'a -> string -> unit

set t data nm ~context str Parse string value str in ~context and stores it in data for field nm of schema t.

#
val fold : ('a -> name -> 'b -> (unit -> string) option -> 'a) -> 'a -> ('c, 'b) t -> 'a

fold f acc t Apply f acc field_name field_extra field_help in turn to all fields of schema t.

#
val iter : (name -> 'a -> (unit -> string) option -> unit) -> ('b, 'a) t -> unit

Same as Schema.fold except no accumulator are involved.

#
val name : ('a, 'b) t -> name

Get the name of the schema.

end
#
module Field : sig

This module defines a field that hold a value. A field can be set and retrieve. It is stored in Data.t.

#
type ('a, 'b, 'c) t

A field.

#
val create : ?schema:('a, 'b) Schema.t -> ?name:name -> ?parse:(?context:'a -> string -> 'c) -> ?print:('c -> string) -> ?default:'c -> ?update:(?context:'a -> 'c -> 'c -> 'c) -> ?help:(unit -> string) -> 'b -> ('a, 'c, 'b) t

Create a field, and optionally attached it to a schema.

#
val fset : Data.t -> ('a, 'b, 'c) t -> ?context:'a -> 'b -> unit

Store a field in a Data.t.

#
val fget : Data.t -> ('a, 'b, 'c) t -> 'b

Retrieve a field from a Data.t.

#
val fsets : Data.t -> ('a, 'b, 'c) t -> ?context:'a -> string -> unit

Same as Field.fset but parses a string to get the value.

#
val fgets : Data.t -> ('a, 'b, 'c) t -> string

Same as Field.fget but applies a printer to the value returned.

end
#
module FieldRO : sig

This module defines a read-only field. However, it can only be set through Schema.set if the field is attached to a schema.

#
val create : ?schema:('a, 'b) Schema.t -> ?name:name -> ?parse:(?context:'a -> string -> 'c) -> ?print:('c -> string) -> ?default:'c -> ?update:(?context:'a -> 'c -> 'c -> 'c) -> ?help:(unit -> string) -> 'b -> Data.t -> 'c

Create a read-only field. The returned function can be used to retrieve the value of the field.

end
end