Module Inifiles

module Inifiles: sig .. end

This library reads ini format property files

exception Invalid_section of string

raised if you ask for a section which doesn't exist

exception Invalid_element of string

raised if you ask for an element (attribute) which doesn't exist, or the element fails to match the validation regex

exception Missing_section of string

raised if a required section is not specified in the config file

exception Missing_element of string

raised if a required element is not specified in the config file

exception Ini_parse_error of (int * string)

raised if there is a parse error in the ini file it will contain the line number and the name of the file in which the error happened

type attribute_specification = {
   atr_name : string;
   atr_required : bool;
   atr_default : string list option;
   atr_validator : Re.Pcre.regexp option;
}

The type of an attribute/element specification

type section_specification = {
   sec_name : string;
   sec_required : bool;
   sec_attributes : attribute_specification list;
}

The type of a section specification

type specification = section_specification list 

The type of a secification

class inifile : ?spec:specification -> string -> object .. end

send the name of an ini file to the constructor the file must exist, but can be empty

val fold : ('a -> inifile -> 'a) -> string -> 'a -> 'a

Executes a fold left across a directory of ini files (skips files which do not end with .ini). fold f path a computes (f ... (f (f file1 a) file2) fileN)