libconfig-d 0.1.0
D library for processing configuration files
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:
This package provides sub packages which can be used individually:
libconfig-d:readconfig - libconfig-d usage example
libconfig-d:updateconfig - libconfig-d usage example
libconfig-d:buildconfig - libconfig-d usage example
libconfig-d
Port of libconfig to the D programming language.
example:
import config;
import std.stdio;
int main()
{
// read a configuration string (can also read from open file or filename)
auto conf = Config.readString(
`inventory = { books = (
{
title = "Treasure Island";
author = "Robert Louis Stevenson";
price = 29.99;
qty = 5;
}, {
title = "Snow Crash";
author = "Neal Stephenson";
price = 9.99;
qty = 8;
}
)}`
);
// fetch and read nodes
auto books = conf.lookUp("inventory.books").asList;
writeln("Available books in inventory:");
writefln("%-30s %-30s %-6s %s", "TITLE", "AUTHOR", "PRICE", "QTY");
foreach (book; books.children)
{
auto title = book.lookUpValue!string("title");
auto author = book.lookUpValue!string("author");
auto price = book.lookUpValue!float("price");
auto qty = book.lookUpValue!int("qty");
if (!title.isNull && !author.isNull && !price.isNull && !qty.isNull)
{
writefln("%-30s %-30s $%6.2f %3d", title, author, price, qty);
}
}
writeln();
// add nodes and values
auto book = books.add!(Type.Group);
book.addScalar("title", "The Plague");
book.addScalar("author", "Albert Camus");
book.addScalar("price", 8.99);
book.addScalar("qty", 3);
// write to a file (can also write to string)
conf.writeTo(File("updated.cfg", "w").lockingTextWriter());
return 0;
}
- Registered by Remi Thebault
- 0.1.0 released 8 years ago
- rtbo/libconfig-d
- BSD/LDC
- Copyright © 2016, Remi Thebault
- Authors:
- Sub packages:
- libconfig-d:readconfig, libconfig-d:updateconfig, libconfig-d:buildconfig
- Dependencies:
- pegged
- Versions:
-
0.1.0 2016-Oct-09 ~master 2016-Oct-16 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
38 downloads total
-
- Score:
- 0.8
- Short URL:
- libconfig-d.dub.pm