22 #ifndef CRNPath_HEADER
23 #define CRNPath_HEADER
78 virtual ~Path()
override =
default;
179 inline size_t Size(
Path &p) noexcept {
return p.Size(); }
186 inline Path operator"" _p(
const char *str,
size_t len)
188 return Path{std::string{str, len}};
199 template<>
struct hash<crn::Path>
const Path & operator+=(const Path &s)
Appends a string.
void Swap(Path &str) noexcept
Swaps two strings.
virtual void Deserialize(xml::Element &el) override
Initializes the object from an XML element.
Path(std::string &s, Format fmt=Format::LOCAL)
Constructor from a std string.
Path(xml::Element &el)
Constructor from an xml element.
Path & operator=(const Path &)=default
Path(char c, size_t n=1, Format fmt=Format::LOCAL)
Constructor from a char.
Path & ToUnix()
Converts the path to Unix format.
StringUTF8 GetScheme() const
Returns the scheme of the URI.
static char Separator() noexcept
Local directory separator.
Path(const std::string &s, Format fmt=Format::LOCAL)
Constructor from a std string.
Path & Decode()
Replaces % codes with the corresponding character.
A UTF32 character string class.
bool IsAbsolute() const
Is the path absolute?
char GetDrive() const
Gets the drive letter.
bool IsWindows() const
Is the path in Windows format?
const Path & operator/=(const Path &s)
Appends a string after adding directory separator if needed.
size_t Size(const Vector &v) noexcept
Size of a vector.
Path(char *s, Format fmt=Format::LOCAL)
Constructor from a cstring.
A convenience class for file paths.
Path & ToWindows()
Converts the path to Windows format.
Path GetDirectory() const
Returns the full directory path.
BoolNotBoolDummy operator+(const BoolNotBoolDummy &, const BoolNotBoolDummy &)
static char NoDrive()
Invalid drive or no drive found.
bool IsURI() const
Is the path a URI?
Path(Format fmt=Format::LOCAL)
Default constructor (empty string)
size_t operator()(const crn::Path &p)
Path & ConvertTo(Format fmt)
Converts to a specific format.
Path & ToURI()
Converts the path to URI.
void Swap(Map &m1, Map &m2) noexcept
std::vector< Path > Split(const StringUTF8 &sep) const
Splits the string in multiple strings delimited by a set of separators.
Path GetBase() const
Returns the base of the filename.
void Swap(StringUTF8 &str) noexcept
Swaps two strings.
Path(const StringUTF8 &s, Format fmt=Format::LOCAL)
Constructor from a UTF8 string.
BoolNotBoolDummy operator/(const BoolNotBoolDummy &, const BoolNotBoolDummy &)
bool IsRelative() const
Is the path relative?
std::string & Std()&noexcept
Conversion to std string.
Path & ToLocal()
Converts the path to the local format.
#define CRN_DECLARE_CLASS_CONSTRUCTOR(classname)
Declares a class constructor.
virtual xml::Element Serialize(xml::Element &parent) const override
Dumps the object to an XML element.
A character string class.
Path(const Path &s, Format fmt=Format::AUTO)
Copy constructor.
virtual ~Path() override=default
bool IsUnix() const
Is the path in Unix format?
Path GetExtension() const
Returns the extension.
Path(int i, Format fmt=Format::LOCAL)
Constructor from an int.
Format GetFormat() const
Returns the format.
Path(const String &s, Format fmt=Format::LOCAL)
Constructor from a UTF32 string.
Path GetFilename() const
Returns the filename.
Path(const char *s, Format fmt=Format::LOCAL)
Constructor from a cstring.