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 {
54 typedef __streambuf parent;
56 class gzfilebuf : public std::streambuf {
57 typedef std::streambuf parent;
69 * @param name file name
70 * @param io_mode mdoe flags
73 gzfilebuf* open( const char* name, ios_openmode io_mode );
76 * Attach to an existing file descriptor
77 * @param file_descriptor file descriptor
78 * @param io_mode mode flags
81 gzfilebuf* attach( int file_descriptor, ios_openmode io_mode );
86 // int setcompressionlevel( int comp_level );
87 // int setcompressionstrategy( int comp_strategy );
89 /** @return true if open, false otherwise */
90 bool is_open() const { return (file != NULL); }
92 /** @return stream position */
93 virtual std::streampos seekoff( std::streamoff off, ios_seekdir way, int which );
95 /** sync the stream */
100 virtual int_type underflow();
102 virtual int_type overflow( int_type c = parent::traits_type::eof() );
108 // Convert io_mode to "rwab" string.
109 void cvt_iomode( char* mode_str, ios_openmode io_mode );
115 bool own_file_descriptor;
117 // Get (input) buffer.
121 enum { page_size = 4096 };
125 gzfilebuf( const gzfilebuf& );
126 void operator= ( const gzfilebuf& );
132 struct gzifstream_base
139 #endif // _zfstream_hxx