btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / support / ZstdCompressionAlgorithm.h
blobdf75e1673d2d1348cd049271ceab9c522c2a85c7
1 /*
2 * Copyright 2017, Jérôme Duval.
3 * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef _ZSTD_COMPRESSION_ALGORITHM_H_
7 #define _ZSTD_COMPRESSION_ALGORITHM_H_
10 #include <CompressionAlgorithm.h>
13 // compression level
14 enum {
15 B_ZSTD_COMPRESSION_NONE = 0,
16 B_ZSTD_COMPRESSION_FASTEST = 1,
17 B_ZSTD_COMPRESSION_BEST = 19,
18 B_ZSTD_COMPRESSION_DEFAULT = 2,
22 class BZstdCompressionParameters : public BCompressionParameters {
23 public:
24 BZstdCompressionParameters(
25 int compressionLevel
26 = B_ZSTD_COMPRESSION_DEFAULT);
27 virtual ~BZstdCompressionParameters();
29 int32 CompressionLevel() const;
30 void SetCompressionLevel(int32 level);
32 size_t BufferSize() const;
33 void SetBufferSize(size_t size);
35 private:
36 int32 fCompressionLevel;
37 size_t fBufferSize;
41 class BZstdDecompressionParameters : public BDecompressionParameters {
42 public:
43 BZstdDecompressionParameters();
44 virtual ~BZstdDecompressionParameters();
46 size_t BufferSize() const;
47 void SetBufferSize(size_t size);
49 private:
50 size_t fBufferSize;
54 class BZstdCompressionAlgorithm : public BCompressionAlgorithm {
55 public:
56 BZstdCompressionAlgorithm();
57 virtual ~BZstdCompressionAlgorithm();
59 virtual status_t CreateCompressingInputStream(BDataIO* input,
60 const BCompressionParameters* parameters,
61 BDataIO*& _stream);
62 virtual status_t CreateCompressingOutputStream(BDataIO* output,
63 const BCompressionParameters* parameters,
64 BDataIO*& _stream);
65 virtual status_t CreateDecompressingInputStream(BDataIO* input,
66 const BDecompressionParameters* parameters,
67 BDataIO*& _stream);
68 virtual status_t CreateDecompressingOutputStream(BDataIO* output,
69 const BDecompressionParameters* parameters,
70 BDataIO*& _stream);
72 virtual status_t CompressBuffer(const void* input,
73 size_t inputSize, void* output,
74 size_t outputSize, size_t& _compressedSize,
75 const BCompressionParameters* parameters
76 = NULL);
77 virtual status_t DecompressBuffer(const void* input,
78 size_t inputSize, void* output,
79 size_t outputSize,
80 size_t& _uncompressedSize,
81 const BDecompressionParameters* parameters
82 = NULL);
84 private:
85 struct CompressionStrategy;
86 struct DecompressionStrategy;
88 template<typename BaseClass, typename Strategy, typename StreamType> struct Stream;
89 template<typename BaseClass, typename Strategy, typename StreamType>
90 friend struct Stream;
92 private:
93 static status_t _TranslateZstdError(size_t error);
97 #endif // _ZSTD_COMPRESSION_ALGORITHM_H_