|
libcrn
3.9.5
A document image processing library
|
A convenience class for file paths. More...
#include <CRNPath.h>
Inheritance diagram for crn::Path:
Collaboration diagram for crn::Path:Public Types | |
| enum | Format { Format::AUTO = 0, Format::URI = 1, Format::UNIX = 2, Format::WINDOWS = 3, Format::LOCAL = 2 } |
Public Member Functions | |
| Path (Format fmt=Format::LOCAL) | |
| Default constructor (empty string) More... | |
| Path (const std::string &s, Format fmt=Format::LOCAL) | |
| Constructor from a std string. More... | |
| Path (std::string &s, Format fmt=Format::LOCAL) | |
| Constructor from a std string. More... | |
| Path (char *s, Format fmt=Format::LOCAL) | |
| Constructor from a cstring. More... | |
| Path (const char *s, Format fmt=Format::LOCAL) | |
| Constructor from a cstring. More... | |
| Path (const Path &s, Format fmt=Format::AUTO) | |
| Copy constructor. More... | |
| Path (Path &&)=default | |
| Path (const StringUTF8 &s, Format fmt=Format::LOCAL) | |
| Constructor from a UTF8 string. More... | |
| Path (const String &s, Format fmt=Format::LOCAL) | |
| Constructor from a UTF32 string. More... | |
| Path (char c, size_t n=1, Format fmt=Format::LOCAL) | |
| Constructor from a char. More... | |
| Path (int i, Format fmt=Format::LOCAL) | |
| Constructor from an int. More... | |
| Path (xml::Element &el) | |
| Constructor from an xml element. More... | |
| virtual | ~Path () override=default |
| Path & | operator= (const Path &)=default |
| Path & | operator= (Path &&)=default |
| std::vector< Path > | Split (const StringUTF8 &sep) const |
| Splits the string in multiple strings delimited by a set of separators. More... | |
| Format | GetFormat () const |
| Returns the format. More... | |
| bool | IsURI () const |
| Is the path a URI? More... | |
| bool | IsUnix () const |
| Is the path in Unix format? More... | |
| bool | IsWindows () const |
| Is the path in Windows format? More... | |
| Path & | ConvertTo (Format fmt) |
| Converts to a specific format. More... | |
| const Path & | operator+= (const Path &s) |
| Appends a string. More... | |
| const Path & | operator/= (const Path &s) |
| Appends a string after adding directory separator if needed. More... | |
| bool | IsAbsolute () const |
| Is the path absolute? More... | |
| bool | IsRelative () const |
| Is the path relative? More... | |
| Path | GetFilename () const |
| Returns the filename. More... | |
| Path | GetBase () const |
| Returns the base of the filename. More... | |
| Path | GetExtension () const |
| Returns the extension. More... | |
| Path | GetDirectory () const |
| Returns the full directory path. More... | |
| void | Swap (Path &str) noexcept |
| Swaps two strings. More... | |
| StringUTF8 | GetScheme () const |
| Returns the scheme of the URI. More... | |
| Path & | ToURI () |
| Converts the path to URI. More... | |
| Path & | Decode () |
| Replaces % codes with the corresponding character. More... | |
| Path & | ToUnix () |
| Converts the path to Unix format. More... | |
| char | GetDrive () const |
| Gets the drive letter. More... | |
| Path & | ToWindows () |
| Converts the path to Windows format. More... | |
| Path & | ToLocal () |
| Converts the path to the local format. More... | |
| virtual void | Deserialize (xml::Element &el) override |
| Initializes the object from an XML element. More... | |
| virtual xml::Element | Serialize (xml::Element &parent) const override |
| Dumps the object to an XML element. More... | |
Public Member Functions inherited from crn::StringUTF8 | |
| StringUTF8 ()=default | |
| Default constructor (empty string) More... | |
| virtual | ~StringUTF8 () override=default |
| StringUTF8 (const std::string &s) | |
| Constructor from a std string. More... | |
| StringUTF8 (std::string &&s) noexcept | |
| Constructor from a std string. More... | |
| StringUTF8 (char *s) | |
| Constructor from a cstring. More... | |
| StringUTF8 (const char *s) | |
| Constructor from a cstring. More... | |
| StringUTF8 (const StringUTF8 &s) | |
| Copy constructor. More... | |
| StringUTF8 (const String &s) | |
| Constructor from a UTF32 string. More... | |
| StringUTF8 (const Prop3 &p) | |
| Constructor from a Prop3. More... | |
| StringUTF8 (char c, size_t n=1) | |
| Constructor from a char. More... | |
| StringUTF8 (int i) | |
| Constructor from an int. More... | |
| StringUTF8 (unsigned int i) | |
| Constructor from an unsigned int. More... | |
| StringUTF8 (long i) | |
| Constructor from a long. More... | |
| StringUTF8 (unsigned long i) | |
| Constructor from an unsigned long. More... | |
| StringUTF8 (float f) | |
| Constructor from a float. More... | |
| StringUTF8 (double d) | |
| Constructor from a double. More... | |
| StringUTF8 (long double d) | |
| Constructor from a long double. More... | |
| StringUTF8 (long long i) | |
| Constructor from an long. More... | |
| StringUTF8 (unsigned long long i) | |
| Constructor from an unsigned long. More... | |
| template<typename T > | |
| StringUTF8 (const std::complex< T > &c) | |
| Constructor from a complex. More... | |
| StringUTF8 (StringUTF8 &&)=default | |
| StringUTF8 & | operator= (StringUTF8 &&)=default |
| std::string & | Std ()&noexcept |
| Conversion to std string. More... | |
| const std::string & | Std () const &noexcept |
| Conversion to std string. More... | |
| std::string | Std ()&& |
| Conversion to std string. More... | |
| const char * | CStr () const noexcept |
| Conversion to UTF8 cstring. More... | |
| Prop3 | ToProp3 () const |
| Conversion to Prop3. More... | |
| int | ToInt () const |
| Conversion to int. More... | |
| unsigned int | ToUInt () const |
| Conversion to unsigned int. More... | |
| long | ToLong () const |
| Conversion to long. More... | |
| unsigned long | ToULong () const |
| Conversion to unsigned long. More... | |
| float | ToFloat () const |
| Conversion to float. More... | |
| double | ToDouble () const |
| Conversion to double. More... | |
| long double | ToLongDouble () const |
| Conversion to long double. More... | |
| long long | ToLongLong () const |
| Conversion to long long. More... | |
| unsigned long long | ToULongLong () const |
| Conversion to unsigned long long. More... | |
| int64_t | ToInt64 () const |
| Conversion to int64_t. More... | |
| uint64_t | ToUInt64 () const |
| Conversion to uint64_t. More... | |
| size_t | Size () const noexcept |
| Returns the number of bytes in the string. More... | |
| size_t | Length () const noexcept |
| Returns the number of characters the string. More... | |
| bool | operator! () const noexcept |
| Checks if the string is empty. More... | |
| bool | IsEmpty () const noexcept |
| Checks if the string is empty. More... | |
| bool | IsNotEmpty () const noexcept |
| Checks if the string is not empty. More... | |
| char & | operator[] (size_t index) |
| Access to a character. More... | |
| const char & | operator[] (size_t index) const |
| Access to a character. More... | |
| StringUTF8 & | operator= (const StringUTF8 &s) |
| Copies from another string. More... | |
| StringUTF8 & | operator+= (const StringUTF8 &s) |
| Appends a string. More... | |
| StringUTF8 & | Insert (size_t pos, const StringUTF8 &s) |
| Inserts a string. More... | |
| StringUTF8 & | Crop (size_t pos, size_t n=0) |
| Crops the string. More... | |
| StringUTF8 & | Erase (size_t pos, size_t n=0) |
| Erases a part of the string. More... | |
| StringUTF8 & | Replace (const StringUTF8 &s, size_t pos, size_t n=0) |
| Replaces a part of the string. More... | |
| StringUTF8 & | Replace (char from, char to) |
| Replaces all occurrences of a character with another. More... | |
| StringUTF8 & | ToUpper () |
| Converts the string to uppercase. More... | |
| StringUTF8 & | FirstCharacterToUpper () |
| Converts the first character of string to uppercase. More... | |
| StringUTF8 & | ToLower () |
| Converts the string to lowercase. More... | |
| StringUTF8 | SubString (size_t pos, size_t n=0) const |
| Extracts a part of the string. More... | |
| bool | StartsWith (const StringUTF8 &s) const |
| Check if string has a given prefix. More... | |
| bool | EndsWith (const StringUTF8 &s) const |
| Check if string has a given suffix. More... | |
| size_t | Find (const StringUTF8 &s, size_t from_pos=0) const |
| Finds the first occurrence of a string. More... | |
| size_t | FindAnyOf (const StringUTF8 &s, size_t from_pos=0) const |
| Finds the first occurrence of character in a list. More... | |
| size_t | FindNotOf (const StringUTF8 &s, size_t from_pos=0) const |
| Finds the first occurrence of character not in a list. More... | |
| size_t | BackwardFind (const StringUTF8 &s, size_t last_pos=NPos()) const |
| Finds the last occurrence of a string. More... | |
| size_t | BackwardFindAnyOf (const StringUTF8 &s, size_t from_pos=NPos()) const |
| Finds the last occurrence of character in a list. More... | |
| size_t | BackwardFindNotOf (const StringUTF8 &s, size_t from_pos=NPos()) const |
| Finds the last occurrence of character not in a list. More... | |
| StringUTF8 & | ReplaceSuffix (const StringUTF8 &old_suffix, const StringUTF8 &new_suffix) |
| Replaces suffix by another pattern if present. More... | |
| std::vector< StringUTF8 > | Split (const StringUTF8 &sep) const |
| Splits the string in multiple strings delimited by a set of separators. More... | |
| void | ShrinkToFit () |
| Optimizes the memory usage. More... | |
| void | Swap (StringUTF8 &str) noexcept |
| Swaps two strings. More... | |
Public Member Functions inherited from crn::Object | |
| virtual | ~Object ()=default |
Static Public Member Functions | |
| static char | Separator () noexcept |
| Local directory separator. More... | |
| static char | NoDrive () |
| Invalid drive or no drive found. More... | |
Static Public Member Functions inherited from crn::StringUTF8 | |
| static int & | Precision () noexcept |
| Precision of the floating point conversion. More... | |
| static size_t | NPos () noexcept |
| Last position in a string. More... | |
| static crn::StringUTF8 | CreateUniqueId (size_t len=8) |
| Generates an almost unique id. More... | |
A convenience class for file paths.
A class to store a file or directory path
|
strong |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
overridevirtualdefault |
| Path & Path::ConvertTo | ( | Path::Format | fmt | ) |
Converts to a specific format.
Converts to a specific format
| [in] | fmt | the destination format |
Definition at line 146 of file CRNPath.cpp.
| Path & Path::Decode | ( | ) |
Replaces % codes with the corresponding character.
Replaces % codes with the corresponding character
Definition at line 490 of file CRNPath.cpp.
|
overridevirtual |
Initializes the object from an XML element.
Initializes the object from an XML element. Unsafe.
| ExceptionInvalidArgument | not a StringUTF8 |
| ExceptionDomain | no CDATA found |
| [in] | el | the XML element to read |
Reimplemented from crn::StringUTF8.
Definition at line 562 of file CRNPath.cpp.
| Path Path::GetBase | ( | ) | const |
Returns the base of the filename.
Returns the base of the filename
| ExceptionLogic | path does not contain a filename |
Definition at line 235 of file CRNPath.cpp.
| Path Path::GetDirectory | ( | ) | const |
Returns the full directory path.
Returns the full directory path
Definition at line 267 of file CRNPath.cpp.
| char Path::GetDrive | ( | ) | const |
Gets the drive letter.
Gets the drive letter
Definition at line 477 of file CRNPath.cpp.
| Path Path::GetExtension | ( | ) | const |
Returns the extension.
Returns the extension
| ExceptionLogic | path does not contain a filename |
Definition at line 252 of file CRNPath.cpp.
| Path Path::GetFilename | ( | ) | const |
Returns the filename.
Returns the filename
Definition at line 205 of file CRNPath.cpp.
| Path::Format Path::GetFormat | ( | ) | const |
Returns the format.
Returns the format
Definition at line 105 of file CRNPath.cpp.
| StringUTF8 Path::GetScheme | ( | ) | const |
Returns the scheme of the URI.
Returns the scheme of the URI
Definition at line 303 of file CRNPath.cpp.
| bool Path::IsAbsolute | ( | ) | const |
Is the path absolute?
Is the path absolute?
Definition at line 173 of file CRNPath.cpp.
|
inline |
| bool Path::IsUnix | ( | ) | const |
Is the path in Unix format?
Is the path in Unix format?
Definition at line 127 of file CRNPath.cpp.
| bool Path::IsURI | ( | ) | const |
Is the path a URI?
Is the path a URI?
Definition at line 119 of file CRNPath.cpp.
| bool Path::IsWindows | ( | ) | const |
Is the path in Windows format?
Is the path in Windows format?
Definition at line 135 of file CRNPath.cpp.
|
static |
Invalid drive or no drive found.
Invalid drive or no drive found
Definition at line 34 of file CRNPath.cpp.
Appends a string.
Appends a path with conversion to the local format
| [in] | s | the string to convert and append |
Definition at line 56 of file CRNPath.cpp.
Appends a string after adding directory separator if needed.
Appends a string after adding directory separator if needed
| [in] | s | the string to convert and append |
Definition at line 80 of file CRNPath.cpp.
|
staticnoexcept |
Local directory separator.
Local directory separator
Definition at line 42 of file CRNPath.cpp.
|
overridevirtual |
Dumps the object to an XML element.
Dumps the object to an XML element. Unsafe.
| [in] | parent | the parent element to which we will add the new element |
Reimplemented from crn::StringUTF8.
Definition at line 583 of file CRNPath.cpp.
| std::vector< Path > Path::Split | ( | const StringUTF8 & | sep | ) | const |
Splits the string in multiple strings delimited by a set of separators.
Splits the string in multiple strings delimited by a set of separators
| [in] | sep | a list of separators |
Definition at line 545 of file CRNPath.cpp.
|
inlinenoexcept |
| Path & Path::ToLocal | ( | ) |
Converts the path to the local format.
Definition at line 534 of file CRNPath.cpp.
| Path & Path::ToUnix | ( | ) |
Converts the path to Unix format.
Converts the path to Unix format
Definition at line 366 of file CRNPath.cpp.
| Path & Path::ToURI | ( | ) |
Converts the path to URI.
Converts the path to URI
Definition at line 315 of file CRNPath.cpp.
| Path & Path::ToWindows | ( | ) |
Converts the path to Windows format.
Converts the path to Windows format
Definition at line 410 of file CRNPath.cpp.
1.8.6