7#ifndef PXR_USD_SDF_VARIABLE_EXPRESSION
8#define PXR_USD_SDF_VARIABLE_EXPRESSION
13#include "pxr/usd/sdf/api.h"
17#include "pxr/base/vt/value.h"
21#include <unordered_set>
24PXR_NAMESPACE_OPEN_SCOPE
26namespace Sdf_VariableExpressionImpl {
106 explicit operator bool()
const;
138 std::vector<std::string> errors;
148 std::unordered_set<std::string> usedVariables;
193 template <
class ResultType>
199 r.value =
VtValue(ResultType());
201 else if (!r.value.IsEmpty() && !r.value.IsHolding<ResultType>()) {
203 _FormatUnexpectedTypeError(r.value,
VtValue(ResultType())));
212 _FormatUnexpectedTypeError(
const VtValue& got,
const VtValue& expected);
214 std::vector<std::string> _errors;
215 std::shared_ptr<Sdf_VariableExpressionImpl::Node> _expression;
216 std::string _expressionStr;
235PXR_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.