Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Attributes
Arc::PathIterator Class Reference

Class to iterate through elements of path. More...

#include <URL.h>

Collaboration diagram for Arc::PathIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PathIterator (const std::string &path, bool end=false)
 Constructor accepts path and stores it internally.
 ~PathIterator ()
PathIteratoroperator++ ()
 Advances iterator to point at next path element.
PathIteratoroperator-- ()
 Moves iterator to element before current.
 operator bool () const
 Return false when iterator moved outside path elements.
std::string operator* () const
 Returns part of initial path from first till and including current.
std::string Rest () const
 Returns part of initial path from one after current till end.

Private Attributes

const std::string & path
std::string::size_type pos
bool end
bool done

Detailed Description

Class to iterate through elements of path.

Definition at line 322 of file URL.h.


Constructor & Destructor Documentation

Arc::PathIterator::PathIterator ( const std::string &  path,
bool  end = false 
)

Constructor accepts path and stores it internally.

If end is set to false iterator is pointing at first element in path. Otherwise selected element is one before last.

Definition at line 944 of file URL.cpp.

    : path(path),
      pos(std::string::npos),
      end(end) {
    if (end)
      operator--();
    else
      operator++();
  }

Here is the call graph for this function:

Definition at line 954 of file URL.cpp.

{}

Member Function Documentation

Arc::PathIterator::operator bool ( void  ) const

Return false when iterator moved outside path elements.

Definition at line 981 of file URL.cpp.

                                    {
    return !done;
  }
std::string Arc::PathIterator::operator* ( ) const

Returns part of initial path from first till and including current.

Definition at line 985 of file URL.cpp.

                                          {
    if (pos != std::string::npos)
      return path.substr(0, pos);
    else if (end)
      return path;
    else
      return "";
  }
PathIterator & Arc::PathIterator::operator++ ( )

Advances iterator to point at next path element.

Definition at line 956 of file URL.cpp.

                                         {
    done = false;
    if (pos != std::string::npos)
      pos = path.find('/', pos + 1);
    else if (!end && !path.empty())
      pos = path.find('/',(path[0] == '/')?1:0);
    else
      done = true;
    end = true;
    return *this;
  }

Here is the caller graph for this function:

PathIterator & Arc::PathIterator::operator-- ( )

Moves iterator to element before current.

Definition at line 968 of file URL.cpp.

                                         {
    done = false;
    if (pos != std::string::npos) {
      pos = pos ? path.rfind('/', pos - 1) : std::string::npos;
    } else if (end && !path.empty()) {
      if((pos = path.rfind('/')) == 0) pos = std::string::npos;
    } else {
      done = true;
    }
    end = false;
    return *this;
  }

Here is the caller graph for this function:

std::string Arc::PathIterator::Rest ( ) const

Returns part of initial path from one after current till end.

Definition at line 994 of file URL.cpp.

                                     {
    if (pos != std::string::npos)
      return path.substr(pos + 1);
    else if (!end)
      return path;
    else
      return "";
  }

Here is the caller graph for this function:


Member Data Documentation

bool Arc::PathIterator::done [private]

Definition at line 349 of file URL.h.

bool Arc::PathIterator::end [private]

Definition at line 348 of file URL.h.

const std::string& Arc::PathIterator::path [private]

Definition at line 346 of file URL.h.

std::string::size_type Arc::PathIterator::pos [private]

Definition at line 347 of file URL.h.


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