OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "OgrePrerequisites.h"
32 #include "OgreDataStream.h"
33 #include "OgreHeaderPrefix.h"
34 
36 struct z_stream_s;
37 typedef struct z_stream_s z_stream;
38 
39 namespace Ogre
40 {
56  {
57  protected:
62  size_t mCurrentPos;
63  size_t mAvailIn;
64 
67 
69  unsigned char *mTmp;
70 
73 
74  void init();
75  void destroy();
76  void compressFinal();
77 
78  size_t getAvailInForSinglePass();
79  public:
87  DeflateStream(const DataStreamPtr& compressedStream, const String& tmpFileName = "",
88  size_t avail_in = 0);
97  DeflateStream(const String& name, const DataStreamPtr& compressedStream, const String& tmpFileName="",
98  size_t avail_in = 0);
99 
100  ~DeflateStream();
101 
108  bool isCompressedStreamValid() const { return mIsCompressedValid; }
109 
112  size_t read(void* buf, size_t count);
113 
116  size_t write(const void* buf, size_t count);
117 
120  void skip(long count);
121 
124  void seek( size_t pos );
125 
128  size_t tell(void) const;
129 
132  bool eof(void) const;
133 
136  void close(void);
137 
138  };
139 }
140 
141 #include "OgreHeaderSuffix.h"
142 
143 #endif
#define _OgreExport
Definition: OgrePlatform.h:255
DataStreamPtr mTmpWriteStream
Definition: OgreDeflate.h:59
StaticCache< 16 *OGRE_STREAM_TEMP_SIZE > mReadCache
Cache for read data in case skipping around.
Definition: OgreDeflate.h:66
z_stream * mZStream
Definition: OgreDeflate.h:61
unsigned char * mTmp
Intermediate buffer for read / write.
Definition: OgreDeflate.h:69
struct z_stream_s z_stream
Definition: OgreDeflate.h:37
bool mIsCompressedValid
Whether the underlying stream is valid compressed data.
Definition: OgreDeflate.h:72
DataStreamPtr mCompressedStream
Definition: OgreDeflate.h:58
Stream which compresses / uncompresses data using the 'deflate' compression algorithm.
Definition: OgreDeflate.h:55
General purpose class used for encapsulating the reading and writing of data.
bool isCompressedStreamValid() const
Returns whether the compressed stream is valid deflated data.
Definition: OgreDeflate.h:108
_StringBase String
Definition: OgreCommon.h:53