LeechCraft 0.6.70-19214-g121e5318a7
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 <QtPlugin>
13#include <QVariant>
14#include <QStringList>
15
16namespace LC::AN
17{
28 struct FieldData
29 {
35 QString ID_;
36
41 QString Name_;
42
48 QString Description_;
49
59 QMetaType::Type Type_ = QMetaType::UnknownType;
60
67 QStringList EventTypes_;
68
70 {
73 QByteArray Id_;
74
77 QString Name_;
78
79 bool operator== (const AllowedValue&) const = default;
80 };
81
83
93 };
94
98 {
101 bool Value_;
102
103 auto operator<=> (const BoolValueMatcher&) const = default;
104 };
105
109 {
113
117 {
120 OGreater = 0x01,
121
124 OLess = 0x02,
125
128 OEqual = 0x04
129 };
130
131 Q_DECLARE_FLAGS (Operations, Operation)
132
133
137 Operations Ops_ = OEqual;
138
139 bool operator== (const IntValueMatcher&) const = default;
140 };
141
145 {
146 struct Exact
147 {
148 QString Pattern_;
149 bool operator== (const Exact&) const = default;
150 };
151
153 {
154 QString Pattern_;
155 bool operator== (const Substring&) const = default;
156 };
157
158 struct Wildcard
159 {
160 QString Pattern_;
161 QRegularExpression Compiled_ = QRegularExpression::fromWildcard (Pattern_);
162
163 bool operator== (const Wildcard&) const = default;
164 };
165
166 struct Pattern : std::variant<Substring, Wildcard, QRegularExpression, Exact>
167 {
168 using variant::variant;
169
170 explicit(false) Pattern (const QString& str)
171 : variant { Exact { str } }
172 {
173 }
174
175 using Base = variant;
176 };
177
181
187 bool Positive_ = true;
188
189 bool operator== (const StringValueMatcher&) const = default;
190 };
191
194 using ValueMatcher = std::variant<BoolValueMatcher, IntValueMatcher, StringValueMatcher>;
195}
196
211class Q_DECL_EXPORT IANEmitter
212{
213public:
214 virtual ~IANEmitter () = default;
215
232};
233
234Q_DECLARE_INTERFACE (IANEmitter, "org.Deviant.LeechCraft.IANEmitter/1.0")
235Q_DECLARE_METATYPE (LC::AN::FieldData)
238
239Q_DECLARE_OPERATORS_FOR_FLAGS (LC::AN::IntValueMatcher::Operations)
Interface for plugins emitting AdvancedNotifications entries.
Definition ianemitter.h:212
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:194
Definition constants.h:15
Matches boolean values.
Definition ianemitter.h:98
auto operator<=>(const BoolValueMatcher &) const =default
bool Value_
The value to match.
Definition ianemitter.h:101
bool operator==(const AllowedValue &) const =default
QString Name_
Human-readable name of the value.
Definition ianemitter.h:77
QByteArray Id_
Persistent, stable value stored in rules on disk.
Definition ianemitter.h:73
A single additional AdvancedNotifications field.
Definition ianemitter.h:29
QString ID_
The field ID.
Definition ianemitter.h:35
QStringList EventTypes_
The types of the event that contain this field.
Definition ianemitter.h:67
QMetaType::Type Type_
The type of this field.
Definition ianemitter.h:59
QString Name_
The name of the field.
Definition ianemitter.h:41
AllowedValues AllowedValues_
The allowed values of this field.
Definition ianemitter.h:92
QList< AllowedValue > AllowedValues
Definition ianemitter.h:82
QString Description_
The description of the field.
Definition ianemitter.h:48
Matches integer values.
Definition ianemitter.h:109
Operation
Describes the elementary semantics of Boundary_.
Definition ianemitter.h:117
@ OEqual
The value should be equal to Boundary_.
Definition ianemitter.h:128
@ OGreater
The value should be greater than Boundary_.
Definition ianemitter.h:120
@ OLess
The value should be less than Boundary_.
Definition ianemitter.h:124
int Boundary_
The boundary to compare the matched values against.
Definition ianemitter.h:112
Operations Ops_
Describe the semantics of Boundary_.
Definition ianemitter.h:137
bool operator==(const IntValueMatcher &) const =default
Matches string values.
Definition ianemitter.h:145
bool Positive_
Whether the values should match or not match Pattern_.
Definition ianemitter.h:187
Pattern Pattern_
The pattern the values should (not) match.
Definition ianemitter.h:180
Q_DECLARE_METATYPE(QVariantList *)