ddn.config.ini¶
INI Configuration Support.
Overview¶
This module provides a robust and flexible implementation of INI file parser and writer. It is designed to work seamlessly with ddn.var.
Structs¶
IniPolicy¶
Policy for parsing and writing INI files.
Fields¶
| Name | Type | Description |
|---|---|---|
commentChars |
string |
Characters that start a comment line. Common choices are ; and #. Default: ";#" |
allowGlobalProperties |
bool |
Allow properties before the first section. If true, these properties are stored in the root object. Additionally, if a section named global is encountered, it is treated as a continuation of the global properties, merging with them. Default: true |
strict |
bool |
If 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. Default: true |
Ini¶
Wrapper for INI configuration data. Provides convenience methods for working with INI structures stored in a var.
Properties¶
data¶
The underlying configuration data.
sections¶
Returns a range of section names. Only keys that map to an object are considered sections.
Functions¶
parseIni¶
Parses INI content into an Ini object.
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string |
The INI content to parse. |
policy |
IniPolicy |
Configuration policy. |
Returns:
An Ini struct containing the parsed data.
toIni¶
Serializes a var object to INI format and returns it as a string.
Parameters:
| Name | Type | Description |
|---|---|---|
v |
var |
The var object to serialize. |
policy |
IniPolicy |
Configuration policy. |
Returns: The INI string representation.
toIni¶
Serializes a var object to INI format and writes to a file.
Parameters:
| Name | Type | Description |
|---|---|---|
v |
var |
The var object to serialize. |
filename |
string |
The path to the file to write. |
policy |
IniPolicy |
Configuration policy. |
save¶
Saves a var object to INI format into an output range.
Parameters:
| Name | Type | Description |
|---|---|---|
v |
var |
The var object to serialize. |
sink |
OutputRange |
The output range to write to. |
policy |
IniPolicy |
Configuration policy. |