Boost logo

Boost Users :

Subject: [Boost-users] boost::serialization, archive not deserializing correctly
From: David Claridge (davidc_at_[hidden])
Date: 2009-11-25 21:17:27


Hi,

I'm trying to use the boost::serialization
text_iarchive/text_oarchive, in a way very similar to the tutorial
(http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/tutorial.html).

I have confirmed that the data that gets serialized is identical to
what is read in when I deserialize (in the code below inbound_data_ is
identical to the contents of the text_oarchive stream), however the
serialize function does not seem to work correctly.

The code to deserialize looks like:

std::string archive_data(&inbound_data_[0], inbound_data_.size());
std::istringstream archive_stream(archive_data);
boost::archive::text_iarchive archive(archive_stream);
archive >> t;

where the corresponding serialize() function is:

template<class Archive>
void Blackboard::serialize(Archive & ar, const unsigned int version) {
   ar & gameController.our_team;
}

(gameController.our_team is a member of the 'Blackboard' class)

when serializing, our_team is equal to 1, when deserializing, it gets
set to zero.

Any thoughts on what I might be doing wrong? I can post more details
of the code if that would be helpful.

Thanks!

--
Dave

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