Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Object serialization

0 views
Skip to first unread message

ds

unread,
Sep 7, 2007, 6:29:10 AM9/7/07
to
Hi all,

this is more a poll to ask for opinions and experiences on
serialization of objects. What toolkit do you use? If not using a
toolkit do you have your own serialization framework? What techniques
are you using? I used the boost serialization framework but - besides
the fact of having all the macros and recursive templates - it does
not work with objects from different dlls, so I am looking for
something else. Any help appreciated!!!!

BR

-- dimitris

Daniel T.

unread,
Sep 7, 2007, 6:37:45 AM9/7/07
to
ds <junkma...@yahoo.com> wrote:

> this is more a poll to ask for opinions and experiences on
> serialization of objects.

http://www.parashift.com/c++-faq-lite/serialization.html

Warren Kenny

unread,
Sep 7, 2007, 6:49:26 AM9/7/07
to

I tend to write my own per-class serialize and deserialize methods. To
back them up, I use a class I've written as part of the General
Systems Library project; gsDataPacker. It's a simple class with
template methods for packing and unpacking primitive types into and
out of data buffers. When I want to build serialization into a class,
I use gsDataPacker's static methods to pack and unpack member objects.
It's a simple approach that works quite well.

co...@mailvault.com

unread,
Sep 7, 2007, 5:57:14 PM9/7/07
to
On Sep 7, 4:29 am, ds <junkmailav...@yahoo.com> wrote:
> Hi all,
>
> this is more a poll to ask for opinions and experiences on
> serialization of objects. What toolkit do you use? If not using a
> toolkit do you have your own serialization framework? What techniques
> are you using?

If you are talking about binary serialization you could
consider www.webebenezer.net.

>I used the boost serialization framework but - besides
> the fact of having all the macros and recursive templates - it does
> not work with objects from different dlls, so I am looking for
> something else. Any help appreciated!!!!
>

I don't know if it works with objects from different dlls, but
it doesn't require macros or friend declarations. It is an
online service so downloading, building and maintaining
the installation aren't required.

Brian Wood
Ebenezer Enterprises

ds

unread,
Sep 10, 2007, 3:57:05 AM9/10/07
to

Hi Brian,

BOOST_SERIALIZATION_SPLIT_MEMBER, BOOST_CLASS_VERSION and so on are
macros that make my code impossible to read and maintain, because if
something goes wrong, I don't have the code that gets compiled, as it
is the case now for me...

Regards,

Dimitris

co...@mailvault.com

unread,
Sep 11, 2007, 6:29:45 PM9/11/07
to

Shalom, Dimitris,

The B.Ser author has used macros liberally and the result is
not surprising. The BOOST_CLASS_VERSION macro is kind of the
tip of an iceberg. I'm skeptical of the approach to version support
advanced by Boost. It encourages users to have one
class for multiple releases and use if statements to figure
out which fields to work with based on the version number.
I think having separate classes when something needs to be
changed between releases is a better approach. Consider the following
scenario:

AccountBase {};

Account : public AccountBase {};

Account_13 : public Account {};

Say there are releases 1.1, 1.2 and 1.3. The Account
class is used in 1.1 and 1.2 but needs to be changed
in 1.3. The 1.3 server needs to support 1.1 and 1.2
clients. The Boost approach suggests using one class,
I'll call it B_Account, to support all of the releases.
Using a B_Account to support 1.1 clients (in a 1.3 server)
is probably wasting memory/time because it has fields in
support of 1.3 as well. And if a 1.3 client sends a
B_Account and an error occurs in the reception of the 1.3
part of the class, there is no sane way to use the 1.1
portion.

I'll explain how this could be handled better now.
Currently in C++, if the constructor of a derived
class throws an exception, the already constructed
sub objects will be destructed. IMO this default
behaviour is dubious in distributed apps. It should
be possible to write something like:

AccountBase* account = new (preserve) Account_13(...);

that would preserve a successfully constructed Account
object when an exception is thrown from Account_13's
constructor. The sender, network and receiver of the
object have put in too much work to throw it all away.
The 1.3 server is able to work with 1.1 Accounts
already so this fits in well with the big picture.

If I were using B.Ser I would want to avoid what it
refers to as "versioning" support.

Brian Wood
Ebenezer Enterprises
www.webebenezer.net

0 new messages