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 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 
27 /// \file ar/resolvedPath.h
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 
36 
37 /// \class ArResolvedPath
38 /// Represents a resolved asset path.
40 {
41 public:
42  /// Construct an ArResolvedPath holding the given \p resolvedPath.
43  explicit ArResolvedPath(const std::string& resolvedPath)
44  : _resolvedPath(resolvedPath)
45  {
46  }
47 
48  /// \overload
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 
98  /// Return hash value for this object.
99  size_t GetHash() const { return TfHash()(*this); }
100 
101  /// Return true if this object is holding a non-empty resolved path,
102  /// false otherwise.
103  explicit operator bool() const { return !IsEmpty(); }
104 
105  /// Return true if this object is holding an empty resolved path,
106  /// false otherwise.
107  bool IsEmpty() const { return _resolvedPath.empty(); }
108 
109  /// Equivalent to IsEmpty. This exists primarily for backwards
110  /// compatibility.
111  bool empty() const { return IsEmpty(); }
112 
113  /// Return the resolved path held by this object as a string.
114  operator const std::string&() const { return GetPathString(); }
115 
116  /// Return the resolved path held by this object as a string.
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 
131 
132 #endif
bool operator>=(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:77
bool operator<=(const std::string &rhs) const
Definition: resolvedPath.h:92
size_t GetHash() const
Return hash value for this object.
Definition: resolvedPath.h:99
ArResolvedPath & operator=(const ArResolvedPath &rhs)=default
bool operator==(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:62
bool empty() const
Definition: resolvedPath.h:111
void TfHashAppend(HashState &h, const ArResolvedPath &p)
Definition: resolvedPath.h:125
bool operator!=(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:65
Definition: hash.h:447
const std::string & GetPathString() const
Return the resolved path held by this object as a string.
Definition: resolvedPath.h:117
bool IsEmpty() const
Definition: resolvedPath.h:107
bool operator!=(const std::string &rhs) const
Definition: resolvedPath.h:83
bool operator<(const std::string &rhs) const
Definition: resolvedPath.h:86
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
ArResolvedPath(const std::string &resolvedPath)
Construct an ArResolvedPath holding the given resolvedPath.
Definition: resolvedPath.h:43
ArResolvedPath(std::string &&resolvedPath)
Definition: resolvedPath.h:49
GLfloat GLfloat p
Definition: glew.h:16656
bool operator>=(const std::string &rhs) const
Definition: resolvedPath.h:95
ArResolvedPath()=default
bool operator>(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:71
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1394
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
bool operator>(const std::string &rhs) const
Definition: resolvedPath.h:89
bool operator<=(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:74
bool operator<(const ArResolvedPath &rhs) const
Definition: resolvedPath.h:68
bool operator==(const std::string &rhs) const
Definition: resolvedPath.h:80