blob: 7301f20c79a60a51bd494046654162b5b1947707 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* This file is part of smolbote. It's copyrighted by the contributors recorded
* in the version control history of the file, available from its original
* location: https://library.iserlohn-fortress.net/aqua/smolbote.git
*
* SPDX-License-Identifier: GPL-3.0
*/
#pragma once
#include <map>
#include <smolbote/filterinterface.hpp>
namespace Hostlist
{
class Filterlist final : public FilterList
{
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;
}
[[nodiscard]] bool isUpToDate() const
{
return true;
}
bool load(QIODevice &device);
[[nodiscard]] static std::map<DomainHash, Rule> parseRule(const QString &line);
private:
std::map<DomainHash, Rule> rules;
};
} // namespace Hostlist
|