General path representation. Does not check whether the target actually exists (e.g., on a filesystem). To check target existence, use Filesystem
.
More...
#include <Path.h>
General path representation. Does not check whether the target actually exists (e.g., on a filesystem). To check target existence, use Filesystem
.
◆ Path() [1/6]
◆ Path() [2/6]
ph::Path::Path |
( |
std::string | path | ) |
|
|
explicit |
Constructs a path from some string representation of the path. The string can be either a relative or absolute path, or even a path fragment. The input format of path
should be in a general, "mostly" OS neutral form [1] which often referred as "generic format" in many libraries.
References: [1] https://www.boost.org/doc/libs/1_83_0/libs/filesystem/doc/reference.html
◆ Path() [3/6]
ph::Path::Path |
( |
std::string_view | path | ) |
|
|
explicit |
◆ Path() [4/6]
◆ Path() [5/6]
ph::Path::Path |
( |
const char * | path | ) |
|
|
explicit |
Similar to Path(std::string), except the string is a null-terminated character sequence pointed to by path
.
◆ Path() [6/6]
ph::Path::Path |
( |
std::filesystem::path | path | ) |
|
|
explicit |
◆ append() [1/2]
Path ph::Path::append |
( |
const Path & | other | ) |
const |
Appending one path to another. System specific directory separators are added in between two path objects.
◆ append() [2/2]
Path ph::Path::append |
( |
std::string_view | pathStr | ) |
const |
◆ clear()
◆ getExtension()
std::string ph::Path::getExtension |
( |
| ) |
const |
Returns filename extension if present. The extension string will start with a period character ".". If the path contains no extension, then an empty string is returned.
◆ getFilename()
std::string ph::Path::getFilename |
( |
| ) |
const |
Returns the filename if present.
- Returns
- Filename including the extension part (if any). Empty if not present.
◆ getLeadingElement()
Path ph::Path::getLeadingElement |
( |
| ) |
const |
If the path starts with a root directory specifier, it will be returned. Example: for the path "/abc/def/", "/" will be returned.
◆ getParent()
Path ph::Path::getParent |
( |
| ) |
const |
Get the parent directory of this path, e.g., the parent of "./aaa/bbb.ext" would be "./aaa".
◆ getTrailingElement()
Path ph::Path::getTrailingElement |
( |
bool | ignoreTrailingSeparator = true | ) |
const |
If the path ends with a path separator, the element returned will be the name before the separator. For example, "C:\\abc\\def\\ghi\\" will return "ghi" as the trailing element. If this is not desired
and an empty path "" is expected instread, set @p ignoreTrailingSeparator to <tt>false</tt>. Filename
with its extension is considered a single element, i.e., "./aaa/bbb.ext" would return "bbb.ext".
◆ isAbsolute()
bool ph::Path::isAbsolute |
( |
| ) |
const |
|
inline |
◆ isEmpty()
bool ph::Path::isEmpty |
( |
| ) |
const |
|
inline |
◆ isRelative()
bool ph::Path::isRelative |
( |
| ) |
const |
|
inline |
◆ operator/() [1/2]
Path ph::Path::operator/ |
( |
const Path & | other | ) |
const |
◆ operator/() [2/2]
Path ph::Path::operator/ |
( |
std::string_view | pathStr | ) |
const |
◆ operator==()
bool ph::Path::operator== |
( |
const Path & | other | ) |
const |
◆ removeExtension()
Path ph::Path::removeExtension |
( |
| ) |
const |
Removes filename extension in the path, if any.
◆ removeLeadingSeparator()
Path ph::Path::removeLeadingSeparator |
( |
| ) |
const |
◆ removeTrailingSeparator()
Path ph::Path::removeTrailingSeparator |
( |
| ) |
const |
◆ replaceExtension()
Path ph::Path::replaceExtension |
( |
std::string_view | replacement | ) |
const |
Changes filename extension in the path, if any. The behavior is the same as std::filesystem::path::replace_extension(1)
.
◆ toAbsolute()
Path ph::Path::toAbsolute |
( |
| ) |
const |
◆ toAbsoluteString()
std::string ph::Path::toAbsoluteString |
( |
| ) |
const |
◆ toNativeString() [1/2]
std::string ph::Path::toNativeString |
( |
| ) |
const |
Get a string representation of this path in native format.
- Returns
- A string that can be passed to the native OS for identifying a target.
◆ toNativeString() [2/2]
std::size_t ph::Path::toNativeString |
( |
TSpan< char > | out_buffer, |
|
|
std::size_t * | out_numTotalChars = nullptr, |
|
|
bool | isNullTerminated = true ) const |
Similar to toNativeString()
, except the buffer is provided. This variant guarantees no dynamic allocation takes place.
- Parameters
-
[out] | out_buffer | The buffer to store the string. |
[out] | out_numTotalChars | Total number of characters in the string representation of this path (including the null terminator). If isNullTerminated is false , the number will not include the null terminator. |
| isNullTerminated | Whether the resultant string should be null-terminated. If true, null terminator will present even if the string is not fully copied. |
- Returns
- Number of copied characters (including the null terminator).
◆ toStdPath()
std::filesystem::path ph::Path::toStdPath |
( |
| ) |
const |
|
inline |
Get a standard path representation of this path.
◆ toString()
std::string ph::Path::toString |
( |
| ) |
const |
Get a string representation of this path in generic format.
The documentation for this class was generated from the following files: