Module: Essential Tools Module Group: File System Classes
Does not inherit
#include <rw/directory.h> RWDirectoryIterator<const char*> it; RWDirectoryIterator<RWCString> it;
The Essential Tools library provides two specializations of the class template: one for const char* which acts like a flat iterator (no iteration of subdirectories); the other one for RWCString which provides a recursive iteration of subdirectories. Neither of these follow symbolic links.
Both iterators are refinements of the Input Iterator concept. One limitation is that they will be usable only in single-pass algorithms.
The nature of the API for manipulating files and directories requires special attention to synchronization issues. These classes are:
Assignable
Copy Constructible
Equality Comparable
None
typedef const char* value_type;
const char* specialization constructors
RWDirectoryIterator();
Constructs an iterator which compares equal with any past-the-end iterator.
explicit RWDirectoryIterator(const char*);
Constructs an iterator over the content of the directory whose name is passed as an argument. If the argument is not a directory, it throws an exception of type (or derived of) RWInternalErr.
RWDirectoryIterator (const RWDirectoryIterator<const char*>&);
Constructs an iterator which is a copy of the iterator passed as the argument. Dereferencing them yields identical results yet they will not compare equal. See the equality comparison operators below.
RWCString specialization constructors
RWDirectoryIterator();
Constructs an iterator which compares equal with any past-the-end iterator.
explicit RWDirectoryIterator(const char*, int depth = 0);
Constructs an iterator over the content of the directory whose name is passed as the argument. The depth argument controls how deep the iteration will go in the directory hierarchy. For the default value it behaves as a flat iterator. Passing an argument value of -1 will do the iteration as deep as the hierarchy goes. If the argument is not a directory, it throws an exception of type (or derived of) RWInternalErr.
RWDirectoryIterator(const RWDirectoryIterator<RWCString>&);
Constructs an iterator which is a copy of the iterator passed as the argument. Dereferencing them yields identical results yet they will not compare equal. See the equality comparison operators below.
Both specializations
~RWDirectoryIterator();
Destroys the object.
Both specializations
RWDirectoryIterator& operator=(const RWDirectoryIterator&);
Assignment operator. Performs the assignment of the value of the argument. Note that the objects will not compare equal unless they are both past-the-end iterators.
RWDirectoryIterator& operator++();
Prefix increment operator. Returns a reference to this object.
RWDirectoryIterator operator++(int)
Postfix increment operator. Returns an iterator which points to the entry previous to the increment operation.
const char* operator*() const;
Dereferencing operator. Returns the file name or 0 if the iterator is a past-the-end iterator.
bool operator==(const RWDirectoryIterator& lhs, const RWDirectoryIterator& rhs) const;
Operator equal. Tests equality between the object pointed to by this and the one passed as a reference. Only past-the-end iterators compare equal.
bool operator!=(const RWDirectoryIterator& lhs, const RWDirectoryIterator& rhs) const;
Operator not equal. Equivalent with !(*this == ref).
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.