inifiled 1.3.0

Compile Time Inifile Reader and Writer Generator


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

inifile-D

alt text

A compile time ini file parser and writter generator for D. inifile.d takes annotated structs and create ini file parser and writer. The ini file format always comments and section and to some degree nesting.

Example

import initest;

import inifiled;

@INI("A child must have a parent") 
struct Child {
	@INI("The firstname of the child") string firstname;

	@INI("The age of the child") int age;
}

@INI("A Spose") 
struct Spose {
	@INI("The age of the spose") int age;

	// Nesting
	@INI("The House of the spose") House house;
}

@INI("A Dog") 
struct Dog {
	@INI("The name of the Dog") string name;
}

@INI("A Person") 
struct Person {
	@INI("The lastname of the Person") string lastname;

	@INI("The height of the Person") float height;

	@INI("Some strings with a very long long INI description that is longer" ~
		" than eigthy lines hopefully."
	) string[] someStrings;

	int dontShowThis;

	// REGARD the nesting
	@INI("A Spose") Spose spose;

	// REGARD the nesting
	@INI("The family dog") Dog dog;
}

@INI("A House")
struct House {
	@INI("Number of Rooms") uint rooms;

	@INI("Number of Floors") uint floors;
}
import initest;
import inifiled;

import std.string;

void main() {
	Person p;
	p.lastname = "Mike";
	p.height = 181.7;

	p.someStrings ~= "Hello";
	p.someStrings ~= "World";

	p.spose.firstname = "Molly";
	p.spose.age = 72;

	p.spose.house.rooms = 5;
	p.spose.house.floors = 2;

	p.dog.name = "Wuff";

	// Here the ini file is written
	writeINIFile(p, "filename.ini");

	// Here the ini file is read
	Person p2;
	readINIFile(p2, "filename.ini");

	// They should be the same
	assert(p == p2, format("%s\n%s", p, p2));
}
Authors:
  • Robert burner Schadek
Dependencies:
none
Versions:
2.0.0 2022-Oct-19
1.3.3 2020-Nov-24
1.3.2 2020-Sep-14
1.3.1 2018-Apr-22
1.3.0 2018-Apr-04
Show all 18 versions
Download Stats:
  • 33 downloads today

  • 269 downloads this week

  • 1555 downloads this month

  • 110180 downloads total

Score:
4.5
Short URL:
inifiled.dub.pm