Disk ARchive  2.4.2
Public Member Functions
libdar::path Class Reference

the class path is here to manipulate paths in the Unix notation: using'/' More...

#include <path.hpp>

List of all members.

Public Member Functions

 path (const std::string &s, bool x_undisclosed=false)
 constructor from a string
 path (const char *s, bool x_undisclosed=false)
 constructor from a char *
 path (const path &ref)
 copy constructor
const pathoperator= (const path &ref)
 assignment operator
bool operator== (const path &ref) const
 comparison operator
std::string basename () const
 get the basename of a path
void reset_read ()
 reset the read_subdir operation
bool read_subdir (std::string &r)
 sequentially read the elements that compose the path
bool is_relative () const
 whether the path is relative or absolute (= start with a /)
bool is_absolute () const
 whether the path is absolute or relative
bool is_undisclosed () const
 whether the path has an undisclosed part at the beginning
bool pop (std::string &arg)
 remove and gives in argument the basename of the path
bool pop_front (std::string &arg)
 remove and gives in argument the outer most member of the path
path operator+ (const path &arg) const
 add a path to the current path. The added path *must* be a relative path
pathoperator+= (const path &arg)
 add a path to the current path. The added path *must* be a relative path
bool is_subdir_of (const path &p, bool case_sensit) const
 test whether the current object is a subdir of the method's argument
std::string display () const
 convert back a path to a string
unsigned int degre () const
 returns the number of member in the path
void explode_undisclosed () const
 if the current object is an undisclosed path, tries to convert it back to normal path

Detailed Description

the class path is here to manipulate paths in the Unix notation: using'/'

several operations are provided as well as convertion functions, but for the API user, it can be used as if it was a std::string object. However if the argument is not a valid path, an exception may be thrown by libdar

Definition at line 52 of file path.hpp.


Constructor & Destructor Documentation

libdar::path::path ( const std::string &  s,
bool  x_undisclosed = false 
)

constructor from a string

This realizes the string to path convertion function

Parameters:
[in]sthe string to convert to path
[in]x_undiscloseddo not split the given string, consider it as a single directory name, even if some '/' are found in it
Note:
empty string is not a valid string (exception thrown)
having undisclosed set to true, does not allow one to pop() right away, first push must be made. While having undisclosed set to false let the user pop() right away if the given string is composed of several path members ("member1/member2/member3" for example of path allow one to pop() three time, while in the same example setting undisclosed to true, allow one to pop() just once).
libdar::path::path ( const char *  s,
bool  x_undisclosed = false 
) [inline]

constructor from a char *

this realizes the char * to path convertion function

Note:
empty string is not a valid string (exception thrown)

Definition at line 70 of file path.hpp.

References path().

Referenced by path().


Member Function Documentation

std::string libdar::path::basename ( ) const

get the basename of a path

this function returns the basename that's it the right most member of a path

unsigned int libdar::path::degre ( ) const [inline]

returns the number of member in the path

Note:
a absolute path counts one more that its relative brother

Definition at line 153 of file path.hpp.

std::string libdar::path::display ( ) const

convert back a path to a string

the returned string is the representation of the current object in Unix notation

Referenced by libdar::mask::is_covered().

bool libdar::path::is_subdir_of ( const path p,
bool  case_sensit 
) const

test whether the current object is a subdir of the method's argument

Parameters:
[in]pthe path to test with
[in]case_sensitwhether the test must be in case sensitive manner or not

Referenced by libdar::exclude_dir_mask::is_covered().

path libdar::path::operator+ ( const path arg) const [inline]

add a path to the current path. The added path *must* be a relative path

Parameters:
[in]argthe relative path to add
Returns:
the resulting path, (the current object is not modified, where from the "const" qualifier)
Note:
arg can be a string also, which is converted to a path on the fly

Definition at line 130 of file path.hpp.

path& libdar::path::operator+= ( const path arg)

add a path to the current path. The added path *must* be a relative path

Parameters:
[in]argthe relative path to add
Returns:
the value of the current (modified) object: "*this".
bool libdar::path::pop ( std::string &  arg)

remove and gives in argument the basename of the path

Parameters:
[out]argthe basename of the path
Returns:
false if the operation was not possible (no sub-directory to pop)
Note:
if the path is absolute the remaing value is '/' when no pop is anymore possible while it is the first component of the original path if the path was relative. a empty path is not a valide value
bool libdar::path::pop_front ( std::string &  arg)

remove and gives in argument the outer most member of the path

Parameters:
[out]argthe value of the outer element of the path
Returns:
true if the pop_front operation was possible and arg could be set.
Note:
removes and returns the first directory of the path, when just the basename is present returns false, if the path is absolute, the first call change it to relative (except if equal to "/" then return false)
bool libdar::path::read_subdir ( std::string &  r)

sequentially read the elements that compose the path

Parameters:
[out]rthe next element of the path
Returns:
true if a next element could be read
Note:
the reading starts at the root and ends with the basename of the path
void libdar::path::reset_read ( ) [inline]

reset the read_subdir operation

reset for read_subdir. next call to read_subdir is the most global

Definition at line 89 of file path.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines