|
Boost Users : |
Subject: [Boost-users] Serialization / No Default Constructor / Messy
From: Dan Eaton (daniel.eaton_at_[hidden])
Date: 2009-05-12 19:31:09
Hi,
My question is similar to past questions asked regarding what to do when a class to be deserialized does not have a default constructor. I'm wondering, though, if there is any better way to support both the BINARY and TEXT archive types, than doing this:
class MyClass
{
public:
MyClass(int myVar);
MyClass( boost::archive::text_iarchive & ar )
{
ar >> *this;
}
MyClass( boost::archive::binary_iarchive & ar )
{
ar >> *this;
}
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /* fileVersion */ )
{
ar & myVar;
}
private:
int myVar;
}
Specifically, I'd rather not have to have a constructor for each type of archive!
Thanks :)
Danny
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