| 1 | #include <iostream>
|
|---|
| 2 |
|
|---|
| 3 | #include <boost/iostreams/filtering_stream.hpp>
|
|---|
| 4 | #include <boost/iostreams/copy.hpp>
|
|---|
| 5 | #include <boost/iostreams/device/back_inserter.hpp>
|
|---|
| 6 | #include <boost/iostreams/filter/bzip2.hpp>
|
|---|
| 7 |
|
|---|
| 8 | using namespace std;
|
|---|
| 9 |
|
|---|
| 10 | int main()
|
|---|
| 11 | {
|
|---|
| 12 | string source("Original");
|
|---|
| 13 | string bzip2String;
|
|---|
| 14 |
|
|---|
| 15 | // Create compressing stream based on original input
|
|---|
| 16 | boost::iostreams::filtering_istream compressingStream;
|
|---|
| 17 | compressingStream.push(boost::iostreams::bzip2_compressor());
|
|---|
| 18 | compressingStream.push(boost::make_iterator_range(source));
|
|---|
| 19 |
|
|---|
| 20 | boost::iostreams::copy(compressingStream, boost::iostreams::back_inserter(bzip2String));
|
|---|
| 21 |
|
|---|
| 22 | cerr << "length of bzip2String: " << bzip2String.size() << endl;
|
|---|
| 23 |
|
|---|
| 24 | return 0;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|