Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 09d2dd5b2fd1c1939cd331b7b4758575 > files > 39

ocaml-release-devel-1.1.0-2.mga4.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="next" href="Release_config_lexer.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Release_config" rel="Chapter" href="Release_config.html">
<link title="Release_config_lexer" rel="Chapter" href="Release_config_lexer.html">
<link title="Release_config_parser" rel="Chapter" href="Release_config_parser.html">
<link title="Release_config_global" rel="Chapter" href="Release_config_global.html">
<link title="Release_config_values" rel="Chapter" href="Release_config_values.html">
<link title="Release_config_validations" rel="Chapter" href="Release_config_validations.html"><title>Release_config</title>
</head>
<body>
<div class="navbar">&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="Release_config_lexer.html" title="Release_config_lexer">Next</a>
</div>
<h1>Module <a href="type_Release_config.html">Release_config</a></h1>

<pre><span class="keyword">module</span> Release_config: <code class="code">sig</code> <a href="Release_config.html">..</a> <code class="code">end</code></pre><div class="info module top">
This module provides an interface to configuration file parsing.
    Configuration files are assumed to be collections of key-value pairs
    possibly organized in sections.
<p>

    Sections are started by a section name enclosed in square brackets.
    Keys and values are separated by an equals sign, and values can be
    integers, floats, booleans, strings, regular expressions, log levels
    or lists of one of those types, as defined by the <code class="code">Release_values.value</code>
    type.
<p>

    Keys must be named starting with a letter and optionally followed by
    any character except whitespace characters, square brackets, equals
    signs or hash signs.
<p>

    Integers values are represented by sequences of digits and floats are
    represented by sequences of digits separated by a dot character.
<p>

    Strings are sequences of characters enclosed by double quotes, and newline
    characters inside strings are supported.
<p>

    Regular expressions are enclosed by forward slash characters and support
    the same constructs as the ones documented in OCaml's <code class="code">Str</code> module, but
    the grouping constructs <code class="code">(</code> and <code class="code">)</code> and the alternative between expressions
    construct <code class="code">|</code> don't need to be escaped by a backslash. Newlines can be
    inserted in regular expressions for organization purposes and are ignored
    along with any following whitespace characters.
<p>

    Log levels are bare words matching the definitions in <code class="code">Lwt_log</code>, that is,
    <code class="code">debug</code>, <code class="code">info</code>, <code class="code">notice</code>, <code class="code">warning</code>, <code class="code">error</code> and <code class="code">fatal</code>.
<p>

    Finally, lists are sequences of the above types enclosed by square brackets
    and separated by commas.
<p>

    In terms of code, configuration files are specified by the
    <a href="Release_config.html#TYPEspec"><code class="code">Release_config.spec</code></a> type. This is simply a list of
    <a href="Release_config.html#TYPEsection"><code class="code">Release_config.section</code></a>s, each containing lists of
    <a href="Release_config.html#TYPEkey"><code class="code">Release_config.key</code></a>s. Keys are defined by their name, an optional
    default value and a list of validations. If a key has no default value
    and is absent from the configuration file, an error will be generated.
<p>

    Validations are functions as defined by the
    <a href="Release_config_values.html#TYPEvalidation"><code class="code">Release_config_values.validation</code></a> type. Many pre-defined validations
    are available in the <a href="Release_config_validations.html"><code class="code">Release_config_validations</code></a> module.<br>
</div>
<hr width="100%">

<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre>
<div class="info ">
The type of a configuration.<br>
</div>


<pre><span id="TYPEkey"><span class="keyword">type</span> <code class="type"></code>key</span> = <code class="type">string * <a href="Release_config_values.html#TYPEvalue">Release_config_values.value</a> option *<br>       <a href="Release_config_values.html#TYPEvalidation">Release_config_values.validation</a> list</code> </pre>
<div class="info ">
The type of a configuration key specification. A key is specified by
      its name, a possible default value and a list of validations.<br>
</div>


<pre><span id="TYPEsection"><span class="keyword">type</span> <code class="type"></code>section</span> = <code class="type">[ `Global of <a href="Release_config.html#TYPEkey">key</a> list<br>       | `Section of string * <a href="Release_config.html#TYPEkey">key</a> list ]</code> </pre>
<div class="info ">
The type of a configuration section specification. A section
      specification contains a list of keys belonging to that section, and
      can either have a name or be global (in which case its keys will not
      appear under any section definitions in the configuration file).<br>
</div>


<pre><span id="TYPEspec"><span class="keyword">type</span> <code class="type"></code>spec</span> = <code class="type"><a href="Release_config.html#TYPEsection">section</a> list</code> </pre>
<div class="info ">
The type of configuration file specifications.<br>
</div>


<pre><span id="VALparse"><span class="keyword">val</span> parse</span> : <code class="type">Lwt_io.file_name -><br>       <a href="Release_config.html#TYPEspec">spec</a> -><br>       [ `Configuration of <a href="Release_config.html#TYPEt">t</a> | `Error of string ] Lwt.t</code></pre><div class="info ">
Parse a configuration file. <code class="code">parse file spec</code> will try to parse <code class="code">file</code>
      and, if it is syntatically correct, validate it against the specification
      given in <code class="code">spec</code>.<br>
</div>

<pre><span id="VALdefaults"><span class="keyword">val</span> defaults</span> : <code class="type"><a href="Release_config.html#TYPEspec">spec</a> -> <a href="Release_config.html#TYPEt">t</a></code></pre><div class="info ">
<code class="code">defaults spec</code> returns a configuration built from the default values
      of <code class="code">spec</code>. This only makes sense if every key in the specification has
      a default value.<br>
</div>

<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type"><a href="Release_config.html#TYPEt">t</a> -> string -> string -> <a href="Release_config_values.html#TYPEvalue">Release_config_values.value</a></code></pre><div class="info ">
<code class="code">get conf section key</code> returns the value of the parameter <code class="code">key</code> of
      section <code class="code">section</code> in configuration <code class="code">conf</code>.<br>
</div>

<pre><span id="VALget_global"><span class="keyword">val</span> get_global</span> : <code class="type"><a href="Release_config.html#TYPEt">t</a> -> string -> <a href="Release_config_values.html#TYPEvalue">Release_config_values.value</a></code></pre><div class="info ">
<code class="code">get_global conf key</code> returns the value of the global parameter <code class="code">key</code>.<br>
</div>
</body></html>