X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmisc%2Fzfstream.hxx;h=a8635483d9e619c942fe8eed6117dac838e55fba;hb=2e71b64de1d937e2b7c34dd4a2365be455d0b82a;hp=945e85482ff19ec6edf19e30616de75a2c89f5af;hpb=82459a2802a939434f9fc5b88d2b2aea58f0043d;p=simgear.git diff --git a/simgear/misc/zfstream.hxx b/simgear/misc/zfstream.hxx index 945e8548..a8635483 100644 --- a/simgear/misc/zfstream.hxx +++ b/simgear/misc/zfstream.hxx @@ -1,5 +1,8 @@ -// A C++ I/O streams interface to the zlib gz* functions -// +/** + * \file zfstream.hxx + * A C++ I/O streams interface to the zlib gz* functions. + */ + // Written by Bernie Bright, 1998 // Based on zlib/contrib/iostream/ by Kevin Ruland // @@ -15,114 +18,88 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ #ifndef _zfstream_hxx #define _zfstream_hxx -#ifdef HAVE_CONFIG_H -# include -#endif - #include -#ifdef HAVE_ZLIB -# include -#else -# include -#endif - -#ifdef FG_HAVE_STD_INCLUDES +#include -# include -# include -# define ios_openmode ios_base::openmode -# define ios_in ios_base::in -# define ios_out ios_base::out -# define ios_app ios_base::app -# define ios_binary ios_base::binary +#include +#include -# define ios_seekdir ios_base::seekdir +#define ios_openmode std::ios_base::openmode +#define ios_in std::ios_base::in +#define ios_out std::ios_base::out +#define ios_app std::ios_base::app +#define ios_binary std::ios_base::binary -# define ios_badbit ios_base::badbit -# define ios_failbit ios_base::failbit +#define ios_seekdir std::ios_base::seekdir -FG_USING_STD(streambuf); -FG_USING_STD(ios_base); -FG_USING_STD(streampos); -FG_USING_STD(streamoff); +#define ios_badbit std::ios_base::badbit +#define ios_failbit std::ios_base::failbit +/** + * A C++ I/O streams interface to the zlib gz* functions. + */ +#ifdef SG_NEED_STREAMBUF_HACK +class gzfilebuf : public __streambuf { + typedef __streambuf parent; #else - -# ifdef FG_HAVE_STREAMBUF -# include -# include -# else -# include -# endif - -//# define ios_openmode ios::open_mode -# define ios_openmode int -# define ios_in ios::in -# define ios_out ios::out -# define ios_app ios::app - -#if defined(__GNUC__) && __GNUC_MINOR__ < 8 -# define ios_binary ios::bin -#elif defined( FG_HAVE_NATIVE_SGI_COMPILERS ) -# define ios_binary 0 -#else -# define ios_binary ios::binary +class gzfilebuf : public std::streambuf { + typedef std::streambuf parent; #endif -# define ios_seekdir ios::seek_dir - -# define ios_badbit ios::badbit -# define ios_failbit ios::failbit - -# include - -#endif // FG_HAVE_STD_INCLUDES - -//----------------------------------------------------------------------------- -// -// -// -class gzfilebuf : public streambuf -{ public: - -#ifndef FG_HAVE_STD_INCLUDES - typedef char_traits traits_type; - typedef char_traits::int_type int_type; - typedef char_traits::pos_type pos_type; - typedef char_traits::off_type off_type; -#endif - + /** Constructor */ gzfilebuf(); + + /** Destructor */ virtual ~gzfilebuf(); + /** + * Open a stream + * @param name file name + * @param io_mode mdoe flags + * @return file stream + */ gzfilebuf* open( const char* name, ios_openmode io_mode ); + + /** + * Attach to an existing file descriptor + * @param file_descriptor file descriptor + * @param io_mode mode flags + * @return file stream + */ gzfilebuf* attach( int file_descriptor, ios_openmode io_mode ); + + /** Close stream */ gzfilebuf* close(); -// int setcompressionlevel( int comp_level ); -// int setcompressionstrategy( int comp_strategy ); + // int setcompressionlevel( int comp_level ); + // int setcompressionstrategy( int comp_strategy ); + + /** @return true if open, false otherwise */ bool is_open() const { return (file != NULL); } - virtual streampos seekoff( streamoff off, ios_seekdir way, int which ); + + /** @return stream position */ + virtual std::streampos seekoff( std::streamoff off, ios_seekdir way, int which ); + + /** sync the stream */ virtual int sync(); protected: virtual int_type underflow(); - virtual int_type overflow( int_type c = traits_type::eof() ); + virtual int_type overflow( int_type c = parent::traits_type::eof() ); private: int_type flushbuf(); @@ -149,10 +126,9 @@ private: void operator= ( const gzfilebuf& ); }; -//----------------------------------------------------------------------------- -// -// -// +/** + * document me + */ struct gzifstream_base { gzifstream_base() {}