Class Path

Class Documentation

class Path

Represents paths on a filesystem; accepts utf-8, Windows utf-16 wchar_t, or std::filesystem::path.

It is suitable for direct use with OS APIs. Features are limited to character-set conversion of paths. It is not intended as a full replacement for std::filesystem::path

Public Types

using value_type = char

character used by native-encoding of filesystem

using string_type = std::basic_string<value_type>

Public Functions

Path() = default
~Path() = default
Path(const Path&) = default
Path(Path&&) = default
Path &operator=(const Path&) = default
Path &operator=(Path&&) = default
inline Path(string_type &&source) noexcept

Construct Path object from source.

Parameters:

source – native-encoding character sequence; no conversion

inline Path(const string_type &source)

Construct Path object from source.

Parameters:

source – native-encoding character sequence; no conversion

inline Path(const value_type *source)

Construct Path object from source.

Parameters:

source – pointer to null-terminated native-encoding character sequence; no conversion

inline std::string string() const

Get path in native-encoding string; no conversion.

Returns:

std::string

inline std::string u8string() const

Get path in utf-8.

Returns:

std::string in utf-8

inline operator string_type() const noexcept

Implicitly convert to native-encoding string, suitable for use with OS APIs.

Returns:

std::string of utf-8 on most OSs, std::wstring of utf-16 on Windows

inline const string_type &native() const noexcept

Returns native-encoding string by const reference, suitable for use with OS APIs.

Returns:

const std::string& of utf-8 on most OSs, const std::wstring& of utf-16 on Windows

inline bool empty() const noexcept

Observes if path is empty (contains no string/folders/filename)

Returns:

bool true if the path is empty, false otherwise