PathName manipulation class. More...
#include <PathName.hpp>
Public Types | |
typedef BLOCXX_NAMESPACE::List < BLOCXX_NAMESPACE::String > | List |
Public Member Functions | |
PathName () | |
Create an empty PathName object. | |
PathName (const PathName &path) | |
Create a Copy of a PathName object. | |
PathName (const PathName::List &list) | |
Create a new PathName object from a PathName::List. | |
PathName (const BLOCXX_NAMESPACE::String &name) | |
Create a new PathName object from a blocxx::String. | |
PathName (const char *name) | |
Create a new PathName object from a c string. | |
virtual | ~PathName () |
PathName & | operator= (const PathName &path) |
Assigns path to this PathName object and returns a reference to it. | |
PathName & | operator+= (const PathName &path) |
Appends path to this PathName object and a reference to it. | |
BLOCXX_NAMESPACE::String | toString () const |
Returns the complete path this PathName object holds. | |
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. | |
BLOCXX_NAMESPACE::String | prefix () const |
Returns the path prefix if existent, otherwise "". | |
bool | empty () const |
Returns true if this PathName object holds an empty path. | |
bool | absolute () const |
Returns true if this PathName object holds an absolute Path. | |
bool | relative () const |
Returns true if this PathName object holds an relative path. | |
PathName | dirName () const |
Returns the directory part of the path string. | |
BLOCXX_NAMESPACE::String | baseName () const |
Returns the base name part of the path string. | |
PathName | absoluteName () const |
Returns the absolute name of the path string this object holds. | |
PathName | relativeName () const |
Returns the relative name of the path string this object holds. | |
PathName | cat (const PathName &add) const |
Create a new PathName object from the concatenation of this and add. | |
PathName | extend (const BLOCXX_NAMESPACE::String &ext) const |
Create a new PathName object by extending this PathName object by ext. | |
bool | equal (const PathName &rpath) const |
Test for equality of this and rpath. | |
Static Public Member Functions | |
static PathName | dirName (const PathName &path) |
Returns the directory part of path | |
static BLOCXX_NAMESPACE::String | baseName (const PathName &path) |
Returns the base name part of path | |
static PathName | absoluteName (const PathName &path) |
Returns the absolute name of path. | |
static PathName | relativeName (const PathName &path) |
Returns the relative name of path. | |
static PathName | cat (const PathName &path, const PathName &add) |
Create a new PathName object by concatenating two existing ones. | |
static PathName | extend (const PathName &path, const BLOCXX_NAMESPACE::String &ext) |
Create a new PathName object by extending path by ext. | |
static bool | equal (const PathName &lpath, const PathName &rpath) |
Static function to test for equality of two PathName objects. | |
Protected Member Functions | |
void | assign (const BLOCXX_NAMESPACE::String &path) |
Assigns path to this PathName objects m_name string. | |
void | assign (const PathName::List &list) |
Assigns list to this PathName objects m_name string. | |
Private Attributes | |
size_t | m_prefix |
holds index of first character in the path string after an (optional) drive letter. | |
BLOCXX_NAMESPACE::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 BLOCXX_NAMESPACE ::List< BLOCXX_NAMESPACE ::String> limal::path::PathName::List |
limal::path::PathName::PathName | ( | ) |
Create an empty PathName object.
limal::path::PathName::PathName | ( | const PathName & | path | ) |
limal::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. |
limal::ValueException |
limal::path::PathName::PathName | ( | const BLOCXX_NAMESPACE::String & | name | ) |
Create a new PathName object from a blocxx::String.
name | The string from which the new PathName object shall be created. |
limal::ValueException |
limal::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. |
limal::ValueException |
virtual limal::path::PathName::~PathName | ( | ) | [virtual] |
Destructor
bool limal::path::PathName::absolute | ( | ) | const |
Returns the absolute name of path.
PathName p1("foo/bar/some_file"); std::cout << absoluteName( p1 ); // == "/foo/bar/some_file"
PathName limal::path::PathName::absoluteName | ( | ) | const |
Returns the absolute name of the path string this object holds.
PathName p1("foo/bar/some_file"); std::cout << p1.absoluteName(); // == "/foo/bar/some_file"
void limal::path::PathName::assign | ( | const PathName::List & | list | ) | [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. |
limal::ValueException |
void limal::path::PathName::assign | ( | const BLOCXX_NAMESPACE::String & | 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. |
limal::ValueException |
static BLOCXX_NAMESPACE ::String limal::path::PathName::baseName | ( | const PathName & | path | ) | [static] |
Returns the base name part of path
Returns the base name (i.e. the file name) of the path string. For example:
PathName p1("/foo/bar/some_file"); std::cout << PathName::baseName( p1 ); // == "some_file"
path | The PathName object you want to inspect |
BLOCXX_NAMESPACE ::String limal::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:
std::cout << PathName("/foo/bar/some_file").baseName(); // == "some_file"
Create a new PathName object by concatenating two existing ones.
Static function for concatenating two PathName objects. For example:
PathName p1("/foo"); PathName p2("bar/some_file"); std::cout << PathName::cat( p1, p2 ); // == "/foo/bar/some_file"
path | The front part of the resulting path. | |
add | The part that is to be added. |
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:
PathName p1("/foo"); PathName p2("bar/some_file"); std::cout << p1.cat( p2 ); // == "/foo/bar/some_file"
add | Reference to the PathName object to be added to this object. |
Returns the directory part of path
Static function to aquire the directory part of a PathName object. For example:
PathName p1("/foo/bar/some_file"); std::cout << PathName::dirName(p1); // == "/foo/bar"
path | The PathName object you want to inspect |
PathName limal::path::PathName::dirName | ( | ) | const |
bool limal::path::PathName::empty | ( | ) | const |
bool limal::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. |
static PathName limal::path::PathName::extend | ( | const PathName & | path, | |
const BLOCXX_NAMESPACE::String & | ext | |||
) | [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 blocxx::String ) For Example:
PathName p1("/foo"); blocxx::String strExt(".old"); std::cout << PathName::extend(p1, strExt ); // == "/foo.old"
path | Reference to a PathName object that is to be extended. | |
ext | Reference to a blocxx::String containing the extension. |
PathName limal::path::PathName::extend | ( | const BLOCXX_NAMESPACE::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 blocxx::String ) For Example:
PathName p1("/foo"); blocxx::String strExt(".old"); std::cout << p1.extend( strExt ); // == "/foo.old"
ext | Reference to a blocxx::String containing the extension. |
BLOCXX_NAMESPACE ::String limal::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 limal::path::PathName::relative | ( | ) | const |
Returns the relative name of path.
PathName p1("/foo/bar/some_file"); std::cout << relativeName( p1 ); // == "./foo/bar/some_file"
PathName limal::path::PathName::relativeName | ( | ) | const |
Returns the relative name of the path string this object holds.
PathName p1("/foo/bar/some_file"); std::cout << p1.relativeName(); // == "./foo/bar/some_file"
PathName::List limal::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.
limal::ValueException |
BLOCXX_NAMESPACE ::String limal::path::PathName::toString | ( | ) | const |
BLOCXX_NAMESPACE ::String limal::path::PathName::m_name [private] |
size_t limal::path::PathName::m_prefix [private] |
holds index of first character in the path string after an (optional) drive letter.