Best way to handle settings files (ini file syntax or similar)

Dicebot m.strashun at gmail.com
Wed Feb 27 13:36:29 PST 2013


I use this simple snippet to get quick and dirty key-value config:

---
string[string] data;
foreach( line; readText(filename).splitLines() )
{
     auto config_pair = array(
         filter!("a.length > 0")(
             map!(strip)(
                 line.splitter("=")
             )
         )
     );
     data[config_pair[0]] = config_pair[1];
}
---

For anything even remotely complex I would have probably chosen 
JSON, either new std.json pending for review (not current 
std.json!) or vibe.data.json from vibed.org project.


More information about the Digitalmars-d-learn mailing list