[Serialization]class(type) name in xml archive?
Is it possible to add class(type) name in xml archive? It would be a big help when looking at the xml output (yes, we want to display those files). for example (from demo.xml): <s type="bus_schedule" class_id="0" tracking_level="0" version="2"> ^^^^^^^^^^^^^^^^^ Thanks, Sean
If you use BOOST_CLASS_EXPORT(my_type) you will get the type name ala class_name="my_type" under the following conditions. a) its a polymorphic derived pointer. b) its the first time that that type is used That may be helpful - but that's the best I can do. Note that the class_id # in the xml output indicates which type is being handled. I would hope that some sort of XML viewer could make sense of it. If you had nothing else to do you could probably enhance this output - I already responded to someone who wanted to do this - but I don't remember if it was via private email or here. Robert Ramey Sean Huang wrote:
Is it possible to add class(type) name in xml archive? It would be a big help when looking at the xml output (yes, we want to display those files). for example (from demo.xml): <s type="bus_schedule" class_id="0" tracking_level="0" version="2"> ^^^^^^^^^^^^^^^^^
Thanks,
Sean
----- Original Message -----
From: "Robert Ramey"
That may be helpful - but that's the best I can do. Note that the class_id # in the xml output indicates which type is being handled. I would hope that some sort of XML viewer could make sense of it.
Do you think it is reasonable to add an option so that users could choose to include class names? I do not mind adding a lookup table at the end of the archive that maps class_id to class_name. But I do not see an easy way to do that. Can you shed some light on it? Thanks, Sean
The library implementation strives to avoid including redundant data in the archive. That's why things are the way they are. Note that you've expressed a desire to do this in order to support the edit of XML archives. In the past I've suggested that this is a bad idea and my opinion hasn't changed. But if you insist you want to do it. Make a derivation of xml_archive which does the following. Overrides the serialization of class id, load, object_id etc to maintain a table which relates object_id -> class_id -> class_name. Then overide serialization of save to lookup the class_id, and class name in the table an add them to the file. This won't be terrible efficient - but heck - its XML so its not going to be efficient anyway. Good luck. Robert Ramey Sean Huang wrote:
----- Original Message ----- From: "Robert Ramey"
To: Sent: Thursday, October 13, 2005 4:33 PM Subject: Re: [Boost-users] [Serialization]class(type) name in xml archive? That may be helpful - but that's the best I can do. Note that the class_id # in the xml output indicates which type is being handled. I would hope that some sort of XML viewer could make sense of it.
Do you think it is reasonable to add an option so that users could choose to include class names? I do not mind adding a lookup table at the end of the archive that maps class_id to class_name. But I do not see an easy way to do that. Can you shed some light on it?
Thanks,
Sean
participants (2)
-
Robert Ramey
-
Sean Huang