File indexing completed on 2024-05-05 04:44:00

0001 /*
0002     SPDX-FileCopyrightText: 2005 Ivor Hewitt <ivor@kde.org>
0003     SPDX-FileCopyrightText: 2008 Maksim Orlovich <maksim@kde.org>
0004     SPDX-FileCopyrightText: 2008 Vyacheslav Tokarev <tsjoker@gmail.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef WEBKIT_FILTER_P_H
0010 #define WEBKIT_FILTER_P_H
0011 
0012 #include <QString>
0013 #include <QRegExp>
0014 #include <QVector>
0015 #include <kwebkitpart.h>
0016 
0017 class StringsMatcher;
0018 
0019 namespace KDEPrivate
0020 {
0021 // This represents a set of filters that may match URLs.
0022 // Currently it supports a subset of AddBlock Plus functionality.
0023 class FilterSet {
0024 public:
0025     FilterSet();
0026     ~FilterSet();
0027 
0028     // Parses and registers a filter. This will also strip @@ for exclusion rules, skip comments, etc.
0029     // The user does have to split black and white lists into separate sets, however
0030     void addFilter(const QString& filter);
0031 
0032     bool isUrlMatched(const QString& url);
0033     QString urlMatchedBy(const QString& url);
0034 
0035     void clear();
0036 
0037 private:
0038     QVector<QRegExp> reFilters;
0039     StringsMatcher* stringFiltersMatcher;
0040 };
0041 
0042 }
0043 
0044 #endif // WEBKIT_FILTER_P_H
0045 
0046 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;