1 /* $NetBSD: zfstream.h,v 1.1.1.1 2006/01/14 20:10:53 christos Exp $ */
10 class gzfilebuf
: public streambuf
{
17 gzfilebuf
*open( const char *name
, int io_mode
);
18 gzfilebuf
*attach( int file_descriptor
, int io_mode
);
21 int setcompressionlevel( int comp_level
);
22 int setcompressionstrategy( int comp_strategy
);
24 inline int is_open() const { return (file
!=NULL
); }
26 virtual streampos
seekoff( streamoff
, ios::seek_dir
, int );
32 virtual int underflow();
33 virtual int overflow( int = EOF
);
39 short own_file_descriptor
;
46 class gzfilestream_common
: virtual public ios
{
48 friend class gzifstream
;
49 friend class gzofstream
;
50 friend gzofstream
&setcompressionlevel( gzofstream
&, int );
51 friend gzofstream
&setcompressionstrategy( gzofstream
&, int );
54 virtual ~gzfilestream_common();
56 void attach( int fd
, int io_mode
);
57 void open( const char *name
, int io_mode
);
61 gzfilestream_common();
70 class gzifstream
: public gzfilestream_common
, public istream
{
75 gzifstream( const char *name
, int io_mode
= ios::in
);
76 gzifstream( int fd
, int io_mode
= ios::in
);
78 virtual ~gzifstream();
82 class gzofstream
: public gzfilestream_common
, public ostream
{
87 gzofstream( const char *name
, int io_mode
= ios::out
);
88 gzofstream( int fd
, int io_mode
= ios::out
);
90 virtual ~gzofstream();
94 template<class T
> class gzomanip
{
95 friend gzofstream
&operator<<(gzofstream
&, const gzomanip
<T
> &);
97 gzomanip(gzofstream
&(*f
)(gzofstream
&, T
), T v
) : func(f
), val(v
) { }
99 gzofstream
&(*func
)(gzofstream
&, T
);
103 template<class T
> gzofstream
&operator<<(gzofstream
&s
, const gzomanip
<T
> &m
)
105 return (*m
.func
)(s
, m
.val
);
108 inline gzofstream
&setcompressionlevel( gzofstream
&s
, int l
)
110 (s
.rdbuf())->setcompressionlevel(l
);
114 inline gzofstream
&setcompressionstrategy( gzofstream
&s
, int l
)
116 (s
.rdbuf())->setcompressionstrategy(l
);
120 inline gzomanip
<int> setcompressionlevel(int l
)
122 return gzomanip
<int>(&setcompressionlevel
,l
);
125 inline gzomanip
<int> setcompressionstrategy(int l
)
127 return gzomanip
<int>(&setcompressionstrategy
,l
);