Added comparator and hash function for path references.
This commit is contained in:
parent
83d3ce9f1f
commit
1d14c1f3ff
@ -11,6 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "../io/stream.hpp"
|
#include "../io/stream.hpp"
|
||||||
|
#include "../util/hash.hpp"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
@ -49,6 +50,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
PathReference(class FileSystemAdapter* adapter, fs::path path) noexcept : adapter_(adapter), path_(std::move(path)) {}
|
PathReference(class FileSystemAdapter* adapter, fs::path path) noexcept : adapter_(adapter), path_(std::move(path)) {}
|
||||||
|
|
||||||
|
auto operator<=>(const PathReference& other) const noexcept = default;
|
||||||
|
|
||||||
[[nodiscard]] class FileSystemAdapter* getAdapter() const noexcept { return adapter_; }
|
[[nodiscard]] class FileSystemAdapter* getAdapter() const noexcept { return adapter_; }
|
||||||
[[nodiscard]] const fs::path& getPath() const noexcept { return path_; }
|
[[nodiscard]] const fs::path& getPath() const noexcept { return path_; }
|
||||||
[[nodiscard]] inline FileInfo getInfo() const;
|
[[nodiscard]] inline FileInfo getInfo() const;
|
||||||
@ -129,4 +132,16 @@ inline std::string formatFileSize(std::size_t sizeInBytes)
|
|||||||
|
|
||||||
} // namespace mijin
|
} // namespace mijin
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct std::hash<mijin::PathReference>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const mijin::PathReference& pathRef) const noexcept
|
||||||
|
{
|
||||||
|
std::size_t hash = 0;
|
||||||
|
mijin::hashCombine(hash, pathRef.getAdapter());
|
||||||
|
mijin::hashCombine(hash, pathRef.getPath());
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#endif // !defined(MIJIN_VIRTUAL_FILESYSTEM_FILESYSTEM_HPP_INCLUDED)
|
#endif // !defined(MIJIN_VIRTUAL_FILESYSTEM_FILESYSTEM_HPP_INCLUDED)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user