Boost logo

Boost Users :

Subject: Re: [Boost-users] [archive] binary archive to memory stream
From: John Maddock (boost.regex_at_[hidden])
Date: 2014-06-18 11:56:48


> I am wrapping my head around archive, specifically binary archive.
>
> I'd like to serialize a vector of objects in such a way, I need to
> capture intermediate vector buffers (literally, to vector of uint8_t)
> so that I can determine their sizes.
>
> After which point the parent object(s) can serialize to file using
> more conventional, built-in file streams and such.
>
> It seems that binary_oarchive is helpful, but still requires there be
> an ostream or streambuf in the mix. Which, as an adapter layer, while
> helpful, it still leaves the question of extending streambuf to work
> with ostream to vector<uint8_t> open.
>
> I've read some docs on vectors and streambuf, but they all seem to be
> geared towards a known-size vector, istream and such. I am interested
> in a vector that can be streamed to, will grow in size, etc. Some
> clues seem to hint at underflow, overflow type issues?
>
> Any helpful pointers how to go about doing this?

Rather than serializing to a vector, can you not serialize to a
stringstream opened in binary mode? I believe that will still give you
all the information you require?

HTH, John.


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