|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
One x-rules entry, or a condition inside one, and its translation into expr/1. More...
#include <rules.hpp>
Public Types | |
| enum class | Kind : std::uint8_t { Engaged , NotEngaged , Equals , Greater , GreaterOrEqual , Less , LessOrEqual , RequiredWhen , ExactlyOneOf , AtLeastOneOf , MutuallyExclusive , VisibleWhen , ReadonlyWhen , And , Or , Not , Unknown } |
| The rule kinds. More... | |
Public Member Functions | |
| Kind | kind () const noexcept |
| The kind. | |
| std::string_view | kindName () const noexcept |
| The kind as the schema spells it. | |
| std::span< std::string const > | fields () const noexcept |
| The fields this node names directly (fields). | |
| bool | names (std::string_view field) const noexcept |
Whether this node names field directly. A presentation rule applies to every field it names. | |
| RuleExpr const * | when () const noexcept |
| The when clause of requiredWhen, visibleWhen and readonlyWhen. | |
| std::span< RuleExpr const > | conditions () const noexcept |
| The operands of and and or, or the one operand of not. | |
| bool | gates () const noexcept |
| Whether the rule decides readiness. visibleWhen and readonlyWhen only present. | |
| bool | presents (Kind kind, std::string_view field) const noexcept |
Whether the rule is a presentation rule of kind that names field. | |
| detail::engine::Json const & | expression () const noexcept |
| The translation, as expr/1 JSON: for a gating rule its test, for a presentation rule its when clause. Set on a node parse returned; a child node holds none. | |
| std::span< std::string const > | operands () const noexcept |
| The wire names the translation reads, by operand index (f0 is the first). | |
| Tri | evaluate (RuleLookup const &lookup) const |
| Evaluates the translation with the UI document's evaluator. | |
| Tri | whenHolds (RuleLookup const &lookup) const |
| Evaluates the when clause of a requiredWhen, visibleWhen or readonlyWhen. | |
Static Public Member Functions | |
| static std::expected< RuleExpr, SchemaError > | parse (detail::engine::Json const &node, std::string const &path) |
| Reads one rule or condition node and translates it. | |
One x-rules entry, or a condition inside one, and its translation into expr/1.
The 16 kinds the emitters write are read; any other kind parses and is Unknown, so an older client never refuses a newer server's form. A rule's operands are numbered f0, f1, … in its translation, and each operand reads as two names: fN.engaged (true, false, or null when its draft does not encode) and fN.value (the encoded value, null unless it is valid). The two are needed because a blank operand and an invalid one are both "no value" to the expression language, and the rules tell them apart: a comparison with a blank operand holds vacuously, one with an invalid operand is Unknown.
|
strong |
The rule kinds.
| Enumerator | |
|---|---|
| Engaged | engaged: the field has a value. |
| NotEngaged | |
| Equals | equals: the field equals the literal value (valueText for wide integers). |
| Greater | greater: the first field is greater than the second, when both are engaged. |
| GreaterOrEqual | |
| Less | less. |
| LessOrEqual | |
| RequiredWhen | requiredWhen: the fields are required while when holds. |
| ExactlyOneOf | exactlyOneOf: exactly one field is engaged. |
| AtLeastOneOf | |
| MutuallyExclusive | mutuallyExclusive: at most one field is engaged. |
| VisibleWhen | visibleWhen: presentation; the fields are shown while when holds. |
| ReadonlyWhen | readonlyWhen: presentation; the fields are frozen while when holds. |
| And | and over conditions. |
| Or | or over conditions. |
| Not | not of condition. |
| Unknown | A kind this engine does not know. |
|
inlinestaticnodiscard |
Reads one rule or condition node and translates it.
| node | The node. |
| path | Where it is, for errors. |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
The when clause of requiredWhen, visibleWhen and readonlyWhen.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Whether the rule decides readiness. visibleWhen and readonlyWhen only present.
|
inlinenodiscardnoexcept |
Whether the rule is a presentation rule of kind that names field.
| kind | RequiredWhen, VisibleWhen or ReadonlyWhen. |
| field | The wire name. |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscard |
Evaluates the translation with the UI document's evaluator.
For a gating rule this is its test; for visibleWhen, readonlyWhen and the presentation side of requiredWhen use whenHolds.
| lookup | Reads each operand. |
|
inlinenodiscard |
Evaluates the when clause of a requiredWhen, visibleWhen or readonlyWhen.
| lookup | Reads each operand. |