|
|
| Path () |
| | Constructs an empty enzo::Path object.
|
| |
|
| Path (const std::string &path) |
| | Constructs an enzo::Path object from a given std::string.
|
| |
|
| Path (const char *path) |
| | Constructs an enzo::Path object from a C string.
|
| |
|
bool | isEmpty () const |
| | Checks if the Path has no characters.
|
| |
|
bool | isRoot () const |
| | Returns true if the Path is "/".
|
| |
|
bool | isAbsolute () const |
| | Returns true if the Path is an absolute path.
|
| |
|
bool | isRelative () const |
| | Returns true if the Path is a relative path.
|
| |
| virtual bool | isValid () const |
| | Runs every validation check and returns true if the path is fully valid.
|
| |
|
std::string | getName () const |
| | Returns the name of the Path, ie, the last component of the path.
|
| |
|
Path | getParent () const |
| | Returns the parent path as a Path if it exists.
|
| |
| std::vector< Path > | getPrefixes () const |
| | Returns every ancestor path leading up to this path, ordered from shortest to longest. The path itself is not included.
|
| |
|
std::vector< std::string > | split () const |
| | Splits all of the components of a Path and returns them as a vector of strings.
|
| |
|
const std::string & | getString () const |
| | Return the path of the Path as an std::string.
|
| |
| Path | append (const enzo::Path &path) const |
| | Returns a new path formed by appending the given path to this one.
|
| |
| virtual Path | increment (int increment=1) const |
| | Increments the numerical suffix of the path's name by a given amount.
|
| |
| Path | makeRelative () const |
| | Converts an absolute path to relative, stripping the root character.
|
| |
| Path | makeAbsolute () const |
| | Converts a relative path to absolute, adding a root character.
|
| |
| Path | makeRelativeTo (const Path &anchor) const |
| | Makes a path relative to a given anchor path.
|
| |
| Path | makeAbsoluteFrom (const Path &anchor) const |
| | Returns the absolute path this one names when read from an anchor.
|
| |
| bool | hasPrefix (const Path &prefix) const |
| | Checks if the Path has any additional prefixes.
|
| |
|
| operator std::string_view () const |
| | Allows a Path to be viewed as its underlying string, e.g. for comparisons against string_views.
|
| |
|
bool | operator== (std::string_view other) const |
| |
|
bool | operator!= (std::string_view other) const |
| |
A default path class for creation and manipulation of tree-based paths.
| bool enzo::Path::isValid |
( |
| ) |
const |
|
virtual |
Runs every validation check and returns true if the path is fully valid.
A path is valid when it is non empty and every component is either a valid name or the ".." step that walks up to a parent. The root path "/" is also valid.
Examples "/assets/mesh_01" valid "assets/mesh" valid relative path "../mesh" valid step up to a sibling "/assets//mesh" invalid empty component "/assets/me!sh" invalid illegal character
- See also
- isValidName for the per component character rules.
Reimplemented in enzo::NetworkPath.
Returns the absolute path this one names when read from an anchor.
A relative path joins onto the anchor and an absolute path ignores it. Either way every ".." step is collapsed, so the result names a location directly.
E.g. against the anchor "/assets/component" "mesh" becomes "/assets/component/mesh" "../mesh" becomes "/assets/mesh" "/assets/mesh" stays "/assets/mesh"
- Note
- A ".." at the root has nowhere to go and stays at the root.
- Parameters
-
| anchor | The absolute path a relative path is read from. |
- Returns
- The resolved absolute path, or an empty Path when the anchor cannot anchor a relative path because it is not itself absolute.