1 | /* This file is part of the KDE libraries |
2 | SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef __kfilterbase__h |
8 | #define __kfilterbase__h |
9 | |
10 | #include <karchive_export.h> |
11 | |
12 | #include <QObject> |
13 | #include <QString> |
14 | class KFilterBasePrivate; |
15 | |
16 | class QIODevice; |
17 | |
18 | /*! |
19 | * \class KFilterBase |
20 | * \inmodule KArchive |
21 | * |
22 | * This is the base class for compression filters |
23 | * such as gzip and bzip2. It's pretty much internal. |
24 | * Don't use directly, use KCompressionDevice instead. |
25 | * \internal |
26 | */ |
27 | class KARCHIVE_EXPORT KFilterBase |
28 | { |
29 | public: |
30 | KFilterBase(); |
31 | virtual ~KFilterBase(); |
32 | |
33 | /*! |
34 | * Sets the device on which the filter will work |
35 | * |
36 | * \a dev the device on which the filter will work |
37 | * |
38 | * \a autodelete if true, \a dev is deleted when the filter is deleted |
39 | */ |
40 | void setDevice(QIODevice *dev, bool autodelete = false); |
41 | // Note that this isn't in the constructor, because of KLibFactory::create, |
42 | // but it should be called before using the filterbase ! |
43 | |
44 | /*! |
45 | * Returns the device on which the filter will work. |
46 | * Returnss the device on which the filter will work |
47 | */ |
48 | QIODevice *device(); |
49 | /*! \internal */ |
50 | virtual bool init(int mode) = 0; |
51 | /*! \internal */ |
52 | virtual int mode() const = 0; |
53 | /*! \internal */ |
54 | virtual bool terminate(); |
55 | /*! \internal */ |
56 | virtual void reset(); |
57 | /*! \internal */ |
58 | virtual bool () = 0; |
59 | /*! \internal */ |
60 | virtual bool (const QByteArray &filename) = 0; |
61 | /*! \internal */ |
62 | virtual void setOutBuffer(char *data, uint maxlen) = 0; |
63 | /*! \internal */ |
64 | virtual void setInBuffer(const char *data, uint size) = 0; |
65 | /*! \internal */ |
66 | virtual bool inBufferEmpty() const; |
67 | /*! \internal */ |
68 | virtual int inBufferAvailable() const = 0; |
69 | /*! \internal */ |
70 | virtual bool outBufferFull() const; |
71 | /*! \internal */ |
72 | virtual int outBufferAvailable() const = 0; |
73 | |
74 | /*! \internal */ |
75 | enum Result { |
76 | Ok, |
77 | End, |
78 | Error, |
79 | }; |
80 | /*! \internal */ |
81 | virtual Result uncompress() = 0; |
82 | /*! \internal */ |
83 | virtual Result compress(bool finish) = 0; |
84 | |
85 | /*! |
86 | * \internal |
87 | * \since 4.3 |
88 | */ |
89 | enum FilterFlags { |
90 | = 0, |
91 | = 1, |
92 | = 2, // only use for gzip compression |
93 | }; |
94 | /*! |
95 | * \internal |
96 | * \since 4.3 |
97 | */ |
98 | void setFilterFlags(FilterFlags flags); |
99 | FilterFlags filterFlags() const; |
100 | |
101 | protected: |
102 | /*! Virtual hook, used to add new "virtual" functions while maintaining |
103 | binary compatibility. Unused in this class. |
104 | */ |
105 | virtual void virtual_hook(int id, void *data); |
106 | |
107 | private: |
108 | Q_DISABLE_COPY(KFilterBase) |
109 | KFilterBasePrivate *const d; |
110 | }; |
111 | |
112 | #endif |
113 | |