Re: Serializing objects derived from GObject to XML
- From: Jacob Kroon <jacob kroon gmail com>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtk-list gnome org
- Subject: Re: Serializing objects derived from GObject to XML
- Date: Fri, 07 Apr 2006 01:41:16 +0200
Very nice, I managed to get something functional without that much hard
work using libxml2 + gobject_class_list_properties() and some other
basic gobject property introspection.
Thanks Murray, Tristan
On Wed, 2006-04-05 at 18:15 +0200, Murray Cumming wrote:
> On Wed, 2006-04-05 at 17:50 +0200, Jacob Kroon wrote:
> > Hi,
> >
> > I'm looking for a way to serialize GObject-derived classes into XML. I'm
> > basically writing a block-diagram editor, similar to Simulink/Matlab,
> > where I have a Diagram class, and diff. block classes, and I'd like to
> > be able to save the diagrams to a file, so my idea is to implement a way
> > to serialize the blocks and the diagram. All interesting attributes are
> > implemented as GObject attributes, so if I can could implement
> > block_to_xml() and diagram_to_xml() functions, things would work out
> > nicely I think. Of course I would have to go the other way too, when
> > loading diagrams, xml_to_block() and xml_to_diagram().
> >
> > The trouble is I don't really know where to start, is this something
> > that has been documented elsewhere, or does anyone know of some example
> > code or ideas I could look into?
> >
> > My initial idea is to implement some sort of GObject serializer, which
> > outputs the classname, and the same for all properties the GObject has
> > registered.
> >
> > Any comments would be most welcome!
>
> You can iterate over the properties. The get_properties() function here
> does that, after instantiating an object of a particular type
> http://cvs.gnome.org/viewcvs/glibmm/tools/extra_defs_gen/generate_extra_defs.cc?view=markup
>
> You would just need to add some code to get the values of a specified
> instance.
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]