Hi,
How to validate datatype before it gets deserialized?
e.g.
struct Abc
{
std::map<string,string> tmpMap;
int a;
float d;
std::list<string> stringList;
void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version)
{
ar & tmpMap;
}
void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version)
{
/////////////////////////////////////////////////////////////////////
/* Now the right thing to do over here is
ar & tmpMap;
ar & a;
ar & d;
ar & stringList;
*/
///////////////////////////////////////////////////////////////////////
//But instead, if by mistake user writes something like
ar & tmpMap;
/*
So how to handle such problem?
Can I validate data somehow before it gets deserialized?
On some platforms like SuSE linux I have observed that such thing doesn't throw exception and we get SEGV.
*/
}
};
Thanks,
Sameer