8#ifndef PXR_USD_SDF_BOOLEAN_EXPRESSION_H
9#define PXR_USD_SDF_BOOLEAN_EXPRESSION_H
11#include "pxr/usd/sdf/api.h"
14#include "pxr/base/tf/functionRef.h"
16#include "pxr/base/vt/value.h"
21PXR_NAMESPACE_OPEN_SCOPE
199 Validate(std::string
const& expression, std::string* errorMessage =
nullptr);
209 SDF_API
friend std::ostream&
213 std::string _parseError;
214 _NodeRefPtr _rootNode;
223PXR_NAMESPACE_CLOSE_SCOPE
Objects of this class represent expressions that can be evaluated to produce a boolean value.
static SDF_API SdfBooleanExpression MakeVariable(TfToken const &variableName)
Constructs an expression representing a variable.
static SDF_API SdfBooleanExpression MakeUnaryOp(SdfBooleanExpression expression, UnaryOperator op)
Constructs an expression that applies the provided operator to the result of the provided subexpressi...
static SDF_API SdfBooleanExpression MakeBinaryOp(SdfBooleanExpression lhs, BinaryOperator op, SdfBooleanExpression rhs)
Constructs an expression that applies the provided operator to the result of the two provided subexpr...
SdfBooleanExpression()=default
Constructs an empty expression.
SDF_API bool IsEmpty() const
An expression is empty if it was default constructed or if there was a problem parsing its string rep...
UnaryOperator
Operators applied to a single subexpression.
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.
SDF_API SdfBooleanExpression(std::string const &text)
Constructs an expression by parsing a string representation.
SDF_API std::string GetText() const
Provides a string representation that can be parsed by SdfBooleanExpression(std::string const&).
static SDF_API SdfBooleanExpression MakeConstant(VtValue const &value)
Constructs an expression wrapping a constant value.
static SDF_API bool Validate(std::string const &expression, std::string *errorMessage=nullptr)
Determines if the provided string can be parsed as an expression.
SDF_API bool Evaluate(VariableCallback const &variableCallback) const
Evaluates the expression.
SDF_API SdfBooleanExpression RenameVariables(NameTransform const &transform) const
Applies the provided transform to each variable name and returns the resulting expression.
BinaryOperator
Operators for combining two subexpressions.
@ EqualTo
The == operator.
@ NotEqualTo
The != operator.
@ LessThanOrEqualTo
The <= operator.
@ GreaterThanOrEqualTo
The >= operator.
@ LessThan
The < operator.
@ GreaterThan
The > operator.
SDF_API std::set< TfToken > GetVariableNames() const
Provides the collection of variable names referenced by the expression.
SDF_API std::string const & GetParseError() const
Return parsing errors as a string if this expression was constructed from a string and parse errors w...
This class provides a non-owning reference to a type-erased callable object with a specified signatur...
Token for efficient comparison, assignment, and hashing of known strings.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...