Aaron Isotton

Bz2stream

bz2stream is an implementation of input and output stream classes for the bz2 compression algorithm. They make it a snap to use bz2 compression in C++ programs transparently.

bz2stream defines four classes: a stream buffer to compress and one to decompress data using the bz2 algorithm, plus an input and an output stream class using the above stream buffers.

The stream buffers do not write directly to anything, but take another stream buffer as source or as destination. Thus a program decompressing bzip2 files from the command line might look like this:

#include "bz2stream.hpp"
#include <fstream>

int main(int argc, char** argv) {
    std::ifstream in(argv[1], std::ios::binary);
    std::ofstream out(argv[2], std::ios::binary);
    bz2istream bz2in(in.rdbuf());
    out << bz2in.rdbuf();
}

There is no need to link to any additional libraries as the implementation is all in one file. (You still need to link against libbz2, of course.)

Documentation

HTML documentation is included in the archive. You can also browse it online.

Notice: This is an early release. I've tested it, and it worked, but that does not mean that it is good, tested and stable code suitable to be used in critical applications. I am quite confident in the compression code; sadly I cannot say the same about the decompression part. It might even not work at all.

Download

Version 0.1.2: bz2stream-0.1.2.tar.gz (30 KB)

Version 0.1.1: bz2stream-0.1.1.tar.gz (30 KB)

Version 0.1.0: bz2stream-0.1.0.tar.gz (26 KB)