parse_conf library

parse_conf is a library for parsing standard configuration or initialization files and supports some extensions over the standard syntax. It supports the separation of config files into different groups and reading strings and numbers. The library is written in ANSI C and designed to be fine with C++. Originally (in 2002, 2004) it was designed for reading initial values for scientific applications of special type. It was rewritten and extended to be a flexible general purpose library. Since version 1.0, a very extensive reference substitution system is included into the library. The library is designed to be thread-safety and you can read/write as many configuration files simultaneously as you would like.

The configuration file consists of sections, led by a [section] header and followed by name: value entries, name=value is also accepted. You also can concatenate a string to the previous value using name += value or name +: value commands. Note that leading and ending whitespaces are removed from string values and ignored from numeric values. To add a whitespace to a string, the string should be quoted by quote " sign or you may use \s and \t values for spaces and tabulations. The rest of lines from # or ; are ignored and may be used to provide comments.

Any variable definition can contain references to other values. See documentation for the details. For example, to substitute the value from variable a of the same group or from the global variables, one may use $a reference or Pythonish %(a)s. You also can reference a variable from another section even if the section appeares after the reference or if the definition also contains a reference. The chain can be as long as you would like but infinite (recursive). Recursive definitions are identified and properly reported of course

Download

Version 1.2

Subversion

Read instructions how to get the developmental version. Use it at your own risk. You will need some additional software to be able to build parse_conf from subversion. Please read INSTALL.SVN for more instructions.

Documentation

html pdf