head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.42; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.02.00; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.06; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.04; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# zfstream.hxx

Go to the documentation of this file.

    00001
    00006 // Written by Bernie Bright, 1998
    00007 // Based on zlib/contrib/iostream/ by Kevin Ruland <kevin@@rodin.wustl.edu>
    00008 //
    00009 // Copyright (C) 1998  Bernie Bright - bbright@@c031.aone.net.au
    00010 //
    00011 // This library is free software; you can redistribute it and/or
    00012 // modify it under the terms of the GNU Library General Public
    00013 // License as published by the Free Software Foundation; either
    00014 // version 2 of the License, or (at your option) any later version.
    00015 //
    00016 // This library is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00019 // Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public
    00022 // License along with this library; if not, write to the
    00023 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00024 // Boston, MA  02111-1307, USA.
    00025 //
    00026 // $Id: zfstream.hxx,v 1.13 2001/12/29 00:35:35 curt Exp $
    00027
    00028 #ifndef _zfstream_hxx
    00029 #define _zfstream_hxx
    00030
    00031 #include <simgear/compiler.h>
    00032
    00033 #include <zlib.h>
    00034
    00035 // At least Irix needs this
    00036 #ifdef SG_HAVE_NATIVE_SGI_COMPILERS
    00037 #include <char_traits.h>
    00038 SG_USING_STD(char_traits);
    00039 #endif
    00040
    00041 #ifdef SG_HAVE_STD_INCLUDES
    00042
    00043 #  include <streambuf>
    00044 #  include <istream>
    00045
    00046 #  define ios_openmode ios_base::openmode
    00047 #  define ios_in       ios_base::in
    00048 #  define ios_out      ios_base::out
    00049 #  define ios_app      ios_base::app
    00050 #  define ios_binary   ios_base::binary
    00051
    00052 #  define ios_seekdir  ios_base::seekdir
    00053
    00054 #  define ios_badbit   ios_base::badbit
    00055 #  define ios_failbit  ios_base::failbit
    00056
    00057 SG_USING_STD(streambuf);
    00058 SG_USING_STD(ios_base);
    00059 SG_USING_STD(streampos);
    00060 SG_USING_STD(streamoff);
    00061
    00062 #else
    00063
    00064 #  ifdef SG_HAVE_STREAMBUF
    00065 #    include <streambuf.h>
    00066 #    include <istream.h>
    00067 #  else
    00068 #    include <iostream.h>
    00069 #  endif
    00070
    00071 //#  define ios_openmode ios::open_mode
    00072 #  define ios_openmode int
    00073 #  define ios_in       ios::in
    00074 #  define ios_out      ios::out
    00075 #  define ios_app      ios::app
    00076
    00077 #if defined(__GNUC__) && __GNUC_MINOR__ < 8
    00078 #  define ios_binary   ios::bin
    00079 #elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
    00080 #  define ios_binary   0
    00081 #else
    00082 #  define ios_binary   ios::binary
    00083 #endif
    00084
    00085 #  define ios_seekdir  ios::seek_dir
    00086
    00087 #  define ios_badbit   ios::badbit
    00088 #  define ios_failbit  ios::failbit
    00089
    00090 #  include <simgear/sg_traits.hxx>
    00091
    00092 #endif // SG_HAVE_STD_INCLUDES
    00093
    00097 class gzfilebuf : public streambuf
    00098 {
    00099 public:
    00100
    00101 #ifndef SG_HAVE_STD_INCLUDES
    00102     typedef char_traits<char>           traits_type;
    00103     typedef char_traits<char>::int_type int_type;
    00104     // typedef char_traits<char>::pos_type pos_type;
    00105     // typedef char_traits<char>::off_type off_type;
    00106 #endif
    00107
    00109     gzfilebuf();
    00110
    00112     virtual ~gzfilebuf();
    00113
    00120     gzfilebuf* open( const char* name, ios_openmode io_mode );
    00121
    00128     gzfilebuf* attach( int file_descriptor, ios_openmode io_mode );
    00129
    00131     gzfilebuf* close();
    00132
    00133     // int setcompressionlevel( int comp_level );
    00134     // int setcompressionstrategy( int comp_strategy );
    00135
    00137     bool is_open() const { return (file != NULL); }
    00138
    00140     virtual streampos seekoff( streamoff off, ios_seekdir way, int which );
    00141
    00143     virtual int sync();
    00144
    00145 protected:
    00146
    00147     virtual int_type underflow();
    00148     virtual int_type overflow( int_type c = traits_type::eof() );
    00149
    00150 private:
    00151
    00152     int_type flushbuf();
    00153     int fillbuf();
    00154
    00155     // Convert io_mode to "rwab" string.
    00156     void cvt_iomode( char* mode_str, ios_openmode io_mode );
    00157
    00158 private:
    00159
    00160     gzFile file;
    00161     ios_openmode mode;
    00162     bool own_file_descriptor;
    00163
    00164     // Get (input) buffer.
    00165     int ibuf_size;
    00166     char* ibuffer;
    00167
    00168     enum { page_size = 4096 };
    00169
    00170 private:
    00171     // Not defined
    00172     gzfilebuf( const gzfilebuf& );
    00173     void operator= ( const gzfilebuf& );
    00174 };
    00175
    00179 struct gzifstream_base
    00180 {
    00181     gzifstream_base() {}
    00182
    00183     gzfilebuf gzbuf;
    00184 };
    00185
    00186 #endif // _zfstream_hxx
    00187

@ 1.3 log @Oops, try again. @ text @d168 1 a168 1