Make UEFI boot-platform build again
[haiku.git] / headers / private / support / CompressionAlgorithm.h
blobf2ca69c74d8e9d4f4480ec038237ac49a52258fe
1 /*
2 * Copyright 2014, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _COMPRESSION_ALGORITHM_H_
6 #define _COMPRESSION_ALGORITHM_H_
9 #include <DataIO.h>
12 class BCompressionParameters {
13 public:
14 BCompressionParameters();
15 virtual ~BCompressionParameters();
19 class BDecompressionParameters {
20 public:
21 BDecompressionParameters();
22 virtual ~BDecompressionParameters();
26 class BCompressionAlgorithm {
27 public:
28 BCompressionAlgorithm();
29 virtual ~BCompressionAlgorithm();
31 virtual status_t CreateCompressingInputStream(BDataIO* input,
32 const BCompressionParameters* parameters,
33 BDataIO*& _stream);
34 virtual status_t CreateCompressingOutputStream(BDataIO* output,
35 const BCompressionParameters* parameters,
36 BDataIO*& _stream);
37 virtual status_t CreateDecompressingInputStream(BDataIO* input,
38 const BDecompressionParameters* parameters,
39 BDataIO*& _stream);
40 virtual status_t CreateDecompressingOutputStream(BDataIO* output,
41 const BDecompressionParameters* parameters,
42 BDataIO*& _stream);
44 virtual status_t CompressBuffer(const void* input,
45 size_t inputSize, void* output,
46 size_t outputSize, size_t& _compressedSize,
47 const BCompressionParameters* parameters
48 = NULL);
49 virtual status_t DecompressBuffer(const void* input,
50 size_t inputSize, void* output,
51 size_t outputSize,
52 size_t& _uncompressedSize,
53 const BDecompressionParameters* parameters
54 = NULL);
56 protected:
57 class BAbstractStream;
58 class BAbstractInputStream;
59 class BAbstractOutputStream;
63 class BCompressionAlgorithm::BAbstractStream : public BDataIO {
64 public:
65 BAbstractStream();
66 virtual ~BAbstractStream();
68 status_t Init(size_t bufferSize);
70 protected:
71 virtual status_t ProcessData(const void* input, size_t inputSize,
72 void* output, size_t outputSize,
73 size_t& bytesConsumed,
74 size_t& bytesProduced) = 0;
75 // must consume or produce at least 1 byte
76 // or return an error
77 virtual status_t FlushPendingData(void* output,
78 size_t outputSize,
79 size_t& bytesProduced) = 0;
81 protected:
82 uint8* fBuffer;
83 size_t fBufferCapacity;
84 size_t fBufferOffset;
85 size_t fBufferSize;
89 class BCompressionAlgorithm::BAbstractInputStream : public BAbstractStream {
90 public:
91 BAbstractInputStream(BDataIO* input);
92 virtual ~BAbstractInputStream();
94 virtual ssize_t Read(void* buffer, size_t size);
96 private:
97 BDataIO* fInput;
98 bool fEndOfInput;
99 bool fNoMorePendingData;
103 class BCompressionAlgorithm::BAbstractOutputStream : public BAbstractStream {
104 public:
105 BAbstractOutputStream(BDataIO* output);
106 virtual ~BAbstractOutputStream();
108 virtual ssize_t Write(const void* buffer, size_t size);
110 virtual status_t Flush();
112 private:
113 ssize_t _Write(const void* buffer, size_t size,
114 bool flush);
116 private:
117 BDataIO* fOutput;
121 #endif // _COMPRESSION_ALGORITHM_H_