diff options
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 |