Make UEFI boot-platform build again
[haiku.git] / headers / private / support / ZlibCompressionAlgorithm.h
blobdf9ddae54ff4d60b2baa193d616596aeea9719a2
1 /*
2 * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _ZLIB_COMPRESSION_ALGORITHM_H_
6 #define _ZLIB_COMPRESSION_ALGORITHM_H_
9 #include <CompressionAlgorithm.h>
12 // compression level
13 enum {
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 {
22 public:
23 BZlibCompressionParameters(
24 int compressionLevel
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);
38 private:
39 int32 fCompressionLevel;
40 size_t fBufferSize;
41 bool fGzipFormat;
45 class BZlibDecompressionParameters : public BDecompressionParameters {
46 public:
47 BZlibDecompressionParameters();
48 virtual ~BZlibDecompressionParameters();
50 size_t BufferSize() const;
51 void SetBufferSize(size_t size);
53 private:
54 size_t fBufferSize;
58 class BZlibCompressionAlgorithm : public BCompressionAlgorithm {
59 public:
60 BZlibCompressionAlgorithm();
61 virtual ~BZlibCompressionAlgorithm();
63 virtual status_t CreateCompressingInputStream(BDataIO* input,
64 const BCompressionParameters* parameters,
65 BDataIO*& _stream);
66 virtual status_t CreateCompressingOutputStream(BDataIO* output,
67 const BCompressionParameters* parameters,
68 BDataIO*& _stream);
69 virtual status_t CreateDecompressingInputStream(BDataIO* input,
70 const BDecompressionParameters* parameters,
71 BDataIO*& _stream);
72 virtual status_t CreateDecompressingOutputStream(BDataIO* output,
73 const BDecompressionParameters* parameters,
74 BDataIO*& _stream);
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
80 = NULL);
81 virtual status_t DecompressBuffer(const void* input,
82 size_t inputSize, void* output,
83 size_t outputSize,
84 size_t& _uncompressedSize,
85 const BDecompressionParameters* parameters
86 = NULL);
88 private:
89 struct CompressionStrategy;
90 struct DecompressionStrategy;
92 template<typename BaseClass, typename Strategy> struct Stream;
93 template<typename BaseClass, typename Strategy>
94 friend struct Stream;
96 private:
97 static status_t _TranslateZlibError(int error);
101 #endif // _ZLIB_COMPRESSION_ALGORITHM_H_