resolvedPath.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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 PXR_USD_AR_RESOLVED_PATH_H
25 #define PXR_USD_AR_RESOLVED_PATH_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/ar/api.h"
31 #include "pxr/base/tf/hash.h"
32 
33 #include <string>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
40 {
41 public:
43  explicit ArResolvedPath(const std::string& resolvedPath)
44  : _resolvedPath(resolvedPath)
45  {
46  }
47 
49  explicit ArResolvedPath(std::string&& resolvedPath)
50  : _resolvedPath(std::move(resolvedPath))
51  {
52  }
53 
54  ArResolvedPath() = default;
55 
56  ArResolvedPath(const ArResolvedPath& rhs) = default;
57  ArResolvedPath(ArResolvedPath&& rhs) = default;
58 
59  ArResolvedPath& operator=(const ArResolvedPath& rhs) = default;
60  ArResolvedPath& operator=(ArResolvedPath&& rhs) = default;
61 
62  bool operator==(const ArResolvedPath& rhs) const
63  { return _resolvedPath == rhs._resolvedPath; }
64 
65  bool operator!=(const ArResolvedPath& rhs) const
66  { return _resolvedPath != rhs._resolvedPath; }
67 
68  bool operator<(const ArResolvedPath& rhs) const
69  { return _resolvedPath < rhs._resolvedPath; }
70 
71  bool operator>(const ArResolvedPath& rhs) const
72  { return _resolvedPath > rhs._resolvedPath; }
73 
74  bool operator<=(const ArResolvedPath& rhs) const
75  { return _resolvedPath <= rhs._resolvedPath; }
76 
77  bool operator>=(const ArResolvedPath& rhs) const
78  { return _resolvedPath >= rhs._resolvedPath; }
79 
80  bool operator==(const std::string& rhs) const
81  { return _resolvedPath == rhs; }
82 
83  bool operator!=(const std::string& rhs) const
84  { return _resolvedPath != rhs; }
85 
86  bool operator<(const std::string& rhs) const
87  { return _resolvedPath < rhs; }
88 
89  bool operator>(const std::string& rhs) const
90  { return _resolvedPath > rhs; }
91 
92  bool operator<=(const std::string& rhs) const
93  { return _resolvedPath <= rhs; }
94 
95  bool operator>=(const std::string& rhs) const
96  { return _resolvedPath >= rhs; }
97 
99  size_t GetHash() const { return TfHash()(*this); }
100 
103  explicit operator bool() const { return !IsEmpty(); }
104 
107  bool IsEmpty() const { return _resolvedPath.empty(); }
108 
111  bool empty() const { return IsEmpty(); }
112 
114  operator const std::string&() const { return GetPathString(); }
115 
117  const std::string& GetPathString() const { return _resolvedPath; }
118 
119 private:
120  std::string _resolvedPath;
121 };
122 
123 template <class HashState>
124 void
125 TfHashAppend(HashState& h, const ArResolvedPath& p)
126 {
127  h.Append(p.GetPathString());
128 }
129 
130 PXR_NAMESPACE_CLOSE_SCOPE
131 
132 #endif
ArResolvedPath(const std::string &resolvedPath)
Construct an ArResolvedPath holding the given resolvedPath.
Definition: resolvedPath.h:43
bool IsEmpty() const
Return true if this object is holding an empty resolved path, false otherwise.
Definition: resolvedPath.h:107
A user-extensible hashing mechanism for use with runtime hash tables.
Definition: hash.h:447
bool empty() const
Equivalent to IsEmpty.
Definition: resolvedPath.h:111
const std::string & GetPathString() const
Return the resolved path held by this object as a string.
Definition: resolvedPath.h:117
ArResolvedPath(std::string &&resolvedPath)
Definition: resolvedPath.h:49
Represents a resolved asset path.
Definition: resolvedPath.h:39
size_t GetHash() const
Return hash value for this object.
Definition: resolvedPath.h:99