13 bool operator()(
const Path& lhs,
const Path& rhs)
const noexcept {
14 return lhs.getUtf8StdString() < rhs.getUtf8StdString();
24 Path(std::filesystem::path
const& path) : Path(path.u8string()) {}
25 Path(std::u8string&& path) { mPathPart.mUtf8StdString = std::move(*
reinterpret_cast<std::string*
>(&path)); }
26 Path(std::string&& path) { mPathPart.mUtf8StdString = std::move(path); }
27 Path(std::u8string
const& path) { mPathPart.mUtf8StdString = *
reinterpret_cast<std::string const*
>(&path); }
28 Path(std::string
const& path) { mPathPart.mUtf8StdString = path; }
29 Path(
char const* path) { mPathPart.mUtf8StdString = path; }
31 Path(
const PathPart& part) : mPathPart{std::move(part)} {}
33 Path(
const Path& other) =
default;
35 Path(Path&& other) noexcept : mPathPart{std::move(other.mPathPart)} {}
37 Path& operator=(
const Path& other) {
38 if (
this != &other) mPathPart.mUtf8StdString = other.mPathPart.mUtf8StdString;
42 Path& operator=(Path&& other)
noexcept {
43 if (
this != &other) mPathPart.mUtf8StdString = std::move(other.mPathPart.mUtf8StdString);
47 bool operator<(
const Path& rhs)
const noexcept {
return mPathPart.mUtf8StdString < rhs.mPathPart.mUtf8StdString; }
49 bool operator==(
const Path& rhs)
const noexcept {
return mPathPart.mUtf8StdString == rhs.mPathPart.mUtf8StdString; }
51 [[nodiscard]]
const char* getUtf8CString() const noexcept {
return mPathPart.mUtf8StdString.c_str(); }
53 [[nodiscard]] std::string_view getUtf8StringView() const noexcept {
return mPathPart.mUtf8StdString; }
55 [[nodiscard]]
const std::string& getUtf8StdString() const noexcept {
return mPathPart.mUtf8StdString; }
57 [[nodiscard]]
size_t size() const noexcept {
return mPathPart.mUtf8StdString.size(); }
59 [[nodiscard]]
bool empty() const noexcept {
return mPathPart.mUtf8StdString.empty(); }
61 [[nodiscard]]
bool isAbsolute() const noexcept {
63 auto const& s = mPathPart.mUtf8StdString;
64 if (s.size() >= 2 && std::isalpha(
static_cast<unsigned char>(s[0])) && s[1] ==
':')
return true;
65 if (s.size() >= 2 && s[0] ==
'\\' && s[1] ==
'\\')
return true;
68 auto const& s = mPathPart.mUtf8StdString;
69 return !s.empty() && s.front() ==
'/';
73 [[nodiscard]]
bool isDotOrDotDot() const noexcept {
74 return mPathPart.mUtf8StdString ==
"." || mPathPart.mUtf8StdString ==
"..";
78 static const Path& EMPTY() {
79 static const Path emptyPath(
"");