KDECore
kfilterbase.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __kfilterbase__h 00021 #define __kfilterbase__h 00022 00023 #include <kdecore_export.h> 00024 00025 #include <QtCore/QObject> 00026 #include <QtCore/QString> 00027 00028 class QIODevice; 00029 00036 class KDECORE_EXPORT KFilterBase 00037 { 00038 public: 00039 KFilterBase(); 00040 virtual ~KFilterBase(); 00041 00047 void setDevice( QIODevice * dev, bool autodelete = false ); 00048 // Note that this isn't in the constructor, because of KLibFactory::create, 00049 // but it should be called before using the filterbase ! 00050 00055 QIODevice * device(); 00057 virtual void init( int mode ) = 0; 00059 virtual int mode() const = 0; 00061 virtual void terminate(); 00063 virtual void reset(); 00065 virtual bool readHeader() = 0; 00067 virtual bool writeHeader( const QByteArray & filename ) = 0; 00069 virtual void setOutBuffer( char * data, uint maxlen ) = 0; 00071 virtual void setInBuffer( const char * data, uint size ) = 0; 00073 virtual bool inBufferEmpty() const; 00075 virtual int inBufferAvailable() const = 0; 00077 virtual bool outBufferFull() const; 00079 virtual int outBufferAvailable() const = 0; 00080 00082 enum Result { Ok, End, Error }; 00084 virtual Result uncompress() = 0; 00086 virtual Result compress( bool finish ) = 0; 00087 00092 enum FilterFlags { 00093 NoHeaders = 0, 00094 WithHeaders = 1 00095 }; 00100 void setFilterFlags(FilterFlags flags); 00101 FilterFlags filterFlags() const; 00102 00109 static KFilterBase * findFilterByFileName( const QString & fileName ); 00110 00117 static KFilterBase * findFilterByMimeType( const QString & mimeType ); 00118 00119 protected: // TODO KDE5: move to d pointer 00120 QIODevice * m_dev; 00121 bool m_bAutoDel; 00122 protected: 00126 virtual void virtual_hook( int id, void* data ); 00127 private: 00128 Q_DISABLE_COPY( KFilterBase ) 00129 class Private; 00130 Private * const d; 00131 }; 00132 00133 #endif
KDE 4.6 API Reference