digitalmars.D.learn - Best way to handle settings files (ini file syntax or similar)
- Samuel Lampa (7/7) Feb 27 2013 Hi,
- Dicebot (18/18) Feb 27 2013 I use this simple snippet to get quick and dirty key-value config:
- Dicebot (3/3) Feb 27 2013 Btw now I have actually noticed it is really bad and dirty, so
- Samuel Lampa (5/8) Feb 27 2013 Thanks! Yeah, you're right, rolling an own is not a too big deal. Just
- Lubos Pintes (3/21) Feb 28 2013 Which JSON is better? I already saw Vibe's JSON, but don't know where is...
- Stephan Schiffels (3/6) Feb 28 2013 Which std.json are you referring to? There is no std.json2 or something
- Dicebot (6/12) Feb 28 2013 Hm, now that I look at wiki, probably false memories. I could
- Jonathan M Davis (10/25) Feb 28 2013 A while ago Robert Jacques (if I remember who it was correctly) indicate...
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
Feb 27 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.
Feb 27 2013
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.
Feb 27 2013
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
Feb 27 2013
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.
Feb 28 2013
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.
Feb 28 2013
On Thursday, 28 February 2013 at 17:53:08 UTC, Stephan Schiffels wrote:Am 27.02.13 21:36, schrieb Dicebot: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 :(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.
Feb 28 2013
On Thursday, February 28, 2013 18:57:37 Dicebot wrote:On Thursday, 28 February 2013 at 17:53:08 UTC, Stephan Schiffels wrote: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 DavisAm 27.02.13 21:36, schrieb Dicebot: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 :(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.
Feb 28 2013