Re: [Boost-users] [Serialization] purpose of GUID

Hi, I am a bit confused about the purpose of GUID. My understanding was, that it is a user defined id for a class, so that the serialization mechanism knows what types to instanciate on load. I somehow assumed it to be a replacement (or equivalent) of the numbers in the class_id attributes. by inserting: BOOST_CLASS_EXPORT_GUID( bus_schedule, "BusSchedule" ); I'd expected to find something like: <schedule class_id="BusSchedule" in the xml file, but I get only: <schedule class_id="1" I know that another purpose of the BOOST_CLASS_EXPORT family of macros is to instanciate the <Archive, T*> pairs, but what is the "BusSchedule" string then for. If my assumption was right, where do I have to place the macros exactly then. I tried at the end of the header with the classes. I then tried at the beginning, after the includes. That didn't work unless I forward declared the classes (no surprise really). Also, is there some docs/tutorials/further reading on xml archives. I am probably going to make my own archive, and need to understand more about the mechanism. Thanks for your help, Ingo

"Ingo Nolden" <nuttygraphics@gmx.de> wrote in message news:20070515191535.399222F8109@wowbagger.osl.iu.edu... Hi, I am a bit confused about the purpose of GUID. My understanding was, that it is a user defined id for a class, so that the serialization mechanism knows what types to instanciate on load. I somehow assumed it to be a replacement (or equivalent) of the numbers in the class_id attributes. *** This is correct. But the "text ID" (GUID) is used only as a last resort. That basically boils down to derived pointers. In other cases, the archive local class id can be generated and used instead. So that's what the serialization library does Robert Ramey

Thank you for your answer, I understand now. I saw the code, that would use the name. But I couldn't see why it was not invoked. My actual intent is to use boost::serialization in a very special way. I am going to write a xml_archive replacement, that will enable me to read nearly arbitrary xml. My first plan was to write an own serialization. After looking into boost::serialization I thought it wouldn't be clever to not use as much of this great code as possible. I especially appreciate that the serialize function does not need to be virtual, and therefore can accept a non polymorphic archive. It seems there is a great level of savvy gone into that part. An alternative for me would be to use an xml-parser directly. But that would not give me the option to model the xml by means of c++ classes. Maybe somebody knows a library or some building blocks that may take me a step closer to my goal? Ingo At 03:55 16.05.2007, you wrote:
"Ingo Nolden" <<mailto:nuttygraphics@gmx.de>nuttygraphics@gmx.de> wrote in message <news:20070515191535.399222F8109@wowbagger.osl.iu.edu>news:20070515191535.399222F8109@wowbagger.osl.iu.edu... Hi,
I am a bit confused about the purpose of GUID. My understanding was, that it is a user defined id for a class, so that the serialization mechanism knows what types to instanciate on load. I somehow assumed it to be a replacement (or equivalent) of the numbers in the class_id attributes.
*** This is correct. But the "text ID" (GUID) is used only as a last resort. That basically boils down to derived pointers. In other cases, the archive local class id can be generated and used instead. So that's what the serialization library does
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

"Ingo Nolden" <nuttygraphics@gmx.de> wrote in message news:20070516202821.34C172F83E5@wowbagger.osl.iu.edu... Thank you for your answer, I understand now. I saw the code, that would use the name. But I couldn't see why it was not invoked. My actual intent is to use boost::serialization in a very special way. I am going to write a xml_archive replacement, that will enable me to read nearly arbitrary xml. *** my personal view is that this is not possible. Boost serialization archives are intimately coupled to the C++ data structures they correspond to. My first plan was to write an own serialization. After looking into boost::serialization I thought it wouldn't be clever to not use as much of this great code as possible. I especially appreciate that the serialize function does not need to be virtual, and therefore can accept a non polymorphic archive. It seems there is a great level of savvy gone into that part. *** There are tools which take an arbitrary XML schema and produce a corresponding C++ data structure. This is the opposite of Boost Serialization. If you're looking for a project, you could make a version/derivative/add-on to the xml_oarchive which produces and xml schema along with the archive itself. Then the archive would be browsable with standard xml tools. I considered this idea when making the xml_archive but concluded it wasn't necessary to meet the minimal requirements for acceptance. Robert Ramey

At 05:43 17.05.2007, you wrote:
"Ingo Nolden" <<mailto:nuttygraphics@gmx.de>nuttygraphics@gmx.de> wrote in message <news:20070516202821.34C172F83E5@wowbagger.osl.iu.edu>news:20070516202821.34C172F83E5@wowbagger.osl.iu.edu...
Thank you for your answer,
I understand now. I saw the code, that would use the name. But I couldn't see why it was not invoked. My actual intent is to use boost::serialization in a very special way. I am going to write a xml_archive replacement, that will enable me to read nearly arbitrary xml.
*** my personal view is that this is not possible. Boost serialization archives are intimately coupled to the C++ data structures they correspond to.
Yes, but I though if I write an own archive class that should somehow be possible. It seems it will not be really easy though.
My first plan was to write an own serialization. After looking into boost::serialization I thought it wouldn't be clever to not use as much of this great code as possible. I especially appreciate that the serialize function does not need to be virtual, and therefore can accept a non polymorphic archive. It seems there is a great level of savvy gone into that part.
*** There are tools which take an arbitrary XML schema and produce a corresponding C++ data structure. This is the opposite of Boost Serialization.
I just downloaded CodeSynthesis, and I will give it a try. Perhaps it is a good solution for the meanwhile.
If you're looking for a project, you could make a version/derivative/add-on to the xml_oarchive which produces and xml schema along with the archive itself. Then the archive would be browsable with standard xml tools. I considered this idea when making the xml_archive but concluded it wasn't necessary to meet the minimal requirements for acceptance.
The advantage, of using a general serialization library is, that it will output binary and any other kind of data as well. That makes it a no 1 choice. Also, the generation of an xml-schema would be nice. On the other hand, if the schema can be used to generate classes for boost::serialization, that would be even better... By the way. Is there a place where people share *archive implementations for boost::serialization ? Thanks for your help so far. It takes me a good step ahead. Ingo
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

"Ingo Nolden" <nuttygraphics@gmx.de> wrote in message news:20070515191535.399222F8109@wowbagger.osl.iu.edu... Hi, I am a bit confused about the purpose of GUID. My understanding was, that it is a user defined id for a class, so that the serialization mechanism knows what types to instanciate on load. I somehow assumed it to be a replacement (or equivalent) of the numbers in the class_id attributes. *** You're correct. But the GUID is used only when the more robust method of an archive local class ID is not possible. Robert Ramey
participants (2)
-
Ingo Nolden
-
Robert Ramey