Re: [Vala] Help me find the right Vala idiom
- From: Jan Spurný <JSpurny seznam cz>
- To: celston katalix com
- Cc: vala-list gnome org
- Subject: Re: [Vala] Help me find the right Vala idiom
- Date: Mon, 05 Mar 2012 15:29:44 +0100 (CET)
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
------------ 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
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
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
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!
] [Thread Prev