7#ifndef PXR_USD_SDF_PATH_EXPRESSION_H
8#define PXR_USD_SDF_PATH_EXPRESSION_H
11#include "pxr/usd/sdf/api.h"
12#include "pxr/usd/sdf/path.h"
13#include "pxr/usd/sdf/pathPattern.h"
22PXR_NAMESPACE_OPEN_SCOPE
80 template <
class HashState>
82 h.Append(er.path, er.name);
87 return std::tie(l.path, l.name) == std::tie(r.path, r.name);
91 operator!=(ExpressionReference
const &l, ExpressionReference
const &r) {
95 friend void swap(ExpressionReference &l, ExpressionReference &r) {
96 auto lt = std::tie(l.path, l.name);
97 auto rt = std::tie(r.path, r.name);
126 std::string
const &parseContext = {});
253 TfFunctionRef<
void (std::vector<std::pair<Op, int>>
const &)> logic,
261 SdfPath const &newPrefix)
const & {
294 return !_refs.empty();
364 explicit operator bool()
const {
375 template <
class HashState>
377 h.Append(expr._ops, expr._refs, expr._patterns, expr._parseError);
381 friend std::ostream &
386 return std::tie(l._ops, l._refs, l._patterns, l._parseError) ==
387 std::tie(r._ops, r._refs, r._patterns, r._parseError);
396 auto lt = std::tie(l._ops, l._refs, l._patterns, l._parseError);
397 auto rt = std::tie(r._ops, r._refs, r._patterns, r._parseError);
401 std::vector<Op> _ops;
402 std::vector<ExpressionReference> _refs;
403 std::vector<PathPattern> _patterns;
407 std::string _parseError;
411PXR_NAMESPACE_CLOSE_SCOPE
Objects of this class represent references to other path expressions, which will be resolved later by...
static SDF_API ExpressionReference const & Weaker()
Return the special "weaker" reference, whose syntax in an SdfPathExpression is "%_".
Objects of this class represent a logical expression syntax tree consisting of SdfPathPattern s,...
SDF_API SdfPathExpression ReplacePrefix(SdfPath const &oldPrefix, SdfPath const &newPrefix) &&
Return a new expression created by replacing literal path prefixes that start with oldPrefix with new...
static SDF_API SdfPathExpression MakeAtom(ExpressionReference &&ref)
Produce a new expression containing only the reference ref.
SDF_API bool IsAbsolute() const
Return true if all contained pattern prefixes are absolute, false otherwise.
static SDF_API SdfPathExpression const & EveryDescendant()
Return the relative expression ".//" which matches all paths descendant to an anchor path.
static SdfPathExpression MakeAtom(ExpressionReference const &ref)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API SdfPathExpression MakeAbsolute(SdfPath const &anchor) &&
Return a new expression created by making any relative path prefixes in this expression absolute by S...
bool IsComplete() const
Return true if this expression is considered "complete".
static SDF_API SdfPathExpression MakeAtom(PathPattern &&pattern)
Produce a new expression containing only the pattern pattern.
SDF_API std::string GetText() const
Return a text representation of this expression that parses to the same expression.
SDF_API SdfPathExpression(std::string const &expr, std::string const &parseContext={})
Construct an expression by parsing expr.
static SdfPathExpression MakeAtom(PathPattern const &pattern)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Op
Enumerant describing a subexpression operation.
static SDF_API SdfPathExpression const & Nothing()
Return the empty expression which matches no paths.
SdfPathExpression ComposeOver(SdfPathExpression const &weaker) const &
Return a new expression created by replacing references to the "weaker expression" (i....
SdfPathExpression ReplacePrefix(SdfPath const &oldPrefix, SdfPath const &newPrefix) const &
Return a new expression created by replacing literal path prefixes that start with oldPrefix with new...
static SDF_API SdfPathExpression MakeComplement(SdfPathExpression &&right)
Produce a new expression representing the set-complement of right.
SdfPathExpression()=default
Default construction produces the "empty" expression.
static SDF_API SdfPathExpression const & Everything()
Return the expression "//" which matches all paths.
bool IsEmpty() const
Return true if this is the empty expression; i.e.
SdfPathExpression MakeAbsolute(SdfPath const &anchor) const &
Return a new expression created by making any relative path prefixes in this expression absolute by S...
static SdfPathExpression MakeOp(Op op, SdfPathExpression const &left, SdfPathExpression const &right)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool ContainsExpressionReferences() const
Return true if this expression contains any references to other collections.
SDF_API void Walk(TfFunctionRef< void(Op, int)> logic, TfFunctionRef< void(ExpressionReference const &)> ref, TfFunctionRef< void(PathPattern const &)> pattern) const
Walk this expression's syntax tree in depth-first order, calling pattern with the current PathPattern...
SDF_API SdfPathExpression ComposeOver(SdfPathExpression const &weaker) &&
This is an overloaded member function, provided for convenience. It differs from the above function o...
static SdfPathExpression MakeAtom(SdfPath const &path)
Produce a new expression that matches path exactly.
std::string const & GetParseError() const &
Return parsing errors as a string if this function was constructed from a string and parse errors wer...
static SdfPathExpression MakeAtom(SdfPath &&path)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static SDF_API SdfPathExpression MakeOp(Op op, SdfPathExpression &&left, SdfPathExpression &&right)
Produce a new expression representing the set-algebraic operation op with operands left and right.
static SDF_API SdfPathExpression const & WeakerRef()
Return the expression "%_", consisting solely of a reference to the "weaker" path expression,...
SDF_API void WalkWithOpStack(TfFunctionRef< void(std::vector< std::pair< Op, int > > const &)> logic, TfFunctionRef< void(ExpressionReference const &)> ref, TfFunctionRef< void(PathPattern const &)> pattern) const
Equivalent to Walk(), except that the logic function is called with a const reference to the current ...
SDF_API SdfPathExpression ResolveReferences(TfFunctionRef< SdfPathExpression(ExpressionReference const &)> resolve) &&
This is an overloaded member function, provided for convenience. It differs from the above function o...
static SdfPathExpression MakeComplement(SdfPathExpression const &right)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SdfPathExpression ResolveReferences(TfFunctionRef< SdfPathExpression(ExpressionReference const &)> resolve) const &
Return a new expression created by resolving collection references in this expression.
SDF_API bool ContainsWeakerExpressionReference() const
Return true if this expression contains one or more "weaker" expression references,...
A path value used to locate objects in layers or scenegraphs.
Objects of this class represent SdfPath matching patterns, consisting of an SdfPath prefix followed b...
This class provides a non-owning reference to a type-erased callable object with a specified signatur...