8#include <QRegularExpression>
18#include "phosphorrules_export.h"
112 return m_kind ==
Kind::All && m_children.isEmpty();
170 static std::optional<MatchExpression>
fromJson(
const QJsonObject& obj);
180 return !(*
this == other);
184 Kind m_kind = Kind::All;
185 Predicate m_predicate;
186 QList<MatchExpression> m_children;
192 std::shared_ptr<QRegularExpression> m_compiledRegex;
204 static std::optional<MatchExpression> fromJsonAtDepth(
const QJsonObject& obj,
int depth);
Kind
Tree node kind.
Definition MatchExpression.h:53
@ All
AND — every child must match.
Definition MatchExpression.h:55
@ Leaf
a single field/op/value predicate
Definition MatchExpression.h:54
static MatchExpression makeLeaf(const Predicate &predicate)
Constructs a leaf predicate expression.
static MatchExpression makeLeaf(Field field, Operator op, const QVariant &value)
bool negatesAnyField(const QSet< Field > &fields) const
True if a leaf predicate on one of fields appears anywhere INSIDE a none{} negation (at any nesting d...
static MatchExpression makeNone(const QList< MatchExpression > &children)
bool isContextOnly() const
True if this expression references only context fields (ScreenId / VirtualDesktop / Activity / Mode /...
MatchExpression()
Default-constructs an empty All{} — the always-true catch-all.
Definition MatchExpression.h:74
static std::optional< MatchExpression > fromJson(const QJsonObject &obj)
Strict loader — returns nullopt on a malformed / invalid expression.
Kind kind() const
Definition MatchExpression.h:88
bool operator!=(const MatchExpression &other) const
Definition MatchExpression.h:178
const QList< MatchExpression > & children() const
Composite accessor — empty for a leaf.
Definition MatchExpression.h:104
const Predicate & predicate() const
Leaf accessor — only meaningful when isLeaf().
Definition MatchExpression.h:98
static MatchExpression makeAny(const QList< MatchExpression > &children)
bool operator==(const MatchExpression &other) const
bool isCatchAll() const
True if this is the empty catch-all All{} — matches every query.
Definition MatchExpression.h:110
bool evaluate(const WindowQuery &query) const
Evaluate this expression against query.
static MatchExpression makeAll(const QList< MatchExpression > &children)
Constructs a composite expression.
bool referencesAnyField(const QSet< Field > &fields) const
True if any leaf predicate anywhere in the tree (including inside none{} negations) tests one of fiel...
static constexpr int kMaxParseDepth
Hard cap on the JSON parser's recursion depth.
Definition MatchExpression.h:175
QJsonObject toJson() const
bool isLeaf() const
Definition MatchExpression.h:92
bool isValid() const
True if this expression is structurally well-formed: every leaf has a field/operator combination that...
Definition ActionParams.h:25
Field
Match fields.
Definition MatchTypes.h:23
@ AppId
Definition MatchTypes.h:25
Operator
Match operators.
Definition MatchTypes.h:441
@ Equals
case-insensitive for strings, numeric for ints, bool for flags
Definition MatchTypes.h:442
Leaf predicate payload.
Definition MatchExpression.h:62
Operator op
Definition MatchExpression.h:64
QVariant value
Definition MatchExpression.h:65
bool operator==(const Predicate &other) const
Definition MatchExpression.h:67
Field field
Definition MatchExpression.h:63
The evaluation input — an attribute bag matched against a MatchExpression.
Definition WindowQuery.h:37