7 #ifndef PXR_USD_SDF_VARIABLE_EXPRESSION
8 #define PXR_USD_SDF_VARIABLE_EXPRESSION
15 #include "pxr/base/vt/array.h"
21 #include <unordered_set>
26 namespace Sdf_VariableExpressionImpl {
110 explicit operator bool()
const;
122 const std::vector<std::string>&
GetErrors()
const;
200 template <
class ResultType>
210 _FormatUnexpectedTypeError(r.
value,
VtValue(ResultType())));
253 friend class SdfVariableExpression;
254 Builder(std::string&& expr) : _expr(std::move(expr)) { }
266 template <
class Argument>
274 friend class SdfVariableExpression;
287 template <
class Element>
300 friend class SdfVariableExpression;
311 template <
class... Arguments>
312 static FunctionBuilder
316 (b.
AddArgument(std::forward<Arguments>(fnArgs)), ...);
325 template <
class... Elements>
330 (b.
AddElement(std::forward<Elements>(elems)), ...);
364 _FormatUnexpectedTypeError(
const VtValue& got,
const VtValue& expected);
369 std::string* expr,
const SdfVariableExpression&
arg,
bool first);
373 _AppendBuilder(std::string* expr,
const Builder&
b,
bool first);
375 template <
class Argument>
377 _Append(std::string* expr, Argument&&
arg,
bool first)
381 if constexpr (std::is_same_v<
382 std::decay_t<Argument>, SdfVariableExpression>) {
383 _AppendExpression(expr, std::forward<Argument>(
arg), first);
386 _AppendBuilder(expr, std::forward<Argument>(
arg), first);
390 std::vector<std::string> _errors;
391 std::shared_ptr<Sdf_VariableExpressionImpl::Node> _expression;
392 std::string _expressionStr;
411 template <
class Argument>
415 SdfVariableExpression::_Append(
416 &_expr, std::forward<Argument>(
arg),
417 *_expr.rbegin() ==
'(');
421 template <
class Element>
425 SdfVariableExpression::_Append(
426 &_expr, std::forward<Element>(
arg),
427 *_expr.rbegin() ==
'[');
434 const std::vector<T>&
values)
436 for (
const T&
v : values) {
ListBuilder & AddLiteralValues(const std::vector< T > &values)
SDF_API SdfVariableExpression()
Construct an object representing an invalid expression.
SDF_API Result Evaluate(const VtDictionary &variables) const
std::unordered_set< std::string > usedVariables
SDF_API ~SdfVariableExpression()
static SDF_API bool IsExpression(const std::string &s)
#define PXR_NAMESPACE_OPEN_SCOPE
GLsizei const GLfloat * value
static ListBuilder MakeList(Elements &&...elems)
static FunctionBuilder MakeFunction(const std::string &fnName, Arguments &&...fnArgs)
static SDF_API Builder MakeLiteral(int64_t value)
Create a literal expression for value.
bool IsEmpty() const
Returns true iff this value is empty.
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
static ListBuilder MakeListOfLiterals(const std::vector< T > &values)
SDF_API const std::vector< std::string > & GetErrors() const
friend class SdfVariableExpression
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
static SDF_API bool IsValidVariableType(const VtValue &value)
GLuint const GLchar * name
friend class SdfVariableExpression
GLboolean GLboolean GLboolean b
FunctionBuilder & AddArgument(Argument &&arg)
static SDF_API Builder MakeNone()
Create a "None" literal expression.
A trait to detect instantiations of VtArray, specialized in array.h.
std::vector< std::string > errors
Errors encountered while evaluating the expression.
GLenum GLsizei GLsizei GLint * values
#define PXR_NAMESPACE_CLOSE_SCOPE
static SDF_API Builder MakeVariable(const std::string &name)
friend class SdfVariableExpression
ListBuilder & AddElement(Element &&elem)
SDF_API const std::string & GetString() const
Returns the expression string used to construct this object.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Result EvaluateTyped(const VtDictionary &variables) const