Slice Tools libFoundation |
example-configfile.iniAn example configuration file.Note that sections and variables are supported, as well as allowing for runtime substitution of variable values. ConfigFile supports multiple substitutions on the same line, nested substitutions, and the ability to set default rules. Notice how in this example NIH.workdir, TIGR.workdir and TIGR.updated.workdir are all set to the same rule, but in the output the substitutions evaluate differently. This is possible because while the default rule is written in the topmost section, the rules are evaluated using the most local values of ORG and {{ORG}}_DIR relative to the child where the rule is referenced. ; $Id: example-configfile.ini,v 1.1 2005/07/29 02:55:16 mschatz Exp $
; Test config to demonstrate config file parsing
APP_NAME=test ; Anything after ; is ignored
APP_VERSION=1.0
PATH={{APP_NAME}}/{{APP_VERSION}} ; Do multiple substitutions on
; the same line
ORG=DEFAULT ; So default rule will resolve
DEFAULT_DIR=DEFAULT_DIR ;
DEFAULTWORKDIR={{{{ORG}}_DIR}}/work/{{PATH}} ; Provide a default rule
; With nested resolution
[NIH] ; NIH Overrides for default rule
ORG=NIH
NIH_DIR=/some/other/path/nih/dir
WORKDIR={{DEFAULTWORKDIR}}
[TIGR] ; These values wont collide
ORG=TIGR ; since they are in a different
TIGR_DIR=/tigr/dir ; scope
WORKDIR= {{DEFAULTWORKDIR}}
OTHERFLAG=--resolve ; Or add a new variable
[TIGR.updated] ; Different Scope again
APP_NAME=updated.test
TIGR_DIR=/tigr/new/dir
WORKDIR = {{DEFAULTWORKDIR}} ; Strips unneeded whitespace
[BAD]
;BAD_REFERENCE={{BAD_REFERENCE}}/other/
;BAD_SUBSTITUTION=}}{{
;=Bad Variable Name
;[ ] ; Bad Section Name
;[BAD] ; Can't have duplicate sections
|