Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Path Class Reference

#include <path.h>

List of all members.

Public Types

typedef vector<string>::const_iterator iterator

Public Methods

 Path ()
 Path (const Path &p, unsigned int l)
 Construct path containing first l components of p.

bool parse (const string &path_string)
 Note that path_string may not contain leading or trailing white space.

const string& str () const
 Return string representation of Path.

const string& operator[] (unsigned int i) const
unsigned int size () const
bool operator== (const Path &p) const
bool operator< (const Path &p) const
iterator begin () const
iterator end () const

Private Attributes

vector<string> path_
string str_
 Memo of string representation for Path::str().


Friends

ostream& operator<< (ostream &,const Path &path)


Member Typedef Documentation

typedef vector< string >::const_iterator Path::iterator<string>
 

Definition at line 26 of file path.h.


Constructor & Destructor Documentation

Path::Path ( ) [inline]
 

Definition at line 10 of file path.h.

00010 {}

Path::Path ( const Path & p,
unsigned int l )
 

Construct path containing first l components of p.

Definition at line 5 of file path.C.

00005                                        {
00006 unsigned int m(min(p.size(),n));
00007 path_.resize(m);
00008 for (unsigned int i=0; i<m; ++i) 
00009   path_[i] = p[i];
00010 }


Member Function Documentation

bool Path::parse ( const string & date_string )
 

Note that path_string may not contain leading or trailing white space.

Definition at line 13 of file path.C.

Referenced by Configuration::parse_expression(), and LogRecord::parse_path().

00013                             {
00014 str_.erase();
00015 path_.clear();
00016 /* Decode the parts of the ps into a vector. The only component of the
00017    vector will be empty iff the ps  == "/". 
00018    We also refuse to append empty strings to path_. This handles cases like
00019    "/a//b" which will result in <"a","b">.
00020 
00021   We use n0 to indicate the start position of a component and
00022   n1 to indicate the position just after the end of the component.
00023 */
00024 string::size_type n0(ps.find_first_not_of('/',0));
00025 
00026 if (n0==string::npos) { // ps must be "/"
00027   path_.push_back("");
00028   return true;
00029   }
00030 
00031 string::size_type n1(string::npos);
00032 
00033 /* The variable n0 points to the start of a component. We make n1 point to
00034    the next '/', if any. The component then is the substring starting at
00035    n0 and ending before n1.
00036 */
00037 while ((n1=ps.find_first_of('/',n0))!=string::npos) {
00038   if (n1>n0) // only non-empty parts are stored.
00039     path_.push_back(ps.substr(n0,n1-n0));
00040   n0 = n1+1;
00041   }
00042 // If ps does not end with '/', we must still add the final component.
00043 if (n0<ps.size())
00044   path_.push_back(ps.substr(n0));
00045 
00046 return true;
00047 }

const string & Path::str ( ) const
 

Return string representation of Path.

Definition at line 50 of file path.C.

Referenced by PathExpression::eval(), and operator<<().

00050                 {
00051 if (str_.size()==0) {
00052   for (unsigned int j=0; j<size() ; ++j) {
00053     str_ += '/';
00054     str_ += path_[j];
00055     }
00056   }
00057 return str_;
00058 }

const string & Path::operator[] ( unsigned int i ) const [inline]
 

Definition at line 20 of file path.h.

00020 { return path_[i]; }

unsigned int Path::size ( ) const [inline]
 

Definition at line 21 of file path.h.

Referenced by Path(), and str().

00021 { return path_.size(); }

bool Path::operator== ( const Path & p ) const [inline]
 

Definition at line 23 of file path.h.

00023 { return path_ == p.path_; }

bool Path::operator< ( const Path & p ) const [inline]
 

Definition at line 24 of file path.h.

00024 { return path_ < p.path_; }

iterator Path::begin ( ) const [inline]
 

Definition at line 27 of file path.h.

00027 { return path_.begin(); }

iterator Path::end ( ) const [inline]
 

Definition at line 28 of file path.h.

00028 { return path_.end(); }


Friends And Related Function Documentation

ostream & operator<< ( ostream & os,
const Path & path ) [friend]
 

Definition at line 61 of file path.C.

00061                                          {
00062 return os << path.str();
00063 }


Member Data Documentation

vector< string > Path::path_<string> [private]
 

Definition at line 32 of file path.h.

string Path::str_ [mutable, private]
 

Memo of string representation for Path::str().

Definition at line 34 of file path.h.


The documentation for this class was generated from the following files:
httpstats-stage03 [ 7 April, 2001]