MPD: Path Class Reference

MPD 0.20.18

Public Member Functions | Static Public Member Functions
Path Class Reference

A path name in the native file system character set. More...

`#include <Path.hxx>`

Inheritance diagram for Path:
[legend]
Collaboration diagram for Path:
[legend]

## Public Member Functions
constexpr | Path (const Path &)=default
| Copy a Path object. More...
Path & | operator= (const Path &)=default
| Copy a Path object. More...
bool | IsNull () const
| Check if this is a "nulled" instance. More...
void | SetNull ()
| Clear this object's value, make it "nulled". More...
gcc_pure size_t | length () const noexcept
gcc_pure const_pointer_type | c_str () const noexcept
| Returns the value as a const C string. More...
gcc_pure const_pointer_type | data () const noexcept
| Returns a pointer to the raw value, not necessarily null-terminated. More...
gcc_pure bool | HasNewline () const noexcept
| Does the path contain a newline character? (Which is usually rejected by MPD because its protocol cannot transfer newline characters). More...
gcc_pure std::string | ToUTF8 () const noexcept
| Convert the path to UTF-8. More...
gcc_pure Path | GetBase () const noexcept
| Determine the "base" file name. More...
gcc_pure AllocatedPath | GetDirectoryName () const noexcept
| Gets directory name of this path. More...
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. More...
gcc_pure bool | IsAbsolute () const noexcept
gcc_pure const_pointer_type | GetSuffix () const noexcept
Public Member Functions inherited from StringPointer< T >
| StringPointer ()=default
constexpr | StringPointer (const_pointer_type _value)
constexpr bool | IsNull () const
| Check if this is a "nulled" instance. More...
constexpr const_pointer_type | c_str () const
bool | empty () const

## Static Public Member Functions
static constexpr Path | Null ()
| Return a "nulled" instance. More...
static constexpr Path | FromFS (const_pointer_type fs)
| Create a new instance pointing to the specified path string. More...

## Additional Inherited Members
Public Types inherited from StringPointer< T >
typedef T | value_type
typedef T & | reference_type
typedef const T & | const_reference_type
typedef T * | pointer_type
typedef const T * | const_pointer_type
Static Public Attributes inherited from StringPointer< T >
static constexpr value_type | SENTINEL = '\0'

## Detailed Description

A path name in the native file system character set.

This class manages a pointer to an existing path string. While an instance lives, the string must not be invalidated.

Definition at line 39 of file Path.hxx.

## Constructor & Destructor Documentation

## ◆ Path()

constexpr Path::Path | ( | const Path & |  | ) |
| default

Copy a Path object.

## Member Function Documentation

## ◆ c_str()

gcc_pure const_pointer_type Path::c_str | ( |  | ) | const
| inlinenoexcept

Returns the value as a const C string.

The returned pointer is invalidated whenever the value of life of this instance ends.

Definition at line 107 of file Path.hxx.

## ◆ data()

gcc_pure const_pointer_type Path::data | ( |  | ) | const
| inlinenoexcept

Returns a pointer to the raw value, not necessarily null-terminated.

Definition at line 116 of file Path.hxx.

## ◆ FromFS()

static constexpr Path Path::FromFS | ( | const_pointer_type | fs | ) |
| inlinestatic

Create a new instance pointing to the specified path string.

Definition at line 64 of file Path.hxx.

## ◆ GetBase()

gcc_pure Path Path::GetBase | ( |  | ) | const
| inlinenoexcept

Determine the "base" file name.

The return value points inside this object.

Definition at line 143 of file Path.hxx.

## ◆ GetDirectoryName()

gcc_pure AllocatedPath Path::GetDirectoryName | ( |  | ) | const
| noexcept

Gets directory name of this path.

Returns a "nulled" instance on error.

## ◆ GetSuffix()

gcc_pure const_pointer_type Path::GetSuffix | ( |  | ) | const
| noexcept

## ◆ HasNewline()

gcc_pure bool Path::HasNewline | ( |  | ) | const
| inlinenoexcept

Does the path contain a newline character? (Which is usually rejected by MPD because its protocol cannot transfer newline characters).

Definition at line 126 of file Path.hxx.

## ◆ IsAbsolute()

gcc_pure bool Path::IsAbsolute | ( |  | ) | const
| inlinenoexcept

Definition at line 166 of file Path.hxx.

## ◆ IsNull()

bool Path::IsNull | ( |  | ) | const
| inline

Check if this is a "nulled" instance.

A "nulled" instance must not be used.

Definition at line 77 of file Path.hxx.

## ◆ length()

gcc_pure size_t Path::length | ( |  | ) | const
| inlinenoexcept

Returns
  the length of this string in number of "value_type" elements (which may not be the number of characters).

Definition at line 95 of file Path.hxx.

## ◆ Null()

static constexpr Path Path::Null | ( |  | ) |
| inlinestatic

Return a "nulled" instance.

Its IsNull() method will return true. Such an object must not be used.

See also
  IsNull()

Definition at line 56 of file Path.hxx.

## ◆ operator=()

Path& Path::operator= | ( | const Path & |  | ) |
| default

Copy a Path object.

## ◆ Relative()

gcc_pure const_pointer_type Path::Relative | ( | Path | other_fs | ) | const
| inlinenoexcept

Determine the relative part of the given path to this object, not including the directory separator.

Returns an empty string if the given path equals this object or nullptr on mismatch.

Definition at line 161 of file Path.hxx.

## ◆ SetNull()

void Path::SetNull | ( |  | ) |
| inline

Clear this object's value, make it "nulled".

See also
  IsNull()

Definition at line 86 of file Path.hxx.

## ◆ ToUTF8()

gcc_pure std::string Path::ToUTF8 | ( |  | ) | const
| noexcept

Convert the path to UTF-8.

Returns empty string on error or if this instance is "nulled" (IsNull returns true).

The documentation for this class was generated from the following file:

- fs/Path.hxx