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
allowGlobalPropertiesis true
Error_Handling: The toIni(var, string) function may throw:
std.stdio.StdioException- If the file cannot be opened or writtenstd.exception.ErrnoException- For other I/O errors
Use the toIni(var) overload returning a string to avoid I/O exceptions.
Types 3
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
classIniParseException : Exception
Thrown when INI content cannot be parsed.
Lets callers catch parse errors specifically (analogous to SemVerParseException / AdamException hierarchies elsewhere in ddn).
Constructors
this(string msg, string file = __FILE__, size_t line = __LINE__)Functions 4
fn
Ini parseIni(string text, IniPolicy policy = IniPolicy.init)Parses INI content into an `Ini` object.fn
void toIni(var v, string filename, IniPolicy policy = IniPolicy.init)Serializes a `var` object to INI format and writes to a file.fn
void save(OutputRange)(var v, auto ref OutputRange sink, IniPolicy policy = IniPolicy.init) if (isOutputRange!(OutputRange, string))