LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
ianemitter.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <variant>
12#include <QObject>
13#include <QVariant>
14#include <QStringList>
15#include <QRegularExpression>
16
17namespace LC::AN
18{
29 struct FieldData
30 {
36 QString ID_;
37
42 QString Name_;
43
49 QString Description_;
50
60 QMetaType::Type Type_ = QMetaType::UnknownType;
61
68 QStringList EventTypes_;
69
71 {
74 QByteArray Id_;
75
78 QString Name_;
79
80 bool operator== (const AllowedValue&) const = default;
81 };
82
84
94 };
95
99 {
102 bool Value_;
103
104 auto operator<=> (const BoolValueMatcher&) const = default;
105 };
106
110 {
114
118 {
121 OGreater = 0x01,
122
125 OLess = 0x02,
126
129 OEqual = 0x04
130 };
131
132 Q_DECLARE_FLAGS (Operations, Operation)
133
134
138 Operations Ops_ = OEqual;
139
140 bool operator== (const IntValueMatcher&) const = default;
141 };
142
146 {
147 struct Exact
148 {
149 QString Pattern_;
150 bool operator== (const Exact&) const = default;
151 };
152
154 {
155 QString Pattern_;
156 bool operator== (const Substring&) const = default;
157 };
158
159 struct Wildcard
160 {
161 QString Pattern_;
162 QRegularExpression Compiled_ = QRegularExpression::fromWildcard (Pattern_);
163
164 bool operator== (const Wildcard&) const = default;
165 };
166
167 struct Pattern : std::variant<Substring, Wildcard, QRegularExpression, Exact>
168 {
169 using variant::variant;
170
171 explicit(false) Pattern (const QString& str)
172 : variant { Exact { str } }
173 {
174 }
175
176 using Base = variant;
177 };
178
182
188 bool Positive_ = true;
189
190 bool operator== (const StringValueMatcher&) const = default;
191 };
192
195 using ValueMatcher = std::variant<BoolValueMatcher, IntValueMatcher, StringValueMatcher>;
196}
197
212class Q_DECL_EXPORT IANEmitter
213{
214public:
215 virtual ~IANEmitter () = default;
216
233};
234
235Q_DECLARE_INTERFACE (IANEmitter, "org.Deviant.LeechCraft.IANEmitter/1.0")
236Q_DECLARE_METATYPE (LC::AN::FieldData)
238
239Q_DECLARE_OPERATORS_FOR_FLAGS (LC::AN::IntValueMatcher::Operations)
Interface for plugins emitting AdvancedNotifications entries.
Definition ianemitter.h:213
virtual ~IANEmitter()=default
virtual QList< LC::AN::FieldData > GetANFields() const =0
Returns the list of additional fields.
auto operator==(const T &left, const T &right)
Definition common.h:21
Q_DECLARE_FLAGS(NotifyFlags, NotifyFlag)
std::variant< BoolValueMatcher, IntValueMatcher, StringValueMatcher > ValueMatcher
A matcher for a value of any supported type.
Definition ianemitter.h:195
Definition constants.h:15
Matches boolean values.
Definition ianemitter.h:99
auto operator<=>(const BoolValueMatcher &) const =default
bool Value_
The value to match.
Definition ianemitter.h:102
bool operator==(const AllowedValue &) const =default
QString Name_
Human-readable name of the value.
Definition ianemitter.h:78
QByteArray Id_
Persistent, stable value stored in rules on disk.
Definition ianemitter.h:74
A single additional AdvancedNotifications field.
Definition ianemitter.h:30
QString ID_
The field ID.
Definition ianemitter.h:36
QStringList EventTypes_
The types of the event that contain this field.
Definition ianemitter.h:68
QMetaType::Type Type_
The type of this field.
Definition ianemitter.h:60
QString Name_
The name of the field.
Definition ianemitter.h:42
AllowedValues AllowedValues_
The allowed values of this field.
Definition ianemitter.h:93
QList< AllowedValue > AllowedValues
Definition ianemitter.h:83
QString Description_
The description of the field.
Definition ianemitter.h:49
Matches integer values.
Definition ianemitter.h:110
Operation
Describes the elementary semantics of Boundary_.
Definition ianemitter.h:118
@ OEqual
The value should be equal to Boundary_.
Definition ianemitter.h:129
@ OGreater
The value should be greater than Boundary_.
Definition ianemitter.h:121
@ OLess
The value should be less than Boundary_.
Definition ianemitter.h:125
int Boundary_
The boundary to compare the matched values against.
Definition ianemitter.h:113
Operations Ops_
Describe the semantics of Boundary_.
Definition ianemitter.h:138
bool operator==(const IntValueMatcher &) const =default
Matches string values.
Definition ianemitter.h:146
bool Positive_
Whether the values should match or not match Pattern_.
Definition ianemitter.h:188
Pattern Pattern_
The pattern the values should (not) match.
Definition ianemitter.h:181
Q_DECLARE_METATYPE(QVariantList *)