AiTown - aitown-cfg

Home

aitown-cfg provides an unified interface to settings for all modules that are part of the package. It also serves to simplify the code in other modules.

The settings are stored in files. The library either receives fully qualified paths or relative paths that are resolved by the underlying platform. In either case the library has no mechanism for guessing files based on provided names.

A tree structure is employed, with sections acting as nodes and keys-values pairs being the leafs. Each section may have a name (null-terminated string, with each character being exactly one byte) and each leaf has a name and a value of same king of string. The slash ('/') can't be part of the section's name, as it is used as path separator.

Here is a simple example file:

; we define a section called "general"
[general]
; the key is "port" and the value is "29777"
port = 29777

A more complex file, with "general" section hosting a subsection (note that the order is not important, and "general" section may be left out).

; a subsection for section "general"
[general/subsection]
; path for following key is general/subsection/key
key = 1
; "general" section can have leafs of its own
[general]
; the key is "port" and the value is "29777"
port = 29777

This tree structure is used for stacking properties, in a way that allows modules to be configured either with their own config file or with settings from a general config file loaded by parent module.

Home