So, I found that I could use a array_sink and pass it the location and size of an array to use. But now I need to know, when bytes are written in, how much is written into it in order that I can get that exact data out. I also need to make sure that, in the case of something like not enough space occurring, I can still get the rest of the data compressed.

Is there anything that I can pass to an array_sink initializer other than a char * pointer that might help me accomplish this?


On Tue, Jan 14, 2014 at 8:20 AM, Kenneth Adam Miller <kennethadammiller@gmail.com> wrote:
I have an object for which operator << is defined, myobj.

I want to compress into a buffer, and I know that this can be done with boost. I would prefer a buffer that dynamically resizes, but that only allocates new space, preferably treating discontiguous space brought on by new allocations as though the whole buffer was one piece; I don't want to find that it's copying data at all. So vector won't work as a buffer; there's no need for it to be contiguous, just as fast as possible.

I've been trying to do this with filtering_istreambuf by pushing a bzip2_compressor (any compression filter will work). So far, it's giving me a lot of trouble. I did find an example where a string was passed to a function, but they went through a process where they first moved the string into an stringstream. I don't want to settle for that extra copy either.

What would be nice is to be able to do something like

compressor << myobj

compressor.buf(); //returns compressed myobj output