SdfPath#
Fully qualified name: usdrt::SdfPath
-
class SdfPath#
A path value used to locate objects in the scenegraph.
Uses omni::fabric::Path for the prim path, and TfToken for the property part.
Note
USDRT paths support is limited to absolute paths.
Constructors
-
SdfPath() = default#
Constructs the default, empty path.
- inline SdfPath( )#
Create a new path from fabric data.
- Parameters:
path – The fabric path.
prop – The property part of the new path. Default empty TfToken.
- inline SdfPath( ) noexcept#
Create a new path from fabric data.
- Parameters:
path – The fabric path.
prop – The property part of the new path. Default empty TfToken.
-
inline SdfPath(const std::string &path)#
Create a new path with a copy of the given string.
- Parameters:
path – The fabric path.
-
inline SdfPath(const char *path)#
Create a new path from the given c-string.
Note
This does not currently check if the path string is valid. It only searches for the property delimiter to construct the fabric path and token
- Parameters:
path – c-string representation of the new path.
-
inline SdfPath(const omni::fabric::Connection &conn)#
Create a new path from the given omni::fabric::Connection.
- Parameters:
conn – omni::fabric::Connection representation of the path.
-
inline SdfPath(omni::core::ObjectPtr<usdrt::IRtPath> rtPath)#
Create a new path from the omni interface object.
- Parameters:
rtPath – the omni interface object
-
~SdfPath() = default#
Destructor.
Public Functions
-
inline std::string GetString() const#
Returns the string representation of this path as a std::string.
-
inline const char *GetText() const#
Returns the string representation of this path as a c string.
-
inline bool IsEmpty() const#
Returns true if this is the empty path (SdfPath::EmptyPath()).
-
inline std::string GetName() const#
Returns the name of the prim, property or relational attribute identified by the path.
-
inline const TfToken &GetNameToken() const#
Returns the name of the prim, property or relational attribute identified by the path, as a token.
-
inline SdfPath GetPrimPath() const#
Create a new SdfPath by stripping all attributes, targets, and properties from the leaf prim in this path.
- Returns:
A new SdfPath that is just the prim.
-
inline size_t GetHash() const#
Get hash value for this path.
-
inline SdfPathVector GetPrefixes() const#
Get the prefix paths of this path.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Returns:
Return an SdfPathVector containing the prefix paths of this path, ordered shortest to longest.
-
inline void GetPrefixes(SdfPathVector *prefixes) const#
Get the prefix paths of this path.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
prefixes – [out] An SdfPathVector containing the prefix paths of this path, ordered shortest to longest.
-
inline SdfPathAncestorsRange GetAncestorsRange() const#
Get a range for iterating over the ancestors of this path.
The range provides iteration over the prefixes of a path, ordered from longest to shortest (the opposite of the order of the prefixes returned by GetPrefixes).
- Returns:
Return the SdfPathAncestorRange for iteration.
-
inline size_t GetPathElementCount() const#
Returns the number of path elements in this path.
-
inline bool IsAbsolutePath() const#
Returns whether the path is absolute.
-
inline bool IsAbsoluteRootPath() const#
Return true if this path is the AbsoluteRootPath().
-
inline bool IsPrimPath() const#
Returns whether the path identifies a prim.
-
inline bool IsAbsoluteRootOrPrimPath() const#
Returns whether the path identifies a prim or the absolute root.
-
inline bool IsRootPrimPath() const#
Returns whether the path identifies a root prim.
The path must be absolute and have a single element (for example
/foo).
-
inline bool IsPropertyPath() const#
Returns whether the path identifies a property.
A relational attribute is considered to be a property, so this method will return true for relational attributes as well as properties of prims.
-
inline bool IsPrimPropertyPath() const#
Returns whether the path identifies a prim’s property.
A relational attribute is not a prim property.
-
inline bool IsNamespacedPropertyPath() const#
Returns whether the path identifies a namespaced property.
A namespaced property has colon embedded in its name.
-
inline bool ContainsPropertyElements() const#
Return true if this path contains any property elements (relationships or attributes), false otherwise.
-
inline SdfPath ReplaceName(TfToken const &newName) const#
Replace the final component of this path with
newName.- Parameters:
newName – The token to replace this path’s name.
- Returns:
Return a copy of this path with its final component changed to newName. If this path is not a prim or property path, it is invalid. Return empty path.
-
inline bool HasPrefix(const SdfPath &prefix) const#
Check if this path has
prefixas a prefix.Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
prefix – Given prefix to check
- Returns:
Return true if both this path and prefix are not the empty path and this path has prefix as a prefix. Return false otherwise.
-
inline SdfPath GetParentPath() const#
Get the path that identifies this path’s namespace parent.
If this path is a property path, assume no target paths and trim the property part. Otherwise, use fabric get the parent path.
- Returns:
Return a new path that identifies this path’s parent.
-
inline SdfPath GetAbsoluteRootOrPrimPath() const#
Creates a path by stripping all properties and relational attributes from this path, leaving the path to the containing prim.
If the path is already a prim or absolute root path, the same path is returned.
-
inline SdfPath AppendPath(const SdfPath &newSuffix) const#
Creates a path by appending a given relative path to this path.
This path and
newSuffixmust meet the following to be valid:If the newSuffix is a prim path, then this path must be a prim path or a root path.
If the newSuffix is a prim property path, then this path must be a prim path.
Neither path can be empty.
- Parameters:
newSuffix – The relative path to append.
- Returns:
Return a new path that appends
newSuffixto this path. If this path ornewSuffixare invalid, return the empty path.
-
inline SdfPath AppendChild(TfToken const &childName) const#
Creates a path by appending an element for
childNameto this path.This path must be a prim path or the AbsoluteRootPath.
- Parameters:
childName – the child prim name to append.
- Returns:
Returns a new path with
childNameappended.
-
inline SdfPath AppendProperty(TfToken const &propName) const#
Creates a path by appending an element for
propNameto this path.This path must be a prim path.
- Parameters:
propName – The prop name to append.
- Returns:
Return a new path with
propNameappended.
- inline SdfPath ReplacePrefix( ) const#
Replace all occurences of the prefix path
oldPrefixwithnewPrefix.Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
oldPrefix – Prefix to replace.
newPrefix – The new path prefix.
fixTargetPaths – This is not supported in fabric.
- Returns:
Returns a path with all occurrences of the prefix path
oldPrefixreplaced with the prefix pathnewPrefix.
-
inline SdfPath GetCommonPrefix(const SdfPath &path) const#
Get a path with maximal length that is a prefix path of both this path and
path.Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
path – Path to query.
- Returns:
Return a new path that is the longest common prefix of this path and
path.
- inline std::pair<SdfPath, SdfPath> RemoveCommonSuffix(
- const SdfPath &otherPath,
- bool stopAtRootPrim = false,
Find and remove the longest common suffix from two paths.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
otherPath – Other path to query.
stopAtRootPrim – If this flag is
truethen neither returned path will be the root path. Default false.
- Returns:
Return a pair of new paths. This path and
otherPathrespectively, with the longest common suffix removed
Public Static Functions
-
static inline const SdfPath AbsoluteRootPath()#
The absolute path representing the top of the namespace hierarchy.
-
static inline bool IsValidIdentifier(const std::string &name)#
Check if the given string represents a legal path identifier.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
name – string representation of the path
- Returns:
Return
trueifnameis a valid path identifier
- static inline bool IsValidNamespacedIdentifier(
- const std::string &name,
Check if the given string represents a legal namespaced path identifier.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
name – string representation of the path
- Returns:
Return
trueifIsValidIdentifierdoes.
- static inline bool IsValidPathString( )#
Check if the given string represents a valid path.
Note
This calls underlying USD SdfPath. No performance improvements over USD.
- Parameters:
pathString – string representation of the path
errMsg – [out] Error message set if the path is not valid. Default 0.
- Returns:
Return
trueifpathStringis a valid path string. Otherwise return false an iferrMsgis not NULL, set the pointed-to string to the parse error.
- static inline std::string JoinIdentifier( )#
Joins
lhsandrhsinto a single identifier using the namesapce delimeter.- Returns:
lhsifrhsis empty, and vice verse.
- static inline std::string JoinIdentifier( )#
Joins
lhsandrhsinto a single identifier using the namesapce delimeter.- Returns:
lhsifrhsis empty, and vice verse.
- static inline std::vector<std::string> TokenizeIdentifier(
- const std::string &name,
Tokenizes
nameby the namespace delimiter. Returns the empty vector ifnameis not a valid namespaced identifier.
-
static inline std::string JoinIdentifier(const TfTokenVector &names)#
Join
namesinto a single identifier using the namespace delimiter. Any empty strings present innamesare ignored when joining.
- static inline std::pair<std::string, bool> StripPrefixNamespace( )#
Returns (
name,true) wherenameis stripped of the prefix specified bymatchNamespaceifnameindeed starts withmatchNamespace. Returns (name,false) otherwise, withnameunmodified.This function deals with both the case where
matchNamespacecontains the trailing namespace delimiter ‘:’ or not.
- static inline std::pair<std::string, bool> StripSuffixNamespace( )#
Returns (
name,true) wherenameis stripped of the suffix specified bymatchNamespaceifnameindeed ends withmatchNamespace. Returns (name,false) otherwise, withnameunmodified.This function deals with both the case where
matchNamespacecontains the leading namespace delimiter ‘:’ or not.
-
SdfPath() = default#