diff options
Diffstat (limited to 'staging/hostlist/filterlist.hpp')
-rw-r--r-- | staging/hostlist/filterlist.hpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/staging/hostlist/filterlist.hpp b/staging/hostlist/filterlist.hpp index 24243e5..6edc19d 100644 --- a/staging/hostlist/filterlist.hpp +++ b/staging/hostlist/filterlist.hpp @@ -17,9 +17,29 @@ namespace Hostlist class Filterlist final : public Filter { public: + typedef uint DomainHash; + struct Rule { + QString domain; + QString redirect; + }; + Filterlist() = default; ~Filterlist() = default; + [[nodiscard]] bool findMatch(const QString &domain) const + { + const auto hash = qHash(domain, 0); + const auto found = rules.find(hash); + if(found != rules.end()) { + return true; + } + return false; + } + int count() const + { + return rules.size(); + } + [[nodiscard]] bool filter(QWebEngineUrlRequestInfo &info) const { return false; @@ -29,12 +49,7 @@ public: return true; } - typedef uint DomainHash; - struct Rule { - QString domain; - QString redirect; - }; - + bool load(QIODevice &device); [[nodiscard]] static std::map<DomainHash, Rule> parseRule(const QString &line); private: |