This repository was archived by the owner on Mar 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrulecontroller.h
More file actions
64 lines (50 loc) · 1.37 KB
/
Copy pathrulecontroller.h
File metadata and controls
64 lines (50 loc) · 1.37 KB
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
59
60
61
62
63
64
#ifndef RULECONTROLLER_H
#define RULECONTROLLER_H
#include <QObject>
#include <QHash>
#include <QDir>
#include <QMap>
#include <QFileInfo>
#include <variant>
#include <optional>
#include "pacmanrunner.h"
class RuleController : public QObject
{
Q_OBJECT
public:
enum class RuleScope {
Any,
Epoche,
Version,
Suffix,
Revision
};
Q_ENUM(RuleScope)
struct RuleInfo {
using RangeContent = std::pair<int, std::optional<int>>;
using Range = std::optional<RangeContent>; // (offset, limit)
QString package;
RuleScope scope = RuleScope::Any;
Range range;
std::optional<int> count;
};
struct RuleSource {
bool extension = false;
bool isRoot = false;
QStringList targets;
};
explicit RuleController(PacmanRunner *runner, QObject *parent = nullptr);
void createRule(const QString &pkg, bool autoDepends, QStringList deps);
void removeRule(const QString &pkg);
QString listRules(bool pkgOnly, bool userOnly);
QList<RuleInfo> findRules(const QString &pkg);
private:
PacmanRunner *_runner;
QMap<QString, RuleSource> _ruleSources;
QMultiHash<QString, RuleInfo> _rules;
void readRules();
QList<RuleInfo> readRuleDefinitions(const QFileInfo &fileInfo, RuleSource &srcBase);
static void parseScope(RuleInfo &ruleInfo, const QStringRef &scopeStr);
static void addRules(QList<RuleInfo> &target, const QList<RuleInfo> &newRules);
};
#endif // RULECONTROLLER_H