test.cpp 526 B

123456789101112131415161718192021222324
  1. #include "zfstream.h"
  2. int main() {
  3. // Construct a stream object with this filebuffer. Anything sent
  4. // to this stream will go to standard out.
  5. gzofstream os( 1, ios::out );
  6. // This text is getting compressed and sent to stdout.
  7. // To prove this, run 'test | zcat'.
  8. os << "Hello, Mommy" << endl;
  9. os << setcompressionlevel( Z_NO_COMPRESSION );
  10. os << "hello, hello, hi, ho!" << endl;
  11. setcompressionlevel( os, Z_DEFAULT_COMPRESSION )
  12. << "I'm compressing again" << endl;
  13. os.close();
  14. return 0;
  15. }