2 * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef _ZLIB_COMPRESSION_ALGORITHM_H_
6 #define _ZLIB_COMPRESSION_ALGORITHM_H_
9 #include <CompressionAlgorithm.h>
14 B_ZLIB_COMPRESSION_NONE
= 0,
15 B_ZLIB_COMPRESSION_FASTEST
= 1,
16 B_ZLIB_COMPRESSION_BEST
= 9,
17 B_ZLIB_COMPRESSION_DEFAULT
= -1,
21 class BZlibCompressionParameters
: public BCompressionParameters
{
23 BZlibCompressionParameters(
25 = B_ZLIB_COMPRESSION_DEFAULT
);
26 virtual ~BZlibCompressionParameters();
28 int32
CompressionLevel() const;
29 void SetCompressionLevel(int32 level
);
31 size_t BufferSize() const;
32 void SetBufferSize(size_t size
);
34 // TODO: Support setting the gzip header.
35 bool IsGzipFormat() const;
36 void SetGzipFormat(bool gzipFormat
);
39 int32 fCompressionLevel
;
45 class BZlibDecompressionParameters
: public BDecompressionParameters
{
47 BZlibDecompressionParameters();
48 virtual ~BZlibDecompressionParameters();
50 size_t BufferSize() const;
51 void SetBufferSize(size_t size
);
58 class BZlibCompressionAlgorithm
: public BCompressionAlgorithm
{
60 BZlibCompressionAlgorithm();
61 virtual ~BZlibCompressionAlgorithm();
63 virtual status_t
CreateCompressingInputStream(BDataIO
* input
,
64 const BCompressionParameters
* parameters
,
66 virtual status_t
CreateCompressingOutputStream(BDataIO
* output
,
67 const BCompressionParameters
* parameters
,
69 virtual status_t
CreateDecompressingInputStream(BDataIO
* input
,
70 const BDecompressionParameters
* parameters
,
72 virtual status_t
CreateDecompressingOutputStream(BDataIO
* output
,
73 const BDecompressionParameters
* parameters
,
76 virtual status_t
CompressBuffer(const void* input
,
77 size_t inputSize
, void* output
,
78 size_t outputSize
, size_t& _compressedSize
,
79 const BCompressionParameters
* parameters
81 virtual status_t
DecompressBuffer(const void* input
,
82 size_t inputSize
, void* output
,
84 size_t& _uncompressedSize
,
85 const BDecompressionParameters
* parameters
89 struct CompressionStrategy
;
90 struct DecompressionStrategy
;
92 template<typename BaseClass
, typename Strategy
> struct Stream
;
93 template<typename BaseClass
, typename Strategy
>
97 static status_t
_TranslateZlibError(int error
);
101 #endif // _ZLIB_COMPRESSION_ALGORITHM_H_