third_party/zlib/contrib/iostream3/test.cc
Go to the documentation of this file.
1 /*
2  * Test program for gzifstream and gzofstream
3  *
4  * by Ludwig Schwardt <schwardt@sun.ac.za>
5  * original version by Kevin Ruland <kevin@rodin.wustl.edu>
6  */
7 
8 #include "zfstream.h"
9 #include <iostream> // for cout
10 
11 int main() {
12 
13  gzofstream outf;
15  char buf[80];
16 
17  outf.open("test1.txt.gz");
18  outf << "The quick brown fox sidestepped the lazy canine\n"
19  << 1.3 << "\nPlan " << 9 << std::endl;
20  outf.close();
21  std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n"
22  << "The quick brown fox sidestepped the lazy canine\n"
23  << 1.3 << "\nPlan " << 9 << std::endl;
24 
25  std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n";
26  inf.open("test1.txt.gz");
27  while (inf.getline(buf,80,'\n')) {
28  std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n";
29  }
30  inf.close();
31 
32  outf.rdbuf()->pubsetbuf(0,0);
33  outf.open("test2.txt.gz");
35  << "The quick brown fox sidestepped the lazy canine\n"
36  << 1.3 << "\nPlan " << 9 << std::endl;
37  outf.close();
38  std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form";
39 
40  std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n";
41  inf.rdbuf()->pubsetbuf(0,0);
42  inf.open("test2.txt.gz");
43  while (inf.getline(buf,80,'\n')) {
44  std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n";
45  }
46  inf.close();
47 
48  return 0;
49 
50 }
zfstream.h
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
gzofstream::open
void open(const char *name, std::ios_base::openmode mode=std::ios_base::out)
Open gzipped file.
Definition: bloaty/third_party/zlib/contrib/iostream3/zfstream.cc:453
main
int main()
Definition: third_party/zlib/contrib/iostream3/test.cc:11
gzofstream
Gzipped file output stream class.
Definition: bloaty/third_party/zlib/contrib/iostream/zfstream.h:80
inf
const char inf[]
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:12099
setcompression
gzofstream & setcompression(gzofstream &gzs, int l, int s=Z_DEFAULT_STRATEGY)
Definition: bloaty/third_party/zlib/contrib/iostream3/zfstream.h:440
Z_NO_COMPRESSION
#define Z_NO_COMPRESSION
Definition: bloaty/third_party/zlib/zlib.h:190
gzofstream::rdbuf
gzfilebuf * rdbuf() const
Definition: bloaty/third_party/zlib/contrib/iostream3/zfstream.h:351
gzifstream
Gzipped file input stream class.
Definition: bloaty/third_party/zlib/contrib/iostream/zfstream.h:68
gzofstream::close
void close()
Close gzipped file.
Definition: bloaty/third_party/zlib/contrib/iostream3/zfstream.cc:475


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:27