17 Path(std::filesystem::path
const& path) : Path(path.u8string()) {}
18 Path(std::u8string&& path) { value = std::move(*
reinterpret_cast<std::string*
>(&path)); }
19 Path(std::string&& path) { value = std::move(path); }
20 Path(std::u8string
const& path) { value = *
reinterpret_cast<std::string const*
>(&path); }
21 Path(std::string
const& path) { value = path; }
22 Path(
char const* path) { value = path; }
24 Path(Path
const& other) =
default;
26 Path(Path&& other) noexcept : Base{std::move(other.value)} {}
28 Path& operator=(Path
const& other) {
29 if (
this != &other) value = other.value;
33 Path& operator=(Path&& other)
noexcept {
34 if (
this != &other) value = std::move(other.value);
38 bool operator<(Path
const& rhs)
const noexcept {
return value < rhs.value; }
40 bool operator==(Path
const& rhs)
const noexcept {
return value == rhs.value; }
42 [[nodiscard]]
char const* getUtf8CString()
const noexcept {
return value.c_str(); }
44 [[nodiscard]] std::string_view getUtf8StringView()
const noexcept {
return value; }
46 [[nodiscard]] std::string
const& getUtf8StdString()
const noexcept {
return value; }
48 [[nodiscard]]
size_t size()
const noexcept {
return value.size(); }
50 [[nodiscard]]
bool empty()
const noexcept {
return value.empty(); }
52 [[nodiscard]]
bool isAbsolute()
const noexcept {
54 auto const& s = value;
55 if (s.size() >= 2 && std::isalpha(
static_cast<unsigned char>(s[0])) && s[1] ==
':')
return true;
56 if (s.size() >= 2 && s[0] ==
'\\' && s[1] ==
'\\')
return true;
59 auto const& s = value;
60 return !s.empty() && s.front() ==
'/';
64 [[nodiscard]]
bool isDotOrDotDot()
const noexcept {
return value ==
"." || value ==
".."; }
67 static Path
const& EMPTY() {
68 static Path
const emptyPath(
"");