Has anyone written an INI parser in tango?

Chris R. Miller lordsauronthegreat at gmail.com
Fri Sep 12 13:40:50 PDT 2008


Bill Baxter wrote:
> On Fri, Sep 12, 2008 at 3:43 PM, Chris R. Miller
> <lordsauronthegreat at gmail.com> wrote:
>> Bill Baxter wrote:
>>> On Fri, Sep 12, 2008 at 9:38 AM, Rayne <DiscipleRayne at gmail.com> wrote:
>>>> Just wondering if anyone had because it doesnt seen that the creators of Tango have, and their crappy properties stuff doesnt appeal to me in the least bit.
>>> Is there some reason you are really set on using a crappy format like ini?
>> What's so bad about ini?
>>
>> 1) It's simple.  Even people with little to no computer savvy can look
>> at an ini file and deduce how to make things work.
>>
>> 2) It's easy to parse.
>>
>> 3) It's not platform-dependent.  Using the line iterator in Tango you
>> don't even have to be cognizant of the differences between /r/n and /n.
>>  Just go!
>>
>> 4) It's simple enough to be edited from a command-line editor.
> 
> It's not hierarchical.

You could emulate that with headers like:

[hier1.hier11]
foo = bar
[hier1.hier12]
bar = foo

I think I did that with a Java project a (long) while back.  That was
using Java's java.util.Properties though... I forget if that was even
partly ini-compliant.

> But you're right, if you never have any plans to go beyond very simple
> key=value uses, then it's fine.  But if that's all you need then maybe
> you don't even need ini.  Just a file with plain old
> ----
> foo = bar
> x = y
> ----
> will do and you can just read the lines with a simple regex.

Heh, I never got as far as a regex.  My code does exactly what you
describe (only it adds the construct of lines beginning with # for
comments).  I only thought it would be useful as a starting point to add
the ability to parse ini headers into.

> That said I don't know the full spec of the ini format.  So maybe it
> has some tricks I'm not aware of.

I think the attractiveness of ini is that there aren't any special
tricks to have to be aware of.  It's the ultimate WYSIWYG in
configuration storage.



More information about the Digitalmars-d mailing list