Cutelee
6.1.0
|
A container for static variables defined in Templates. More...
#include <cutelee/variable.h>
Public Member Functions | |
Variable () | |
Variable (const QString &var) | |
Variable (const Variable &other) | |
~Variable () | |
bool | isConstant () const |
bool | isLocalized () const |
bool | isTrue (Context *c) const |
bool | isValid () const |
QVariant | literal () const |
QStringList | lookups () const |
Variable & | operator= (const Variable &other) |
QVariant | resolve (Context *c) const |
This class is only relevant to Template tag authors.
When processing a template tag in a AbstractNodeFactory implementation, it will sometimes make sense to process arguments to the tag as Cutelee::Variables. Note that usually they should be processed as FilterExpression objects instead.
Arguments to the tag can be used to construct Variables, which may then be resolved into the objects they represent in the given Context in the render stage.
Definition at line 52 of file variable.h.
Variable::Variable | ( | ) |
Constructs an invalid Variable
Definition at line 62 of file variable.cpp.
|
explicit |
Creates a Variable represented by the given var
Definition at line 77 of file variable.cpp.
References Cutelee::markSafe(), and Cutelee::unescapeStringLiteral().
Variable::Variable | ( | const Variable & | other | ) |
Copy constructor
Definition at line 57 of file variable.cpp.
Variable::~Variable | ( | ) |
Destructor
Definition at line 64 of file variable.cpp.
bool Variable::isConstant | ( | ) | const |
Returns whether this Variable is a constant in the Template. A constant is represented as a static string in the template
Definition at line 139 of file variable.cpp.
bool Variable::isLocalized | ( | ) | const |
Returns whether this variable is localized, that is, if it is wrapped with _().
Definition at line 147 of file variable.cpp.
bool Variable::isTrue | ( | Context * | c | ) | const |
Returns whether this Variable evaluates to true with the Context c
.
Definition at line 145 of file variable.cpp.
References resolve(), and Cutelee::variantIsTrue().
bool Variable::isValid | ( | ) | const |
Returns whether this Variable is valid.
Definition at line 133 of file variable.cpp.
QVariant Variable::literal | ( | ) | const |
Returns whether this variable is a literal string or number. A literal Variable does not have any lookup components.
Definition at line 153 of file variable.cpp.
Referenced by DictSortFilter::doFilter().
QStringList Variable::lookups | ( | ) | const |
Returns the lookup components of this Variable.
Definition at line 159 of file variable.cpp.
Referenced by DictSortFilter::doFilter().
Assignment operator.
Definition at line 66 of file variable.cpp.
Resolves this Variable with the Context c
.
Definition at line 175 of file variable.cpp.
References Cutelee::getSafeString(), Cutelee::isSafeString(), Cutelee::Context::localizer(), and Cutelee::Context::lookup().
Referenced by isTrue().