
Download: Language: Objective Caml
License: GNU GPL
OS: Any
Description:
Support for VDF (Versatile Data Format) in OCaml programs. (read and write)
VDF:
Custom file format which I use to store options etc. It stands somewhere between INI and XML.
The structure of a VDF file corresponds to the following types:
Code: Select all
(** VDF values *)
type tvalue =
| Vval of string (** standard values: strings *)
| Vaval of string list (** array(list) of strings *)
(** A group is a value or a group of values and groups *)
type tgroup =
| Gval of string * tvalue (** standard value *)
| Ggrp of string * tgroup list (** group *)
| Gcom of string (** comment *)
| Gparam of string * string (** parameter *)
Code: Select all
# comment
!vdf_parameter = some value
a_value = 1/2
{ group
avalue = 3.14
{ subgroup
val = something
a_list = [
first elem
second
...
]
}
# etc...
}
{ other_group
# etc...
}
Use ./buildlib.sh to build the library. See test.ml for an example program.
In a nutshell, just do
Code: Select all
open Vdflib
...
let f = new Vdf.file "example.vdf" in
...
Note:
It is possible to define mathematical and logical relationships between values, using the method transform f. Since it deals with the values in their order of appearance in the file, if f is a mathematical evaluator with side-effects (such as MEME), you can define a value as a function of another:
Code: Select all
x = let x = 5 in x
y = if x > 10 then 2*x else 3*x
Code: Select all
x = "5"
y = "15"