libcamgm
|
PathName manipulation class. More...
#include <PathName.hpp>
Public Types | |
typedef std::list< std::string > | List |
Public Member Functions | |
PathName () | |
Create an empty PathName object. More... | |
PathName (const PathName &path) | |
Create a Copy of a PathName object. More... | |
PathName (const PathName::List &list) | |
Create a new PathName object from a PathName::List. More... | |
PathName (const std::string &name) | |
Create a new PathName object from a std::string. More... | |
PathName (const char *name) | |
Create a new PathName object from a c string. More... | |
virtual | ~PathName () |
PathName & | operator= (const PathName &path) |
Assigns path to this PathName object and returns a reference to it. More... | |
PathName & | operator+= (const PathName &path) |
Appends path to this PathName object and a reference to it. More... | |
std::string | toString () const |
Returns the complete path this PathName object holds. More... | |
std::string | asString () const |
PathName::List | toList () const |
Returns the path this PathName object holds, as a PathName::List. The first element of that list is either the prefix, or, if there is no drive prefix it's an empty string. More... | |
std::string | prefix () const |
Returns the path prefix if existent, otherwise "". More... | |
bool | empty () const |
Returns true if this PathName object holds an empty path. More... | |
bool | absolute () const |
Returns true if this PathName object holds an absolute Path. More... | |
bool | relative () const |
Returns true if this PathName object holds an relative path. More... | |
PathName | dirName () const |
Returns the directory part of the path string. More... | |
std::string | baseName () const |
Returns the base name part of the path string. More... | |
PathName | absoluteName () const |
Returns the absolute name of the path string this object holds. More... | |
PathName | relativeName () const |
Returns the relative name of the path string this object holds. More... | |
PathName | cat (const PathName &add) const |
Create a new PathName object from the concatenation of this and add. More... | |
PathName | extend (const std::string &ext) const |
Create a new PathName object by extending this PathName object by ext. More... | |
bool | equal (const PathName &rpath) const |
Test for equality of this and rpath. More... | |
Static Public Member Functions | |
static PathName | dirName (const PathName &path) |
Returns the directory part of path More... | |
static std::string | baseName (const PathName &path) |
Returns the base name part of path More... | |
static PathName | absoluteName (const PathName &path) |
Returns the absolute name of path. More... | |
static PathName | relativeName (const PathName &path) |
Returns the relative name of path. More... | |
static PathName | cat (const PathName &path, const PathName &add) |
Create a new PathName object by concatenating two existing ones. More... | |
static PathName | extend (const PathName &path, const std::string &ext) |
Create a new PathName object by extending path by ext. More... | |
static bool | equal (const PathName &lpath, const PathName &rpath) |
Static function to test for equality of two PathName objects. More... | |
Protected Member Functions | |
void | assign (const std::string &path) |
Assigns path to this PathName objects m_name string. More... | |
void | assign (const PathName::List &list) |
Assigns list to this PathName objects m_name string. More... | |
Private Attributes | |
size_t | m_prefix |
holds index of first character in the path string after an (optional) drive letter. More... | |
std::string | m_name |
PathName manipulation class.
This class is intended for internal usage inside of LiMaL pluglibs and should never appear in the pluglib interface.
typedef std::list<std::string> ca_mgm::path::PathName::List |
ca_mgm::path::PathName::PathName | ( | ) |
Create an empty PathName object.
ca_mgm::path::PathName::PathName | ( | const PathName & | path | ) |
ca_mgm::path::PathName::PathName | ( | const PathName::List & | list | ) |
Create a new PathName object from a PathName::List.
list | The PathName::List from which the new PathName object shall be created. The first element of this List has to be a prefix, or if there is no prefix an empty string. |
ca_mgm::ValueException |
ca_mgm::path::PathName::PathName | ( | const std::string & | name | ) |
Create a new PathName object from a std::string.
name | The string from which the new PathName object shall be created. |
ca_mgm::ValueException |
ca_mgm::path::PathName::PathName | ( | const char * | name | ) |
Create a new PathName object from a c string.
name | The character pointer to the c string from which the new PathName object shall be created. |
ca_mgm::ValueException |
|
virtual |
Destructor
bool ca_mgm::path::PathName::absolute | ( | ) | const |
PathName ca_mgm::path::PathName::absoluteName | ( | ) | const |
Returns the absolute name of the path string this object holds.
Returns the absolute name of path.
|
protected |
Assigns path to this PathName objects m_name string.
Takes the given path string, cleans it (i.e.: removing redundant parts from it like './foo/../bar/some_file" -> './bar/some_file') sets m_prefix and assigns the cleansed path string to m_path.
path | path string that is to be assigned to this object. |
ca_mgm::ValueException |
|
protected |
Assigns list to this PathName objects m_name string.
Takes the given path list, cleans it (i.e.: removing redundant parts from it like './foo/../bar/some_file" -> './bar/some_file') sets m_prefix and assigns the cleansed path string to m_path.
path | path string that is to be assigned to this object. |
ca_mgm::ValueException |
|
inline |
References ca_mgm::str::toString().
std::string ca_mgm::path::PathName::baseName | ( | ) | const |
Returns the base name part of the path string.
Returns the base name (i.e. the file name) of the path string. For example:
|
static |
Returns the base name part of path
Returns the base name (i.e. the file name) of the path string. For example:
path | The PathName object you want to inspect |
Create a new PathName object from the concatenation of this and add.
Creates a new PathName object consisting of the concatenation of this PathName object and add and returns it. For example:
add | Reference to the PathName object to be added to this object. |
Create a new PathName object by concatenating two existing ones.
Static function for concatenating two PathName objects. For example:
path | The front part of the resulting path. |
add | The part that is to be added. |
PathName ca_mgm::path::PathName::dirName | ( | ) | const |
Returns the directory part of path
Static function to aquire the directory part of a PathName object. For example:
path | The PathName object you want to inspect |
bool ca_mgm::path::PathName::empty | ( | ) | const |
bool ca_mgm::path::PathName::equal | ( | const PathName & | rpath | ) | const |
Test for equality of this and rpath.
rpath | Reference to the PathName object that is to be compared to this object. |
PathName ca_mgm::path::PathName::extend | ( | const std::string & | ext | ) | const |
Create a new PathName object by extending this PathName object by ext.
Use this function to create a new PathName object that consists of this PathName object extended by the string ext. Basically it just glues the two strings together and calls PathName( const std::string ) For Example:
ext | Reference to a std::string containing the extension. |
|
static |
Create a new PathName object by extending path by ext.
Static function to create a new PathName object that consists of path extended by the string ext. Basically it just glues the two strings together and calls PathName( const std::string ) For Example:
path | Reference to a PathName object that is to be extended. |
ext | Reference to a std::string containing the extension. |
std::string ca_mgm::path::PathName::prefix | ( | ) | const |
Returns the path prefix if existent, otherwise "".
Returns the path prefix (i.e. drive letter), if the path this PathName object holds contains one (like in 'c:/foo/bar'), otherwise the empty string will be returned.
bool ca_mgm::path::PathName::relative | ( | ) | const |
PathName ca_mgm::path::PathName::relativeName | ( | ) | const |
Returns the relative name of the path string this object holds.
Returns the relative name of path.
PathName::List ca_mgm::path::PathName::toList | ( | ) | const |
Returns the path this PathName object holds, as a PathName::List. The first element of that list is either the prefix, or, if there is no drive prefix it's an empty string.
ca_mgm::ValueException |
std::string ca_mgm::path::PathName::toString | ( | ) | const |
|
private |
|
private |
holds index of first character in the path string after an (optional) drive letter.