 |
Gorgon Game Engine
|
Go to the documentation of this file.
22 class Iterator :
public std::iterator<std::forward_iterator_tag, std::string> {
30 Iterator(
const std::string &directory,
const std::string &pattern=
"*");
35 current(std::move(dir.current)) {
60 swap(data, other.data);
61 swap(basedir, other.basedir);
62 swap(current, other.current);
67 std::string
Get()
const {
69 if(!data || current==
"") {
70 throw std::runtime_error(
"Invalid iterator.");
81 if(!data || current==
"") {
82 throw std::runtime_error(
"Invalid iterator.");
91 operator std::string()
const {
147 return data && current!=
"";
154 return other.data==
nullptr;
158 return other.basedir==basedir && other.current==current;
165 return other.data!=
nullptr;
169 return other.basedir!=basedir || other.current!=current;
173 internal::iterator_data *data;
bool IsValid() const
Checks whether the iterator is valid.
Definition: Iterator.h:146
const std::string * operator->()
Returns the current path.
Definition: Iterator.h:79
bool operator!=(const Iterator &other) const
Compares two iterators.
Definition: Iterator.h:163
Iterator & operator++()
Move to the next path in the directory.
Definition: Iterator.h:109
~Iterator()
Destructor.
Definition: Iterator.h:53
std::string operator*() const
Returns the current path.
Definition: Iterator.h:97
Iterator(Iterator &&dir)
Move constructor.
Definition: Iterator.h:34
void Swap(Iterator &other)
Swaps iterators, used for move semantics.
Definition: Iterator.h:57
void swap(Iterator &l, Iterator &r)
Swaps two iterators.
Definition: Iterator.h:181
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
void Destroy()
Destroys the current iterator.
Definition: Linux.cpp:431
Iterator & operator=(Iterator other)
Assignment.
Definition: Iterator.h:49
This iterator allows iteration of directories.
Definition: Iterator.h:22
Iterator & operator+=(int i)
Moves directory by i elements.
Definition: Iterator.h:117
bool operator==(const Iterator &other) const
Compares two iterators.
Definition: Iterator.h:152
std::string Current()
Returns the current path.
Definition: Iterator.h:103
bool Next()
Next path in the directory.
Definition: Linux.cpp:438
std::string Get() const
Returns the current path.
Definition: Iterator.h:67
Iterator()
Empty constructor. Effectively generates end iterator.
Definition: Iterator.h:45