20 #ifndef MPD_FS_ALLOCATED_PATH_HXX 21 #define MPD_FS_ALLOCATED_PATH_HXX 47 explicit AllocatedPath(const_pointer_type _value):value(_value) {}
49 AllocatedPath(const_pointer_type _begin, const_pointer_type _end)
50 :value(_begin, _end) {}
54 static AllocatedPath Build(const_pointer_type a,
size_t a_size,
55 const_pointer_type b,
size_t b_size) {
85 operator Path() const noexcept {
94 const_pointer_type b) noexcept {
101 return Build(a.c_str(), b);
106 return Build(a, b.c_str());
113 b.value.c_str(), b.value.size());
118 const_pointer_type b) noexcept {
119 return Build(a.value.c_str(), a.value.size(),
126 return Build(a.value.c_str(), a.value.size(),
127 b.value.c_str(), b.value.size());
141 const_pointer_type _end) noexcept {
177 value = std::move(other.value);
183 return value == other.value;
188 return value != other.value;
196 return std::move(value);
204 return value.empty();
222 return value.length();
231 const_pointer_type
c_str() const noexcept {
232 return value.c_str();
240 const_pointer_type
data() const noexcept {
250 std::string
ToUTF8() const noexcept;
static gcc_pure AllocatedPath FromFS(string &&fs) noexcept
Convert a C++ string that is already in the filesystem character set to a Path instance.
gcc_pure static gcc_nonnull_all string Build(const_pointer_type a, size_t a_size, const_pointer_type b, size_t b_size) noexcept
Constructs the path from the given components.
AllocatedPath & operator=(const AllocatedPath &)=default
Copy an AllocatedPath object.
gcc_pure const_pointer_type data() const noexcept
Returns a pointer to the raw value, not necessarily null-terminated.
gcc_pure bool IsAbsolute() const noexcept
AllocatedPath(Path other)
gcc_pure const_pointer_type c_str() const noexcept
Returns the value as a const C string.
gcc_pure size_t length() const noexcept
gcc_pure static gcc_nonnull_all AllocatedPath Build(Path a, const_pointer_type b) noexcept
gcc_pure static gcc_nonnull_all AllocatedPath Build(const_pointer_type a, const_pointer_type b) noexcept
Join two path components with the path separator.
gcc_pure bool operator!=(const AllocatedPath &other) const noexcept
A path name in the native file system character set.
string && Steal()
Allows the caller to "steal" the internal value by providing a rvalue reference to the std::string at...
static gcc_const AllocatedPath Null() noexcept
Return a "nulled" instance.
gcc_pure AllocatedPath GetDirectoryName() const noexcept
Gets directory name of this path.
gcc_pure static gcc_nonnull_all const_pointer_type Relative(const_pointer_type base, const_pointer_type other) noexcept
Determine the relative part of the given path to this object, not including the directory separator...
const Storage const char const char * path_utf8
gcc_pure static gcc_nonnull_all AllocatedPath Build(const_pointer_type a, const AllocatedPath &b) noexcept
static gcc_pure AllocatedPath Build(const AllocatedPath &a, const AllocatedPath &b) noexcept
Pointer::pointer_type pointer_type
static constexpr Path FromFS(const_pointer_type fs)
Create a new instance pointing to the specified path string.
gcc_pure std::string ToUTF8() const noexcept
Convert the path to UTF-8.
static gcc_pure AllocatedPath FromFS(const_pointer_type _begin, const_pointer_type _end) noexcept
bool IsNull() const noexcept
Check if this is a "nulled" instance.
gcc_pure static gcc_nonnull_all bool IsAbsolute(const_pointer_type p) noexcept
AllocatedPath & operator=(AllocatedPath &&other)
Move an AllocatedPath object.
Pointer::const_pointer_type const_pointer_type
A path name in the native file system character set.
void ChopSeparators() noexcept
Chop trailing directory separators.
AllocatedPath(AllocatedPath &&other)
Move an AllocatedPath object.
gcc_pure static gcc_nonnull_all size_t GetLength(const_pointer_type p) noexcept
static gcc_pure AllocatedPath FromFS(const_pointer_type fs) noexcept
Convert a C string that is already in the filesystem character set to a Path instance.
static gcc_nonnull_all AllocatedPath FromUTF8Throw(const char *path_utf8)
Convert a UTF-8 C string to an AllocatedPath instance.
gcc_pure const_pointer_type Relative(Path other_fs) const noexcept
Determine the relative part of the given path to this object, not including the directory separator...
gcc_pure bool operator==(const AllocatedPath &other) const noexcept
gcc_pure static gcc_nonnull_all AllocatedPath FromUTF8(const char *path_utf8) noexcept
Convert a UTF-8 C string to an AllocatedPath instance.
gcc_pure static gcc_nonnull_all AllocatedPath Build(const AllocatedPath &a, const_pointer_type b) noexcept
char_traits::char_type value_type
gcc_pure static gcc_nonnull_all AllocatedPath Build(Path a, Path b) noexcept
void SetNull() noexcept
Clear this object's value, make it "nulled".