WorldResolver.h header
#include <ew/app/WorldResolver.h>
Namespace ew::app
WorldResolver class
class ew::app::WorldResolver
Names any object in the world, and any property of it, inside any expression.
Built once and consumed by all four expression surfaces – validation rules, computed and rollup fields, spreadsheet formulas and branching conditions – because four resolvers would be four subtly different answers, and they would disagree exactly at the edges nobody tests: a deleted target, a hidden one, an empty list, a name that is also a field.
The syntax. @Rhys.stats.strength is Rhys's strength; the @ says the name is an object rather than a field of whatever the expression is about. Everything after it is an ordinary property path (see valuesAtPath): into a block, across a reference, over a list. A name with spaces is typed with underscores, as story variables are. A trailing #moment reads the value as of a moment on the timeline – @Rhys.title#coronation – naming a timeline marker, an era, or a date the project's calendar understands.
Stored by id, shown by name. What is saved is @ followed by the object's stable id, so renaming Rhys breaks nothing anywhere; the editor shows and accepts the name (see toDisplayExpression and toStoredExpression). An id that no longer resolves is a readable refusal AND a dangling-reference finding, never a silent zero – an expression that quietly answered 0 for a deleted object would be a rule that passed because its subject was gone.
Members
ew::app::expression::WorldResolver::WorldResolver(const ew::core::project::Project &project, Viewer viewer, std::optional< qint64 > instant)
Resolves names in project for viewer, reading values as of instant (std::nullopt for the current ones).
bool ew::app::expression::WorldResolver::isNameStart(QChar character) const override
Adds '@' and '#' to the path characters, so an object reference and its moment are one name.
bool ew::app::expression::WorldResolver::isNameCharacter(QChar character) const override
Adds the path characters plus '@' and '#'.
std::optional< std::vector< ew::core::expression::Value > > ew::app::expression::WorldResolver::resolve(QStringView name, QString &error) const override
Resolves an object path. name may name the object by id (@<id>, what is stored), by name (@Rhys), or bare (Rhys) where nothing nearer claims the name.
QStringList ew::app::expression::WorldResolver::names() const override
Every object the viewer may see, spelled as a reference (@Rhys), for autocomplete.
QStringList ew::app::expression::WorldResolver::danglingIn(const QString &expression) const
The object references in expression that no longer resolve, as the ids were written.
What a validator turns into a dangling-reference finding. Empty for a sound expression, and for one whose objects are merely invisible to this viewer – being unable to see something is not the same as its being gone, and reporting it as deleted would tell a restricted reader about content they are not allowed to know exists.
Functions
QString ew::app::expression::objectReferenceName(const ew::core::project::Project &project, ew::core::foundation::ContentId id)
The name id is typed as inside an expression – its own name with each space an underscore – or the compact id itself when nothing in project has that id.
Falling back to the id rather than to "(deleted)" keeps a readout honest about what the rule still holds, which is the thing that could repair it.
ew::core::foundation::ContentId ew::app::expression::objectReferenced(const ew::core::project::Project &project, const QString &reference)
The object reference names, or a null id when it names nothing. reference is the head of an object path, with or without its '@': a compact id, a typed name, or an alias.
QString ew::app::expression::toDisplayExpression(const ew::core::project::Project &project, const QString &expression)
expression with every object reference written by name, for showing to an author.
@0f3c9d...stats.strength becomes @Rhys.stats.strength. A reference whose object is gone is left exactly as it is – rewriting it to "(deleted)" would destroy the id on the next save, and the id is the only thing that could still be repaired.
QString ew::app::expression::toStoredExpression(const ew::core::project::Project &project, const QString &expression, const ew::core::expression::Bindings *claimed)
expression with every object reference written by id, for saving.
The inverse of toDisplayExpression, and the reason renaming never breaks an expression. A name that claimed already resolves is left alone: in a validation rule price is the subject's field, and it must not be captured by an entity that happens to be called Price. Pass the surface's own bindings as claimed, or nullptr where nothing else names anything.