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.
Attachment:
config_file
Description: Text document
Attachment:
parse_table.c
Description: Text Data