• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
khtml_filter_p.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2
3 Copyright (C) 2005 Ivor Hewitt <ivor@kde.org>
4 Copyright (C) 2008 Maksim Orlovich <maksim@kde.org>
5 Copyright (C) 2008 Vyacheslav Tokarev <tsjoker@gmail.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include <QString>
24#include <QRegExp>
25#include <QVector>
26#include <wtf/HashMap.h>
27#include <QHash>
28#include <QBitArray>
29
30namespace khtml {
31
32// Updateable Multi-String Matcher based on Rabin-Karp's algorithm
33class StringsMatcher {
34public:
35 // add filter to matching set
36 void addString(const QString& pattern);
37
38 // check if string matches at least one string from matching set,
39 // optionally return the matching string or filter
40 bool isMatched(const QString& str, QString *by = 0) const;
41
42 // add filter to matching set with wildcards (*,?) in it
43 void addWildedString(const QString& prefix, const QRegExp& rx);
44
45 void clear();
46
47private:
48 QVector<QString> stringFilters;
49 QVector<QString> shortStringFilters;
50 QVector<QRegExp> reFilters;
51 QVector<QString> rePrefixes;
52 QBitArray fastLookUp;
53
54 WTF::HashMap<int, QVector<int> > stringFiltersHash;
55};
56
57// This represents a set of filters that may match URLs.
58// Currently it supports a subset of AddBlock Plus functionality.
59class FilterSet {
60public:
61 // Parses and registers a filter. This will also strip @@ for exclusion rules, skip comments, etc.
62 // The user does have to split black and white lists into separate sets, however
63 void addFilter(const QString& filter);
64
65 bool isUrlMatched(const QString& url);
66 QString urlMatchedBy(const QString& url);
67
68 void clear();
69
70private:
71 QVector<QRegExp> reFilters;
72 StringsMatcher stringFiltersMatcher;
73};
74
75}
76
77// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;
QVector
Definition: khtmlview.h:36
khtml::FilterSet
Definition: khtml_filter_p.h:59
khtml::FilterSet::addFilter
void addFilter(const QString &filter)
Definition: khtml_filter.cpp:60
khtml::FilterSet::clear
void clear()
Definition: khtml_filter.cpp:174
khtml::FilterSet::urlMatchedBy
QString urlMatchedBy(const QString &url)
Definition: khtml_filter.cpp:155
khtml::FilterSet::isUrlMatched
bool isUrlMatched(const QString &url)
Definition: khtml_filter.cpp:141
khtml::StringsMatcher
Definition: khtml_filter_p.h:33
khtml::StringsMatcher::clear
void clear()
Definition: khtml_filter.cpp:304
khtml::StringsMatcher::isMatched
bool isMatched(const QString &str, QString *by=0) const
Definition: khtml_filter.cpp:237
khtml::StringsMatcher::addWildedString
void addWildedString(const QString &prefix, const QRegExp &rx)
Definition: khtml_filter.cpp:215
khtml::StringsMatcher::addString
void addString(const QString &pattern)
Definition: khtml_filter.cpp:181
prefix
QString prefix()
pattern
QString pattern(Mode mode=Reading)
khtml
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal