[GCC-XML] Xrtti.h

Bryan Ischo bji-gccxml at ischo.com
Wed Apr 25 23:34:06 EDT 2007


> This is really nice.
>
> Just a thought, are you using pygccxml to parse the GCCXML and generate
> the reflection dictionary?

Thank you for your kind words.

No, I do not use pygccxml, I use gccxml directly.  The generated GCCXML
output is parsed by my program, called "xrttigen", that outputs a .cpp
file that you can compile.  This file contains a big table of all
reflection data.  You do have to "register" this table at runtime by
calling "Xrtti::Register(generated_table);".  I have in the past
experimented with auto-registration using static class constructors, but I
believe that bugs in g++ prevented this from working.  It may work better
now that g++ version 4 is out, I haven't tried it in a while.


> BTW, I have been thinking on working on the C++ object serialization of
> data as well. In my case the specification would be in the XSD.

Yes, there is considerable interest I think in serializing C++ objects to
XML.  I personally have no interest in XML and prefer compact binary
formats.  There already exist some projects to do C++ serialization into
XML (and other formats), such as Boost::Serialization, and s11n.  But
these all require that the developer essentially implement serialization
manually for each class using macros provided by the tool.

As you have probably already decided for yourself, it would be much nicer
if a tool took care of all of this for you, so that there is no effort
needed on the part of the programmer (aside from running an extra program
during build time) to have serialization of C++ objects.

GCCXML fits perfectly into this, because it provides a way to parse enough
information out of C++ class definitions to create serialization methods
for those classes.

> I was planning to combine the concepts of these two tools to accomplish
> for any kind of customization of class generation and serialization,
>
> 	A. http://www.rexx.com/~dkuhlman/generateDS.html
> 	+ This has code that can understand the XSD type and generate
> python 	  classes, but can be extended to generate cpp classes (possible
> use 	  py++)
> 	- Does not preserve the data types (needed for serialization)
>
> 	B.
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498149
> 		Has a nice way to represent the data types that can be
> used to 		generate the C++ serialization code.
>
> I am going to try 2 first for my needs.

When I release Xrtti, you might also consider basing your tool on it.  It
will provide enough type information for you to generate C++ serialization
into and out of XML.

I have as a personal goal as a developer to never use XML unless I
absolutely have to.  I have a variety of reasons for disliking it, and
this is not the proper forum for going into that; but my point is that
even though I intend to write a tool which would do essentially what you
are talking about - use C++ reflection via a GCCXML-based tool to generate
serialization methods for C++ objects - I will use a well-defined binary
format for the serialized form instead of XML.  So if you need XML, my
serialization project would not be interesting to you.  Still, you might
find the Xrtti system that my serialization project will be based on, to
be a good basis for your XML serialization efforts.

> One more benefit is that, you can also generate any form of
> serialization once you got the XSD definition and Class generation
> right. I have three use cases, binary, XML and human readable format for
> logging purposes.

I prefer to serialize always to binary, keeping the serialization itself
well defined, compact, and simple.  I would write a separate library for
converting binary serialized objects to/from human-readable form or
(shudder) XML.

> This would be in next one month or so...

Please keep me updated on your progress.  I would be happy to supply you a
release of Xrtti as a basis for your XML serialization, if you would find
it useful.

Very best wishes,
Bryan

------------------------------------------------------------------------
Bryan Ischo                bryan at ischo.com            2001 Mazda 626 GLX
Hamilton, New Zealand      http://www.ischo.com     RedHat Fedora Core 5
------------------------------------------------------------------------





More information about the gccxml mailing list