VDF library (OBSOLETE)

Some of the small programs I wrote on my spare time. They are Free Software, and written mostly in OCaml.
Post Reply
User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

VDF library (OBSOLETE)

Post by Vincent » Fri Sep 05, 2008 5:17 pm

OBSOLETE VERSION

-> New version here

Download:
VDF-module.tar.gz
(130 KiB) Downloaded 742 times
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 *)
A VDF file looks like this:

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...
}
Usage:
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
...
See the documentation of the class Vdf.file.

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
once transformed, you would get

Code: Select all

x = "5"
y = "15"
{ Vincent Hugot }

Post Reply

Who is online

Users browsing this forum: No registered users and 167 guests