can we separate the main serialize method in different class to make it easier and less complex using boost libraries for c++? -


how separate serialize method code , encapsulate class don't have write in every class create.

class test   {   private:           friend class boost::serialization::access;      template<class archive> void serialize(archive & ar,               const unsigned int version)        {           ar & boost_serialization_nvp(a);           ar & boost_serialization_nvp(b);           ar & boost_serialization_nvp(emp);      }        int a;      int b;      employee *emp;  public:       test(int a, int b,int c, int d)       {           this->a = a;           this->b = b;          emp = new employee(c,d);      }   };  

as written in docs can use free function serialize class. of course requires data members public.

for "real" classes hide data define "serialization struct" gets passed in , out of real class serialization purposes.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -