This is the format that is written by the ezcConfigurationIniWriter class and
read by the ezcConfigurationIniReader class. The parser itself is located in
the ezcConfigurationIniParser class.
The parser will remove leading and trailing whitespace from group names,
settings and setting values. If you wish to keep whitespace in a string, it will
have to be quoted.
Comments are written using a # (hash) and must be placed at the start of the
line. The whitespace block before the comment text on all the lines will be
trimmed away while whitespace after this block is kept. Trailing whitespace is
also trimmed. For instance, the follow comments:
# A simple comment
# A simple comment
# A simple comment
will become:
#A simple comment
# A simple comment
# A simple comment
Multiple comment lines will be read as one comment with multiple lines. If
there are empty lines in between comments, they will be read as empty lines in
the comment itself:
# A single line comment
Setting = value
# Multiple lines
# for this
# comment
Setting = value
# Multiple lines
# with empty lines
# for this comment
Setting = value
# Multiple lines
#
# with empty lines
# for this comment
# Actually same as above
Setting = value
Comments are always placed in front of the group or setting. A line
that only contains whitespace will be ignored.
Files are always encoded in UTF-8 format, meaning that they can contain Unicode
characters or plain ASCII without specific encoding.
Groups are defined by placing an identifier inside square brackets. Any setting
that is read after this will be placed as part of this
group. Settings without groups are not allowed and will cause an error to be
issued. The group name will have its leading and trailing whitespace trimmed
away:
[Group1]
[Another group]
[ Yet another group ]
Settings are defined by placing an identifier followed by an equal sign (=),
finally followed by the value. The setting identifier and corresponding value
must be on the same line, and cannot span multiple lines:
Setting1 = Some example string
Setting2 = 42
The values of settings are generally strings, with the exception of:
Booleans, which can be written as true or false. If you need a string
that contains the text true or false it must be quoted:
SystemEnabled = true
LogErrors = false
Numbers, which are written using English locale and can be in the following
formats:
decimal:
[1-9][0-9]* | [0]
MaxSize = 400
MinSize = 0
hexadecimal:
0[xX][0-9a-fA-F]+
BackgroundColor = 0xaabbcc
TextColor = 0x0102FE
octal:
0[0-7]+
Permission = 0666
float:
LNUM [0-9]+
DNUM ([0-9]*[\.]{LNUM}) | ({LNUM}[\.][0-9]*)
EXPONENT_DNUM ( ({LNUM} | {DNUM}) [eE][+-]? {LNUM})
Price = 10.4
Seed = 10e5
- An explicit string, which is enclosed in double quotes ("). All whitespace is
kept inside the quotes and characters are read literally with the exception
of escaped characters. The escaped characters are:
\" which will be replaced with the quote character ("):
"This contains \"quote\" characters"
\\ which will be replaced with the backslash character (\):
"This contains a backslash \\"
In addition, it is possible to define arrays in a second way by using square
brackets ([]) after the setting name and before the equal (=) character. This
will make the setting an array and the value is parsed as explained above.
In addition, the square brackets may be enclosed around a string, turning the
array into a hash (or associative array) with the text being used as the key.
List[] = First string
List[] = Second string
List[] = 5
Hash[abc] = 4
Hash["def"] = 5