KDECore
kgzipfilter.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000, 2009 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 __kgzipfilter__h 00021 #define __kgzipfilter__h 00022 00023 #include "kfilterbase.h" 00024 00032 class KDECORE_EXPORT KGzipFilter : public KFilterBase 00033 { 00034 public: 00035 KGzipFilter(); 00036 virtual ~KGzipFilter(); 00037 00038 00039 virtual void init(int mode); 00040 00041 // The top of zlib.h explains it: there are three cases. 00042 // - Raw deflate, no header (e.g. inside a ZIP file) 00043 // - Thin zlib header (1) (which is normally what HTTP calls "deflate" (2)) 00044 // - Gzip header, implemented here by readHeader 00045 // 00046 // (1) as written out by compress()/compress2() 00047 // (2) see http://www.zlib.net/zlib_faq.html#faq39 00048 enum Flag { 00049 RawDeflate = 0, // raw deflate data 00050 ZlibHeader = 1, // zlib headers (HTTP deflate) 00051 GZipHeader = 2 00052 }; 00053 void init(int mode, Flag flag); // for direct users of KGzipFilter 00054 virtual int mode() const; 00055 virtual void terminate(); 00056 virtual void reset(); 00057 virtual bool readHeader(); // this is about the GZIP header 00058 virtual bool writeHeader( const QByteArray & fileName ); 00059 void writeFooter(); 00060 virtual void setOutBuffer( char * data, uint maxlen ); 00061 virtual void setInBuffer( const char * data, uint size ); 00062 virtual int inBufferAvailable() const; 00063 virtual int outBufferAvailable() const; 00064 virtual Result uncompress(); 00065 virtual Result compress( bool finish ); 00066 00067 private: 00068 Result uncompress_noop(); 00069 class Private; 00070 Private* const d; 00071 }; 00072 00073 #endif