Falkon Develop
Cross-platform Qt-based web browser
adblocksearchtree.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef ADBLOCKSEARCHTREE_H
19#define ADBLOCKSEARCHTREE_H
20
21#include <QChar>
22#include <QHash>
23
24#include "qzcommon.h"
25
26class QWebEngineUrlRequestInfo;
27
28class AdBlockRule;
29
31{
32public:
33 explicit AdBlockSearchTree();
35
36 void clear();
37
38 bool add(const AdBlockRule* rule);
39 const AdBlockRule* find(const QWebEngineUrlRequestInfo &request, const QString &domain, const QString &urlString) const;
40
41private:
42 struct Node {
43 QChar c;
44 const AdBlockRule* rule;
45 QHash<QChar, Node*> children;
46
47 Node() : c(0) , rule(nullptr) { }
48 };
49
50 const AdBlockRule* prefixSearch(const QWebEngineUrlRequestInfo &request, const QString &domain,
51 const QString &urlString, const QChar* string, int len) const;
52
53 void deleteNode(Node* node);
54
55 Node* m_root;
56};
57
58#endif // ADBLOCKSEARCHTREE_H
#define FALKON_EXPORT
Definition: qzcommon.h:28