8 #include "Include/fg_stl_config.h"
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( short comp_level );
22 int setcompressionstrategy( short 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();
71 class gzifstream : public gzfilestream_common, public istream {
76 gzifstream( const char *name, int io_mode = ios::in );
77 gzifstream( int fd, int io_mode = ios::in );
79 virtual ~gzifstream();
83 class gzofstream : public gzfilestream_common, public ostream {
88 gzofstream( const char *name, int io_mode = ios::out );
89 gzofstream( int fd, int io_mode = ios::out );
91 virtual ~gzofstream();
95 template<class T> class gzomanip {
96 friend gzofstream &operator << _FG_NULL_TMPL_ARGS (gzofstream &, const gzomanip<T> &);
98 gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { }
100 gzofstream &(*func)(gzofstream &, T);
104 template<class T> gzofstream &operator<<(gzofstream &s,
105 const gzomanip<T> &m) {
106 return (*m.func)(s, m.val);
110 inline gzofstream &setcompressionlevel( gzofstream &s, int l ) {
111 (s.rdbuf())->setcompressionlevel(l);
115 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);
130 #endif // _zfstream_hxx