Boost logo

Boost Users :

From: sam p (sameersp21_at_[hidden])
Date: 2008-08-21 23:55:50


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 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