Skip to content

INI format specification

Petr Stefan edited this page May 16, 2016 · 1 revision

Specification of .ini format

  • Comment

    • text from ; symbol to the end of line
  • Identifier

    • string of characters from a-z, A-Z, 0-9, _, ~, -, ., :, $, space begining with one of a-z, A-Z, . , $, :
  • Section

    • part of configuration file marked with identifier
    • starts with a header, which is identifier of the section in squared brackets at the begining of line, for example [Defaults]
    • ends at begining of following section or end of file
    • cannot be splitted to more parts, every identifier can be present only once in the config file
    • contains 0 or more configuration options
  • Option

    • pair of (identifier, value) in any section
    • in file written as identifier=value
    • white spaces at the begining and end of identifier or value are stripped unless preceded with \
    • spaces between words (characters without spaces) are part of identifier or value
    • value is represented by one or more elements of the same type with separator , or :. When both separators are present, , has higher priority and will be used.
  • Element

    • text representing value paired with identifier of option
    • text of the element can be link to other element (also in different section)
      • format of the link is ${section#option}
      • value is only text replacement, so special characters and commands will be interpreted after insertion
      • link is not interpreted when \ is preceding of $ character
    • element can be one of the types: boolean, signed, unsigned, float, enum or string
      • boolean element can be 0, f, n, off, no, disabled for false value and 1, t, y, on, yes, enabled for true value
      • signed type is 64-bit value with limitations of the type (in 2 complement)
      • unsigned is 64-bit integer value
      • signed and unsigned specifies decimal numbers by default. Hexadecimal numbex must be prefixed with 0x, octal with 0 and binary with 0b
      • float is 64-bit floating point type (IEEE 754 standard)
      • enum type is one of former defined set of strings
      • string can contain arbitrary characters except ,, : and ;, which must be prefixed with \

Example of valid .ini file

[Section 1]
; comment
Option 1 = value 1                     ; option 'Option 1' has value 'value 1'
oPtion 1    =  \ value 2\ \ \          ; option 'oPtion 1' has value ' value 2   ', 'oPtion 1' and 'Option 1' are different

[$Section::subsection]                 ; no subsection, only valid identifier of section
Option 2=value 1:value 2:value 3       ; option 'Option 2' is list of 'value 1', 'value 2' and 'value 3'
Option 3 =value 1, ${Section 1#Option 1} ; option 'Option 3' is list of 'value 1' and 'value 1'
Option 4= v1,${$Section::subsection#Option 3},v2 ; option 'Option 4' is list of 'v1', 'value 1', 'value 1', 'v2'
Option 5= v1, v2:v3                    ; option 'Option 5' is list of 'v1' a 'v2:v3'

[Numbers]
num = -1285
num_bin = 0b01101001
num_hex = 0x12ae,0xAc2B
num_oct = 01754

float1 = -124.45667356
float2 = +4.1234565E+45
float3 = 412.34565e45
float4 = -1.1245864E-6

[Other]
bool1 = 1
bool2 = on
bool3=f
Clone this wiki locally