HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
path.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef SDF_PATH_H
25 #define SDF_PATH_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/api.h"
29 #include "pxr/usd/sdf/pool.h"
30 #include "pxr/usd/sdf/tokens.h"
31 #include "pxr/base/tf/stl.h"
32 #include "pxr/base/tf/token.h"
33 #include "pxr/base/vt/traits.h"
34 
35 #include <hboost/intrusive_ptr.hpp>
36 #include <hboost/operators.hpp>
37 
38 #include <algorithm>
39 #include <iterator>
40 #include <set>
41 #include <string>
42 #include <type_traits>
43 #include <utility>
44 #include <vector>
45 
47 
49 
50 // Ref-counting pointer to a path node.
51 // Intrusive ref-counts are used to keep the size of SdfPath
52 // the same as a raw pointer. (shared_ptr, by comparison,
53 // is the size of two pointers.)
54 
55 typedef hboost::intrusive_ptr<const Sdf_PathNode> Sdf_PathNodeConstRefPtr;
56 
59 
60 // Tags used for the pools of path nodes.
61 struct Sdf_PathPrimTag;
62 struct Sdf_PathPropTag;
63 
64 // These are validated below.
65 static constexpr size_t Sdf_SizeofPrimPathNode = sizeof(void *) * 3;
66 static constexpr size_t Sdf_SizeofPropPathNode = sizeof(void *) * 3;
67 
69  Sdf_PathPrimTag, Sdf_SizeofPrimPathNode, /*regionBits=*/8>;
70 
72  Sdf_PathPropTag, Sdf_SizeofPropPathNode, /*regionBits=*/8>;
73 
76 
77 // This handle class wraps up the raw Prim/PropPartPool handles.
78 template <class Handle, bool Counted, class PathNode=Sdf_PathNode const>
80 private:
82 
83 public:
84  constexpr Sdf_PathNodeHandleImpl() noexcept {};
85 
86  explicit
87  Sdf_PathNodeHandleImpl(Sdf_PathNode const *p, bool add_ref = true)
88  : _poolHandle(Handle::GetHandle(reinterpret_cast<char const *>(p))) {
89  if (p && add_ref) {
90  _AddRef(p);
91  }
92  }
93 
94  explicit
95  Sdf_PathNodeHandleImpl(Handle h, bool add_ref = true)
96  : _poolHandle(h) {
97  if (h && add_ref) {
98  _AddRef();
99  }
100  }
101 
103  : _poolHandle(rhs._poolHandle) {
104  if (_poolHandle) {
105  _AddRef();
106  }
107  }
108 
110  if (_poolHandle) {
111  _DecRef();
112  }
113  }
114 
117  if (Counted && *this == rhs) {
118  return *this;
119  }
120  this_type(rhs).swap(*this);
121  return *this;
122  }
123 
125  : _poolHandle(rhs._poolHandle) {
126  rhs._poolHandle = nullptr;
127  }
128 
131  this_type(std::move(rhs)).swap(*this);
132  return *this;
133  }
134 
136  operator=(Sdf_PathNode const *rhs) noexcept {
137  this_type(rhs).swap(*this);
138  return *this;
139  }
140 
141  void reset() noexcept {
142  _poolHandle = Handle { nullptr };
143  }
144 
145  Sdf_PathNode const *
146  get() const noexcept {
147  return reinterpret_cast<Sdf_PathNode *>(_poolHandle.GetPtr());
148  }
149 
150  Sdf_PathNode const &
151  operator*() const {
152  return *get();
153  }
154 
155  Sdf_PathNode const *
156  operator->() const {
157  return get();
158  }
159 
160  explicit operator bool() const noexcept {
161  return static_cast<bool>(_poolHandle);
162  }
163 
164  void swap(Sdf_PathNodeHandleImpl &rhs) noexcept {
165  _poolHandle.swap(rhs._poolHandle);
166  }
167 
168  inline bool operator==(Sdf_PathNodeHandleImpl const &rhs) const noexcept {
169  return _poolHandle == rhs._poolHandle;
170  }
171  inline bool operator!=(Sdf_PathNodeHandleImpl const &rhs) const noexcept {
172  return _poolHandle != rhs._poolHandle;
173  }
174  inline bool operator<(Sdf_PathNodeHandleImpl const &rhs) const noexcept {
175  return _poolHandle < rhs._poolHandle;
176  }
177 private:
178 
179  void _AddRef(Sdf_PathNode const *p) const {
180  if (Counted) {
182  }
183  }
184 
185  void _AddRef() const {
186  _AddRef(get());
187  }
188 
189  void _DecRef() const {
190  if (Counted) {
191  intrusive_ptr_release(get());
192  }
193  }
194 
195  Handle _poolHandle { nullptr };
196 };
197 
200 
203 
204 
205 /// A set of SdfPaths.
206 typedef std::set<class SdfPath> SdfPathSet;
207 /// A vector of SdfPaths.
208 typedef std::vector<class SdfPath> SdfPathVector;
209 
210 // Tell VtValue that SdfPath is cheap to copy.
212 
213 /// \class SdfPath
214 ///
215 /// A path value used to locate objects in layers or scenegraphs.
216 ///
217 /// \section sec_SdfPath_Overview Overview
218 ///
219 /// SdfPath is used in several ways:
220 /// \li As a storage key for addressing and accessing values held in a SdfLayer
221 /// \li As a namespace identity for scenegraph objects
222 /// \li As a way to refer to other scenegraph objects through relative paths
223 ///
224 /// The paths represented by an SdfPath class may be either relative or
225 /// absolute. Relative paths are relative to the prim object that contains them
226 /// (that is, if an SdfRelationshipSpec target is relative, it is relative to
227 /// the SdfPrimSpec object that owns the SdfRelationshipSpec object).
228 ///
229 /// SdfPath objects can be readily created from and converted back to strings,
230 /// but as SdfPath objects, they have behaviors that make it easy and efficient
231 /// to work with them. The SdfPath class provides a full range of methods for
232 /// manipulating scene paths by appending a namespace child, appending a
233 /// relationship target, getting the parent path,
234 /// and so on. Since the SdfPath class uses a node-based representation
235 /// internally, you should use the editing functions rather than converting to
236 /// and from strings if possible.
237 ///
238 /// \section sec_SdfPath_Syntax Path Syntax
239 ///
240 /// Like a filesystem path, an SdfPath is conceptually just a sequence of
241 /// path components. Unlike a filesystem path, each component has a type,
242 /// and the type is indicated by the syntax.
243 ///
244 /// Two separators are used between parts of a path. A slash ("/") following an
245 /// identifier is used to introduce a namespace child. A period (".") following
246 /// an identifier is used to introduce a property. A property may also have
247 /// several non-sequential colons (':') in its name to provide a rudimentary
248 /// namespace within properties but may not end or begin with a colon.
249 ///
250 /// A leading slash in the string representation of an SdfPath object indicates
251 /// an absolute path. Two adjacent periods indicate the parent namespace.
252 ///
253 /// Brackets ("[" and "]") are used to indicate relationship target paths for
254 /// relational attributes.
255 ///
256 /// The first part in a path is assumed to be a namespace child unless
257 /// it is preceded by a period. That means:
258 /// \li <c>/Foo</c> is an absolute path specifying the root prim Foo.
259 /// \li <c>/Foo/Bar</c> is an absolute path specifying namespace child Bar
260 /// of root prim Foo.
261 /// \li <c>/Foo/Bar.baz</c> is an absolute path specifying property \c baz of
262 /// namespace child Bar of root prim Foo.
263 /// \li <c>Foo</c> is a relative path specifying namespace child Foo of
264 /// the current prim.
265 /// \li <c>Foo/Bar</c> is a relative path specifying namespace child Bar of
266 /// namespace child Foo of the current prim.
267 /// \li <c>Foo/Bar.baz</c> is a relative path specifying property \c baz of
268 /// namespace child Bar of namespace child Foo of the current prim.
269 /// \li <c>.foo</c> is a relative path specifying the property \c foo of the
270 /// current prim.
271 /// \li <c>/Foo.bar[/Foo.baz].attrib</c> is a relational attribute path. The
272 /// relationship <c>/Foo.bar</c> has a target <c>/Foo.baz</c>. There is a
273 /// relational attribute \c attrib on that relationship-&gt;target pair.
274 ///
275 /// \section sec_SdfPath_ThreadSafety A Note on Thread-Safety
276 ///
277 /// SdfPath is strongly thread-safe, in the sense that zero additional
278 /// synchronization is required between threads creating or using SdfPath
279 /// values. Just like TfToken, SdfPath values are immutable. Internally,
280 /// SdfPath uses a global prefix tree to efficiently share representations
281 /// of paths, and provide fast equality/hashing operations, but
282 /// modifications to this table are internally synchronized. Consequently,
283 /// as with TfToken, for best performance it is important to minimize
284 /// the number of values created (since it requires synchronized access to
285 /// this table) or copied (since it requires atomic ref-counting operations).
286 ///
287 class SdfPath : hboost::totally_ordered<SdfPath>
288 {
289 public:
290  /// The empty path value, equivalent to SdfPath().
291  SDF_API static const SdfPath & EmptyPath();
292 
293  /// The absolute path representing the top of the
294  /// namespace hierarchy.
295  SDF_API static const SdfPath & AbsoluteRootPath();
296 
297  /// The relative path representing "self".
298  SDF_API static const SdfPath & ReflexiveRelativePath();
299 
300  /// \name Constructors
301  /// @{
302 
303  /// Constructs the default, empty path.
304  ///
305  constexpr SdfPath() = default;
306 
307  /// Creates a path from the given string.
308  ///
309  /// If the given string is not a well-formed path, this will raise
310  /// a Tf error. Note that passing an empty std::string() will also
311  /// raise an error; the correct way to get the empty path is SdfPath().
312  ///
313  /// Internal dot-dots will be resolved by removing the first dot-dot,
314  /// the element preceding it, and repeating until no internal dot-dots
315  /// remain.
316  ///
317  /// Note that most often new paths are expected to be created by
318  /// asking existing paths to return modified versions of themselves.
319  //
320  // XXX We may want to revisit the behavior when constructing
321  // a path with an empty string ("") to accept it without error and
322  // return EmptyPath.
323  SDF_API explicit SdfPath(const std::string &path);
324 
325  /// @}
326 
327  /// \name Querying paths
328  /// @{
329 
330  /// Returns the number of path elements in this path.
331  SDF_API size_t GetPathElementCount() const;
332 
333  /// Returns whether the path is absolute.
334  SDF_API bool IsAbsolutePath() const;
335 
336  /// Returns whether the path identifies a prim.
337  SDF_API bool IsPrimPath() const;
338 
339  /// Returns whether the path identifies a prim or the absolute root.
340  SDF_API bool IsAbsoluteRootOrPrimPath() const;
341 
342  /// Returns whether the path identifies a root prim.
343  ///
344  /// the path must be absolute and have a single element
345  /// (for example <c>/foo</c>).
346  SDF_API bool IsRootPrimPath() const;
347 
348  /// Returns whether the path identifies a property.
349  ///
350  /// A relational attribute is considered to be a property, so this
351  /// method will return true for relational attributes as well
352  /// as properties of prims.
353  SDF_API bool IsPropertyPath() const;
354 
355  /// Returns whether the path identifies a prim's property.
356  ///
357  /// A relational attribute is not a prim property.
358  SDF_API bool IsPrimPropertyPath() const;
359 
360  /// Returns whether the path identifies a namespaced property.
361  ///
362  /// A namespaced property has colon embedded in its name.
363  SDF_API bool IsNamespacedPropertyPath() const;
364 
365  /// Returns whether the path identifies a variant selection for a
366  /// prim.
367  SDF_API bool IsPrimVariantSelectionPath() const;
368 
369  /// Return true if this path is a prim path or is a prim variant
370  /// selection path.
372 
373  /// Returns whether the path or any of its parent paths identifies
374  /// a variant selection for a prim.
376 
377  /// Return true if this path contains any property elements, false
378  /// otherwise. A false return indicates a prim-like path, specifically a
379  /// root path, a prim path, or a prim variant selection path. A true return
380  /// indicates a property-like path: a prim property path, a target path, a
381  /// relational attribute path, etc.
383  return static_cast<bool>(_propPart);
384  }
385 
386  /// Return true if this path is or has a prefix that's a target path or a
387  /// mapper path.
388  SDF_API bool ContainsTargetPath() const;
389 
390  /// Returns whether the path identifies a relational attribute.
391  ///
392  /// If this is true, IsPropertyPath() will also be true.
393  SDF_API bool IsRelationalAttributePath() const;
394 
395  /// Returns whether the path identifies a relationship or
396  /// connection target.
397  SDF_API bool IsTargetPath() const;
398 
399  /// Returns whether the path identifies a connection mapper.
400  SDF_API bool IsMapperPath() const;
401 
402  /// Returns whether the path identifies a connection mapper arg.
403  SDF_API bool IsMapperArgPath() const;
404 
405  /// Returns whether the path identifies a connection expression.
406  SDF_API bool IsExpressionPath() const;
407 
408  /// Returns true if this is the empty path (SdfPath::EmptyPath()).
409  inline bool IsEmpty() const noexcept {
410  return *this == SdfPath();
411  }
412 
413  /// Returns the string representation of this path as a TfToken.
414  SDF_API TfToken const &GetToken() const;
415 
416  /// Returns the string representation of this path as a std::string.
417  SDF_API const std::string &GetString() const;
418 
419  /// Returns the string representation of this path as a c string.
420  SDF_API const char *GetText() const;
421 
422  /// Returns the prefix paths of this path.
423  ///
424  /// Prefixes are returned in order of shortest to longest. The path
425  /// itself is returned as the last prefix.
426  SDF_API SdfPathVector GetPrefixes() const;
427 
428  /// Fills prefixes with prefixes of this path.
429  ///
430  /// This avoids copy constructing the return value.
431  ///
432  /// Prefixes are returned in order of shortest to longest. The path
433  /// itself is returned as the last prefix.
434  SDF_API void GetPrefixes(SdfPathVector *prefixes) const;
435 
436  /// Returns the name of the prim, property or relational
437  /// attribute identified by the path.
438  ///
439  /// Returns EmptyPath if this path is a target or mapper path.
440  ///
441  /// <ul>
442  /// <li>Returns "" for EmptyPath.</li>
443  /// <li>Returns "." for ReflexiveRelativePath.</li>
444  /// <li>Returns ".." for a path ending in ParentPathElement.</li>
445  /// </ul>
446  SDF_API const std::string &GetName() const;
447 
448  /// Returns the name of the prim, property or relational
449  /// attribute identified by the path, as a token.
450  SDF_API const TfToken &GetNameToken() const;
451 
452  /// Returns an ascii representation of the "terminal" element
453  /// of this path, which can be used to reconstruct the path using
454  /// \c AppendElementString() on its parent.
455  ///
456  /// EmptyPath(), AbsoluteRootPath(), and ReflexiveRelativePath() are
457  /// \em not considered elements (one of the defining properties of
458  /// elements is that they have a parent), so \c GetElementString() will
459  /// return the empty string for these paths.
460  ///
461  /// Unlike \c GetName() and \c GetTargetPath(), which provide you "some"
462  /// information about the terminal element, this provides a complete
463  /// representation of the element, for all element types.
464  ///
465  /// Also note that whereas \c GetName(), \c GetNameToken(), \c GetText(),
466  /// \c GetString(), and \c GetTargetPath() return cached results,
467  /// \c GetElementString() always performs some amount of string
468  /// manipulation, which you should keep in mind if performance is a concern.
470 
471  /// Like GetElementString() but return the value as a TfToken.
473 
474  /// Return a copy of this path with its final component changed to
475  /// \a newName. This path must be a prim or property path.
476  ///
477  /// This method is shorthand for path.GetParentPath().AppendChild(newName)
478  /// for prim paths, path.GetParentPath().AppendProperty(newName) for
479  /// prim property paths, and
480  /// path.GetParentPath().AppendRelationalAttribute(newName) for relational
481  /// attribute paths.
482  ///
483  /// Note that only the final path component is ever changed. If the name of
484  /// the final path component appears elsewhere in the path, it will not be
485  /// modified.
486  ///
487  /// Some examples:
488  ///
489  /// ReplaceName('/chars/MeridaGroup', 'AngusGroup') -> '/chars/AngusGroup'
490  /// ReplaceName('/Merida.tx', 'ty') -> '/Merida.ty'
491  /// ReplaceName('/Merida.tx[targ].tx', 'ty') -> '/Merida.tx[targ].ty'
492  ///
493  SDF_API SdfPath ReplaceName(TfToken const &newName) const;
494 
495  /// Returns the relational attribute or mapper target path
496  /// for this path.
497  ///
498  /// Returns EmptyPath if this is not a target, relational attribute or
499  /// mapper path.
500  ///
501  /// Note that it is possible for a path to have multiple "target" paths.
502  /// For example a path that identifies a connection target for a
503  /// relational attribute includes the target of the connection as well
504  /// as the target of the relational attribute. In these cases, the
505  /// "deepest" or right-most target path will be returned (the connection
506  /// target in this example).
507  SDF_API const SdfPath &GetTargetPath() const;
508 
509  /// Returns all the relationship target or connection target
510  /// paths contained in this path, and recursively all the target paths
511  /// contained in those target paths in reverse depth-first order.
512  ///
513  /// For example, given the path: '/A/B.a[/C/D.a[/E/F.a]].a[/A/B.a[/C/D.a]]'
514  /// this method produces: '/A/B.a[/C/D.a]', '/C/D.a', '/C/D.a[/E/F.a]',
515  /// '/E/F.a'
516  SDF_API void GetAllTargetPathsRecursively(SdfPathVector *result) const;
517 
518  /// Returns the variant selection for this path, if this is a variant
519  /// selection path.
520  /// Returns a pair of empty strings if this path is not a variant
521  /// selection path.
522  SDF_API
523  std::pair<std::string, std::string> GetVariantSelection() const;
524 
525  /// Return true if both this path and \a prefix are not the empty
526  /// path and this path has \a prefix as a prefix. Return false otherwise.
527  SDF_API bool HasPrefix( const SdfPath &prefix ) const;
528 
529  /// @}
530 
531  /// \name Creating new paths by modifying existing paths
532  /// @{
533 
534  /// Return the path that identifies this path's namespace parent.
535  ///
536  /// For a prim path (like '/foo/bar'), return the prim's parent's path
537  /// ('/foo'). For a prim property path (like '/foo/bar.property'), return
538  /// the prim's path ('/foo/bar'). For a target path (like
539  /// '/foo/bar.property[/target]') return the property path
540  /// ('/foo/bar.property'). For a relational attribute or mapper path (like
541  /// '/foo/bar.property[/target].relAttr') return the relationship target's
542  /// path ('/foo/bar.property[/target]'). For a prim variant selection path
543  /// (like '/foo/bar{var=sel}') return the prim path ('/foo/bar'). For a
544  /// root prim path (like '/rootPrim'), return AbsoluteRootPath() ('/'). For
545  /// a single element relative prim path (like 'relativePrim'), return
546  /// ReflexiveRelativePath() ('.'). For ReflexiveRelativePath(), return the
547  /// relative parent path ('..').
548  ///
549  /// Note that the parent path of a relative parent path ('..') is a relative
550  /// grandparent path ('../..'). Use caution writing loops that walk to
551  /// parent paths since relative paths have infinitely many ancestors.
552  SDF_API SdfPath GetParentPath() const;
553 
554  /// Creates a path by stripping all relational attributes, targets,
555  /// properties, and variant selections from the leafmost prim path, leaving
556  /// the nearest path for which \a IsPrimPath() returns true.
557  ///
558  /// See \a GetPrimOrPrimVariantSelectionPath also.
559  ///
560  /// If the path is already a prim path, the same path is returned.
561  SDF_API SdfPath GetPrimPath() const;
562 
563  /// Creates a path by stripping all relational attributes, targets,
564  /// and properties, leaving the nearest path for which
565  /// \a IsPrimOrPrimVariantSelectionPath() returns true.
566  ///
567  /// See \a GetPrimPath also.
568  ///
569  /// If the path is already a prim or a prim variant selection path, the same
570  /// path is returned.
572 
573  /// Creates a path by stripping all properties and relational
574  /// attributes from this path, leaving the path to the containing prim.
575  ///
576  /// If the path is already a prim or absolute root path, the same
577  /// path is returned.
578  SDF_API SdfPath GetAbsoluteRootOrPrimPath() const;
579 
580  /// Create a path by stripping all variant selections from all
581  /// components of this path, leaving a path with no embedded variant
582  /// selections.
583  SDF_API SdfPath StripAllVariantSelections() const;
584 
585  /// Creates a path by appending a given relative path to this path.
586  ///
587  /// If the newSuffix is a prim path, then this path must be a prim path
588  /// or a root path.
589  ///
590  /// If the newSuffix is a prim property path, then this path must be
591  /// a prim path or the ReflexiveRelativePath.
592  SDF_API SdfPath AppendPath(const SdfPath &newSuffix) const;
593 
594  /// Creates a path by appending an element for \p childName
595  /// to this path.
596  ///
597  /// This path must be a prim path, the AbsoluteRootPath
598  /// or the ReflexiveRelativePath.
599  SDF_API SdfPath AppendChild(TfToken const &childName) const;
600 
601  /// Creates a path by appending an element for \p propName
602  /// to this path.
603  ///
604  /// This path must be a prim path or the ReflexiveRelativePath.
605  SDF_API SdfPath AppendProperty(TfToken const &propName) const;
606 
607  /// Creates a path by appending an element for \p variantSet
608  /// and \p variant to this path.
609  ///
610  /// This path must be a prim path.
611  SDF_API
612  SdfPath AppendVariantSelection(const std::string &variantSet,
613  const std::string &variant) const;
614 
615  /// Creates a path by appending an element for
616  /// \p targetPath.
617  ///
618  /// This path must be a prim property or relational attribute path.
619  SDF_API SdfPath AppendTarget(const SdfPath &targetPath) const;
620 
621  /// Creates a path by appending an element for
622  /// \p attrName to this path.
623  ///
624  /// This path must be a target path.
625  SDF_API
626  SdfPath AppendRelationalAttribute(TfToken const &attrName) const;
627 
628  /// Replaces the relational attribute's target path
629  ///
630  /// The path must be a relational attribute path.
631  SDF_API
632  SdfPath ReplaceTargetPath( const SdfPath &newTargetPath ) const;
633 
634  /// Creates a path by appending a mapper element for
635  /// \p targetPath.
636  ///
637  /// This path must be a prim property or relational attribute path.
638  SDF_API SdfPath AppendMapper(const SdfPath &targetPath) const;
639 
640  /// Creates a path by appending an element for
641  /// \p argName.
642  ///
643  /// This path must be a mapper path.
644  SDF_API SdfPath AppendMapperArg(TfToken const &argName) const;
645 
646  /// Creates a path by appending an expression element.
647  ///
648  /// This path must be a prim property or relational attribute path.
649  SDF_API SdfPath AppendExpression() const;
650 
651  /// Creates a path by extracting and appending an element
652  /// from the given ascii element encoding.
653  ///
654  /// Attempting to append a root or empty path (or malformed path)
655  /// or attempting to append \em to the EmptyPath will raise an
656  /// error and return the EmptyPath.
657  ///
658  /// May also fail and return EmptyPath if this path's type cannot
659  /// possess a child of the type encoded in \p element.
660  SDF_API SdfPath AppendElementString(const std::string &element) const;
661 
662  /// Like AppendElementString() but take the element as a TfToken.
663  SDF_API SdfPath AppendElementToken(const TfToken &elementTok) const;
664 
665  /// Returns a path with all occurrences of the prefix path
666  /// \p oldPrefix replaced with the prefix path \p newPrefix.
667  ///
668  /// If fixTargetPaths is true, any embedded target paths will also
669  /// have their paths replaced. This is the default.
670  ///
671  /// If this is not a target, relational attribute or mapper path this
672  /// will do zero or one path prefix replacements, if not the number of
673  /// replacements can be greater than one.
674  SDF_API
675  SdfPath ReplacePrefix(const SdfPath &oldPrefix,
676  const SdfPath &newPrefix,
677  bool fixTargetPaths=true) const;
678 
679  /// Returns a path with maximal length that is a prefix path of
680  /// both this path and \p path.
681  SDF_API SdfPath GetCommonPrefix(const SdfPath &path) const;
682 
683  /// Find and remove the longest common suffix from two paths.
684  ///
685  /// Returns this path and \p otherPath with the longest common suffix
686  /// removed (first and second, respectively). If the two paths have no
687  /// common suffix then the paths are returned as-is. If the paths are
688  /// equal then this returns empty paths for relative paths and absolute
689  /// roots for absolute paths. The paths need not be the same length.
690  ///
691  /// If \p stopAtRootPrim is \c true then neither returned path will be
692  /// the root path. That, in turn, means that some common suffixes will
693  /// not be removed. For example, if \p stopAtRootPrim is \c true then
694  /// the paths /A/B and /B will be returned as is. Were it \c false
695  /// then the result would be /A and /. Similarly paths /A/B/C and
696  /// /B/C would return /A/B and /B if \p stopAtRootPrim is \c true but
697  /// /A and / if it's \c false.
698  SDF_API
699  std::pair<SdfPath, SdfPath>
700  RemoveCommonSuffix(const SdfPath& otherPath,
701  bool stopAtRootPrim = false) const;
702 
703  /// Returns the absolute form of this path using \p anchor
704  /// as the relative basis.
705  ///
706  /// \p anchor must be an absolute prim path.
707  ///
708  /// If this path is a relative path, resolve it using \p anchor as the
709  /// relative basis.
710  ///
711  /// If this path is already an absolute path, just return a copy.
712  SDF_API SdfPath MakeAbsolutePath(const SdfPath & anchor) const;
713 
714  /// Returns the relative form of this path using \p anchor
715  /// as the relative basis.
716  ///
717  /// \p anchor must be an absolute prim path.
718  ///
719  /// If this path is an absolute path, return the corresponding relative path
720  /// that is relative to the absolute path given by \p anchor.
721  ///
722  /// If this path is a relative path, return the optimal relative
723  /// path to the absolute path given by \p anchor. (The optimal
724  /// relative path from a given prim path is the relative path
725  /// with the least leading dot-dots.
726  SDF_API SdfPath MakeRelativePath(const SdfPath & anchor) const;
727 
728  /// @}
729 
730  /// \name Valid path strings, prim and property names
731  /// @{
732 
733  /// Returns whether \p name is a legal identifier for any
734  /// path component.
735  SDF_API static bool IsValidIdentifier(const std::string &name);
736 
737  /// Returns whether \p name is a legal namespaced identifier.
738  /// This returns \c true if IsValidIdentifier() does.
740 
741  /// Tokenizes \p name by the namespace delimiter.
742  /// Returns the empty vector if \p name is not a valid namespaced
743  /// identifier.
744  SDF_API static std::vector<std::string> TokenizeIdentifier(const std::string &name);
745 
746  /// Tokenizes \p name by the namespace delimiter.
747  /// Returns the empty vector if \p name is not a valid namespaced
748  /// identifier.
749  SDF_API
751 
752  /// Join \p names into a single identifier using the namespace delimiter.
753  /// Any empty strings present in \p names are ignored when joining.
754  SDF_API
755  static std::string JoinIdentifier(const std::vector<std::string> &names);
756 
757  /// Join \p names into a single identifier using the namespace delimiter.
758  /// Any empty strings present in \p names are ignored when joining.
759  SDF_API
761 
762  /// Join \p lhs and \p rhs into a single identifier using the
763  /// namespace delimiter.
764  /// Returns \p lhs if \p rhs is empty and vice verse.
765  /// Returns an empty string if both \p lhs and \p rhs are empty.
766  SDF_API
767  static std::string JoinIdentifier(const std::string &lhs,
768  const std::string &rhs);
769 
770  /// Join \p lhs and \p rhs into a single identifier using the
771  /// namespace delimiter.
772  /// Returns \p lhs if \p rhs is empty and vice verse.
773  /// Returns an empty string if both \p lhs and \p rhs are empty.
774  SDF_API
775  static std::string JoinIdentifier(const TfToken &lhs, const TfToken &rhs);
776 
777  /// Returns \p name stripped of any namespaces.
778  /// This does not check the validity of the name; it just attempts
779  /// to remove anything that looks like a namespace.
780  SDF_API
782 
783  /// Returns \p name stripped of any namespaces.
784  /// This does not check the validity of the name; it just attempts
785  /// to remove anything that looks like a namespace.
786  SDF_API
787  static TfToken StripNamespace(const TfToken &name);
788 
789  /// Returns (\p name, \c true) where \p name is stripped of the prefix
790  /// specified by \p matchNamespace if \p name indeed starts with
791  /// \p matchNamespace. Returns (\p name, \c false) otherwise, with \p name
792  /// unmodified.
793  ///
794  /// This function deals with both the case where \p matchNamespace contains
795  /// the trailing namespace delimiter ':' or not.
796  ///
797  SDF_API
798  static std::pair<std::string, bool>
800  const std::string &matchNamespace);
801 
802  /// Return true if \p pathString is a valid path string, meaning that
803  /// passing the string to the \a SdfPath constructor will result in a valid,
804  /// non-empty SdfPath. Otherwise, return false and if \p errMsg is not NULL,
805  /// set the pointed-to string to the parse error.
806  SDF_API
807  static bool IsValidPathString(const std::string &pathString,
808  std::string *errMsg = 0);
809 
810  /// @}
811 
812  /// \name Operators
813  /// @{
814 
815  /// Equality operator.
816  /// (Boost provides inequality from this.)
817  inline bool operator==(const SdfPath &rhs) const {
818  return _AsInt() == rhs._AsInt();
819  }
820 
821  /// Comparison operator.
822  ///
823  /// This orders paths lexicographically, aka dictionary-style.
824  ///
825  inline bool operator<(const SdfPath &rhs) const {
826  if (_AsInt() == rhs._AsInt()) {
827  return false;
828  }
829  if (!_primPart || !rhs._primPart) {
830  return !_primPart && rhs._primPart;
831  }
832  // Valid prim parts -- must walk node structure, etc.
833  return _LessThanInternal(*this, rhs);
834  }
835 
836  // For hash maps and sets
837  struct Hash {
838  inline size_t operator()(const SdfPath& path) const {
839  // The hash function is pretty sensitive performance-wise. Be
840  // careful making changes here, and run tests.
841  uint32_t primPart, propPart;
842  memcpy(&primPart, &path._primPart, sizeof(primPart));
843  memcpy(&propPart, &path._propPart, sizeof(propPart));
844 
845  // Important considerations here:
846  // - It must be fast to execute.
847  // - It must do well in hash tables that find indexes by taking
848  // the remainder divided by a prime number of buckets.
849  // - It must do well in hash tables that find indexes by taking
850  // just the low-order bits.
851 
852  // This hash function maps the (primPart, propPart) pair to a single
853  // value by using triangular numbers. So the first few path hash
854  // values would look like this, for primPart as X increasing
855  // left-to-right and for propPart as Y increasing top-to-bottom.
856  //
857  // 0 2 5 9 14 20
858  // 1 4 8 13 19 26
859  // 3 7 12 18 25 33
860  // 6 11 17 24 32 41
861  // 10 16 23 31 40 50
862  // 15 22 30 39 49 60
863 
864  uint64_t x = primPart >> 8;
865  uint64_t y = x + (propPart >> 8);
866  return x + (y * (y + 1)) / 2;
867  }
868  };
869 
870  inline size_t GetHash() const {
871  return Hash()(*this);
872  }
873 
874  // For cases where an unspecified total order that is not stable from
875  // run-to-run is needed.
876  struct FastLessThan {
877  inline bool operator()(const SdfPath& a, const SdfPath& b) const {
878  return a._AsInt() < b._AsInt();
879  }
880  };
881 
882  /// @}
883 
884  /// \name Utilities
885  /// @{
886 
887  /// Given some vector of paths, get a vector of concise unambiguous
888  /// relative paths.
889  ///
890  /// GetConciseRelativePaths requires a vector of absolute paths. It
891  /// finds a set of relative paths such that each relative path is
892  /// unique.
893  SDF_API static SdfPathVector
894  GetConciseRelativePaths(const SdfPathVector& paths);
895 
896  /// Remove all elements of \a paths that are prefixed by other
897  /// elements in \a paths. As a side-effect, the result is left in sorted
898  /// order.
899  SDF_API static void RemoveDescendentPaths(SdfPathVector *paths);
900 
901  /// Remove all elements of \a paths that prefix other elements in
902  /// \a paths. As a side-effect, the result is left in sorted order.
903  SDF_API static void RemoveAncestorPaths(SdfPathVector *paths);
904 
905  /// @}
906 
907 private:
908 
909  // This is used for all internal path construction where we do operations
910  // via nodes and then want to return a new path with a resulting prim and
911  // property parts.
912 
913  // Accept rvalues.
914  explicit SdfPath(Sdf_PathPrimNodeHandle &&primNode)
915  : _primPart(std::move(primNode)) {}
916 
917  // Construct from prim & prop parts.
918  SdfPath(Sdf_PathPrimNodeHandle const &primPart,
919  Sdf_PathPropNodeHandle const &propPart)
920  : _primPart(primPart)
921  , _propPart(propPart) {}
922 
923  // Construct from prim & prop node pointers.
924  SdfPath(Sdf_PathNode const *primPart,
925  Sdf_PathNode const *propPart)
926  : _primPart(primPart)
927  , _propPart(propPart) {}
928 
929  friend class Sdf_PathNode;
930  friend class Sdfext_PathAccess;
931 
932  // converts elements to a string for parsing (unfortunate)
933  static std::string
934  _ElementsToString(bool absolute, const std::vector<std::string> &elements);
935 
936  SdfPath _ReplacePrimPrefix(SdfPath const &oldPrefix,
937  SdfPath const &newPrefix) const;
938 
939  SdfPath _ReplaceTargetPathPrefixes(SdfPath const &oldPrefix,
940  SdfPath const &newPrefix) const;
941 
942  SdfPath _ReplacePropPrefix(SdfPath const &oldPrefix,
943  SdfPath const &newPrefix,
944  bool fixTargetPaths) const;
945 
946  // Helper to implement the uninlined portion of operator<.
947  SDF_API static bool
948  _LessThanInternal(SdfPath const &lhs, SdfPath const &rhs);
949 
950  inline uint64_t _AsInt() const {
951  static_assert(sizeof(*this) == sizeof(uint64_t), "");
952  uint64_t ret;
953  std::memcpy(&ret, this, sizeof(*this));
954  return ret;
955  }
956 
957  friend void swap(SdfPath &lhs, SdfPath &rhs) {
958  lhs._primPart.swap(rhs._primPart);
959  lhs._propPart.swap(rhs._propPart);
960  }
961 
962  Sdf_PathPrimNodeHandle _primPart;
963  Sdf_PathPropNodeHandle _propPart;
964 
965 };
966 
967 // Overload hash_value for SdfPath. Used by things like hboost::hash.
968 inline size_t hash_value(SdfPath const &path)
969 {
970  return path.GetHash();
971 }
972 
973 /// Writes the string representation of \p path to \p out.
974 SDF_API std::ostream & operator<<( std::ostream &out, const SdfPath &path );
975 
976 // Helper for SdfPathFindPrefixedRange & SdfPathFindLongestPrefix. A function
977 // object that returns an SdfPath const & unchanged.
979  inline SdfPath const &operator()(SdfPath const &arg) const {
980  return arg;
981  }
982 };
983 
984 /// Find the subrange of the sorted range [\a begin, \a end) that includes all
985 /// paths prefixed by \a path. The input range must be ordered according to
986 /// SdfPath::operator<. If your range's iterators' value_types are not SdfPath,
987 /// but you can obtain SdfPaths from them (e.g. map<SdfPath, X>::iterator), you
988 /// can pass a function to extract the path from the dereferenced iterator in
989 /// \p getPath.
990 template <class ForwardIterator, class GetPathFn = Sdf_PathIdentity>
991 std::pair<ForwardIterator, ForwardIterator>
992 SdfPathFindPrefixedRange(ForwardIterator begin, ForwardIterator end,
993  SdfPath const &prefix,
994  GetPathFn const &getPath = GetPathFn()) {
995  using IterRef =
997 
998  struct Compare {
999  Compare(GetPathFn const &getPath) : _getPath(getPath) {}
1000  GetPathFn const &_getPath;
1001  bool operator()(IterRef a, SdfPath const &b) const {
1002  return _getPath(a) < b;
1003  }
1004  };
1005 
1006  std::pair<ForwardIterator, ForwardIterator> result;
1007 
1008  // First, use lower_bound to find where \a prefix would go.
1009  result.first = std::lower_bound(begin, end, prefix, Compare(getPath));
1010 
1011  // Next, find end of range starting from the lower bound, using the
1012  // prefixing condition to define the boundary.
1013  result.second = TfFindBoundary(result.first, end,
1014  [&prefix, &getPath](IterRef iterRef) {
1015  return getPath(iterRef).HasPrefix(prefix);
1016  });
1017 
1018  return result;
1019 }
1020 
1021 template <class RandomAccessIterator, class GetPathFn>
1022 RandomAccessIterator
1024  RandomAccessIterator end,
1025  SdfPath const &path,
1026  bool strictPrefix,
1027  GetPathFn const &getPath)
1028 {
1029  using IterRef =
1031 
1032  struct Compare {
1033  Compare(GetPathFn const &getPath) : _getPath(getPath) {}
1034  GetPathFn const &_getPath;
1035  bool operator()(IterRef a, SdfPath const &b) const {
1036  return _getPath(a) < b;
1037  }
1038  };
1039 
1040  // Search for the path in [begin, end). If present, return it. If not,
1041  // examine prior element in [begin, end). If none, return end. Else, is it
1042  // a prefix of path? If so, return it. Else find common prefix of that
1043  // element and path and recurse.
1044 
1045  // If empty sequence, return.
1046  if (begin == end)
1047  return end;
1048 
1049  // Search for where this path would lexicographically appear in the range.
1050  RandomAccessIterator result =
1051  std::lower_bound(begin, end, path, Compare(getPath));
1052 
1053  // If we didn't get the end, check to see if we got the path exactly if
1054  // we're not looking for a strict prefix.
1055  if (!strictPrefix && result != end && getPath(*result) == path)
1056  return result;
1057 
1058  // If we got begin (and didn't match in the case of a non-strict prefix)
1059  // then there's no prefix.
1060  if (result == begin)
1061  return end;
1062 
1063  // If the prior element is a prefix, we're done.
1064  if (path.HasPrefix(getPath(*--result)))
1065  return result;
1066 
1067  // Otherwise, find the common prefix of the lexicographical predecessor and
1068  // recurse looking for it or its longest prefix in the preceding range. We
1069  // always pass strictPrefix=false, since now we're operating on prefixes of
1070  // the original caller's path.
1071  RandomAccessIterator final =
1073  begin, result, path.GetCommonPrefix(getPath(*result)),
1074  /*strictPrefix=*/ false, getPath);
1075 
1076  // If the recursion failed, promote the recursive call's end to our end.
1077  return final == result ? end : final;
1078 }
1079 
1080 /// Return an iterator to the element of [\a begin, \a end) that is the longest
1081 /// prefix of the given path (including the path itself), if there is such an
1082 /// element, otherwise \a end. The input range must be ordered according to
1083 /// SdfPath::operator<. If your range's iterators' value_types are not SdfPath,
1084 /// but you can obtain SdfPaths from them (e.g. vector<pair<SdfPath,
1085 /// X>>::iterator), you can pass a function to extract the path from the
1086 /// dereferenced iterator in \p getPath.
1087 template <class RandomAccessIterator, class GetPathFn = Sdf_PathIdentity,
1088  class = typename std::enable_if<
1089  std::is_base_of<
1090  std::random_access_iterator_tag,
1091  typename std::iterator_traits<
1092  RandomAccessIterator>::iterator_category
1093  >::value
1094  >::type
1095  >
1096 RandomAccessIterator
1097 SdfPathFindLongestPrefix(RandomAccessIterator begin,
1098  RandomAccessIterator end,
1099  SdfPath const &path,
1100  GetPathFn const &getPath = GetPathFn())
1101 {
1103  begin, end, path, /*strictPrefix=*/false, getPath);
1104 }
1105 
1106 /// Return an iterator to the element of [\a begin, \a end) that is the longest
1107 /// prefix of the given path (excluding the path itself), if there is such an
1108 /// element, otherwise \a end. The input range must be ordered according to
1109 /// SdfPath::operator<. If your range's iterators' value_types are not SdfPath,
1110 /// but you can obtain SdfPaths from them (e.g. vector<pair<SdfPath,
1111 /// X>>::iterator), you can pass a function to extract the path from the
1112 /// dereferenced iterator in \p getPath.
1113 template <class RandomAccessIterator, class GetPathFn = Sdf_PathIdentity,
1114  class = typename std::enable_if<
1115  std::is_base_of<
1116  std::random_access_iterator_tag,
1117  typename std::iterator_traits<
1118  RandomAccessIterator>::iterator_category
1119  >::value
1120  >::type
1121  >
1122 RandomAccessIterator
1123 SdfPathFindLongestStrictPrefix(RandomAccessIterator begin,
1124  RandomAccessIterator end,
1125  SdfPath const &path,
1126  GetPathFn const &getPath = GetPathFn())
1127 {
1129  begin, end, path, /*strictPrefix=*/true, getPath);
1130 }
1131 
1132 template <class Iter, class MapParam, class GetPathFn = Sdf_PathIdentity>
1133 Iter
1135  MapParam map, SdfPath const &path, bool strictPrefix,
1136  GetPathFn const &getPath = GetPathFn())
1137 {
1138  // Search for the path in map. If present, return it. If not, examine
1139  // prior element in map. If none, return end. Else, is it a prefix of
1140  // path? If so, return it. Else find common prefix of that element and
1141  // path and recurse.
1142 
1143  const Iter mapEnd = map.end();
1144 
1145  // If empty, return.
1146  if (map.empty())
1147  return mapEnd;
1148 
1149  // Search for where this path would lexicographically appear in the range.
1150  Iter result = map.lower_bound(path);
1151 
1152  // If we didn't get the end, check to see if we got the path exactly if
1153  // we're not looking for a strict prefix.
1154  if (!strictPrefix && result != mapEnd && getPath(*result) == path)
1155  return result;
1156 
1157  // If we got begin (and didn't match in the case of a non-strict prefix)
1158  // then there's no prefix.
1159  if (result == map.begin())
1160  return mapEnd;
1161 
1162  // If the prior element is a prefix, we're done.
1163  if (path.HasPrefix(getPath(*--result)))
1164  return result;
1165 
1166  // Otherwise, find the common prefix of the lexicographical predecessor and
1167  // recurse looking for it or its longest prefix in the preceding range. We
1168  // always pass strictPrefix=false, since now we're operating on prefixes of
1169  // the original caller's path.
1170  return Sdf_PathFindLongestPrefixImpl<Iter, MapParam>(
1171  map, path.GetCommonPrefix(getPath(*result)), /*strictPrefix=*/false,
1172  getPath);
1173 }
1174 
1175 /// Return an iterator pointing to the element of \a set whose key is the
1176 /// longest prefix of the given path (including the path itself). If there is
1177 /// no such element, return \a set.end().
1178 SDF_API
1179 typename std::set<SdfPath>::const_iterator
1180 SdfPathFindLongestPrefix(std::set<SdfPath> const &set, SdfPath const &path);
1181 
1182 /// Return an iterator pointing to the element of \a map whose key is the
1183 /// longest prefix of the given path (including the path itself). If there is
1184 /// no such element, return \a map.end().
1185 template <class T>
1186 typename std::map<SdfPath, T>::const_iterator
1187 SdfPathFindLongestPrefix(std::map<SdfPath, T> const &map, SdfPath const &path)
1188 {
1190  typename std::map<SdfPath, T>::const_iterator,
1191  std::map<SdfPath, T> const &>(map, path, /*strictPrefix=*/false,
1192  TfGet<0>());
1193 }
1194 template <class T>
1195 typename std::map<SdfPath, T>::iterator
1196 SdfPathFindLongestPrefix(std::map<SdfPath, T> &map, SdfPath const &path)
1197 {
1199  typename std::map<SdfPath, T>::iterator,
1200  std::map<SdfPath, T> &>(map, path, /*strictPrefix=*/false,
1201  TfGet<0>());
1202 }
1203 
1204 /// Return an iterator pointing to the element of \a set whose key is the
1205 /// longest prefix of the given path (excluding the path itself). If there is
1206 /// no such element, return \a set.end().
1207 SDF_API
1208 typename std::set<SdfPath>::const_iterator
1209 SdfPathFindLongestStrictPrefix(std::set<SdfPath> const &set,
1210  SdfPath const &path);
1211 
1212 /// Return an iterator pointing to the element of \a map whose key is the
1213 /// longest prefix of the given path (excluding the path itself). If there is
1214 /// no such element, return \a map.end().
1215 template <class T>
1216 typename std::map<SdfPath, T>::const_iterator
1218  std::map<SdfPath, T> const &map, SdfPath const &path)
1219 {
1221  typename std::map<SdfPath, T>::const_iterator,
1222  std::map<SdfPath, T> const &>(map, path, /*strictPrefix=*/true,
1223  TfGet<0>());
1224 }
1225 template <class T>
1226 typename std::map<SdfPath, T>::iterator
1228  std::map<SdfPath, T> &map, SdfPath const &path)
1229 {
1231  typename std::map<SdfPath, T>::iterator,
1232  std::map<SdfPath, T> &>(map, path, /*strictPrefix=*/true,
1233  TfGet<0>());
1234 }
1235 
1237 
1238 // Sdf_PathNode is not public API, but we need to include it here
1239 // so we can inline the ref-counting operations, which must manipulate
1240 // its internal _refCount member.
1241 #include "pxr/usd/sdf/pathNode.h"
1242 
1244 
1245 static_assert(Sdf_SizeofPrimPathNode == sizeof(Sdf_PrimPathNode), "");
1246 static_assert(Sdf_SizeofPropPathNode == sizeof(Sdf_PrimPropertyPathNode), "");
1247 
1249 
1250 #endif // SDF_PATH_H
SDF_API const char * GetText() const
Returns the string representation of this path as a c string.
SDF_API bool IsPrimOrPrimVariantSelectionPath() const
SDF_API SdfPath AppendTarget(const SdfPath &targetPath) const
SDF_API bool IsMapperPath() const
Returns whether the path identifies a connection mapper.
friend void swap(SdfPath &lhs, SdfPath &rhs)
Definition: path.h:957
SDF_API const std::string & GetName() const
static SDF_API const SdfPath & AbsoluteRootPath()
friend class Sdfext_PathAccess
Definition: path.h:930
SDF_API std::string GetElementString() const
SDF_API bool IsExpressionPath() const
Returns whether the path identifies a connection expression.
GLuint const GLchar * name
Definition: glew.h:1814
SDF_API SdfPath AppendExpression() const
Sdf_PathNodeHandleImpl(Handle h, bool add_ref=true)
Definition: path.h:95
SDF_API SdfPath AppendMapper(const SdfPath &targetPath) const
bool operator==(const SdfPath &rhs) const
Definition: path.h:817
Sdf_PathPropPartPool::Handle Sdf_PathPropHandle
Definition: path.h:75
SDF_API SdfPath ReplaceTargetPath(const SdfPath &newTargetPath) const
FMT_CONSTEXPR auto begin(const C &c) -> decltype(c.begin())
Definition: format.h:251
void reset() noexcept
Definition: path.h:141
std::pair< ForwardIterator, ForwardIterator > SdfPathFindPrefixedRange(ForwardIterator begin, ForwardIterator end, SdfPath const &prefix, GetPathFn const &getPath=GetPathFn())
Definition: path.h:992
static SDF_API bool IsValidPathString(const std::string &pathString, std::string *errMsg=0)
internal::named_arg< T, char > arg(string_view name, const T &arg)
Definition: core.h:1393
RandomAccessIterator Sdf_PathFindLongestPrefixImpl(RandomAccessIterator begin, RandomAccessIterator end, SdfPath const &path, bool strictPrefix, GetPathFn const &getPath)
Definition: path.h:1023
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
SDF_API bool IsMapperArgPath() const
Returns whether the path identifies a connection mapper arg.
SDF_API const SdfPath & GetTargetPath() const
SDF_API bool IsPrimPropertyPath() const
SDF_API SdfPath GetAbsoluteRootOrPrimPath() const
Sdf_PathNodeHandleImpl & operator=(Sdf_PathNodeHandleImpl &&rhs) noexcept
Definition: path.h:130
static SDF_API void RemoveDescendentPaths(SdfPathVector *paths)
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:409
bool operator==(Sdf_PathNodeHandleImpl const &rhs) const noexcept
Definition: path.h:168
GLenum GLsizei const void * pathString
Definition: glew.h:13636
Sdf_PathNodeHandleImpl(Sdf_PathNode const *p, bool add_ref=true)
Definition: path.h:87
SdfPath const & operator()(SdfPath const &arg) const
Definition: path.h:979
size_t GetHash() const
Definition: path.h:870
SDF_API std::pair< std::string, std::string > GetVariantSelection() const
size_t OIIO_API Hash(const char *s, size_t len)
SDF_API SdfPath StripAllVariantSelections() const
SDF_API SdfPath AppendRelationalAttribute(TfToken const &attrName) const
static SDF_API std::vector< std::string > TokenizeIdentifier(const std::string &name)
static SDF_API const SdfPath & EmptyPath()
The empty path value, equivalent to SdfPath().
Sdf_PathNodeHandleImpl(Sdf_PathNodeHandleImpl const &rhs)
Definition: path.h:102
Definition: token.h:89
bool operator<(const SdfPath &rhs) const
Definition: path.h:825
void swap(Sdf_PathNodeHandleImpl &rhs) noexcept
Definition: path.h:164
SDF_API void GetAllTargetPathsRecursively(SdfPathVector *result) const
bool ContainsPropertyElements() const
Definition: path.h:382
SDF_API bool IsPrimVariantSelectionPath() const
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
bool operator!=(Sdf_PathNodeHandleImpl const &rhs) const noexcept
Definition: path.h:171
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
void intrusive_ptr_add_ref(Sdf_PathNode const *)
SDF_API SdfPath AppendChild(TfToken const &childName) const
static SDF_API bool IsValidNamespacedIdentifier(const std::string &name)
Sdf_PathNode const & operator*() const
Definition: path.h:151
GLuint GLuint end
Definition: glew.h:1253
GLuint const GLuint * names
Definition: glew.h:2690
SDF_API SdfPath AppendVariantSelection(const std::string &variantSet, const std::string &variant) const
SDF_API SdfPath AppendMapperArg(TfToken const &argName) const
SDF_API bool IsAbsolutePath() const
Returns whether the path is absolute.
static SDF_API std::string JoinIdentifier(const std::vector< std::string > &names)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
SDF_API bool ContainsTargetPath() const
static SDF_API bool IsValidIdentifier(const std::string &name)
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
SDF_API size_t GetPathElementCount() const
Returns the number of path elements in this path.
constexpr SdfPath()=default
Definition: stl.h:391
Definition: path.h:287
SDF_API TfToken GetElementToken() const
Like GetElementString() but return the value as a TfToken.
SDF_API const std::string & GetString() const
Returns the string representation of this path as a std::string.
SDF_API bool IsPrimPath() const
Returns whether the path identifies a prim.
size_t operator()(const SdfPath &path) const
Definition: path.h:838
Sdf_PathPrimPartPool::Handle Sdf_PathPrimHandle
Definition: path.h:74
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
Sdf_PathNodeHandleImpl & operator=(Sdf_PathNode const *rhs) noexcept
Definition: path.h:136
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:208
constexpr Sdf_PathNodeHandleImpl() noexcept
Definition: path.h:84
SDF_API const TfToken & GetNameToken() const
SDF_API bool HasPrefix(const SdfPath &prefix) const
SDF_API bool IsRelationalAttributePath() const
std::set< class SdfPath > SdfPathSet
A set of SdfPaths.
Definition: path.h:206
SDF_API SdfPath AppendProperty(TfToken const &propName) const
GLsizei const GLchar *const * path
Definition: glew.h:6461
SDF_API bool ContainsPrimVariantSelection() const
hboost::intrusive_ptr< const Sdf_PathNode > Sdf_PathNodeConstRefPtr
Definition: path.h:48
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLfloat GLfloat p
Definition: glew.h:16321
#define SDF_API
Definition: api.h:40
GLsizei const GLchar *const * string
Definition: glew.h:1844
bool operator<(Sdf_PathNodeHandleImpl const &rhs) const noexcept
Definition: path.h:174
SDF_API std::ostream & operator<<(std::ostream &out, const SdfPath &path)
Writes the string representation of path to out.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1245
SDF_API SdfPath GetCommonPrefix(const SdfPath &path) const
SDF_API TfToken const & GetToken() const
Returns the string representation of this path as a TfToken.
SDF_API bool IsTargetPath() const
Sdf_PathNodeHandleImpl & operator=(Sdf_PathNodeHandleImpl const &rhs)
Definition: path.h:116
SDF_API std::pair< SdfPath, SdfPath > RemoveCommonSuffix(const SdfPath &otherPath, bool stopAtRootPrim=false) const
size_t hash_value(SdfPath const &path)
Definition: path.h:968
SDF_API bool IsRootPrimPath() const
SDF_API SdfPath AppendPath(const SdfPath &newSuffix) const
void intrusive_ptr_release(Sdf_PathNode const *)
SDF_API SdfPath MakeAbsolutePath(const SdfPath &anchor) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:83
SDF_API bool IsNamespacedPropertyPath() const
SDF_API SdfPath AppendElementToken(const TfToken &elementTok) const
Like AppendElementString() but take the element as a TfToken.
SDF_API SdfPath GetParentPath() const
static SDF_API SdfPathVector GetConciseRelativePaths(const SdfPathVector &paths)
SDF_API SdfPath GetPrimOrPrimVariantSelectionPath() const
GLenum const void GLuint GLint reference
Definition: glew.h:13644
GLuint64EXT * result
Definition: glew.h:14007
SDF_API bool IsPropertyPath() const
static SDF_API std::pair< std::string, bool > StripPrefixNamespace(const std::string &name, const std::string &matchNamespace)
RandomAccessIterator SdfPathFindLongestPrefix(RandomAccessIterator begin, RandomAccessIterator end, SdfPath const &path, GetPathFn const &getPath=GetPathFn())
Definition: path.h:1097
static SDF_API void RemoveAncestorPaths(SdfPathVector *paths)
#define const
Definition: zconf.h:214
SDF_API bool IsAbsoluteRootOrPrimPath() const
Returns whether the path identifies a prim or the absolute root.
RandomAccessIterator SdfPathFindLongestStrictPrefix(RandomAccessIterator begin, RandomAccessIterator end, SdfPath const &path, GetPathFn const &getPath=GetPathFn())
Definition: path.h:1123
Sdf_PathNode const * operator->() const
Definition: path.h:156
Sdf_PathNodeHandleImpl(Sdf_PathNodeHandleImpl &&rhs) noexcept
Definition: path.h:124
SDF_API SdfPathVector GetPrefixes() const
static SDF_API std::string StripNamespace(const std::string &name)
friend struct Handle
Definition: pool.h:93
SDF_API SdfPath ReplaceName(TfToken const &newName) const
static SDF_API const SdfPath & ReflexiveRelativePath()
The relative path representing "self".
GLsizei const GLfloat * value
Definition: glew.h:1849
SDF_API SdfPath AppendElementString(const std::string &element) const
bool operator()(const SdfPath &a, const SdfPath &b) const
Definition: path.h:877
VT_TYPE_IS_CHEAP_TO_COPY(class SdfPath)
Definition: pool.h:78
SDF_API SdfPath MakeRelativePath(const SdfPath &anchor) const
SDF_API SdfPath ReplacePrefix(const SdfPath &oldPrefix, const SdfPath &newPrefix, bool fixTargetPaths=true) const
SDF_API SdfPath GetPrimPath() const
void * Handle
Definition: plugin.h:53
static SDF_API TfTokenVector TokenizeIdentifierAsTokens(const std::string &name)
GLenum const void * paths
Definition: glew.h:13589