Scopira 20080306

scopira::tool::dir_iterator Class Reference

#include <diriterator.h>

List of all members.

Public Member Functions

 dir_iterator (void)
bool failed (void) const
bool open (const std::string &dirname)
void close (void)
bool next (std::string &out)

Detailed Description

This class iterates of a collection of files in a directory, giving you a list of file names.

Typical usage of this class:

   dir_iterator dd;
   std::string filename;

   if (dd.open("somedir"))
     while (dd.next(filename))
       OUTPUT << "A filename: " << filename << '\n';
Author:
Aleksander Demko

Constructor & Destructor Documentation

scopira::tool::dir_iterator::dir_iterator ( void  )

Constructor.

Author:
Aleksander Demko

Member Function Documentation

void scopira::tool::dir_iterator::close ( void  )

Closes the current iteration.

You typically never need to call this as the iterator will close the stream upon its destruction or if you open another iteration.

Author:
Aleksander Demko
bool scopira::tool::dir_iterator::failed ( void  ) const [inline]

Is this iterator in a failed state?

Author:
Aleksander Demko
bool scopira::tool::dir_iterator::next ( std::string &  out)

Get the next filename in the iteration. Only the filename will be returned, there will be no path element attached. You typically put this call in a while loop. The dir_iterator must have previously been succesfully opened.

Parameters:
outthe output string (useful only if this call is succesful)
Returns:
true if successful, false on failure (for example, if there are no more files in the directory)
Author:
Aleksander Demko
bool scopira::tool::dir_iterator::open ( const std::string &  dirname)

Opens a directory for iteration.

Parameters:
dirnamethe directory to open
Returns:
true on success
Author:
Aleksander Demko

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