1 /* 2 * Copyright (c) 2003-2008 André Wöbbeking <Woebbeking@kde.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 20 #ifndef CERVISIA_STRINGMATCHER_H 21 #define CERVISIA_STRINGMATCHER_H 22 23 24 #include <QStringList> 25 26 27 28 namespace Cervisia 29 { 30 31 32 class StringMatcher 33 { 34 public: 35 36 /** 37 * @return \c true, if text matches one of the given patterns. 38 */ 39 bool match(const QString& text) const; 40 41 /** 42 * Adds pattern \a pattern. 43 */ 44 void add(const QString& pattern); 45 46 /** 47 * Removes all patterns. 48 */ 49 void clear(); 50 51 private: 52 53 /** 54 * The patterns which are tested in match(). 55 */ 56 QStringList m_exactPatterns; 57 58 /** 59 * The patterns which are tested in match(). 60 */ 61 QStringList m_startPatterns; 62 63 /** 64 * The patterns which are tested in match(). 65 */ 66 QStringList m_endPatterns; 67 68 /** 69 * The patterns which are tested in match(). 70 */ 71 QList<QByteArray> m_generalPatterns; 72 }; 73 74 75 } // namespace Cervisia 76 77 78 #endif // CERVISIA_STRINGMATCHER_H 79