Panda3D
zStream.h
1 // Filename: zStream.h
2 // Created by: drose (05Aug02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ZSTREAM_H
16 #define ZSTREAM_H
17 
18 #include "pandabase.h"
19 
20 // This module is not compiled if zlib is not available.
21 #ifdef HAVE_ZLIB
22 
23 #include "zStreamBuf.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : IDecompressStream
27 // Description : An input stream object that uses zlib to decompress
28 // (inflate) the input from another source stream
29 // on-the-fly.
30 //
31 // Attach an IDecompressStream to an existing istream that
32 // provides compressed data, and read the corresponding
33 // uncompressed data from the IDecompressStream.
34 //
35 // Seeking is not supported.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_PANDAEXPRESS IDecompressStream : public istream {
38 PUBLISHED:
39  INLINE IDecompressStream();
40  INLINE IDecompressStream(istream *source, bool owns_source);
41 
42  INLINE IDecompressStream &open(istream *source, bool owns_source);
43  INLINE IDecompressStream &close();
44 
45 private:
46  ZStreamBuf _buf;
47 };
48 
49 ////////////////////////////////////////////////////////////////////
50 // Class : OCompressStream
51 // Description : An input stream object that uses zlib to compress
52 // (deflate) data to another destination stream
53 // on-the-fly.
54 //
55 // Attach an OCompressStream to an existing ostream that will
56 // accept compressed data, and write your uncompressed
57 // source data to the OCompressStream.
58 //
59 // Seeking is not supported.
60 ////////////////////////////////////////////////////////////////////
61 class EXPCL_PANDAEXPRESS OCompressStream : public ostream {
62 PUBLISHED:
63  INLINE OCompressStream();
64  INLINE OCompressStream(ostream *dest, bool owns_dest,
65  int compression_level = 6);
66 
67  INLINE OCompressStream &open(ostream *dest, bool owns_dest,
68  int compression_level = 6);
69  INLINE OCompressStream &close();
70 
71 private:
72  ZStreamBuf _buf;
73 };
74 
75 #include "zStream.I"
76 
77 #endif // HAVE_ZLIB
78 
79 
80 #endif
81 
82