Every line is read from the file and trimmed from whitespace.
If line is empty or starts with ; then nothing happens.
Otherwise, if line starts with [ then section is changed
to the string between [ and ]. If line does not end
with ] then an error is reported.
Otherwise, if line contains an = sign, then all characters
before = are treated as variable and all characters
following = are treated as value. Both are trimmed. If the
variable was already assigned earlier, an error is
reported. Otherwise, the corresponding assigment is added to the
section.
Otherwise, the line is reported as an error.
Default section algorithm
Insert every variable from the default section into every other section, without overwriting existing variables.
Interpolation algorithm
Locally within each section, every occurrence “variable"isreplacedby"{section:variable}”.
Every occurrence of “${section:variable}” is replaced by its value.
The previous step is repeated until no more replacements are possible, or until the recursion depth (by default, 10) is reached.
IniPP
Simple header-only C++ ini parser and generator.
Features
Example
To include in a cmake project:
Parsing algorithm
The section is set to the empty string.
Every line is read from the file and trimmed from whitespace.
If line is empty or starts with
;then nothing happens.Otherwise, if line starts with
[then section is changed to the string between[and]. If line does not end with]then an error is reported.Otherwise, if line contains an
=sign, then all characters before=are treated as variable and all characters following=are treated as value. Both are trimmed. If the variable was already assigned earlier, an error is reported. Otherwise, the corresponding assigment is added to the section.Otherwise, the line is reported as an error.
Default section algorithm
Insert every variable from the default section into every other section, without overwriting existing variables.
Interpolation algorithm