diff options
author | Patrick Simianer <p@simianer.de> | 2011-08-29 22:02:45 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2011-09-23 19:13:58 +0200 |
commit | aceb387526478e34e41db6c046f707234953e0b5 (patch) | |
tree | 3cb19b9f1c3390d52c4a732e22a3b31b52e4f483 /dtrain/test/compression-test.cc | |
parent | 2001f2c1c96049b78f9aa5aaa05aeca26e3fc55a (diff) |
big update: working iterating, pretty output, test scripts and more
Diffstat (limited to 'dtrain/test/compression-test.cc')
-rw-r--r-- | dtrain/test/compression-test.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/dtrain/test/compression-test.cc b/dtrain/test/compression-test.cc new file mode 100644 index 00000000..29a1a420 --- /dev/null +++ b/dtrain/test/compression-test.cc @@ -0,0 +1,49 @@ +#include <iostream> +#include <fstream> +#include <boost/iostreams/device/file.hpp> +#include <boost/iostreams/filter/zlib.hpp> +//#include <boost/iostreams/filter/bzip2.hpp> +#include <boost/iostreams/filter/gzip.hpp> +#include <boost/iostreams/filtering_stream.hpp> + + + +using namespace boost::iostreams; +using namespace std; + +int main() +{ + + + //ofstream raw("out-raw"); + filtering_ostream out_z; + out_z.push(gzip_compressor()); + //out_gz.push(gzip_compressor()); + out_z.push(file_sink("out-z", std::ios::binary)); + //out_gz.push(file_sink("out-gz", std::ios::binary)); + for ( size_t i = 0; i < 10; i++) { + out_z << "line #" << i << endl; + //out_gz << "line #" << i << endl; + //out_bz << "line #" << i << endl; + //raw << "line #" << i << endl; + } + // flush(out); + close(out_z); + //close(out_gz); + //close(out_bz); + //raw.close(); + + for (size_t i = 0; i < 5; i++) { + ifstream file("out-z", ios_base::in | ios_base::binary); + filtering_istream in; + in.push(gzip_decompressor()); + in.push(file); + string s; + while (getline(in, s)) { + cout << s << endl; + } + file.close(); + } + +} + |