Blog
Using XML in the real world.
Date: 13/10/2008
Some people have some very er... interesting ways to use XML. Myself, on the other hand think of it as a flexible data store for lightweight things like application options and as glue between 2 disparate systems. Said interesting people have tendencies to mirror all the XML elements in C++ with arcane, long winded, fragile and complicated class hierarchies where each element and attribute has it's own class. I however am not insane.

I like tools that reduce the lines of code I have to write. And I almost always use generic DOM trees for all my work, keeps the lines of code to a minimum.

My latest little innovation is a little UI glue library that makes my lightweight XML library (DOM tree style) talk to standard Lgi controls. I've actually been using this for quite a while in the simple case of converting an XML element's attributes to values in controls on a dialog and back again for serializing UI to disk. i.e. take a string value from the XML, stuff it in an editbox, let the user change it, then write it back into the XML element's attribute and then eventually to disk. Fairly mundane.

However this week I'm starting to experiment, successfully, with serializing more complex controls, like list boxes and tree controls to XML elements. I found myself writing the same code over and over, i.e. taking lists of XML elements and using them to instantiate rows into a listbox and back again. So this week I wrote that functionality into the base XML<->UI layer. I plan to apply the same idea to tree controls as well at some point, probably when the need arises. The main change to make that feasible was adding a virtual method to the GList class so that the UI glue code can ask the list item to read or write itself to XML.

I'm always a little careful about breaking the ABI, I'd rather not if it's all the same. But I think thats the great thing about Lgi, it's small enough not to worry about frozen versions that I can't change, if a change would improve the apps and make my life easy... do it.
 
Reply
From:
Email (optional): (Will be HTML encoded to evade harvesting)
Message:
 
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.
BBcode:
[q]text[/q]
[url=link]description[/url]
[img]url_to_image[/img]
[pre]some_code[/pre]
[b]bold_text[/b]