Ticket #36204: test.cpp

File test.cpp, 739 bytes (added by rob.patro@…, 12 years ago)
Line 
1#include <iostream>
2#include <fstream>
3#include <boost/iostreams/device/file.hpp>
4#include <boost/iostreams/filtering_stream.hpp>
5#include <boost/iostreams/filter/gzip.hpp>
6
7#define _GLIBCXX_DEBUG 0
8#define _GLIBCXX_DEBUG_PEDANTIC 0
9
10int main(int argc, char** argv) {
11
12  std::string fname(argv[1]);
13
14  std::ifstream file(fname.c_str(), std::ios_base::in | std::ios_base::binary);
15
16  boost::iostreams::filtering_istream in;
17  in.push(boost::iostreams::gzip_decompressor());
18  in.push(boost::iostreams::file_source(fname));
19  try {
20
21    for( std::string str; std::getline(in, str); ) {
22      std::cout << "Processed line " << str << '\n';
23    }
24  } catch(const boost::iostreams::gzip_error& e) {
25        std::cout << e.what() << '\n';
26  }
27}