Loading...
Searching...
No Matches
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
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
18PXR_NAMESPACE_OPEN_SCOPE
19
23{
24public:
26 explicit ArResolvedPath(const std::string& resolvedPath)
27 : _resolvedPath(resolvedPath)
28 {
29 }
30
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
82 size_t GetHash() const { return TfHash()(*this); }
83
86 explicit operator bool() const { return !IsEmpty(); }
87
90 bool IsEmpty() const { return _resolvedPath.empty(); }
91
94 bool empty() const { return IsEmpty(); }
95
97 operator const std::string&() const { return GetPathString(); }
98
100 const std::string& GetPathString() const { return _resolvedPath; }
101
102private:
103 std::string _resolvedPath;
104};
105
106template <class HashState>
107void
108TfHashAppend(HashState& h, const ArResolvedPath& p)
109{
110 h.Append(p.GetPathString());
111}
112
113PXR_NAMESPACE_CLOSE_SCOPE
114
115#endif
Represents a resolved asset path.
Definition: resolvedPath.h:23
const std::string & GetPathString() const
Return the resolved path held by this object as a string.
Definition: resolvedPath.h:100
bool empty() const
Equivalent to IsEmpty.
Definition: resolvedPath.h:94
ArResolvedPath(const std::string &resolvedPath)
Construct an ArResolvedPath holding the given resolvedPath.
Definition: resolvedPath.h:26
bool IsEmpty() const
Return true if this object is holding an empty resolved path, false otherwise.
Definition: resolvedPath.h:90
size_t GetHash() const
Return hash value for this object.
Definition: resolvedPath.h:82
ArResolvedPath(std::string &&resolvedPath)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: resolvedPath.h:32
A user-extensible hashing mechanism for use with runtime hash tables.
Definition: hash.h:472
STL namespace.