Boost logo

Boost Users :

Subject: [Boost-users] Pointer serialization and deserialization
From: niranjan bangera (niranjannina_at_[hidden])
Date: 2009-03-09 07:57:21


Hi all,

Boost:1.38.0
compiler:gcc4.1.1

I am trying to serialize and deserialize a pointer to the class, but ended
with the segmentation fault, Is that the null pointer serialization gives
the segmentation fault?. I read in document that, library will maintain the
Null pointer. if not how can i serialize? ,any docs or related refference is
a;so acceptable. Thanks in advance....

one more thing: what -1 in archive(text_archive) indicates?

Example
------------

#include <fstream>
   #include "boost/archive/text_iarchive.hpp"
   #include "boost/archive/text_oarchive.hpp"
  #include "boost/serialization/access.hpp"
  #include "boost/serialization/assume_abstract.hpp"

class Dkpt
{

public:

  friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned int file_version)
    {
       (void) file_version;
          ar & data_;
          ar & b_i;
          ar & f_er;
          ar & pa_er;
          ar & ct_c;
  }

private:

uint8_t data_;
bool b_i;
bool f_er;
bool pa_er;
bool ct_c;

};

----
class RB : public RM
{
public:
  virtual void checkpoint_save(boost::archive::text_oarchive & oa)
  {
     oa & dr;
  }
  virtual void checkpoint_retrive(boost::archive::text_iarchive & ia)
  {
     ia & dr;
  }
private:
 Dkpt* dr;
;}
Thanks.
Niranjan


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