VariableBindings.h header
#include <ew/app/VariableBindings.h>
Namespace ew::app
VariableBindings class
class ew::app::VariableBindings
The names a branching condition may use: the story's variables, as the reader's playthrough currently holds them.
A variable is named as it is written in the Variables list. Where that name has spaces, an underscore stands in for each – has key is typed has_key – which is the convention Chat Mapper settled on for the same reason: an author should not have to rename their variables to be able to test them.
A Flag resolves to 1 or 0, so hasKey, hasKey = TRUE and NOT hasKey all read correctly. A declared variable the state does not carry resolves to its declared initial value rather than an error: the declaration is what the author wrote down, and a walk that has not reached the node which sets it is exactly the case a condition is there to handle. The world is reachable too. A condition may name any object – gold >= @Sword_of_Rhys.price – through the same resolver a validation rule uses, so a branch can depend on the world the story is set in and not only on the counters the author remembered to declare. A variable's name is looked for first, so nothing already written changes meaning.
Members
ew::app::expression::VariableBindings::VariableBindings(const std::vector< ew::core::branching::Variable > &variables, const std::map< ew::core::foundation::VariableId, ew::core::branching::VariableValue > &state, const WorldResolver *world=nullptr)
Binds variables, read at the values state currently holds. world resolves object names, or nullptr where a condition may name only variables.
bool ew::app::expression::VariableBindings::isNameStart(QChar character) const override
Adds the object sigil and the path characters when a world was given.
bool ew::app::expression::VariableBindings::isNameCharacter(QChar character) const override
Adds the path characters when a world was given.
std::optional< std::vector< ew::core::expression::Value > > ew::app::expression::VariableBindings::resolve(QStringView name, QString &error) const override
Resolves one variable name, then an object path.
QStringList ew::app::expression::VariableBindings::names() const override
Every variable's name, spelled the way a condition must type it, and every object.
Functions
QString ew::app::expression::expressionName(const ew::core::branching::Variable &variable)
The name variable is typed as inside an expression: its own name with each space replaced by an underscore.