dini
is a library written in D Programming Language
that allows you to read and write INI configuration files with ease.
-
Easy to use
Documentation and examples helps you understand library. It's also very nice to use :).
-
Well documented
The code is well documented. If you find something that isn't, be sure to open issue about it.
-
Variable lookups
You can "paste" defined variables values in values using
%variable%
-
Section inheriting
Sections can inherit values from other sections
-
Configurable
Since version 2
You can define custom quotes, comments and use custom type to store values (reader only).
Also, if you want to create custom data from INI, you can use
INIReader
to construct one.
NOTE: Current development version -
2.0.0
is backwards API compatible, if you have any compatibility issues, please report them.
Stable version
{
...
"dependencies": {
"dini": "~> 1.0.1"
}
...
}
Latest version
{
...
"dependencies": {
"dini": "~> 2.0.0-rc"
}
...
}
Let's check how it works in real life. In the examples, we'll use following configuration file:
[def]
name1=value1
name2=value2
[foo : def]
name1=Name1 from foo. Lookup for def.name2: %name2%
Now, lets try to parse it, we can do it with using code similar to:
import std.stdio;
import dini;
void main()
{
// Parse file
auto ini = Ini.Parse("path/to/file.conf");
// Print foo.name1 value
writeln(ini["foo"].getKey("name1"));
}
You can also set INI variables before parsing:
import std.stdio, std.path;
import dini;
void main()
{
// Create ini struct instance
Ini ini;
// Set key value
ini.setKey("currentdir", getcwd());
// Now, you can use currentdir in ini file
ini.parse();
// Print foo.name1 value
writeln(ini["foo"].getKey("currentdir"));
}
This allows for using %currentdir%
in configuration file now.
If you would like to inherit sections that are in another one, you can use .
at the beggining to start from global scope:
[a]
[a.b]
[b]
; Note the dot at beggining
[b.c : .a.b]
The same goes for variable lookups:
[a]
[a.b]
var=test
[b]
[b.c]
var=%.a.b.var%