I have implement iostream wrappers around the zlib and bzip2 compression library. I emphasize that the zlib wrapper does not rely on gz methods and therefore it is not limited to file->buffer or buffer->file operation.

A simple example of the stream is as follows:

ostream& output; // suppose this reference is initialized

{
    zip_ostream zipper( output ); // creating a zipper on top of output
    // zipper behaves as any ostream
    zipper<<"hello";
    ...
} // when closed, the zipper is flushed.

That's it. Basically, these wrapper makes it very easy to add compression to existing applications. Any suggestions welcome :)


The demo application is in the yahoo files section, at http://f4.grp.yahoofs.com/v1/8I59P2nge463UXu3tTedwKzeExG8x4XegRqG4Q1Ovvt7RkgQba70tS6udf6RXviGTf1-UeE9HUE5Df2T-z6qgQdOEAlQ5os7UJTdtg/zipstream_demo.zip
You can also have  a look at an article that explains deeper zipstreams at http://www.codeproject.com/vcpp/stl/zipstream.asp

-----------------------------------------------------------------------------------
Jonathan de Halleux, Research Assistant
Center for Systems Engineering and Applied Mechanics (CESAME)
Universite catholique de Louvain
Batiment Euler , Av. Georges Lemaitre, 4 Tel : +32-10-47 2595
B-1348 Louvain-la-Neuve Belgium
E-mail : dehalleux@auto.ucl.ac.be
-----------------------------------------------------------------------------------