23 Path(std::filesystem::path
const& path) : Path(path.u8string()) {}
24 Path(std::u8string&& path) { value = std::move(*
reinterpret_cast<std::string*
>(&path)); }
25 Path(std::string&& path) { value = std::move(path); }
26 Path(std::u8string
const& path) { value = *
reinterpret_cast<std::string const*
>(&path); }
27 Path(std::string
const& path) { value = path; }
28 Path(
char const* path) { value = path; }
30 Path(
PathPart const& part) : Base{std::move(part.mUtf8StdString)} {}
32 Path(
const Path& other) =
default;
34 Path(Path&& other) noexcept : Base{std::move(other.value)} {}
36 Path& operator=(
const Path& other) {
37 if (
this != &other) value = other.value;
41 Path& operator=(Path&& other)
noexcept {
42 if (
this != &other) value = std::move(other.value);
46 bool operator<(
const Path& rhs)
const noexcept {
return value < rhs.value; }
48 bool operator==(
const Path& rhs)
const noexcept {
return value == rhs.value; }
50 [[nodiscard]]
const char* getUtf8CString()
const noexcept {
return value.c_str(); }
52 [[nodiscard]] std::string_view getUtf8StringView()
const noexcept {
return value; }
54 [[nodiscard]]
const std::string& getUtf8StdString()
const noexcept {
return value; }
56 [[nodiscard]]
size_t size()
const noexcept {
return value.size(); }
58 [[nodiscard]]
bool empty()
const noexcept {
return value.empty(); }
60 [[nodiscard]]
bool isAbsolute()
const noexcept {
62 auto const& s = value;
63 if (s.size() >= 2 && std::isalpha(
static_cast<unsigned char>(s[0])) && s[1] ==
':')
return true;
64 if (s.size() >= 2 && s[0] ==
'\\' && s[1] ==
'\\')
return true;
67 auto const& s = value;
68 return !s.empty() && s.front() ==
'/';
72 [[nodiscard]]
bool isDotOrDotDot()
const noexcept {
73 return value ==
"." || value ==
"..";
77 static const Path& EMPTY() {
78 static const Path emptyPath(
"");