|
HDK
|
#include <booleanExpression.h>
Public Types | |
| enum | BinaryOperator { BinaryOperator::EqualTo, BinaryOperator::NotEqualTo, BinaryOperator::LessThan, BinaryOperator::LessThanOrEqualTo, BinaryOperator::GreaterThan, BinaryOperator::GreaterThanOrEqualTo, BinaryOperator::And, BinaryOperator::Or } |
| enum | UnaryOperator { UnaryOperator::Not } |
| using | BinaryVisitor = TfFunctionRef< void(SdfBooleanExpression const &, BinaryOperator, SdfBooleanExpression const &)> |
| using | UnaryVisitor = TfFunctionRef< void(SdfBooleanExpression const &, UnaryOperator)> |
| using | VariableVisitor = TfFunctionRef< void(TfToken const &)> |
| using | ConstantVisitor = TfFunctionRef< void(VtValue const &)> |
| using | VariableCallback = TfFunctionRef< VtValue(TfToken const &)> |
| using | NameTransform = TfFunctionRef< TfToken(TfToken const &)> |
Public Member Functions | |
| SdfBooleanExpression ()=default | |
| Constructs an empty expression. More... | |
| SDF_API | SdfBooleanExpression (std::string const &text) |
| SDF_API bool | IsEmpty () const |
| SDF_API std::string | GetText () const |
| SDF_API std::string const & | GetParseError () const |
| SDF_API std::set< TfToken > | GetVariableNames () const |
| Provides the collection of variable names referenced by the expression. More... | |
| SDF_API void | Visit (VariableVisitor variable, ConstantVisitor constant, BinaryVisitor binary, UnaryVisitor unary) const |
| Invokes one of the given callbacks based on the type of the expression. More... | |
| SDF_API bool | Evaluate (VariableCallback const &variableCallback) const |
| SDF_API SdfBooleanExpression | RenameVariables (NameTransform const &transform) const |
| TF_DECLARE_REF_PTRS (_Node) | |
Static Public Member Functions | |
| static SDF_API SdfBooleanExpression | MakeVariable (TfToken const &variableName) |
| static SDF_API SdfBooleanExpression | MakeConstant (VtValue const &value) |
| static SDF_API SdfBooleanExpression | MakeBinaryOp (SdfBooleanExpression lhs, BinaryOperator op, SdfBooleanExpression rhs) |
| static SDF_API SdfBooleanExpression | MakeUnaryOp (SdfBooleanExpression expression, UnaryOperator op) |
| static SDF_API bool | Validate (std::string const &expression, std::string *errorMessage=nullptr) |
Friends | |
| SDF_API friend std::ostream & | operator<< (std::ostream &, SdfBooleanExpression const &) |
Objects of this class represent expressions that can be evaluated to produce a boolean value. See Sdf_Page_BooleanExpressions for more details.
Definition at line 29 of file booleanExpression.h.
| using SdfBooleanExpression::BinaryVisitor = TfFunctionRef<void(SdfBooleanExpression const&, BinaryOperator, SdfBooleanExpression const&)> |
The Visit() method will invoke this callback if the receiver represents a binary operator applied to two subexpressions.
Given the expression width > 10.0, the callback would be invoked with the arguments:
| argument | value |
|---|---|
| lhs | SdfBooleanExpression representing width |
| op | BinaryOperator::GreaterThan |
| rhs | SdfBooleanExpression representing 10.0 |
Definition at line 144 of file booleanExpression.h.
| using SdfBooleanExpression::ConstantVisitor = TfFunctionRef<void(VtValue const&)> |
The Visit() method will invoke this callback if the receiver represents a constant.
Definition at line 169 of file booleanExpression.h.
| using SdfBooleanExpression::NameTransform = TfFunctionRef<TfToken(TfToken const&)> |
Encapsulates a transformation that may be applied to a variable name. Used by RenameVariables().
Definition at line 187 of file booleanExpression.h.
| using SdfBooleanExpression::UnaryVisitor = TfFunctionRef<void(SdfBooleanExpression const&, UnaryOperator)> |
The Visit() method will invoke this callback if the receiver represents an operator applied to a single subexpression
Given the expression !(width > 10.0), the callback would be invoked with the arguments:
| argument | value |
|---|---|
| expression | SdfBooleanExpression representing width > 10.0 |
| op | UnaryOp::Not |
Definition at line 157 of file booleanExpression.h.
| using SdfBooleanExpression::VariableCallback = TfFunctionRef<VtValue (TfToken const&)> |
Provides the current value for a given variable. Used by Evaluate() when evaluating the expression.
Definition at line 179 of file booleanExpression.h.
| using SdfBooleanExpression::VariableVisitor = TfFunctionRef<void(TfToken const&)> |
The Visit() method will invoke this callback if the receiver represents a variable.
Definition at line 163 of file booleanExpression.h.
|
strong |
Operators for combining two subexpressions.
Definition at line 70 of file booleanExpression.h.
|
strong |
Operators applied to a single subexpression.
| Enumerator | |
|---|---|
| Not |
The |
Definition at line 113 of file booleanExpression.h.
|
default |
Constructs an empty expression.
|
explicit |
Constructs an expression by parsing a string representation. If an error occurs while parsing the string, the result will be an empty expression. See also GetParseError().
| SDF_API bool SdfBooleanExpression::Evaluate | ( | VariableCallback const & | variableCallback | ) | const |
Evaluates the expression. If the expression contains any variables, variableCallback will be invoked to determine their current values.
| SDF_API std::string const& SdfBooleanExpression::GetParseError | ( | ) | const |
Return parsing errors as a string if this expression was constructed from a string and parse errors were encountered.
| SDF_API std::string SdfBooleanExpression::GetText | ( | ) | const |
Provides a string representation that can be parsed by SdfBooleanExpression(std::string const&). If the expression was constructed from a string, the existing formatting will be preserved.
Provides the collection of variable names referenced by the expression.
| SDF_API bool SdfBooleanExpression::IsEmpty | ( | ) | const |
An expression is empty if it was default constructed or if there was a problem parsing its string representation.
|
static |
Constructs an expression that applies the provided operator to the result of the two provided subexpressions.
The expression width > 10.0 would be constructed with the arguments:
| argument | value |
|---|---|
| lhs | SdfBooleanExpression::MakeVariable(TfToken("width")); |
| op | BinaryOperator::GreaterThan |
| rhs | SdfBooleanExpression::MakeConstant(VtValue(10.0)); |
|
static |
Constructs an expression wrapping a constant value.
|
static |
Constructs an expression that applies the provided operator to the result of the provided subexpression.
The expression !(width > 10.0) would be constructed with the arguments:
| argument | value |
|---|---|
| expression | SdfBooleanExpression representing width > 10.0 |
| op | UnaryOp::Not |
|
static |
Constructs an expression representing a variable.
| SDF_API SdfBooleanExpression SdfBooleanExpression::RenameVariables | ( | NameTransform const & | transform | ) | const |
Applies the provided transform to each variable name and returns the resulting expression.
| SdfBooleanExpression::TF_DECLARE_REF_PTRS | ( | _Node | ) |
|
static |
Determines if the provided string can be parsed as an expression. Returns true if the expression is valid, otherwise returns false. If the string is not a valid expression, errorMessage (if non-null) will be filled with an explanatory error message.
| SDF_API void SdfBooleanExpression::Visit | ( | VariableVisitor | variable, |
| ConstantVisitor | constant, | ||
| BinaryVisitor | binary, | ||
| UnaryVisitor | unary | ||
| ) | const |
Invokes one of the given callbacks based on the type of the expression.
|
friend |