|
| | MatchExpression () |
| | Default-constructs an empty All{} — the always-true catch-all.
|
| Kind | kind () const |
| bool | isLeaf () const |
| const Predicate & | predicate () const |
| | Leaf accessor — only meaningful when isLeaf().
|
| const QList< MatchExpression > & | children () const |
| | Composite accessor — empty for a leaf.
|
| bool | isCatchAll () const |
| | True if this is the empty catch-all All{} — matches every query.
|
| bool | isContextOnly () const |
| | True if this expression references only context fields (ScreenId / VirtualDesktop / Activity / Mode / TiledWindowCount) — i.e.
|
| bool | referencesAnyField (const QSet< Field > &fields) const |
| | True if any leaf predicate anywhere in the tree (including inside none{} negations) tests one of fields.
|
| 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 depth).
|
| bool | evaluate (const WindowQuery &query) const |
| | Evaluate this expression against query.
|
| bool | isValid () const |
| | True if this expression is structurally well-formed: every leaf has a field/operator combination that can actually match (a string operator on a numeric field is rejected), and Regex patterns compile.
|
| QJsonObject | toJson () const |
| bool | operator== (const MatchExpression &other) const |
| bool | operator!= (const MatchExpression &other) const |
A composable predicate tree evaluated against a WindowQuery.
An expression is either:
- a leaf — a Predicate { field, op, value }, or
- a composite — All (AND), Any (OR), or None (NOT-any) over a list of child expressions.
MatchExpression is a copyable value type — it lives inside QList<Rule>. The compiled regex for a Regex leaf is built eagerly at construction time (in makeLeaf / fromJson) and stored in a shared_ptr so value-copies share the same compiled program rather than recompiling.
Thread-safety. evaluate() performs no lazy mutation of the MatchExpression itself — it only reads the already-compiled program. It is therefore reentrant. It is NOT, however, safe to call concurrently on two MatchExpression copies that share a Regex leaf: the shared shared_ptr<QRegularExpression> means both copies dispatch through one QRegularExpression instance, and QRegularExpression::match() mutates that instance's internal state (it is not thread-safe for concurrent match() calls on the same object). Callers that evaluate copies of a regex-bearing expression from multiple threads must serialize those calls themselves.
An empty All{} is the always-true catch-all — the migrated provider default. An empty Any{} / None{} are always-false / always-true respectively, following the standard fold identities.
| bool PhosphorRules::MatchExpression::evaluate |
( |
const WindowQuery & | query | ) |
const |
Evaluate this expression against query.
A leaf predicate over an absent window field evaluates false. Composites fold per their kind. The empty All{} returns true.
Reentrant, but not safe to call concurrently on copies that share a Regex leaf — see the class-level thread-safety note. Callers must serialize concurrent evaluation of regex-bearing expressions.
| bool PhosphorRules::MatchExpression::negatesAnyField |
( |
const QSet< Field > & | fields | ) |
const |
True if a leaf predicate on one of fields appears anywhere INSIDE a none{} negation (at any nesting depth).
This is the negation-polarity guard for resolvers whose query cannot answer a field. An absent field makes its leaf evaluate FALSE, which is the safe, inert outcome for a positive leaf — but none{} matches when no child matched, so the same absence makes a NEGATED leaf match unconditionally: none{AppId == firefox} on a windowless context query matches every context. A resolver that does not stamp a field must therefore exclude rules that NEGATE it; positive references stay admitted, because inert-false is exactly the documented behaviour for them and an any{} rule's other branches may legitimately fire.