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

KHTML

khtml_filter_p.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002 
00003    Copyright (C) 2005 Ivor Hewitt     <ivor@kde.org>
00004    Copyright (C) 2008 Maksim Orlovich <maksim@kde.org>
00005    Copyright (C) 2008 Vyacheslav Tokarev <tsjoker@gmail.com>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include <QString>
00024 #include <QRegExp>
00025 #include <QVector>
00026 #include <wtf/HashMap.h>
00027 #include <QHash>
00028 #include <QBitArray>
00029 
00030 namespace khtml {
00031 
00032 // Updateable Multi-String Matcher based on Rabin-Karp's algorithm
00033 class StringsMatcher {
00034 public:
00035     // add filter to matching set
00036     void addString(const QString& pattern);
00037 
00038     // check if string matches at least one string from matching set,
00039     // optionally return the matching string or filter
00040     bool isMatched(const QString& str, QString *by = 0) const;
00041 
00042     // add filter to matching set with wildcards (*,?) in it
00043     void addWildedString(const QString& prefix, const QRegExp& rx);
00044 
00045     void clear();
00046 
00047 private:
00048     QVector<QString> stringFilters;
00049     QVector<QString> shortStringFilters;
00050     QVector<QRegExp> reFilters;
00051     QVector<QString> rePrefixes;
00052     QBitArray fastLookUp;
00053 
00054     WTF::HashMap<int, QVector<int> > stringFiltersHash;
00055 };
00056 
00057 // This represents a set of filters that may match URLs.
00058 // Currently it supports a subset of AddBlock Plus functionality.
00059 class FilterSet {
00060 public:
00061     // Parses and registers a filter. This will also strip @@ for exclusion rules, skip comments, etc.
00062     // The user does have to split black and white lists into separate sets, however
00063     void addFilter(const QString& filter);
00064 
00065     bool isUrlMatched(const QString& url);
00066     QString urlMatchedBy(const QString& url);
00067 
00068     void clear();
00069 
00070 private:
00071     QVector<QRegExp> reFilters;
00072     StringsMatcher stringFiltersMatcher;
00073 };
00074 
00075 }
00076 
00077 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;

KHTML

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal