18 Path(std::filesystem::path
const& path) : Path(path.u8string()) {}
19 Path(std::u8string&& path) { value = std::move(*
reinterpret_cast<std::string*
>(&path)); }
20 Path(std::string&& path) { value = std::move(path); }
21 Path(std::u8string
const& path) { value = *
reinterpret_cast<std::string const*
>(&path); }
22 Path(std::string
const& path) { value = path; }
23 Path(
char const* path) { value = path; }
25 Path(
PathPart const& part) : Base{std::move(part.mUtf8StdString)} {}
27 Path(
const Path& other) =
default;
29 Path(Path&& other) noexcept : Base{std::move(other.value)} {}
31 Path& operator=(
const Path& other) {
32 if (
this != &other) value = other.value;
36 Path& operator=(Path&& other)
noexcept {
37 if (
this != &other) value = std::move(other.value);
41 bool operator<(
const Path& rhs)
const noexcept {
return value < rhs.value; }
43 bool operator==(
const Path& rhs)
const noexcept {
return value == rhs.value; }
45 [[nodiscard]]
const char* getUtf8CString()
const noexcept {
return value.c_str(); }
47 [[nodiscard]] std::string_view getUtf8StringView()
const noexcept {
return value; }
49 [[nodiscard]]
const std::string& getUtf8StdString()
const noexcept {
return value; }
51 [[nodiscard]]
size_t size()
const noexcept {
return value.size(); }
53 [[nodiscard]]
bool empty()
const noexcept {
return value.empty(); }
55 [[nodiscard]]
bool isAbsolute()
const noexcept {
57 auto const& s = value;
58 if (s.size() >= 2 && std::isalpha(
static_cast<unsigned char>(s[0])) && s[1] ==
':')
return true;
59 if (s.size() >= 2 && s[0] ==
'\\' && s[1] ==
'\\')
return true;
62 auto const& s = value;
63 return !s.empty() && s.front() ==
'/';
67 [[nodiscard]]
bool isDotOrDotDot()
const noexcept {
68 return value ==
"." || value ==
"..";
72 static const Path& EMPTY() {
73 static const Path emptyPath(
"");