From e2b1cc628b304e3f153abc17fb350aa781e26b36 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 18 Dec 2017 14:32:45 +0100 Subject: Basic adblock FilterRule --- lib/adblock/filterrule.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lib/adblock/filterrule.h (limited to 'lib/adblock/filterrule.h') diff --git a/lib/adblock/filterrule.h b/lib/adblock/filterrule.h new file mode 100644 index 0000000..66731e2 --- /dev/null +++ b/lib/adblock/filterrule.h @@ -0,0 +1,62 @@ +/******************************************************************************* + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 Xian Nox + ** + ** This program is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** This program is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with this program. If not, see . + ** + ******************************************************************************/ + +#ifndef FILTERRULE_H +#define FILTERRULE_H + +#include + +class QUrl; +class FilterRule +{ +public: + + FilterRule(const QString &line); + + // delete the copy constructor and assignment operator + FilterRule(const FilterRule&) = delete; + FilterRule& operator=(const FilterRule&) = delete; + + // move constructor + FilterRule(FilterRule&& other) { + valid = other.valid; + exception = other.exception; + rule = other.rule; + } + + ~FilterRule(); + + bool isValid() const; + bool isException() const; + bool shouldBlock(const QUrl &requestUrl) const; + +private: + bool parse(const QString &line); + + bool valid; + bool exception; + + QRegularExpression rule; + +}; + +QString createRegExpPattern(const QString &line); + +#endif // FILTERRULE_H -- cgit v1.2.1