84 lines
2.1 KiB
Markdown
84 lines
2.1 KiB
Markdown
## initial - INI parser for the D programming language
|
|
|
|
My attempt at making a sane and high-quality INI parsing library for D.
|
|
|
|
```ini
|
|
[section]
|
|
key = value
|
|
```
|
|
|
|
The contents of an INI file is stored in an `INIUnit` structure. This
|
|
contains an associative array of `INISection`s that you can read or set
|
|
yourself.
|
|
|
|
initial also provides serialisation facilities that can turn `INIUnit`s
|
|
and `INISection`s 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.
|
|
|
|
initial.d is licensed under the Boost Software License, version 1.0. See
|
|
COPYING for the full licence text.
|
|
|
|
## Demo
|
|
|
|
```d
|
|
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
|
|
|
|
### Unimplemented
|
|
|
|
- Key referencing
|
|
|
|
Currently initial.d does all I need it to, and I consider it complete.
|
|
However if you have any questions, feel free to send an email to [my
|
|
public inbox][1] or directly to my address (jeremy@baxters.nz). Patches
|
|
are also welcome which you can generate with `git format-patch` and attach
|
|
to an email or just copy into the body of an email ([`git send-email`][2]
|
|
can do this automatically).
|
|
|
|
[1]: https://lists.sr.ht/~jeremy/public-inbox
|
|
[2]: https://git-send-email.io
|
|
|
|
## Build status
|
|
|
|
Status on building with LDC latest and 1.30.0:
|
|
[](https://builds.sr.ht/~jeremy/initial)
|