Re: [Vala] Help me find the right Vala idiom



Hi Jan,

I am indeed using KeyFile for the key/value parsing in my
work-in-progress Vala code - I'd like to take the parsed values out of
the KeyFile object and make them members of my own configuration class.

I suspect I *could* make it work leaving the values in the KeyFile, but
I'd like to be able to do things like compare instances of my
configuration class, which I think might be easier if the values were
real members of the class in question.

The important bit to me isn't really the parsing of the data, what I
seek is the flexible table based method of making that data into member
variables of the class.

Cheers,

Chris.

On Mon, 2012-03-05 at 15:29 +0100, Jan Spurný wrote:
Hi,

I'm not sure if that's what you need - but since vala uses glib internaly (of course unless you use that 
new profile..), why don't you just use this: http://valadoc.org/glib-2.0/GLib.KeyFile.html ?

I use it a lot when I need just a couple of key=value items and when things get complicated, I go for JSON 
or XML.

Jan Spurny

------------ Původní zpráva ------------
Od: Chris Elston <celston katalix com>
Předmět: [Vala] Help me find the right Vala idiom
Datum: 05.3.2012 15:22:04
----------------------------------------
Hello list,

I have a pattern I commonly use in C which I've so far failed to
translate to an equivalent Vala or indeed OO equivalent.  I was hoping
that those more used to thinking in such terms would be able to point me
in the right direction.

Attached is a C file which (dumbly) parses a config file with entries of
the format:

    key=value

Where a given key is uniquely associated with a particular type of data
(string, int etc...)

My aim is to parse the config file data into appropriately typed
variables, but to do so using a table based lookup on the key to find
the appropriate function to parse the data and the address of the
location to place the data.

Hopefully the C is clear enough, I apologise for posting C to this list,
but I'm not confident enough of my terminology to communicate the ideas
in Vala.

I'm looking to produce a Vala class which is able to parse <some text
data> into it's own member variables, based on a table lookup. The
important bit for me isn't the parsing, it's the lookup from key to
parse function and destination for the data.

Suggestions gratefully received!

Many thanks,

Chris.







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]