3 * A C++ I/O streams interface to the zlib gz* functions.
6 // Written by Bernie Bright, 1998
7 // Based on zlib/contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
9 // Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Library General Public
13 // License as published by the Free Software Foundation; either
14 // version 2 of the License, or (at your option) any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Library General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <simgear/compiler.h>
38 #define ios_openmode std::ios_base::openmode
39 #define ios_in std::ios_base::in
40 #define ios_out std::ios_base::out
41 #define ios_app std::ios_base::app
42 #define ios_binary std::ios_base::binary
44 #define ios_seekdir std::ios_base::seekdir
46 #define ios_badbit std::ios_base::badbit
47 #define ios_failbit std::ios_base::failbit
50 * A C++ I/O streams interface to the zlib gz* functions.
52 #ifdef SG_NEED_STREAMBUF_HACK
53 class gzfilebuf : public __streambuf
55 class gzfilebuf : public std::streambuf
67 * @param name file name
68 * @param io_mode mdoe flags
71 gzfilebuf* open( const char* name, ios_openmode io_mode );
74 * Attach to an existing file descriptor
75 * @param file_descriptor file descriptor
76 * @param io_mode mode flags
79 gzfilebuf* attach( int file_descriptor, ios_openmode io_mode );
84 // int setcompressionlevel( int comp_level );
85 // int setcompressionstrategy( int comp_strategy );
87 /** @return true if open, false otherwise */
88 bool is_open() const { return (file != NULL); }
90 /** @return stream position */
91 virtual std::streampos seekoff( std::streamoff off, ios_seekdir way, int which );
93 /** sync the stream */
98 virtual int_type underflow();
100 virtual int_type overflow( int_type c = std::streambuf::traits_type::eof() );
106 // Convert io_mode to "rwab" string.
107 void cvt_iomode( char* mode_str, ios_openmode io_mode );
113 bool own_file_descriptor;
115 // Get (input) buffer.
119 enum { page_size = 4096 };
123 gzfilebuf( const gzfilebuf& );
124 void operator= ( const gzfilebuf& );
130 struct gzifstream_base
137 #endif // _zfstream_hxx