OGRE  1.9.0
OgreDeflate.h
Go to the documentation of this file.
1 /*
2  -----------------------------------------------------------------------------
3  This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5  For the latest info, see http://www.ogre3d.org/
6 
7  Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9  Permission is hereby granted, free of charge, to any person obtaining a copy
10  of this software and associated documentation files (the "Software"), to deal
11  in the Software without restriction, including without limitation the rights
12  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  copies of the Software, and to permit persons to whom the Software is
14  furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  THE SOFTWARE.
26  -----------------------------------------------------------------------------
27  */
28 #ifndef __OGRE_DEFLATE_H__
29 #define __OGRE_DEFLATE_H__
30 
31 #if OGRE_NO_ZIP_ARCHIVE == 0
32 
33 #include "OgrePrerequisites.h"
34 #include "OgreDataStream.h"
35 #include "OgreHeaderPrefix.h"
36 
38 struct z_stream_s;
39 typedef struct z_stream_s z_stream;
40 
41 namespace Ogre
42 {
58  {
59  protected:
64  size_t mCurrentPos;
65  size_t mAvailIn;
66 
69 
71  unsigned char *mTmp;
72 
75 
76  void init();
77  void destroy();
78  void compressFinal();
79 
80  size_t getAvailInForSinglePass();
81  public:
89  DeflateStream(const DataStreamPtr& compressedStream, const String& tmpFileName = "",
90  size_t avail_in = 0);
99  DeflateStream(const String& name, const DataStreamPtr& compressedStream, const String& tmpFileName="",
100  size_t avail_in = 0);
101 
102  ~DeflateStream();
103 
110  bool isCompressedStreamValid() const { return mIsCompressedValid; }
111 
114  size_t read(void* buf, size_t count);
115 
118  size_t write(const void* buf, size_t count);
119 
122  void skip(long count);
123 
126  void seek( size_t pos );
127 
130  size_t tell(void) const;
131 
134  bool eof(void) const;
135 
138  void close(void);
139 
140  };
141 }
142 
143 #include "OgreHeaderSuffix.h"
144 
145 #endif
146 
147 #endif
#define _OgreExport
Definition: OgrePlatform.h:260
z_stream * mZStream
Definition: OgreDeflate.h:63
DataStreamPtr mCompressedStream
Definition: OgreDeflate.h:60
bool mIsCompressedValid
Whether the underlying stream is valid compressed data.
Definition: OgreDeflate.h:74
General purpose class used for encapsulating the reading and writing of data.
_StringBase String
bool isCompressedStreamValid() const
Returns whether the compressed stream is valid deflated data.
Definition: OgreDeflate.h:110
StaticCache< 16 *OGRE_STREAM_TEMP_SIZE > mReadCache
Cache for read data in case skipping around.
Definition: OgreDeflate.h:68
unsigned char * mTmp
Intermediate buffer for read / write.
Definition: OgreDeflate.h:71
Stream which compresses / uncompresses data using the 'deflate' compression algorithm.
Definition: OgreDeflate.h:57
struct z_stream_s z_stream
Definition: OgreDeflate.h:39
DataStreamPtr mTmpWriteStream
Definition: OgreDeflate.h:61