| 1 | /* This file is part of the KDE libraries |
| 2 | SPDX-FileCopyrightText: 2021 Albert Astals Cid <aacid@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KZSTDFILTER_H |
| 8 | #define KZSTDFILTER_H |
| 9 | |
| 10 | #include <config-compression.h> |
| 11 | |
| 12 | #if HAVE_ZSTD_SUPPORT |
| 13 | |
| 14 | #include "kfilterbase.h" |
| 15 | |
| 16 | #include <memory> |
| 17 | |
| 18 | /*! |
| 19 | * Internal class used by KCompressionDevice |
| 20 | * \internal |
| 21 | */ |
| 22 | class KZstdFilter : public KFilterBase |
| 23 | { |
| 24 | public: |
| 25 | KZstdFilter(); |
| 26 | ~KZstdFilter() override; |
| 27 | |
| 28 | bool init(int) override; |
| 29 | int mode() const override; |
| 30 | bool terminate() override; |
| 31 | void reset() override; |
| 32 | bool () override |
| 33 | { |
| 34 | return true; |
| 35 | } |
| 36 | bool (const QByteArray &) override |
| 37 | { |
| 38 | return true; |
| 39 | } |
| 40 | void setOutBuffer(char *data, uint maxlen) override; |
| 41 | void setInBuffer(const char *data, uint size) override; |
| 42 | int inBufferAvailable() const override; |
| 43 | int outBufferAvailable() const override; |
| 44 | Result uncompress() override; |
| 45 | Result compress(bool finish) override; |
| 46 | |
| 47 | private: |
| 48 | class Private; |
| 49 | const std::unique_ptr<Private> d; |
| 50 | }; |
| 51 | |
| 52 | #endif |
| 53 | |
| 54 | #endif |
| 55 | |