24#ifndef PXR_USD_SDF_VARIABLE_EXPRESSION
25#define PXR_USD_SDF_VARIABLE_EXPRESSION
30#include "pxr/usd/sdf/api.h"
34#include "pxr/base/vt/value.h"
38#include <unordered_set>
41PXR_NAMESPACE_OPEN_SCOPE
43namespace Sdf_VariableExpressionImpl {
123 explicit operator bool()
const;
155 std::vector<std::string> errors;
165 std::unordered_set<std::string> usedVariables;
210 template <
class ResultType>
216 r.value =
VtValue(ResultType());
218 else if (!r.value.IsEmpty() && !r.value.IsHolding<ResultType>()) {
220 _FormatUnexpectedTypeError(r.value,
VtValue(ResultType())));
229 _FormatUnexpectedTypeError(
const VtValue& got,
const VtValue& expected);
231 std::vector<std::string> _errors;
232 std::shared_ptr<Sdf_VariableExpressionImpl::Node> _expression;
233 std::string _expressionStr;
252PXR_NAMESPACE_CLOSE_SCOPE
Class responsible for parsing and evaluating variable expressions.
SDF_API const std::string & GetString() const
Returns the expression string used to construct this object.
static SDF_API bool IsExpression(const std::string &s)
Returns true if s is a variable expression, false otherwise.
SDF_API SdfVariableExpression()
Construct an object representing an invalid expression.
static SDF_API bool IsValidVariableType(const VtValue &value)
Returns true if value holds a type that is supported by variable expressions, false otherwise.
SDF_API Result Evaluate(const VtDictionary &variables) const
Evaluates this expression using the variables in variables and returns a Result object with the final...
SDF_API const std::vector< std::string > & GetErrors() const
Returns a list of errors encountered when parsing this expression.
Result EvaluateTyped(const VtDictionary &variables) const
Evaluates this expression using the variables in variables and returns a Result object with the final...
SDF_API SdfVariableExpression(const std::string &expr)
Construct using the expression expr.
A result value representing an empty list.
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Array concept. By default, types are not arrays.