HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resolvedPath.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_AR_RESOLVED_PATH_H
8 #define PXR_USD_AR_RESOLVED_PATH_H
9 
10 /// \file ar/resolvedPath.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/ar/api.h"
14 #include "pxr/base/tf/hash.h"
15 
16 #include <string>
17 
19 
20 /// \class ArResolvedPath
21 /// Represents a resolved asset path.
23 {
24 public:
25  /// Construct an ArResolvedPath holding the given \p resolvedPath.
26  explicit ArResolvedPath(const std::string& resolvedPath)
27  : _resolvedPath(resolvedPath)
28  {
29  }
30 
31  /// \overload
32  explicit ArResolvedPath(std::string&& resolvedPath)
33  : _resolvedPath(std::move(resolvedPath))
34  {
35  }
36 
37  ArResolvedPath() = default;
38 
39  ArResolvedPath(const ArResolvedPath& rhs) = default;
40  ArResolvedPath(ArResolvedPath&& rhs) = default;
41 
42  ArResolvedPath& operator=(const ArResolvedPath& rhs) = default;
43  ArResolvedPath& operator=(ArResolvedPath&& rhs) = default;
44 
45  bool operator==(const ArResolvedPath& rhs) const
46  { return _resolvedPath == rhs._resolvedPath; }
47 
48  bool operator!=(const ArResolvedPath& rhs) const
49  { return _resolvedPath != rhs._resolvedPath; }
50 
51  bool operator<(const ArResolvedPath& rhs) const
52  { return _resolvedPath < rhs._resolvedPath; }
53 
54  bool operator>(const ArResolvedPath& rhs) const
55  { return _resolvedPath > rhs._resolvedPath; }
56 
57  bool operator<=(const ArResolvedPath& rhs) const
58  { return _resolvedPath <= rhs._resolvedPath; }
59 
60  bool operator>=(const ArResolvedPath& rhs) const
61  { return _resolvedPath >= rhs._resolvedPath; }
62 
63  bool operator==(const std::string& rhs) const
64  { return _resolvedPath == rhs; }
65 
66  bool operator!=(const std::string& rhs) const
67  { return _resolvedPath != rhs; }
68 
69  bool operator<(const std::string& rhs) const
70  { return _resolvedPath < rhs; }
71 
72  bool operator>(const std::string& rhs) const
73  { return _resolvedPath > rhs; }
74 
75  bool operator<=(const std::string& rhs) const
76  { return _resolvedPath <= rhs; }
77 
78  bool operator>=(const std::string& rhs) const
79  { return _resolvedPath >= rhs; }
80 
81  /// Return hash value for this object.
82  size_t GetHash() const { return TfHash()(*this); }
83 
84  /// Return true if this object is holding a non-empty resolved path,
85  /// false otherwise.
86  explicit operator bool() const { return !IsEmpty(); }
87 
88  /// Return true if this object is holding an empty resolved path,
89  /// false otherwise.
90  bool IsEmpty() const { return _resolvedPath.empty(); }
91 
92  /// Equivalent to IsEmpty. This exists primarily for backwards
93  /// compatibility.
94  bool empty() const { return IsEmpty(); }
95 
96  /// Return the resolved path held by this object as a string.
97  operator const std::string&() const { return GetPathString(); }
98 
99  /// Return the resolved path held by this object as a string.
100  const std::string& GetPathString() const { return _resolvedPath; }
101 
102 private:
103  std::string _resolvedPath;
104 };
105 
106 template <class HashState>
107 void
108 TfHashAppend(HashState& h, const ArResolvedPath& p)
109 {
110  h.Append(p.GetPathString());
111 }
112 
114 
115 #endif
bool operator>=(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:60
bool operator<=(const std::string &rhs) const
Definition: resolvedPath.h:75
size_t GetHash() const
Return hash value for this object.
Definition: resolvedPath.h:82
ArResolvedPath & operator=(const ArResolvedPath &rhs)=default
bool operator==(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:45
bool empty() const
Definition: resolvedPath.h:94
void TfHashAppend(HashState &h, const ArResolvedPath &p)
Definition: resolvedPath.h:108
OutGridT const XformOp bool bool
bool operator!=(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:48
Definition: hash.h:472
const std::string & GetPathString() const
Return the resolved path held by this object as a string.
Definition: resolvedPath.h:100
bool IsEmpty() const
Definition: resolvedPath.h:90
bool operator!=(const std::string &rhs) const
Definition: resolvedPath.h:66
bool operator<(const std::string &rhs) const
Definition: resolvedPath.h:69
ArResolvedPath(const std::string &resolvedPath)
Construct an ArResolvedPath holding the given resolvedPath.
Definition: resolvedPath.h:26
ArResolvedPath(std::string &&resolvedPath)
Definition: resolvedPath.h:32
bool operator>=(const std::string &rhs) const
Definition: resolvedPath.h:78
ArResolvedPath()=default
bool operator>(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:54
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool operator>(const std::string &rhs) const
Definition: resolvedPath.h:72
bool operator<=(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:57
bool operator<(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:51
bool operator==(const std::string &rhs) const
Definition: resolvedPath.h:63