62 size_t sep(tmp.
Find(
"://"));
64 StringUTF8::operator+=(tmp);
65 else if (sep + 3 < tmp.
Size())
66 StringUTF8::operator+=(tmp.
CStr() + sep + 3);
137 if (
Find(
":\\") == 1)
177 if ((*
this)[0] ==
'.')
181 size_t sep(
Find(
"://"));
182 if ((sep !=
NPos()) && (sep + 3 <
Size()))
184 if ((*
this)[sep + 3] ==
'/')
191 if ((*
this)[1] ==
':')
196 if ((*
this)[0] ==
'/')
222 else if (pos ==
Size() - 1)
224 return Path(
"", format);
241 if ((ppos !=
NPos()) && (ppos != 0))
244 return Path(
"", format);
258 if ((ppos !=
NPos()) && (ppos != fname.
Size() - 1))
261 return Path(
"", format);
278 if ((pos ==
NPos()) || (pos ==
Size() - 1))
282 size_t beg =
Find(
"://") + 3;
292 size_t beg =
Find(
"://") + 3;
332 if ((*
this)[1] ==
':')
335 uri.
Std() += (*this)[0];
336 uri.
Std() += (*this)[1];
341 if ((*
this)[2] ==
'\\')
346 for (
size_t tmp = beg; tmp <
Size(); ++tmp)
348 if ((*
this)[tmp] ==
'\\')
351 uri.
Std() += (*this)[tmp];
377 if ((*
this)[1] ==
':')
380 uri.
Std() += (*this)[0];
385 if ((*
this)[2] ==
'\\')
390 for (
size_t tmp = beg; tmp <
Size(); ++tmp)
392 if ((*
this)[tmp] ==
'\\')
395 uri.
Std() += (*this)[tmp];
416 for (
size_t tmp = 0; tmp <
Size(); ++tmp)
418 if ((*
this)[tmp] ==
'/')
438 if ((uri[1] ==
'/') && (uri[0] !=
'.'))
440 uri2.
Std() += uri[0];
445 if ((
Size() >= 3) && (beg == 0))
447 if ((uri[0] ==
'/') && (uri[2] ==
'/'))
449 uri2.
Std() += uri[1];
454 if ((
Size() >= 4) && (beg == 0))
456 if ((uri[0] ==
'/') && (uri[2] ==
':') && (uri[3] ==
'/'))
458 uri2.
Std() += uri[1];
463 for (
size_t tmp = beg; tmp < uri.
Size(); ++tmp)
468 uri2.
Std() += uri[tmp];
493 for (
size_t tmp = 0; tmp <
Size(); ++tmp)
495 if ((*
this)[tmp] ==
'%')
500 if (((*
this)[tmp] >=
'0') && ((*this)[tmp] <=
'9'))
502 val = ((*this)[tmp] -
'0') * 16;
504 else if (((*
this)[tmp] >=
'a') && ((*
this)[tmp] <=
'f'))
506 val = ((*this)[tmp] -
'a' + 10) * 16;
508 else if (((*
this)[tmp] >=
'A') && ((*
this)[tmp] <=
'F'))
510 val = ((*this)[tmp] -
'A' + 10) * 16;
513 if (((*
this)[tmp] >=
'0') && ((*
this)[tmp] <=
'9'))
515 val += (*this)[tmp] -
'0';
517 else if (((*
this)[tmp] >=
'a') && ((*
this)[tmp] <=
'f'))
519 val += (*this)[tmp] -
'a' + 10;
521 else if (((*
this)[tmp] >=
'A') && ((*
this)[tmp] <=
'F'))
523 val += (*this)[tmp] -
'A' + 10;
525 dec.
Std() += char(val);
528 dec.
Std() += (*this)[tmp];
548 std::vector<Path> words;
567 _(
"Wrong XML element."));
const Path & operator+=(const Path &s)
Appends a string.
virtual StringUTF8 GetValue() const override
Gets the content of the node.
void Swap(Path &str) noexcept
Swaps two strings.
virtual void Deserialize(xml::Element &el) override
Initializes the object from an XML element.
StringUTF8()=default
Default constructor (empty string)
Path & ToUnix()
Converts the path to Unix format.
std::vector< StringUTF8 > Split(const StringUTF8 &sep) const
Splits the string in multiple strings delimited by a set of separators.
StringUTF8 GetScheme() const
Returns the scheme of the URI.
bool IsNotEmpty() const noexcept
Checks if the string is not empty.
static char Separator() noexcept
Local directory separator.
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
Path & Decode()
Replaces % codes with the corresponding character.
bool IsAbsolute() const
Is the path absolute?
char GetDrive() const
Gets the drive letter.
Text PushBackText(const StringUTF8 &text, bool cdata=false)
Adds a text at the end of the children list.
bool IsWindows() const
Is the path in Windows format?
const Path & operator/=(const Path &s)
Appends a string after adding directory separator if needed.
StringUTF8 SubString(size_t pos, size_t n=0) const
Extracts a part of the string.
const char * CStr() const noexcept
Conversion to UTF8 cstring.
bool IsEmpty() const noexcept
Checks if the string is empty.
A convenience class for file paths.
Path & ToWindows()
Converts the path to Windows format.
Path GetDirectory() const
Returns the full directory path.
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
virtual StringUTF8 GetValue() const
Gets the content of the node.
static char NoDrive()
Invalid drive or no drive found.
static size_t NPos() noexcept
Last position in a string.
bool IsURI() const
Is the path a URI?
Path(Format fmt=Format::LOCAL)
Default constructor (empty string)
Path & ConvertTo(Format fmt)
Converts to a specific format.
Node GetFirstChild()
Gets the first child node.
Path & ToURI()
Converts the path to URI.
size_t BackwardFind(const StringUTF8 &s, size_t last_pos=NPos()) const
Finds the last occurrence of a string.
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 ShrinkToFit()
Optimizes the memory usage.
StringUTF8 & operator+=(const StringUTF8 &s)
Appends a string.
std::string & Std()&noexcept
Conversion to std string.
Path & ToLocal()
Converts the path to the local format.
virtual xml::Element Serialize(xml::Element &parent) const override
Dumps the object to an XML element.
size_t Size() const noexcept
Returns the number of bytes in the string.
A character string class.
size_t Find(const StringUTF8 &s, size_t from_pos=0) const
Finds the first occurrence of a string.
bool IsUnix() const
Is the path in Unix format?
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
Path GetExtension() const
Returns the extension.
Format GetFormat() const
Returns the format.
Invalid argument error (e.g.: nullptr pointer)
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
Path GetFilename() const
Returns the filename.