Description

A library for parsing config files

Package Information

Version0.1.0 (2016-May-04)
Repositoryhttps://github.com/stefan-brus/inid
LicenseBSL-1.0
CopyrightCopyright © 2016, Stefan Brus
AuthorsStefan Brus
Registered byStefan Brus
Dependenciesnone

Installation

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

dub.json
dub.sdl

Readme

inid

A library for parsing config files in .ini format

Usage

import inid;

import std.stdio;

struct Config
{
    struct Server
    {
        string address;
        ushort port;
    }

    Server srv;
}

enum CONFIG_STR = "
[SERVER]
address = 127.0.0.1
port = 4711
";

void main ( )
{
    auto config = ConfigParser!Config(CONFIG_STR);

    writefln("Server address: %s", config.srv.address);
    writefln("Listening on port: %s", config.srv.port);
}

Parsing a file

Assume there exists a file called config.ini in the current working directory:

import inid;

import std.stdio;

struct Config
{
    struct Server
    {
        string address;
        ushort port;
    }

    Server srv;
}

void main ( )
{
    auto config = parseConfigFile!Config("config.ini");

    writefln("Server address: %s", config.srv.address);
    writefln("Listening on port: %s", config.srv.port);
}

Available versions

0.1.0 ~master