Skip to content
A library for parsing config files
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
source/inid
.gitignore
LICENSE
README.md
dub.json

README.md

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);
}
You can’t perform that action at this time.