Boost logo

Boost Users :

From: Ioannis Papadopoulos (ipapadop_at_[hidden])
Date: 2008-06-23 22:09:39

Robert Ramey wrote:
> You're making this way, way, way too hard.
> All current archives are implemented in terms of standard library
> input/output.
> Study the standard library.
> You will find that you can make your own custom streambuf and
> attach that to stream. This is how stringstream is implemented.
> Then instanticiate an archive using a stream with your custom
> streambuf and serialize to that. This is not hard to do and
> would provide a universal solution for all archives. Actually
> I would expect a web search would turn up source code
> for making a custom streambuf as this is the way the
> standard library was designed to be used.
> Of course if you're really lazy, you can just serialize
> to a string stream, retrieve the size of the string
> and throw it away. But that's too lazy - even for me.
> Robert Ramey
> Oh - if you've got nothing else to do, you can make a streambuf
> which does nothing but calcuates a CRC. I would find that
> useful.
> RR

I was hoping to minimize the virtual functions calls as much as
possible. I'm not trying to be lazy, I'm trying to optimize for speed
without reinventing Boost.Serialization.

Thanks for the tip though, I implemented it the way you recommend (it's
only five LoC).

> Ioannis Papadopoulos wrote:
>> Hi,
>> I want to calculate exactly how much space it is needed to serialize a
>> number of objects. What I'm thinking is another class that implements
>> the Saving Archive concept and only invokes sizeof() rather than
>> actually writing anything.
>> From what I understand I should overload the << and & operators for
>> this class to call save() or serialize() on the object, unless it is a
>> POD (in which case the size is already known).
>> Has this been done before?
>> Thanks

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at