KDECore
kmimemagicrule_p.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 * Copyright 2007 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 KMIMEMAGICRULE_H 00021 #define KMIMEMAGICRULE_H 00022 00023 #include <QList> 00024 #include <QString> 00025 class QIODevice; 00026 00031 struct KMimeMagicMatch 00032 { 00033 bool match(QIODevice* device, qint64 deviceSize, QByteArray& availableData, const QString& mimeType) const; 00034 00035 qint64 m_rangeStart; 00036 qint64 m_rangeLength; 00037 QByteArray m_data; 00038 QByteArray m_mask; 00039 QList<KMimeMagicMatch> m_subMatches; 00040 }; 00041 00053 class KMimeMagicRule 00054 { 00055 public: 00056 KMimeMagicRule(const QString& mimetype, int priority, const QList<KMimeMagicMatch>& matches) 00057 : m_mimetype(mimetype), m_priority(priority), m_matches(matches) {} 00058 00059 bool match(QIODevice* device, qint64 deviceSize, QByteArray& availableData) const; 00060 00061 QString mimetype() const { return m_mimetype; } 00062 int priority() const { return m_priority; } 00063 // For unit test only 00064 QList<KMimeMagicMatch> matches() const { return m_matches; } 00065 00066 private: 00067 QString m_mimetype; 00068 int m_priority; 00069 QList<KMimeMagicMatch> m_matches; 00070 }; 00071 00072 #endif /* KMIMEMAGICRULE_H */
KDE 4.6 API Reference