7#ifndef PXR_USD_SDF_PATH_PATTERN_H
8#define PXR_USD_SDF_PATH_PATTERN_H
11#include "pxr/usd/sdf/api.h"
12#include "pxr/usd/sdf/path.h"
13#include "pxr/usd/sdf/predicateExpression.h"
22PXR_NAMESPACE_OPEN_SCOPE
67 bool IsStretch()
const {
68 return predicateIndex == -1 && text.empty();
72 int predicateIndex = -1;
73 bool isLiteral =
false;
76 return std::tie(l.text, l.predicateIndex, l.isLiteral) ==
77 std::tie(r.text, r.predicateIndex, r.isLiteral);
84 template <
class HashState>
85 friend void TfHashAppend(HashState &h,
Component const &c) {
86 h.Append(c.text, c.predicateIndex, c.isLiteral);
90 auto lt = std::tie(l.text, l.predicateIndex, l.isLiteral);
91 auto rt = std::tie(r.text, r.predicateIndex, r.isLiteral);
100 std::string *reason =
nullptr)
const {
110 std::string *reason =
nullptr)
const;
134 std::string *reason =
nullptr)
const {
144 std::string *reason =
nullptr)
const;
172 return std::move(_prefix);
226 return std::move(_components);
231 std::vector<SdfPredicateExpression>
const &
237 std::vector<SdfPredicateExpression>
239 return std::move(_predExprs);
249 explicit operator bool()
const {
255 std::vector<Component> &&components,
256 std::vector<SdfPredicateExpression> &&predExprs,
259 template <
class HashState>
260 friend void TfHashAppend(HashState &h,
SdfPathPattern const &pat) {
261 h.Append(pat._prefix, pat._components,
262 pat._predExprs, pat._isProperty);
267 return std::tie(l._prefix, l._components,
268 l._predExprs, l._isProperty) ==
269 std::tie(r._prefix, r._components,
270 r._predExprs, r._isProperty);
280 l._prefix, l._components, l._predExprs, l._isProperty);
282 r._prefix, r._components, r._predExprs, r._isProperty);
287 std::vector<Component> _components;
288 std::vector<SdfPredicateExpression> _predExprs;
293PXR_NAMESPACE_CLOSE_SCOPE
A path value used to locate objects in layers or scenegraphs.
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Objects of this class represent SdfPath matching patterns, consisting of an SdfPath prefix followed b...
bool IsProperty() const
Return true if this pattern identifies properties exclusively, false otherwise.
SDF_API SdfPathPattern & AppendChild(std::string const &text)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API SdfPathPattern()
Construct the empty pattern whose bool-conversion operator returns false.
bool CanAppendProperty(std::string const &text, std::string *reason=nullptr) const
Return true if it is valid to append the property element text to this pattern.
SDF_API SdfPathPattern(SdfPath &&prefix)
Construct a SdfPathPattern with the prefix path.
SDF_API std::string GetText() const
Return the string representation of this pattern.
bool CanAppendChild(std::string const &text, std::string *reason=nullptr) const
Return true if it is valid to append the child element text to this pattern.
SdfPathPattern & SetPrefix(SdfPath const &p)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API SdfPathPattern & RemoveTrailingComponent()
If this pattern has components, remove the final component.
std::vector< SdfPredicateExpression > GetPredicateExprs() &&
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API bool CanAppendChild(std::string const &text, SdfPredicateExpression const &predExpr, std::string *reason=nullptr) const
Return true if it is valid to append the child element text and predExpr to this pattern.
SDF_API SdfPathPattern & AppendProperty(std::string const &text, SdfPredicateExpression &&predExpr)
Append a prim property component to this pattern, with optional predicate expression predExpr.
static SDF_API SdfPathPattern const & Everything()
Return the pattern "//" which matches all paths.
std::vector< Component > GetComponents() &&
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API SdfPathPattern & AppendChild(std::string const &text, SdfPredicateExpression const &predExpr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API SdfPathPattern & SetPrefix(SdfPath &&p)
Set this pattern's non-speculative prefix (leading path components with no wildcards and no predicate...
SDF_API SdfPathPattern & AppendChild(std::string const &text, SdfPredicateExpression &&predExpr)
Append a prim child component to this pattern, with optional predicate expression predExpr.
SDF_API SdfPathPattern & AppendProperty(std::string const &text, SdfPredicateExpression const &predExpr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< Component > const & GetComponents() const &
Return this pattern's components that follow its non-speculative prefix path.
SDF_API SdfPathPattern & RemoveTrailingStretch()
Remove trailing stretch from this pattern if it has trailing stretch.
SdfPath const & GetPrefix() const &
Return this pattern's non-speculative prefix (leading path components with no wildcards and no predic...
std::vector< SdfPredicateExpression > const & GetPredicateExprs() const &
Return the predicate expressions used by this pattern.
SDF_API bool HasTrailingStretch() const
Return true if this pattern ends with a stretch component: //, false otherwise.
static SdfPathPattern Nothing()
Return a default constructed SdfPathPattern that matches nothing.
SDF_API SdfPathPattern & AppendStretchIfPossible()
Append a stretch component (i.e.
SDF_API SdfPathPattern(SdfPath const &prefix)
Construct a SdfPathPattern with the prefix path.
static SDF_API SdfPathPattern const & EveryDescendant()
Return the pattern ".//" which matches all paths descendant to an anchor path.
SDF_API bool HasLeadingStretch() const
Return true if this pattern's prefix is the absolute root path and and its first component is a stret...
SDF_API SdfPathPattern & AppendProperty(std::string const &text)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API bool CanAppendProperty(std::string const &text, SdfPredicateExpression const &predExpr, std::string *reason=nullptr) const
Return true if it is valid to append the property element text and predExpr to this pattern.
SdfPath GetPrefix() &&
This is an overloaded member function, provided for convenience. It differs from the above function o...
Represents a logical expression syntax tree consisting of predicate function calls joined by the logi...
A component represents a pattern matching component past the initial SdfPath prefix.