1 // A C++ I/O streams interface to the zlib gz* functions
3 // Written by Bernie Bright, 1998
4 // Based on zlib/contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
6 // Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the
20 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 // Boston, MA 02111-1307, USA.
32 #include <simgear/compiler.h>
37 # include <simgear/zlib/zlib.h>
40 #ifdef FG_HAVE_STD_INCLUDES
45 # define ios_openmode ios_base::openmode
46 # define ios_in ios_base::in
47 # define ios_out ios_base::out
48 # define ios_app ios_base::app
49 # define ios_binary ios_base::binary
51 # define ios_seekdir ios_base::seekdir
53 # define ios_badbit ios_base::badbit
54 # define ios_failbit ios_base::failbit
56 FG_USING_STD(streambuf);
57 FG_USING_STD(ios_base);
58 FG_USING_STD(streampos);
59 FG_USING_STD(streamoff);
63 # ifdef FG_HAVE_STREAMBUF
64 # include <streambuf.h>
67 # include <iostream.h>
70 //# define ios_openmode ios::open_mode
71 # define ios_openmode int
72 # define ios_in ios::in
73 # define ios_out ios::out
74 # define ios_app ios::app
76 #if defined(__GNUC__) && __GNUC_MINOR__ < 8
77 # define ios_binary ios::bin
78 #elif defined( FG_HAVE_NATIVE_SGI_COMPILERS )
81 # define ios_binary ios::binary
84 # define ios_seekdir ios::seek_dir
86 # define ios_badbit ios::badbit
87 # define ios_failbit ios::failbit
89 # include <simgear/fg_traits.hxx>
91 #endif // FG_HAVE_STD_INCLUDES
93 //-----------------------------------------------------------------------------
97 class gzfilebuf : public streambuf
101 #ifndef FG_HAVE_STD_INCLUDES
102 typedef char_traits<char> traits_type;
103 typedef char_traits<char>::int_type int_type;
104 // typedef char_traits<char>::pos_type pos_type;
105 // typedef char_traits<char>::off_type off_type;
109 virtual ~gzfilebuf();
111 gzfilebuf* open( const char* name, ios_openmode io_mode );
112 gzfilebuf* attach( int file_descriptor, ios_openmode io_mode );
115 // int setcompressionlevel( int comp_level );
116 // int setcompressionstrategy( int comp_strategy );
117 bool is_open() const { return (file != NULL); }
118 virtual streampos seekoff( streamoff off, ios_seekdir way, int which );
123 virtual int_type underflow();
124 virtual int_type overflow( int_type c = traits_type::eof() );
131 // Convert io_mode to "rwab" string.
132 void cvt_iomode( char* mode_str, ios_openmode io_mode );
138 bool own_file_descriptor;
140 // Get (input) buffer.
144 enum { page_size = 4096 };
148 gzfilebuf( const gzfilebuf& );
149 void operator= ( const gzfilebuf& );
152 //-----------------------------------------------------------------------------
156 struct gzifstream_base
163 #endif // _zfstream_hxx