Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-07-13 12:32:12


I don't know that I can offer you a good solution. But here is what I can
come up with.

First a couple of relevant facts about the serialization library.

a) generally it saves in the archive only that information absolutely
required
to be able to recover the data. This is basad on design/efficiency
considerations.

b) In some cases it stores "optional" information. That it is, the archive
may be written to save and recover this information. Normally these
are just stubbed out as no ops.

c) In xml archives, information about object and class id and their
references is included in the xml. I'm don't remember whether its done
in the "optional" types or not.

c) class name was not considered as one of these optional types
    i) it wasn't deemed necessary
    ii) it is not always available. Many types (e.g. primitives) are
serialized
without calling the library code. For these cases the "optional" data
is not called.

So back to your situation.

What is really needed for you is the following:

a) some sort reflection for C++ so that you can write something like
t.name().
b) derive from xml_oarchive to invoke t.name() and insert it into
the xml stream output. Examples of deriving from one archive
type to produce another are in the documentation.

So the problem is "reduced" to making/finding something like t.name()
which returns a text string which can be inserted into the output stream.

This already exists on one form - the RTTI implementation uses
type_id(t).name to return a pointer to a name. This may be sufficient
for your needs. The only problem with it is that

a) the name will be mangled to a unique C++ name. This may not always
be user friendly.
b) the name will be mangled differently for each compiler.

If you can work with the above limitations - perhaps by massaging the
mangled name to something readable - this can probably be made to work
for you.

If not - you can use the name passed by BOOST_CLASS_EXPORT which
was "invented" to address the issues above. The only problem is that
BOOST_CLASS_EXPORT might not bedefined for all your types.

You should have enough here to craft a solution to your problem.

Good Luck

Robert Ramey

"Eduardo Ferro Aldama" <eduardo_ferro_at_[hidden]> wrote in message
news:OFCDA9E07E.A71F2EB0-ONC12571AA.003AE8AF-C12571AA.003AE8B4_at_carrefour.com...
Hi!

We are trying the boost's serialization-lib to serialize C++ objets to send
them throw the network. Initialy, we are use xml-serialization to facilitate
the inspect the comunications.

We are trying to develop a little tool to work/inspect this messages
(xml-serializated) but we need to develop this tool in another languaje (in
this case python) and We want that this tool don't need to know nothing
about
the original C++ clases.... In order to develop this tool we need add to the
output xml string information about the names of the class that we are
serializing

-Is possible to configure something to add the class name in the xml output
format?
probably

-Can we add any other information to taht format without disturb the
deserialization process??
you have to add it the ouput - and skip in on the input. xml input
archives already skip irrelevent attributes so this might not be a problem.

Some hint/tipo/doc to add this functionality without changing the boost-lib
source?
se above.

Thanks in advance
you're welcome in advanced

Please accept my apologies for my poor english
no problem - I live in california.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net