diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-18 14:32:45 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-18 14:32:45 +0100 |
commit | e2b1cc628b304e3f153abc17fb350aa781e26b36 (patch) | |
tree | 269fc864b57b9356dd19c78b2965cb595371e0b7 /lib/adblock/filterrule.h | |
parent | ProfileView dialog (diff) | |
download | smolbote-e2b1cc628b304e3f153abc17fb350aa781e26b36.tar.xz |
Basic adblock FilterRule
Diffstat (limited to 'lib/adblock/filterrule.h')
-rw-r--r-- | lib/adblock/filterrule.h | 62 |
1 files changed, 62 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. + ** + ******************************************************************************/ + +#ifndef FILTERRULE_H +#define FILTERRULE_H + +#include <QRegularExpression> + +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 |