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.
class IniParseException
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 7
private fn
string unescapeIniString(string val)Decode the backslash escapes produced by escapeIniString.private fn
string escapeIniString(string val)Escape a string for use inside a quoted INI value: control characters become backslash escapes, and `\` and `"` are escaped.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.private fn
void validateName(string what, string name, IniPolicy policy)Saves a `var` object to INI format into an output range.fn
void save(OutputRange)(var v, auto ref OutputRange sink, IniPolicy policy = IniPolicy.init) if (isOutputRange!(OutputRange, string))