Boost logo

Boost Users :

Subject: Re: [Boost-users] Pointer serialization and deserialization
From: niranjan bangera (niranjannina_at_[hidden])
Date: 2009-03-10 01:59:07


Robert,

Yes the pointer is been initialized by NULL in the constructor of the class
of that pointer.

Thanks,
Niranjan

Do you know for a fact that the *pointer* has been initialized?

 Robert Ramey

"niranjan bangera"
<niranjannina_at_...<http://www.nabble.com/user/SendEmail.jtp?type=post&post=22416132&i=0>>
wrote in message
news:50a2f6f20903090457n37c0bfb2n3eec9d716a56c84c@...>
...
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