Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Path< T, SEP, ALEAD, AREPEAT, ATRAIL > Class Template Reference

#include <Path.h>

Inheritance diagram for Path< T, SEP, ALEAD, AREPEAT, ATRAIL >:
Inheritance graph
[legend]
Collaboration diagram for Path< T, SEP, ALEAD, AREPEAT, ATRAIL >:
Collaboration graph
[legend]

Public Types

typedef T elem_t
 
typedef Path< T, SEP, ALEAD, AREPEAT, ATRAIL > path_t
 
typedef std::list< path_tlist_t
 

Public Member Functions

 Path (const path_t &p)
 Copy constructor.
 
 Path (typename path_t::const_iterator it, typename path_t::const_iterator it2)
 Secondary copy constructor. Handy for creating a parent path, for example.
 
template<typename ... TT>
 Path (const path_t &arg, const TT &... args)
 Initialize with a path.
 
template<typename ... TT>
 Path (const std::string &arg, const TT &... args)
 Initialize with a path.
 
template<typename ... TT>
 Path (const char *arg, const TT &... args)
 Initialize with a path.
 
virtual ~Path ()
 Why the three above instead of this?
 
template<typename ... TT>
void set (const TT &... args)
 
template<typename T2 , typename ... TT>
void append (const T2 &arg, const TT &... args)
 Append path with element(s), path(s) or string(s).
 
template<typename ... TT>
void append (const path_t &p, const TT &... args)
 
template<typename ... TT>
void append (const char *arg, const TT &... args)
 
template<typename ... TT>
void append (const std::string &arg, const TT &... args)
 
void appendPath (const char *p)
 Specialized handler for strings (note, possibly: elem_t==std:::string)
 
void appendPath (const path_t &p)
 
void appendElem (const elem_t &elem)
 Main method for adding elements.
 
bool isRoot () const
 Returns true, if the path as only one element which is empty. An empty path is not a root. More...
 
bool hasRoot () const
 Returns true, if the path is not empty and the first element is empty. More...
 
path_tensureRoot ()
 Returns true, if the path is not empty and the first element is empty. More...
 
void trimHead (bool COMPLETE=false)
 Removes leading empty elements. The resulting string presentation will not start with the separator. More...
 
void trimTail (bool COMPLETE=false)
 Removes trailing empty elements. The resulting string presentation will not end with the separator.
 
void simplify ()
 ORIGINAL. Removes trailing empty elements, except for the root itself. More...
 
void simplifyHead ()
 Remove duplicates of empty elements from the start.
 
void simplifyTail ()
 Remove duplicates of empty elements from the end.
 
path_toperator= (const path_t &p)
 Assigns a path directly with std::list assignment. More...
 
template<class T2 >
path_toperator= (const Path< T2 > &p)
 Conversion from str path type. More...
 
path_toperator= (const std::string &p)
 
path_toperator= (const char *p)
 
path_toperator<< (const elem_t &elem)
 Append an element, unless empty string. More...
 
path_toperator<< (const path_t &path)
 
template<class T2 >
path_toperator<< (const T2 &strlike)
 
path_toperator>> (elem_t &e)
 Extract last element.
 
virtual std::ostream & toStream (std::ostream &ostr) const
 Path is written like a list, adding the separator between items. Exception: root is displayed as separator.
 
virtual std::string str () const
 
virtual operator std::string () const
 
std::ostream & debug (std::ostream &ostr=std::cout) const
 

Public Attributes

const PathSeparatorPolicy separator
 

Protected Member Functions

void _append (const elem_t &elem)
 "Default" append function.
 
template<typename T2 >
void _append (const T2 &p)
 Handler for all the rest args, assumed convertable to elem_t.
 
void _appendPath (const std::string &p, size_t start=0)
 Extract elements from the string, starting at position i.
 
void append ()
 Terminal function for variadic templates.
 

Detailed Description

template<class T, char SEP = '/', bool ALEAD = true, bool AREPEAT = false, bool ATRAIL = true>
class drain::Path< T, SEP, ALEAD, AREPEAT, ATRAIL >

Template Parameters
T- path element, eg. PathElement
SEP- separator char
ALEAD- accept leading separator
AREPEAT- accept repeated separators
ATRAIL- accept trailing separator

Member Function Documentation

◆ ensureRoot()

path_t& ensureRoot ( )
inline

Returns true, if the path is not empty and the first element is empty.

See also
isRoot()

◆ hasRoot()

bool hasRoot ( ) const
inline

Returns true, if the path is not empty and the first element is empty.

See also
isRoot()

◆ isRoot()

bool isRoot ( ) const
inline

Returns true, if the path as only one element which is empty. An empty path is not a root.

See also
hasRoot()
ODIMPath::isRoot()

Todo: also accept empty path as a root? Perhaps no, because appending creates a relative path.

◆ operator<<()

path_t& operator<< ( const elem_t &  elem)
inline

Append an element, unless empty string.

Append an element. If path is rooted, allows empty (root) element only as the first.

◆ operator=() [1/2]

path_t& operator= ( const Path< T2 > &  p)
inline

Conversion from str path type.

Does separator checking, trims leading or trailing paths if needed.

◆ operator=() [2/2]

path_t& operator= ( const path_t p)
inline

Assigns a path directly with std::list assignment.

Should be safe, because separator policy is the same.

◆ simplify()

void simplify ( )
inline

ORIGINAL. Removes trailing empty elements, except for the root itself.

keep this for a while void removeTrailing(){ if ((this->size() > 1)){ if (this->back().empty()){ this->pop_back(); removeTrailing(); } } } Remove duplicates of empty elements from the start and the end.

◆ trimHead()

void trimHead ( bool  COMPLETE = false)
inline

Removes leading empty elements. The resulting string presentation will not start with the separator.

After this operation there is no root, ie. there is no leading separator.


The documentation for this class was generated from the following file: