Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-09-25 11:47:46


Its hard to understand what you're trying to - but I'll guess anyway.

Sounds like you want to do something like leave the pointers as they are just change the values they point to.

So maybe you want something like:

template<class Archive>
void A::serialize(Archive &ar, const unsigned int version){
    ar & *m_pi;
}

Just a guess.

Good Luck

Robert Ramey

  "Anna Kloper" <annakloper_at_[hidden]> wrote in message news:20060925063658.8147.qmail_at_web56804.mail.re3.yahoo.com...
  Hi all,
  I'm new to BOOST and need help with this kind of problem of pointers serialization:

  class A{
  public:
  A(int *anInt):m_pi(anInt){}
  ~A(){}
  private:
  int *m_pi;
  };

  class B{
  public:
  B(int *anInt):m_a1(anInt),m_a2(anInt){}
  ~B(){}
  private:
  A m_a1;
  A m_a2;
  };

  int main()
  {
  int i=1;
  B b(&i);
  //serialize b

  i=2;
  //serialize b

  //de-serialize b expected i = 1 and b.m_a1=b.m_a2=1
  //de-serialize b expected i = 2 and b.m_a1=b.m_a2=2

  }

  Now, assuming that there are serialization functions for class A and B I'd like to serialize object b swice with track never so that when de-serializing b I'd like b to contain a pointer to the location of i. The problem is that when I de-serializing b I notice that b doesn't pointer to the location of i anymore but to another location.
  I need this for serializing of communication, so I need to save all the data trough a pointer and read the data back step by step for preprocessing to the same location in the memory.

  Is there anything I can do to overcome this problem with pointers?

  Thank you in advance, Anna.

------------------------------------------------------------------------------
  Do you Yahoo!?
  Everyone is raving about the all-new Yahoo! Mail.

------------------------------------------------------------------------------

  _______________________________________________
  Boost-users mailing list
  Boost-users_at_[hidden]
  http://lists.boost.org/mailman/listinfo.cgi/boost-users



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