initial: INI parsing library for D

initial is an attempt at making a sane and high-quality INI parsing library for D.

download

⤥ initial.d (direct download, master branch)

Compile it as an individual object and link it in with your program, or add it to the list of sources to build all at once.

documentation

Reference documentation can be found in the source code as Ddoc comments. A quick start guide is provided below.

getting started

The contents of an INI file is stored in an INIUnit structure. This contains an associative array of INISections that you can read or set, or you can use readINI() to fill it in with data from a string of INI. readINIFile() does the same thing but reads from a file instead of a D string.

initial also provides serialisation facilities that can turn INIUnits and INISections back into an INI document. Handy for if your program has some sort of GUI configuration interface or if you're passing around INI through a network connection.
INIUnit ini;

/* write INI data to an INIUnit */
ini["section"]["key"] = "value";
ini["section"]["num"] = "4.8";

/* read INI from a string */
readINI(ini, `
    [section]
    num = 5.3
`);

assert(ini["section"]["key"] == "value");
assert(ini["section"]["num"] == "5.3");

/* read INI from file */
readINIFile(ini, "config.ini");

/* write INI to file */
import std.file : write;
write("config.ini", ini.serialise());

progress

initial implements INI keys, sections, the default section, and comments. Key referencing is unimplemented. The library does all I need and I consider it complete.

git repository

The git repository can be found at git.reformers.dev.

Maintained by Jeremy Baxter <jeremy@baxters.nz>