2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__
27 #define __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__
29 #include "juce_OutputStream.h"
30 #include "../../memory/juce_OptionalScopedPointer.h"
31 #include "../../memory/juce_HeapBlock.h"
34 //==============================================================================
36 A stream which uses zlib to compress the data written into it.
38 @see GZIPDecompressorInputStream
40 class JUCE_API GZIPCompressorOutputStream
: public OutputStream
43 //==============================================================================
44 /** Creates a compression stream.
46 @param destStream the stream into which the compressed data should
48 @param compressionLevel how much to compress the data, between 1 and 9, where
49 1 is the fastest/lowest compression, and 9 is the
50 slowest/highest compression. Any value outside this range
51 indicates that a default compression level should be used.
52 @param deleteDestStreamWhenDestroyed whether or not to delete the destStream object when
53 this stream is destroyed
54 @param windowBits this is used internally to change the window size used
55 by zlib - leave it as 0 unless you specifically need to set
56 its value for some reason
58 GZIPCompressorOutputStream (OutputStream
* destStream
,
59 int compressionLevel
= 0,
60 bool deleteDestStreamWhenDestroyed
= false,
64 ~GZIPCompressorOutputStream();
66 //==============================================================================
69 bool setPosition (int64 newPosition
);
70 bool write (const void* destBuffer
, int howMany
);
72 /** These are preset values that can be used for the constructor's windowBits paramter.
73 For more info about this, see the zlib documentation for its windowBits parameter.
78 windowBitsGZIP
= 15 + 16
82 //==============================================================================
83 OptionalScopedPointer
<OutputStream
> destStream
;
84 HeapBlock
<uint8
> buffer
;
85 class GZIPCompressorHelper
;
86 friend class ScopedPointer
<GZIPCompressorHelper
>;
87 ScopedPointer
<GZIPCompressorHelper
> helper
;
91 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPCompressorOutputStream
);
94 #endif // __JUCE_GZIPCOMPRESSOROUTPUTSTREAM_JUCEHEADER__