VideoTools
|
A directory tree iterator for sorted, depth-first traversal of files and directories. More...
#include <gdirectorytree.h>
Public Member Functions | |
DirectoryTree () | |
Default contructor for an off-the-end iterator. | |
DirectoryTree (const G::Path &root, bool reverse=false, DirectoryTreeCallback *ignore=0) | |
Contructor for a tree iterator rooted at the given path. More... | |
DirectoryTree & | operator++ () |
Pre-increment operator. Moves to the next file or directory. | |
const DirectoryList::Item & | operator* () const |
Dereference operator yielding a G::DirectoryList::Item. | |
bool | operator== (const DirectoryTree &) const |
Comparison operator. | |
bool | operator!= (const DirectoryTree &) const |
Comparison operator. | |
size_t | depth () const |
Returns the nesting depth compared to the root. | |
bool | down (const std::string &name, bool at_or_after=false) |
Moves deeper into the directory tree, with a precondition that the iterator currently points to a directory. More... | |
void | up () |
Moves up to the parent directory. More... | |
void | swap (DirectoryTree &other) |
Swaps this and other. | |
DirectoryTree (const DirectoryTree &) | |
Copy constructor. | |
DirectoryTree & | operator= (const DirectoryTree &) |
Assignment operator. | |
void | reverse (bool in_reverse=true) |
Changes the reversal state, returning the previous value. | |
bool | reversed () const |
Returns the current reversal state. | |
A directory tree iterator for sorted, depth-first traversal of files and directories.
Definition at line 40 of file gdirectorytree.h.
|
explicit |
Contructor for a tree iterator rooted at the given path.
If reverse-d the iterator moves through each depth level in reverse; this is not the same a reversal of the whole sequence because the sequence includes non-leaf nodes. It follows that reversal is more useful when directories are filtered out by client code (see G::FileTree).
An optional callback function, taking a path and a depth, can be used to filter out files and directories that should be ignored. Directories that are ignored are not traversed at all.
Definition at line 68 of file gdirectorytree.cpp.
bool G::DirectoryTree::down | ( | const std::string & | name, |
bool | at_or_after = false |
||
) |
Moves deeper into the directory tree, with a precondition that the iterator currently points to a directory.
If 'at_or_after' is false the iterator is moved into the directory to a position that matches the requested name. Returns false if not found, with the iterator position unchanged.
If 'at_or_after' is true the iterator is moved into the directory to a position that is at or after the requested name and then returns true. However, if the requested name is lexicographically later than the last name in the directory, then the iterator might advance to another directory altogether or completely off-the-end of the tree, and in this case false is returned.
Precondition: operator*().m_is_dir
Definition at line 203 of file gdirectorytree.cpp.
void G::DirectoryTree::up | ( | ) |
Moves up to the parent directory.
Precondition: depth() >= 1
Definition at line 245 of file gdirectorytree.cpp.