Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 08, 2014 ini library in OSX | ||||
---|---|---|---|---|
| ||||
Is there any ini library that works in OSX? I've tried the ones I found. I think they have the same issue. Joels-MacBook-Pro:ChrisMill joelcnz$ dmd ini -unittest ini.d(330): Error: cannot pass dynamic arrays to extern(C) vararg functions ini.d(387): Error: undefined identifier 'replace', did you mean 'template replace(E, R1, R2)(E[] subject, R1 from, R2 to) if (isDynamicArray!(E[]) && isForwardRange!R1 && isForwardRange!R2 && (hasLength!R2 || isSomeString!R2))'? ini.d(495): Error: cannot pass dynamic arrays to extern(C) vararg functions ini.d(571): Error: cannot pass dynamic arrays to extern(C) vararg functions ini.d(571): Error: cannot pass dynamic arrays to extern(C) vararg functions Joels-MacBook-Pro:ChrisMill joelcnz$ |
September 09, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | On Monday, 8 September 2014 at 06:32:52 UTC, Joel wrote: > Is there any ini library that works in OSX? > > I've tried the ones I found. I think they have the same issue. > > Joels-MacBook-Pro:ChrisMill joelcnz$ dmd ini -unittest > ini.d(330): Error: cannot pass dynamic arrays to extern(C) vararg functions > ini.d(387): Error: undefined identifier 'replace', did you mean 'template replace(E, R1, R2)(E[] subject, R1 from, R2 to) if (isDynamicArray!(E[]) && isForwardRange!R1 && isForwardRange!R2 && (hasLength!R2 || isSomeString!R2))'? > ini.d(495): Error: cannot pass dynamic arrays to extern(C) vararg functions > ini.d(571): Error: cannot pass dynamic arrays to extern(C) vararg functions > ini.d(571): Error: cannot pass dynamic arrays to extern(C) vararg functions > Joels-MacBook-Pro:ChrisMill joelcnz$ You have a pretty functional INI parser here: http://forum.dlang.org/thread/1329910543.20062.9.camel@jonathan |
September 09, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | Or this one: http://dpaste.dzfl.pl/1b29ef20# |
September 09, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | On Tuesday, 9 September 2014 at 08:57:30 UTC, Dejan Lekic wrote:
>
> Or this one: http://dpaste.dzfl.pl/1b29ef20#
Thanks Dejan Lekic, I'll look them up.
|
September 10, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | How do you use this ini file parser? ----------------- http://dpaste.dzfl.pl/1b29ef20 module rangeini; import std.stdio: File, writeln; import std.range; import std.algorithm: canFind; import std.string: strip, splitLines; import std.traits: Unqual; import std.conv: text; struct ConfigItem { string section; string key; string value; } private struct ConfigItems(Range,string kvSeparators=":=",string commentChars=";#") { Unqual!Range _input; string currentSection = "GLOBAL"; this(Unqual!Range r) { _input = r; skipNonKeyValueLines(); } @property bool empty() { return _input.empty; } @property void popFront() { _input.popFront(); skipNonKeyValueLines(); } @property auto front() { auto line = _input.front; foreach(uint i, const c; line) { if (kvSeparators.canFind(c)) { auto key = line[0..i]; auto value = line[i+1..$]; return ConfigItem(currentSection, key.idup, value.idup); } } return ConfigItem(currentSection, line.idup, ""); } private void skipNonKeyValueLines() { while(!_input.empty) { auto line = strip(_input.front); if (line == "" || isComment(line)) { _input.popFront(); continue; } if (line[0] == '[' && line[$-1] == ']') { /* section start */ currentSection = line[1..$-1].idup; _input.popFront(); continue; } break; } } private static bool isComment(in char[] line) pure @safe { assert (line != ""); auto c = line[0]; if (commentChars.canFind(c)) return true; return false; } } auto parseINIlines(Range)(Range r) if (isInputRange!(Unqual!Range)) { return ConfigItems!(Range)(r); } auto parseINI(string data) { return data.splitLines.parseINIlines; } auto parseINI(File fh) { return fh.byLine.parseINIlines; } unittest { auto data = " general section=possible [Simple Values] key=value spaces in keys=allowed spaces in values=allowed as well spaces around the delimiter = obviously you can also use : to delimit keys from values [All Values Are Strings] values like this: 1000000 or this: 3.14159265359 are they treated as numbers? : no integers, floats and booleans are held as: strings can use the API to get converted values directly: true [Multiline Values] [No Values] key_without_value empty string value here = [You can use comments] # like this ; or this # By default only in an empty line. # Inline comments can be harmful because they prevent users # from using the delimiting characters as parts of values. # That being said, this can be customized. [Sections Can Be Indented] can_values_be_as_well = True does_that_mean_anything_special = False purpose = formatting for readability # Did I mention we can indent comments, too?"; foreach(item; parseINI(data)) { writeln("[*", text(item), "*]"); } } int main() { return 0; } |
September 10, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | Here's a failed attempt of mine - after the line. I would usually have stuff like the following (right next): Ini ini; ini=new Ini( cfg ); ini["section"]["key"] = value; ----------- import ini; void main() { import std.conv; //load string data; int i; foreach(item; parseINI(File("test.ini"))) { data ~= item.to!string~"\n"; writeln("[*", i++, ' ', text(item), "*]"); } //save //#not working! data ~= "frog=jump"; // add more information data ~= "frog=jump"; auto file = File("test.ini", "w"); file.write(data); i = 0; foreach(item; parseINI(File("test.ini"))) { writeln("[+", i++, ' ', text(item), "+]"); } } |
September 11, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | some self promo: http://code.dlang.org/packages/inifiled |
October 11, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert burner Schadek | On Thursday, 11 September 2014 at 10:49:48 UTC, Robert burner Schadek wrote:
> some self promo:
>
> http://code.dlang.org/packages/inifiled
I would like an example?
|
October 13, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joel | On Saturday, 11 October 2014 at 22:38:20 UTC, Joel wrote:
> On Thursday, 11 September 2014 at 10:49:48 UTC, Robert burner Schadek wrote:
>> some self promo:
>>
>> http://code.dlang.org/packages/inifiled
>
> I would like an example?
go to the link and scroll down a page
|
December 20, 2014 Re: ini library in OSX | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert burner Schadek | On Monday, 13 October 2014 at 16:06:42 UTC, Robert burner Schadek wrote:
> On Saturday, 11 October 2014 at 22:38:20 UTC, Joel wrote:
>> On Thursday, 11 September 2014 at 10:49:48 UTC, Robert burner Schadek wrote:
>>> some self promo:
>>>
>>> http://code.dlang.org/packages/inifiled
>>
>> I would like an example?
>
> go to the link and scroll down a page
How do you use it with current ini files ([label] key=name)?
|
Copyright © 1999-2021 by the D Language Foundation