[serialization] boost::system::error_category
Dear list, I'm trying to write serialization code for Boost.System's error_codes, however I'm having trouble to serialize/deserialize an error_category, which are polymorphic singleton objects. I guess when saving, type information needs to be stored, like with polymorphic pointers? When loading, a global function (get_generic_category(), get_system_category(), etc.) could be used to obtain a reference to the singleton object. Is there any way to use the exported type information in such way that a reference to the correct singleton is obtained? Any suggestions on how to approach this? Thanks in advance, Kind regards, Rutger ter Borg
Rutger ter Borg wrote: [snip]
Any suggestions on how to approach this?
Sorry to be replying to myself, but being a couple of hours further down the road, I think I made little progress. I thought I could approach the serialization of a polymorphic singleton basically by saving its (polymorphic) pointer, and loading it back by overloading the load_construct data and assign the singleton object there. Unfortunately, I am dealing with an abstract base class (error_category) which is declared in boost/system/error_code.hpp. The definition and implementation of error_category singleton objects are not visible in the header files of the Boost.System library; it resides in the binary library file only. Which leaves me with an unregistered class. I'm unable to register it (because I can not access its definition), I tried to use forward declarations and export those, but that didn't work, too. I tried to export the base and derived relationship, without success, too. My next step would be to bypass serialization facilities and implement something like below save( ... ) { ar << category.name(); } load( ... ) { std::string name; ar >> name; if ( name == ... ) { } } Is there a way to register type information that is not seen yet by the serialization library (i.e., it will be linked in)? Is there a way to export classes that reside in a DLL? Thanks in advance, Kind regards, Rutger ter Borg
participants (1)
-
Rutger ter Borg