]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/zfstream.hxx
cppbind: automatic conversion of SGReferenced derived pointers.
[simgear.git] / simgear / misc / zfstream.hxx
index e4c1ff1f83237088d52ecf49d29c0630719d39c4..004340d3fce06c6f4f2c5bc552552e5711fdf1c2 100644 (file)
 
 #include <zlib.h>
 
-#ifdef SG_HAVE_STD_INCLUDES
 
-#  include <streambuf>
-#  include <istream>
+#include <streambuf>
+#include <istream>
 
-#  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_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_seekdir  std::ios_base::seekdir
+#define ios_seekdir  std::ios_base::seekdir
 
-#  define ios_badbit   std::ios_base::badbit
-#  define ios_failbit  std::ios_base::failbit
-
-#else
-
-#  ifdef SG_HAVE_STREAMBUF
-#    include <streambuf.h>
-#    include <istream.h>
-#  else
-#    include <iostream.h>
-#  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
-#else
-#  define ios_binary   ios::binary
-#endif
-
-#  define ios_seekdir  ios::seek_dir
-
-#  define ios_badbit   ios::badbit
-#  define ios_failbit  ios::failbit
-
-#  include <simgear/sg_traits.hxx>
-
-#endif // SG_HAVE_STD_INCLUDES
+#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
+class gzfilebuf : public __streambuf {
+    typedef __streambuf parent;
 #else
-class gzfilebuf : public std::streambuf
-#endif
-{
-public:
-
-#ifndef SG_HAVE_STD_INCLUDES
-    typedef char_traits<char>           traits_type;
-    typedef char_traits<char>::int_type int_type;
-    // typedef char_traits<char>::pos_type pos_type;
-    // typedef char_traits<char>::off_type off_type;
+class gzfilebuf : public std::streambuf {
+    typedef std::streambuf parent;
 #endif
 
+public:
     /** Constructor */
     gzfilebuf();
 
@@ -104,7 +67,7 @@ public:
     /**
      * Open a stream
      * @param name file name
-     * @param io_mode mdoe flags
+     * @param io_mode mode flags
      * @return file stream
      */
     gzfilebuf* open( const char* name, ios_openmode io_mode );
@@ -120,14 +83,14 @@ public:
     /** 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); }
 
     /** @return stream position */
-    virtual std::streampos seekoff( std::streamoff off, ios_seekdir way, int which );
+    virtual std::streampos seekoff( std::streamoff off, ios_seekdir way, ios_openmode which );
 
     /** sync the stream */
     virtual int sync();
@@ -135,11 +98,12 @@ public:
 protected:
 
     virtual int_type underflow();
-#ifndef SG_HAVE_STD_INCLUDES
-    virtual int_type overflow( int_type c = traits_type::eof() );
-#else
-    virtual int_type overflow( int_type c = std::streambuf::traits_type::eof() );
-#endif
+
+    virtual int_type overflow( int_type c = parent::traits_type::eof() );
+    bool    out_waiting();
+    char*   base() {return obuffer;}
+    int     blen() {return obuf_size;}
+    char    allocate();
 
 private:
 
@@ -159,7 +123,11 @@ private:
     int ibuf_size;
     char* ibuffer;
 
-    enum { page_size = 4096 };
+    // Put (output) buffer.
+    int obuf_size;
+    char* obuffer;
+
+    enum { page_size = 65536 };
 
 private:
     // Not defined
@@ -177,5 +145,14 @@ struct gzifstream_base
     gzfilebuf gzbuf;
 };
 
-#endif // _zfstream_hxx
+/**
+ * document me too
+ */
+struct gzofstream_base
+{
+    gzofstream_base() {}
+
+    gzfilebuf gzbuf;
+};
 
+#endif // _zfstream_hxx