Module Utils

module Utils: sig .. end
Miscellaneous utility functions (time, string, i/o, parsing, XML).


Time functions

val current_time : unit -> string
Returns the current time as a string.

String functions

val trim : string -> string
Returns the passed string without leading and trailing whitespaces.
val string_hash : string -> int
Returns the hash value for the passed string.

I/O functions

val read_lines : string -> string list
read_lines file returns the lines of file file ("-" being interpreted as the standard input).

Raises an exception if an i/o error occurs.

val write_lines : string list -> string -> unit
write_lines lines file writes the strings lines to the file file.

Raises an exception if an i/o error occurs.


Parsing functions

val parse_file : string -> (Lexing.lexbuf -> 'a) -> 'a
parse_file file f parses the file file through function f.

XML functions

val xml_header : string
The XML header for produced XML files.
val escape_xml : string -> string
escape_xml s escapes s in such a way it can be used in XML.
type xml_tree = {
   tag_name : string; (*
XML node tag name.
*)
   tag_attributes : (string * string) list; (*
XML node attributes, as an association list.
*)
   tag_data : xml_data list;
}
XML node children.
type xml_data = 
| Text of string (*
Embedded text data (will be escaped).
*)
| Data of string (*
Embedded text data (will not be escaped).
*)
| Child of xml_tree (*
Embedded XML node.
*)
The type of (simplified) XML tree.

The type of data elements embedded into an XML node.

val string_of_xml_tree : xml_tree -> string
Converts the passed XML tree into a string.

Binary format

val binary_magic_number : string
Magic number (header) for files using binary format.
val binary_current_version : int * int
Current version of binary format.