Check out the Boost Iostreams
As an example, I created the following file from the command line:
$ echo "this is the first line" > file $ echo "this is the second line" >> file $ echo "this is the third line" >> file $ bzip2 file $ file file.bz2 file.bz2: bzip2 compressed data, block size = 900k
Then I used boost :: iostreams :: filtering_istream to read the results of the unzipped bzip2 file named file.bz2.
#include <boost/iostreams/device/file.hpp> #include <boost/iostreams/filter/bzip2.hpp> #include <boost/iostreams/filtering_stream.hpp> #include <iostream> namespace io = boost::iostreams; /* To Compile: g++ -Wall -o ./bzipIOStream ./bzipIOStream.cpp -lboost_iostreams */ int main(){ io::filtering_istream in; in.push(io::bzip2_decompressor()); in.push(io::file_source("./file.bz2")); while(in.good()){ char c = in.get(); if(in.good()){ std::cout << c; } } return 0; }
The result of the command is decompressed data.
$ ./bzipIOStream this is the first line this is the second line this is the third line
Of course, you did not read the data symbol by nature, but I tried to keep this example simple.
source share