serialization-lib add user info to XML format

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? -Can we add any other information to taht format without disturb the deserialization process?? Some hint/tipo/doc to add this functionality without changing the boost-lib source? Thanks in advance Please accept my apologies for my poor english -- Eduardo Ferro Aldama Desarrollo TPVs (Gestión Stock) Tlf 91 5142101 Ext:2101 Ce message électronique et tous les fichiers attachés sont confidentiels et destinés exclusivement à l'usage de la personne à laquelle ils sont adressés. Si vous n'êtes pas le destinataire de ce message, merci d'avertir ou de le retourner à son émetteur et détruire ce message électronique et tous les fichiers attachés de votre système informatique. La publication, l'usage, la distribution, l'impression ou la copie non autorisée de ce message et des attachements qu'il contient sont strictement interdits. This e-mail and any attachment are confidential and intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited. Este correo electrónico y todos los ficheros adjuntos son confidenciales y destinados exclusivamente al uso de la persona a la cual han sido remitidos. Si Usted no es el destinatario del mensaje, agradecemos advierta al remitente y elimine el mensaje y sus adjuntos de su sistema. La publicación, distribución, impresión o copia no autorizada de este mensaje y de sus adjuntos queda estrictamente prohibida.

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"
participants (2)
-
Eduardo Ferro Aldama
-
Robert Ramey