Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] deserialized instance empty even though proper serialize methods called [Honeywell Internal]
From: Hickman, Steve (AdvTech) (Steve.Hickman_at_[hidden])
Date: 2014-05-29 14:28:01


Classification: Honeywell Internal
All serialized classes have
BOOST_CLASS_EXPORT_IMPLEMENT(fully_qualified_class_name) in the .cpp file (at the end of file)
BOOST_CLASS_EXPORT_KEY(fully_qualified_class_name) in the .hpp file outside of all namespaces (at the end of file)

In addition, I have a static template (templated on Archive type) method that calls ar.register_type for all serialized library classes. This method is called for both the output and the input archive before any serialization is done. This insures that all the library classes are registered with the archive in the same order. I do not attempt to register classes that I have not defined (e.g. std::string, ...). I do include the serialization headers for these types. (e.g. <boost/serialization/string.hpp>,...)

I found that just using the macros was insufficient. In that case, the proper serialize methods were not called by the deserializing application (serialization worked fine). Adding the call that registers the library classes on both the input and output archives results in the proper serialize methods being called on both serialization and deserialization.

However, even with this, the fields in the instance after deserialization have only default values.

I did not detect any serialization exceptions during either serialization or deserialization.

Note that I get the same behavior if I use manually created default constructors (AFAICT all my default constructors initialize all members to something). I do not get any uninitialized data exceptions.

---
Steve H.
From: Robert Ramey [mailto:robertmacleranramey_at_[hidden]]
Sent: Thursday, May 29, 2014 9:28 AM
To: boostusers_at_[hidden]
Cc: boost-users_at_[hidden]; boost-users_at_[hidden]; Hickman, Steve (AdvTech)
Subject: Re: [Boost-users] [serialization] deserialized instance empty even though proper serialize methods called
When running tests where the same EXE serializes then deserializes everything works (I'm serializing to/from XML, text and binary).  When running tests where I serialize in one EXE then deserialize in another EXE, (using text archives on both sides) the serialization works fine and the deserialization appears to work fine (all the appropriate deserialize methods are called), but the resulting object contains none of the data. The data is arriving at the receiving/deserializing application as a string which is then placed in a stringstream and that is used to initialize a text_iarchive.
The serialize methods use BOOST_SERIALIZATION_NVP since this is set up to handle XML as well. After each line such as this:
   ar & BOOST_SERIALIZATION_NVP(valid);
I would expect the referent member variable to be set, but it does not change. Nor has anything changed when examining the created instance after deserialization has completed.
Look into the documentation for the topic - "registration".  When serializing only through pointers, one needs to give the compiler some more info on what the base types are.  Look for topics "register" and EXPORT
Robert Ramey
============================================================================================================================================================================================================
This message classified as Honeywell Internal by Hickman, Steve (AdvTech) on Thursday, May 29, 2014 at 11:28:00 AM.
The above classification labels are in accordance with the Honeywell Corporate Classification Policy. The information contained in this electronic message is confidential and intended only for the use of the individual/entity named above, and the information may be privileged. If you, the reader of this message, are not the intended recipient or an employee or agent responsible to deliver this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and delete the original message.
============================================================================================================================================================================================================


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