00001 // Filename: zStream.h 00002 // Created by: drose (05Aug02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef ZSTREAM_H 00020 #define ZSTREAM_H 00021 00022 #include "pandabase.h" 00023 00024 // This module is not compiled if zlib is not available. 00025 #ifdef HAVE_ZLIB 00026 00027 #include "zStreamBuf.h" 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : IDecompressStream 00031 // Description : An input stream object that uses zlib to decompress 00032 // (inflate) the input from another source stream 00033 // on-the-fly. 00034 // 00035 // Attach an IDecompressStream to an existing istream that 00036 // provides compressed data, and read the corresponding 00037 // uncompressed data from the IDecompressStream. 00038 // 00039 // Seeking is not supported. 00040 //////////////////////////////////////////////////////////////////// 00041 class EXPCL_PANDAEXPRESS IDecompressStream : public istream { 00042 public: 00043 INLINE IDecompressStream(); 00044 INLINE IDecompressStream(istream *source, bool owns_source); 00045 00046 INLINE IDecompressStream &open(istream *source, bool owns_source); 00047 INLINE IDecompressStream &close(); 00048 00049 private: 00050 ZStreamBuf _buf; 00051 }; 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Class : OCompressStream 00055 // Description : An input stream object that uses zlib to compress 00056 // (deflate) data to another destination stream 00057 // on-the-fly. 00058 // 00059 // Attach an OCompressStream to an existing ostream that will 00060 // accept compressed data, and write your uncompressed 00061 // source data to the OCompressStream. 00062 // 00063 // Seeking is not supported. 00064 //////////////////////////////////////////////////////////////////// 00065 class EXPCL_PANDAEXPRESS OCompressStream : public ostream { 00066 public: 00067 INLINE OCompressStream(); 00068 INLINE OCompressStream(ostream *dest, bool owns_dest, 00069 int compression_level = 6); 00070 00071 INLINE OCompressStream &open(ostream *dest, bool owns_dest, 00072 int compression_level = 6); 00073 INLINE OCompressStream &close(); 00074 00075 private: 00076 ZStreamBuf _buf; 00077 }; 00078 00079 #include "zStream.I" 00080 00081 #endif // HAVE_ZLIB 00082 00083 00084 #endif 00085 00086