]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/zfstream.hxx
Update the SoundSample api so we can request that a copy of the sample be
[simgear.git] / simgear / misc / zfstream.hxx
index 41b3d04dbc4eb48c8117b1d3ea267a52408568d1..e226166c985bff5ef7db4ab0da2fbab4796e2061 100644 (file)
@@ -1,23 +1,27 @@
-//  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 <kevin@rodin.wustl.edu>
 //
 // Copyright (C) 1998  Bernie Bright - bbright@c031.aone.net.au
 //
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
 //
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
+// Library General Public License for more details.
 //
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+// 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.
 //
 // $Id$
 
@@ -28,7 +32,7 @@
 
 #include <zlib.h>
 
-#ifdef FG_HAVE_STD_INCLUDES
+#ifdef SG_HAVE_STD_INCLUDES
 
 #  include <streambuf>
 #  include <istream>
 #  define ios_badbit   ios_base::badbit
 #  define ios_failbit  ios_base::failbit
 
-FG_USING_STD(streambuf);
-FG_USING_STD(ios_base);
-FG_USING_STD(streampos);
-FG_USING_STD(streamoff);
+SG_USING_STD(streambuf);
+SG_USING_STD(ios_base);
+SG_USING_STD(streampos);
+SG_USING_STD(streamoff);
 
 #else
 
-#  ifdef FG_HAVE_STREAMBUF
+#  ifdef SG_HAVE_STREAMBUF
 #    include <streambuf.h>
 #    include <istream.h>
 #  else
@@ -66,8 +70,6 @@ FG_USING_STD(streamoff);
 
 #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
 #endif
@@ -77,42 +79,73 @@ FG_USING_STD(streamoff);
 #  define ios_badbit   ios::badbit
 #  define ios_failbit  ios::failbit
 
-#  include <simgear/fg_traits.hxx>
+#  include <simgear/sg_traits.hxx>
 
-#endif // FG_HAVE_STD_INCLUDES
+#endif // SG_HAVE_STD_INCLUDES
 
-//-----------------------------------------------------------------------------
-//
-//
-//
+/**
+ * A C++ I/O streams interface to the zlib gz* functions.
+ */
+#ifdef SG_NEED_STREAMBUF_HACK
+class gzfilebuf : public __streambuf
+#else
 class gzfilebuf : public streambuf
+#endif
 {
 public:
 
-#ifndef FG_HAVE_STD_INCLUDES
+#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;
+    // typedef char_traits<char>::pos_type pos_type;
+    // typedef char_traits<char>::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); }
+
+    /** @return stream position */
     virtual streampos seekoff( streamoff off, ios_seekdir way, int which );
+
+    /** sync the stream */
     virtual int sync();
 
 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 = streambuf::traits_type::eof() );
+#endif
 
 private:
 
@@ -140,10 +173,9 @@ private:
     void operator= ( const gzfilebuf& );
 };
 
-//-----------------------------------------------------------------------------
-//
-// 
-//
+/**
+ * document me
+ */
 struct gzifstream_base
 {
     gzifstream_base() {}