17 outf.
open(
"test1.txt.gz");
18 outf <<
"The quick brown fox sidestepped the lazy canine\n" 19 << 1.3 <<
"\nPlan " << 9 << std::endl;
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;
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";
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;
38 std::cout <<
"\nWrote the same message to 'test2.txt.gz' in uncompressed form";
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";
void open(const char *name, std::ios_base::openmode mode=std::ios_base::in)
Open gzipped file.
Gzipped file output stream class.
GLenum GLuint GLenum GLsizei const GLchar * buf
void open(const char *name, std::ios_base::openmode mode=std::ios_base::out)
Open gzipped file.
gzfilebuf * rdbuf() const
Obtain underlying stream buffer.
void close()
Close gzipped file.
gzfilebuf * rdbuf() const
Obtain underlying stream buffer.
int inf(FILE *source, FILE *dest)
Gzipped file input stream class.
gzofstream & setcompression(gzofstream &gzs, int l, int s=Z_DEFAULT_STRATEGY)
void close()
Close gzipped file.