dini 2.0.0

INI-like format parser written in D.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

dini

BuildStatus Version Downloads Maintained

dini is a library written in D Programming Language that allows you to read and write INI configuration files with ease.

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. 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.

Quick start

Installation

Stable version

{
    ...
    "dependencies": {
        "dini": "~> 1.0.1"
    }
    ...
}

Latest version

{
    ...
    "dependencies": {
        "dini": "~> 2.0.0-rc"
    }
    ...
}

Usage

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:
  • 0 downloads today

  • 18 downloads this week

  • 167 downloads this month

  • 5571 downloads total

Score:
3.4
Short URL:
dini.dub.pm