1
/* This file is part of the KDE libraries
2
Copyright (C) 2000 David Faure <faure@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
19
#ifndef __kfilterbase__h
20
#define __kfilterbase__h
22
#include <QtCore/QObject>
23
#include <QtCore/QString>
28
* This is the base class for compression filters
29
* such as gzip and bzip2. It's pretty much internal.
30
* Don't use directly, use KFilterDev instead.
37
virtual ~KFilterBase();
40
* Sets the device on which the filter will work
41
* @param dev the device on which the filter will work
42
* @param autodelete if true, @p dev is deleted when the filter is deleted
44
void setDevice( QIODevice * dev, bool autodelete = false );
45
// Note that this isn't in the constructor, because of KLibFactory::create,
46
// but it should be called before using the filterbase !
49
* Returns the device on which the filter will work.
50
* @returns the device on which the filter will work
54
virtual void init( int mode ) = 0;
56
virtual int mode() const = 0;
58
virtual void terminate();
62
virtual bool readHeader() = 0;
64
virtual bool writeHeader( const QByteArray & filename ) = 0;
66
virtual void setOutBuffer( char * data, uint maxlen ) = 0;
68
virtual void setInBuffer( const char * data, uint size ) = 0;
70
virtual bool inBufferEmpty() const;
72
virtual int inBufferAvailable() const = 0;
74
virtual bool outBufferFull() const;
76
virtual int outBufferAvailable() const = 0;
79
enum Result { Ok, End, Error };
81
virtual Result uncompress() = 0;
83
virtual Result compress( bool finish ) = 0;
86
* Call this to create the appropriate filter for the file
88
* @param fileName the name of the file to filter
89
* @return the filter for the @p fileName, or 0 if not found
91
static KFilterBase * findFilterByFileName( const QString & fileName );
94
* Call this to create the appropriate filter for the mimetype
95
* @p mimeType. For instance application/x-gzip.
96
* @param mimeType the mime type of the file to filter
97
* @return the filter for the @p mimeType, or 0 if not found
99
static KFilterBase * findFilterByMimeType( const QString & mimeType );
105
/** Virtual hook, used to add new "virtual" functions while maintaining
106
binary compatibility. Unused in this class.
108
virtual void virtual_hook( int id, void* data );
110
Q_DISABLE_COPY( KFilterBase )