~ubuntu-branches/ubuntu/precise/stellarium/precise

« back to all changes in this revision

Viewing changes to src/external/kfilter/kfilterbase.h

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2009-03-13 20:07:22 UTC
  • mfrom: (1.1.8 upstream) (4.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090313200722-l66s4zy2s3e8up0s
Tags: 0.10.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE libraries
 
2
   Copyright (C) 2000 David Faure <faure@kde.org>
 
3
 
 
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.
 
7
 
 
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.
 
12
 
 
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.
 
17
*/
 
18
 
 
19
#ifndef __kfilterbase__h
 
20
#define __kfilterbase__h
 
21
 
 
22
#include <QtCore/QObject>
 
23
#include <QtCore/QString>
 
24
 
 
25
class QIODevice;
 
26
 
 
27
/**
 
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.
 
31
 * @internal
 
32
 */
 
33
class KFilterBase
 
34
{
 
35
public:
 
36
    KFilterBase();
 
37
    virtual ~KFilterBase();
 
38
 
 
39
    /**
 
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
 
43
     */
 
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 !
 
47
 
 
48
    /**
 
49
     * Returns the device on which the filter will work.
 
50
     * @returns the device on which the filter will work
 
51
     */
 
52
    QIODevice * device();
 
53
    /** \internal */
 
54
    virtual void init( int mode ) = 0;
 
55
    /** \internal */
 
56
    virtual int mode() const = 0;
 
57
    /** \internal */
 
58
    virtual void terminate();
 
59
    /** \internal */
 
60
    virtual void reset();
 
61
    /** \internal */
 
62
    virtual bool readHeader() = 0;
 
63
    /** \internal */
 
64
    virtual bool writeHeader( const QByteArray & filename ) = 0;
 
65
    /** \internal */
 
66
    virtual void setOutBuffer( char * data, uint maxlen ) = 0;
 
67
    /** \internal */
 
68
    virtual void setInBuffer( const char * data, uint size ) = 0;
 
69
    /** \internal */
 
70
    virtual bool inBufferEmpty() const;
 
71
    /** \internal */
 
72
    virtual int  inBufferAvailable() const = 0;
 
73
    /** \internal */
 
74
    virtual bool outBufferFull() const;
 
75
    /** \internal */
 
76
    virtual int  outBufferAvailable() const = 0;
 
77
 
 
78
    /** \internal */
 
79
    enum Result { Ok, End, Error };
 
80
    /** \internal */
 
81
    virtual Result uncompress() = 0;
 
82
    /** \internal */
 
83
    virtual Result compress( bool finish ) = 0;
 
84
 
 
85
    /**
 
86
     * Call this to create the appropriate filter for the file
 
87
     * named @p fileName.
 
88
     * @param fileName the name of the file to filter
 
89
     * @return the filter for the @p fileName, or 0 if not found
 
90
     */
 
91
    static KFilterBase * findFilterByFileName( const QString & fileName );
 
92
 
 
93
    /**
 
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
 
98
     */
 
99
    static KFilterBase * findFilterByMimeType( const QString & mimeType );
 
100
 
 
101
protected:
 
102
    QIODevice * m_dev;
 
103
    bool m_bAutoDel;
 
104
protected:
 
105
    /** Virtual hook, used to add new "virtual" functions while maintaining
 
106
        binary compatibility. Unused in this class.
 
107
    */
 
108
    virtual void virtual_hook( int id, void* data );
 
109
private:
 
110
    Q_DISABLE_COPY( KFilterBase )
 
111
    class Private;
 
112
    Private * const d;
 
113
};
 
114
 
 
115
#endif