INI parsing library for D
Find a file
2024-06-05 12:43:00 +12:00
.gitignore add basic gitignore 2024-01-26 13:31:22 +13:00
COPYING license under the Boost Software License 2024-01-24 21:04:26 +13:00
dub.json add dub.json 2024-01-26 14:22:09 +13:00
initial.d implement basic comments 2024-02-06 16:45:12 +13:00
README.md improve readme contents 2024-06-05 12:43:00 +12:00

initial - INI parser for the D programming language

My attempt at making a sane and high-quality INI parsing library for D.

[section]
key = value

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

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.

Demo

INIUnit ini;

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

/* read INI data */
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());

Usage

Copy initial.d to somewhere in your import path, then compile it alongside your program and link it in. Or you can do it all at once by using -i.

dmd program.d initial.d
dmd -i program.d

Documentation can be found by reading the documentation comments in the code.

Progress

Finished

  • Keys
  • Sections
  • Default section
  • Comments

Todo

  • Key referencing
  • Testing D: