A library for parsing config files in .ini format
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);
}
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);
}