dini 1.0.1

INI-like format parser written in D.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Dini

What's that

Dini is a library written in D Programming Language that allows you to parse INI configuration files easily.

Features

  • Easy to use

    Documentation and examples helps you understand library. It's also very nice to use :).

  • Well documented

    The code is well documented, allowing you to understand it easier.

  • Variable lookups

    You can "paste" defined variables values in values using %variable%

  • Section inheriting

    Sections can inherit values from other sections

Learning Dini

Simple example

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.

Global Inheriting

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]

Global lookups

The same goes for variable lookups:

[a]
[a.b]
var=test

[b]
[b.c]
var=%.a.b.var%
Dependencies:
none
Versions:
2.0.0 2016-Oct-02
2.0.0-rc 2016-Aug-08
1.0.1 2016-Mar-05
1.0.0 2014-Nov-15
~master 2016-Oct-02
Show all 5 versions
Download Stats:
  • 1 downloads today

  • 4 downloads this week

  • 5 downloads this month

  • 1185 downloads total

Score:
1.2
Short URL:
dini.dub.pm