KArchive

kfilterbase.h
1 /* This file is part of the KDE libraries
2  SPDX-FileCopyrightText: 2000 David Faure <[email protected]>
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 kfilterbase.h KFilterBase
20  *
21  * This is the base class for compression filters
22  * such as gzip and bzip2. It's pretty much internal.
23  * Don't use directly, use KCompressionDevice instead.
24  * @internal
25  */
26 class KARCHIVE_EXPORT KFilterBase
27 {
28 public:
29  KFilterBase();
30  virtual ~KFilterBase();
31 
32  /**
33  * Sets the device on which the filter will work
34  * @param dev the device on which the filter will work
35  * @param autodelete if true, @p dev is deleted when the filter is deleted
36  */
37  void setDevice(QIODevice *dev, bool autodelete = false);
38  // Note that this isn't in the constructor, because of KLibFactory::create,
39  // but it should be called before using the filterbase !
40 
41  /**
42  * Returns the device on which the filter will work.
43  * @returns the device on which the filter will work
44  */
45  QIODevice *device();
46  /** \internal */
47  virtual bool init(int mode) = 0;
48  /** \internal */
49  virtual int mode() const = 0;
50  /** \internal */
51  virtual bool terminate();
52  /** \internal */
53  virtual void reset();
54  /** \internal */
55  virtual bool readHeader() = 0;
56  /** \internal */
57  virtual bool writeHeader(const QByteArray &filename) = 0;
58  /** \internal */
59  virtual void setOutBuffer(char *data, uint maxlen) = 0;
60  /** \internal */
61  virtual void setInBuffer(const char *data, uint size) = 0;
62  /** \internal */
63  virtual bool inBufferEmpty() const;
64  /** \internal */
65  virtual int inBufferAvailable() const = 0;
66  /** \internal */
67  virtual bool outBufferFull() const;
68  /** \internal */
69  virtual int outBufferAvailable() const = 0;
70 
71  /** \internal */
72  enum Result {
73  Ok,
74  End,
75  Error,
76  };
77  /** \internal */
78  virtual Result uncompress() = 0;
79  /** \internal */
80  virtual Result compress(bool finish) = 0;
81 
82  /**
83  * \internal
84  * \since 4.3
85  */
86  enum FilterFlags {
87  NoHeaders = 0,
88  WithHeaders = 1,
89  ZlibHeaders = 2, // only use for gzip compression
90  };
91  /**
92  * \internal
93  * \since 4.3
94  */
95  void setFilterFlags(FilterFlags flags);
96  FilterFlags filterFlags() const;
97 
98 protected:
99  /** Virtual hook, used to add new "virtual" functions while maintaining
100  binary compatibility. Unused in this class.
101  */
102  virtual void virtual_hook(int id, void *data);
103 
104 private:
105  Q_DISABLE_COPY(KFilterBase)
106  KFilterBasePrivate *const d;
107 };
108 
109 #endif
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Dec 8 2022 03:55:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.