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
38struct z_stream_s;
39typedef struct z_stream_s z_stream;
40
41namespace Ogre
42{
58 {
59 protected:
65 size_t mAvailIn;
66
69
71 unsigned char *mTmp;
72
75
76 void init();
77 void destroy();
79
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
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
struct z_stream_s z_stream
Definition: OgreDeflate.h:39
#define _OgreExport
Definition: OgrePlatform.h:260
General purpose class used for encapsulating the reading and writing of data.
Stream which compresses / uncompresses data using the 'deflate' compression algorithm.
Definition: OgreDeflate.h:58
DataStreamPtr mCompressedStream
Definition: OgreDeflate.h:60
DataStreamPtr mTmpWriteStream
Definition: OgreDeflate.h:61
size_t getAvailInForSinglePass()
unsigned char * mTmp
Intermediate buffer for read / write.
Definition: OgreDeflate.h:71
DeflateStream(const DataStreamPtr &compressedStream, const String &tmpFileName="", size_t avail_in=0)
Constructor for creating unnamed stream wrapping another stream.
bool mIsCompressedValid
Whether the underlying stream is valid compressed data.
Definition: OgreDeflate.h:74
StaticCache< 16 *OGRE_STREAM_TEMP_SIZE > mReadCache
Cache for read data in case skipping around.
Definition: OgreDeflate.h:68
size_t tell(void) const
Returns the current byte offset from beginning.
bool isCompressedStreamValid() const
Returns whether the compressed stream is valid deflated data.
Definition: OgreDeflate.h:110
bool eof(void) const
Returns true if the stream has reached the end.
z_stream * mZStream
Definition: OgreDeflate.h:63
DeflateStream(const String &name, const DataStreamPtr &compressedStream, const String &tmpFileName="", size_t avail_in=0)
Constructor for creating named stream wrapping another stream.
size_t read(void *buf, size_t count)
Read the requisite number of bytes from the stream, stopping at the end of the file.
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...
void seek(size_t pos)
Repositions the read point to a specified byte.
void skip(long count)
Skip a defined number of bytes.
void close(void)
Close the stream; this makes further operations invalid.
Template version of cache based on static array.
_StringBase String