ddn.config.ini

INI Configuration Support

This module provides a robust and flexible implementation of INI file parser and writer. It is designed to work seamlessly with ddn.var.

Section_Names: Section names in INI files should follow these guidelines:

  • Alphanumeric characters (a-z, A-Z, 0-9) are always safe
  • Underscores (_), hyphens (-), and periods (.) are commonly supported
  • Spaces and special characters may work but are not recommended for portability
  • Section names are case-sensitive in this implementation
  • Empty section names are not allowed
  • The special section name "global" is reserved when allowGlobalProperties is true

Error_Handling: The toIni(var, string) function may throw:

  • std.stdio.StdioException - If the file cannot be opened or written
  • std.exception.ErrnoException - For other I/O errors

Use the toIni(var) overload returning a string to avoid I/O exceptions.

Types 2

structIniPolicy

Policy for parsing and writing INI files.

Fields
string commentCharsCharacters that start a comment line. Common choices are `;` and `#`.
bool allowGlobalPropertiesAllow properties before the first section. If true, these properties are stored in the root object.
bool strictIf true, the parser will throw an Exception on malformed lines. Malformed lines are those that are not comments, sections, or key-value pairs. If false, such lines are ignored.
structIni

Wrapper for INI configuration data.

Provides convenience methods for working with INI structures stored in a var.

Fields
var dataThe underlying configuration data.
Methods
string[] sections() @propertyReturns an array of section names.
Constructors
this(var data)Constructs an `Ini` object from a `var`.

Functions 6

private fnstring unescapeIniString(string val)
private fnstring escapeIniString(string val)
fnIni parseIni(string text, IniPolicy policy = IniPolicy.init)Parses INI content into an `Ini` object.
fnvoid toIni(var v, string filename, IniPolicy policy = IniPolicy.init)Serializes a `var` object to INI format and writes to a file.
fnvoid save(OutputRange)(var v, auto ref OutputRange sink, IniPolicy policy = IniPolicy.init) if (isOutputRange!(OutputRange, string))Saves a `var` object to INI format into an output range.
fnstring toIni(var v, IniPolicy policy = IniPolicy.init)Serializes a `var` object to INI format.