Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2002-11-17 13:44:33


From: brangdon_at_[hidden] (Dave Harris)
>>From the headers...
>> typedef unsigned char version_type; // upto 255 versions
>> namespace serialization_detail {
>> typedef unsigned short class_id_type; // upto 64k kinds
>> // of objects
>> typedef int object_id_type; // upto 2G objects
>> }

>It seems to me these limits are arbitrary, and in some cases rather low.
>Wouldn't it be better, and more general, to use int or long?

they are arbitrary. but unimaginably high in my view. more than 64K class
definitions in a program? maintaining compatibility with more than
256 previous versions of a particular class? more than 2G objects?
This is a problem?

>On a related note, I think variable length integers ought to be supported
>as primitive.

[snip]

>If we are saving in an ASCII format we wouldn't want to do this because ASCII is intrinsically
>variable length anyway.

you answered your own question.

But it touches upon another issue.

I have gone to great lengths to NOT include ANY non fundemental types as
primitives. The only exception is std::string and std:wstring.
The power of the library is the fact that it can be added used with
any set of classes in a completely orthogonal way. It makes
no presumptions about the data types a user want's to serialize
and no presumptions about the "storage medium". Attempts to
"make it more efficient" that alter these design decisions would
end up make it too complex to use.

>Are reference-counted objects supported? If I am using my own
>reference-counted class, what do I have to do to get serialisation to work
>for it?

[snip]

Serialization of boost::shared_ptr is included as an example. I believe
it address the issues you raise. It also is a good example of how
correct serialization can be implemented non-intrusively for one
of the most subtle examples in the boost library.

>I have looked at the posted code but I've not been able to figure it all
>out. I see lots of use of (T *), which is wrong.

whats wrong with it?

>I ask because in the past I have been bitten by Microsoft's MFC system,
>which makes no provision for reference counting.

reference counting is a function of any smart pointer being serialized
not of the serialization system itself - see above cited example.

>(1) The 1-step construction issue. In other words, whether:
>
> const MyClass object(ar);
>can be supported.

This should not be supported for reasons cited in previous post.

>(2) Whether the archive handles reference counts correctly.

This is addressed in the code an tested pretty rigoursly. I have
no evidence that there is any problem in this area. If you have
a counter example please submit it.

>(3) That variable length integers be supported. [ as a primitive]

This an extremely bad idea for reasons cited above

>(4) That the limits on version numbers etc are too small.

This suggests a lack of shared understanding as to what
the version numbers are used for. Have you a class for which
you need to maintain compatiblity with 255 previous versions?

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk