Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
February 27, 2013 Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Hi, I was wondering what would be the most straightforward way to handle settings files in D, currently? Is there support for ini filesor something similar, or would I be better off going with JSON or XML or similar? BR // Samuel |
February 27, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Samuel Lampa | 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. |
February 27, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | Btw now I have actually noticed it is really bad and dirty, so good to sometimes check your 2-year code. I think you can write better one anyway, just an example of how small it can be. |
February 28, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On 02/27/2013 10:46 PM, Dicebot wrote:
> Btw now I have actually noticed it is really bad and dirty, so good to sometimes check your 2-year code. I think you can write better one anyway, just an example of how small it can be.
Thanks! Yeah, you're right, rolling an own is not a too big deal. Just wanted to make sure I'm not missing something :)
Best Regards
// Samuel
|
February 28, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | Which JSON is better? I already saw Vibe's JSON, but don't know where is that new std.json.
Dňa 27. 2. 2013 22:36 Dicebot wrote / napísal(a):
> 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.
|
February 28, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | Am 27.02.13 21:36, schrieb Dicebot:
> 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.
Which std.json are you referring to? There is no std.json2 or something in the review queue.
|
February 28, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Schiffels | On Thursday, 28 February 2013 at 17:53:08 UTC, Stephan Schiffels wrote:
> Am 27.02.13 21:36, schrieb Dicebot:
>> 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.
>
> Which std.json are you referring to? There is no std.json2 or something in the review queue.
Hm, now that I look at wiki, probably false memories. I could have sworn I have tried one intended to be proposed for review about a year ago and can't anything resembling it now when you asked :(
|
February 28, 2013 Re: Best way to handle settings files (ini file syntax or similar) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | On Thursday, February 28, 2013 18:57:37 Dicebot wrote:
> On Thursday, 28 February 2013 at 17:53:08 UTC, Stephan Schiffels
>
> wrote:
> > Am 27.02.13 21:36, schrieb Dicebot:
> >> 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.
> >
> > Which std.json are you referring to? There is no std.json2 or something in the review queue.
>
> Hm, now that I look at wiki, probably false memories. I could have sworn I have tried one intended to be proposed for review about a year ago and can't anything resembling it now when you asked :(
A while ago Robert Jacques (if I remember who it was correctly) indicated that he had a major rewrite of std.json, but it required an overhaul of std.variant (which he'd also done), so that would have needed to be done first. However, he never got any of it ready for review. IIRC, he felt that needed to polish some stuff up before that, and he doesn't appear to ever have done it. So, I have no idea where that stands now. He's still around and posts at least from time to time, but maybe he just doesn't have time to work on D right now. I don't know.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation