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) {
100 return Build(a.
c_str(), b);
105 return Build(a, b.
c_str());
111 b.value.c_str(), b.value.size());
116 return Build(a.value.c_str(), a.value.size(),
123 return Build(a.value.c_str(), a.value.size(),
124 b.value.c_str(), b.value.size());
138 const_pointer_type _end) {
174 value = std::move(other.value);
180 return value == other.value;
185 return value != other.value;
193 return std::move(value);
201 return value.empty();
219 return value.length();
229 return value.c_str();
237 const_pointer_type
data()
const {
247 std::string
ToUTF8()
const;
gcc_pure static gcc_nonnull_all AllocatedPath Build(Path a, const_pointer_type b)
AllocatedPath & operator=(const AllocatedPath &)=default
Copy an AllocatedPath object.
gcc_pure const_pointer_type Relative(Path other_fs) const
Determine the relative part of the given path to this object, not including the directory separator...
AllocatedPath(Path other)
gcc_pure static gcc_nonnull_all AllocatedPath FromUTF8Throw(const char *path_utf8)
Convert a UTF-8 C string to an AllocatedPath instance.
void SetNull()
Clear this object's value, make it "nulled".
gcc_pure static gcc_nonnull_all AllocatedPath FromUTF8(const char *path_utf8)
Convert a UTF-8 C string to an AllocatedPath instance.
A path name in the native file system character set.
static gcc_pure AllocatedPath FromFS(const_pointer_type _begin, const_pointer_type _end)
string && Steal()
Allows the caller to "steal" the internal value by providing a rvalue reference to the std::string at...
gcc_pure const_pointer_type data() const
Returns a pointer to the raw value, not necessarily null-terminated.
const Storage const char const char * path_utf8
gcc_pure size_t length() const
gcc_pure static gcc_nonnull_all AllocatedPath Build(const_pointer_type a, const_pointer_type b)
Join two path components with the path separator.
gcc_pure static gcc_nonnull_all const_pointer_type Relative(const_pointer_type base, const_pointer_type other)
Determine the relative part of the given path to this object, not including the directory separator...
Pointer::pointer_type pointer_type
static gcc_pure AllocatedPath Build(const AllocatedPath &a, const AllocatedPath &b)
gcc_pure std::string ToUTF8() const
Convert the path to UTF-8.
gcc_pure bool IsAbsolute() const
static constexpr Path FromFS(const_pointer_type fs)
Create a new instance pointing to the specified path string.
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.
AllocatedPath(AllocatedPath &&other)
Move an AllocatedPath object.
static gcc_const AllocatedPath Null()
Return a "nulled" instance.
gcc_pure static gcc_nonnull_all AllocatedPath Build(const_pointer_type a, const AllocatedPath &b)
gcc_pure bool operator==(const AllocatedPath &other) const
gcc_pure AllocatedPath GetDirectoryName() const
Gets directory name of this path.
gcc_pure bool operator!=(const AllocatedPath &other) const
gcc_pure const_pointer_type c_str() const
Returns the value as a const C string.
gcc_pure static gcc_nonnull_all size_t GetLength(const_pointer_type p)
static gcc_pure AllocatedPath FromFS(const_pointer_type fs)
Convert a C string that is already in the filesystem character set to a Path instance.
void ChopSeparators()
Chop trailing directory separators.
char_traits::char_type value_type
gcc_pure const_pointer_type c_str() const
Returns the value as a const C string.
gcc_pure static gcc_nonnull_all bool IsAbsolute(const_pointer_type p)
bool IsNull() const
Check if this is a "nulled" instance.
static gcc_pure AllocatedPath FromFS(string &&fs)
Convert a C++ string that is already in the filesystem character set to a Path instance.
gcc_pure static gcc_nonnull_all AllocatedPath Build(const AllocatedPath &a, const_pointer_type b)
gcc_pure static gcc_nonnull_all AllocatedPath Build(Path a, Path b)
gcc_pure static gcc_nonnull_all string Build(const_pointer_type a, size_t a_size, const_pointer_type b, size_t b_size)
Constructs the path from the given components.