The easy way is to use:
 
    template<class Archive>
    void serialize(Archive & ar, const unsigned int file_version)
   {
       ar & tmpMap;
       ar & a;
       ar & d;
       ar & stringList;
   }
 
then input/output are always insync.
 
Robert Ramey
"sam p" <sameersp21@gmail.com> wrote in message news:c49aaa00808212055v39e5036habe307521a42d5b@mail.gmail.com...
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;
       ar & a;
       ar & d;
       ar & stringList;
   }
     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 & a;
       ar & d;
       ar & stringList;
       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


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users