Boost logo

Boost Users :

Subject: [Boost-users] help on build and write pointer to socket in raw mode
From: boost_at_[hidden]
Date: 2011-04-12 12:57:54


On Mon, 11 Apr 2011 22:06:01 -0700 (PDT), Jerry wrote:
 Thanks Robert.
You mis-understood my intention. What we want is to serilaize an derived
type object directly (not throught base type pointer) but deserialize it to
a base type pointer. So we want the exactly the following codes:   Derived
d;
oa > b;   But it seems this does not work. The reason we prefer this is
that we have three nodes. One node sends/serialize the derived type object,
while two other nodes are receivers. Howerver, one receives/deserializes
the obj via derived type and the other deserializes the obj via base type
pointer. We want,   // The sender Derived d;
oa > b;   // The
other Receiver  Derived dcopy; ia >> dcopy;       On Tue, Apr 12, 2011 at
2:14 PM, Robert Ramey [via Boost] wrote:
 Jerry wrote:
> I know that we
can serialize/deserialize a derived type through a
> base type pointer
(using register_type()). But I cannot serialize a
> derived type and
deserialize it through a base type pointer. It seems
> to me the data type
in serialization and deserialization should be
> extactly the same one.

when you serialize through a derived type, extra information
 about the
derived type isn't saved as it's assumed it will
be deserialized the same
way.

>
> What I want is,
>
> Base{...};
> Derived : Base{...};
>
>
//Derived d;
 Base *d = new Derived; // use this instead !!

>
boost::archive::binary_oarchive oa(...);
> oa
> Base *b;
>
boost::archive::binary_iarchive ia(...);
> ia.register_type();
> ia >> b
 // Deseiralize to a base type pointer
>
> I have tried this but it does
not work. Is there any way to make this
> work?
>
> Many thanks!!!

_______________________________________________
 Boost-users mailing
list
[hidden email] [1]

http://lists.boost.org/mailman/listinfo.cgi/boost-users
[2]

-------------------------
 If you reply to this email, your message
will be added to the discussion
below:http://boost.2283326.n4.nabble.com/Serialization-How-to-serialize-a-derived-type-but-deserialize-it-as-a-base-type-pointer-tp3440971p3443692.html
[3]

-------------------------
 View this message in context: Re:
[Serialization] How to serialize a derived type but deserialize it as a
base type pointer? [4]
 Sent from the Boost - Users mailing list archive
[5] at Nabble.com.

Links:
------
[1]
http://user/SendEmail.jtp?type=node&node=3443692&i=0&by-user=t
[2]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
[3]
http://boost.2283326.n4.nabble.com/Serialization-How-to-serialize-a-derived-type-but-deserialize-it-as-a-base-type-pointer-tp3440971p3443692.html?by-user=t
[4]
http://boost.2283326.n4.nabble.com/Serialization-How-to-serialize-a-derived-type-but-deserialize-it-as-a-base-type-pointer-tp3440971p3443724.html
[5]
http://boost.2283326.n4.nabble.com/Boost-Users-f2553780.html



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