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-2013 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 
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 
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
OgreHeaderSuffix.h
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::DeflateStream::mTempFileName
String mTempFileName
Definition: OgreDeflate.h:60
Ogre::DeflateStream::destroy
void destroy()
Ogre::DeflateStream::mAvailIn
size_t mAvailIn
Definition: OgreDeflate.h:63
Ogre::DeflateStream::mCurrentPos
size_t mCurrentPos
Definition: OgreDeflate.h:62
z_stream
struct z_stream_s z_stream
Definition: OgreDeflate.h:37
Ogre::DeflateStream::tell
size_t tell(void) const
Returns the current byte offset from beginning.
Ogre::DataStream
General purpose class used for encapsulating the reading and writing of data.
Definition: OgreDataStream.h:177
Ogre::DeflateStream::close
void close(void)
Close the stream; this makes further operations invalid.
Ogre::DeflateStream::seek
void seek(size_t pos)
Repositions the read point to a specified byte.
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::DeflateStream::write
size_t write(const void *buf, size_t count)
Write the requisite number of bytes from the stream (only applicable to streams that are not read-onl...
Ogre::DeflateStream::skip
void skip(long count)
Skip a defined number of bytes.
OgreHeaderPrefix.h
OgrePrerequisites.h
Ogre::DeflateStream::mZStream
z_stream * mZStream
Definition: OgreDeflate.h:61
Ogre::DeflateStream::mIsCompressedValid
bool mIsCompressedValid
Whether the underlying stream is valid compressed data.
Definition: OgreDeflate.h:72
Ogre::DeflateStream::DeflateStream
DeflateStream(const String &name, const DataStreamPtr &compressedStream, const String &tmpFileName="", size_t avail_in=0)
Constructor for creating named stream wrapping another stream.
Ogre::DeflateStream::mTmpWriteStream
DataStreamPtr mTmpWriteStream
Definition: OgreDeflate.h:59
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::DeflateStream
Stream which compresses / uncompresses data using the 'deflate' compression algorithm.
Definition: OgreDeflate.h:56
Ogre::DeflateStream::eof
bool eof(void) const
Returns true if the stream has reached the end.
Ogre::DeflateStream::init
void init()
Ogre::DeflateStream::compressFinal
void compressFinal()
Ogre::SharedPtr< DataStream >
Ogre::DeflateStream::~DeflateStream
~DeflateStream()
Ogre::StaticCache< 16 *OGRE_STREAM_TEMP_SIZE >
Ogre::DeflateStream::isCompressedStreamValid
bool isCompressedStreamValid() const
Returns whether the compressed stream is valid deflated data.
Definition: OgreDeflate.h:108
Ogre::DeflateStream::mCompressedStream
DataStreamPtr mCompressedStream
Definition: OgreDeflate.h:58
Ogre::DeflateStream::DeflateStream
DeflateStream(const DataStreamPtr &compressedStream, const String &tmpFileName="", size_t avail_in=0)
Constructor for creating unnamed stream wrapping another stream.
OgreDataStream.h
Ogre::DeflateStream::mReadCache
StaticCache< 16 *OGRE_STREAM_TEMP_SIZE > mReadCache
Cache for read data in case skipping around.
Definition: OgreDeflate.h:66
Ogre::DeflateStream::read
size_t read(void *buf, size_t count)
Read the requisite number of bytes from the stream, stopping at the end of the file.
Ogre::DeflateStream::getAvailInForSinglePass
size_t getAvailInForSinglePass()
Ogre::DeflateStream::mTmp
unsigned char * mTmp
Intermediate buffer for read / write.
Definition: OgreDeflate.h:69

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.