Gorgon Game Engine
Iterator Class Reference

This iterator allows iteration of directories. More...

Inheritance diagram for Iterator:
[legend]

Public Member Functions

 Iterator ()
 Empty constructor. Effectively generates end iterator. More...
 
 Iterator (const Iterator &other)
 Copy constructor. More...
 
 Iterator (const std::string &directory, const std::string &pattern="*")
 Creates a new iterator from the given directory and pattern. More...
 
 Iterator (Iterator &&dir)
 Move constructor. More...
 
 ~Iterator ()
 Destructor. More...
 
std::string Current ()
 Returns the current path. More...
 
void Destroy ()
 Destroys the current iterator. More...
 
std::string Get () const
 Returns the current path. More...
 
bool IsValid () const
 Checks whether the iterator is valid. More...
 
bool Next ()
 Next path in the directory. More...
 
 operator std::string () const
 Returns the current path. More...
 
bool operator!= (const Iterator &other) const
 Compares two iterators. More...
 
std::string operator* () const
 Returns the current path. More...
 
Iteratoroperator++ ()
 Move to the next path in the directory. More...
 
Iterator operator++ (int)
 Move to the next path in the directory, return unmodified iterator. More...
 
Iteratoroperator+= (int i)
 Moves directory by i elements. More...
 
const std::string * operator-> ()
 Returns the current path. More...
 
Iteratoroperator= (Iterator other)
 Assignment. More...
 
bool operator== (const Iterator &other) const
 Compares two iterators. More...
 
void Swap (Iterator &other)
 Swaps iterators, used for move semantics. More...
 

Detailed Description

This iterator allows iteration of directories.

It is a forward only iterator. An empty iterator can be used for end(). Also instead of comparing the iterator with end, IsValid() function could be used.

Constructor & Destructor Documentation

◆ Iterator() [1/4]

Iterator ( const std::string &  directory,
const std::string &  pattern = "*" 
)

Creates a new iterator from the given directory and pattern.

Parameters
directoryis the directory to be iterated. Should exists, otherwise it will throw PathNotFoundError
patternwildcard pattern to match paths against
Exceptions
PathNotFoundErrorif the given directory does not exists

References Iterator::Destroy(), and Iterator::Next().

◆ Iterator() [2/4]

Iterator ( Iterator &&  dir)

Move constructor.

◆ Iterator() [3/4]

Iterator ( const Iterator other)

Copy constructor.

References Iterator::Destroy().

◆ Iterator() [4/4]

Iterator ( )

Empty constructor. Effectively generates end iterator.

◆ ~Iterator()

~Iterator ( )

Destructor.

References Iterator::Destroy().

Member Function Documentation

◆ Current()

std::string Current ( )

Returns the current path.

Exceptions
std::runtime_error(debug only) if the iterator is not valid

References Iterator::Get().

◆ Destroy()

void Destroy ( )

Destroys the current iterator.

◆ Get()

std::string Get ( ) const

Returns the current path.

Exceptions
std::runtime_error(debug only) if the iterator is not vali

◆ IsValid()

bool IsValid ( ) const

Checks whether the iterator is valid.

◆ Next()

bool Next ( )

Next path in the directory.

Returns
true if the iterator is valid
Exceptions
std::runtime_error(debug only) if the iterator is not valid

References Iterator::Destroy().

◆ operator std::string()

operator std::string ( ) const

Returns the current path.

Exceptions
std::runtime_error(debug only) if the iterator is not valid

References Iterator::Get().

◆ operator!=()

bool operator!= ( const Iterator other) const

Compares two iterators.

◆ operator*()

std::string operator* ( ) const

Returns the current path.

Exceptions
std::runtime_error(debug only) if the iterator is not valid

References Iterator::Get().

◆ operator++() [1/2]

Iterator& operator++ ( )

Move to the next path in the directory.

References Iterator::Next().

◆ operator++() [2/2]

Iterator operator++ ( int  )

Move to the next path in the directory, return unmodified iterator.

References Iterator::Next().

◆ operator+=()

Iterator& operator+= ( int  i)

Moves directory by i elements.

◆ operator->()

const std::string* operator-> ( )

Returns the current path.

Exceptions
std::runtime_error(debug only) if the iterator is not vali

◆ operator=()

Iterator& operator= ( Iterator  other)

Assignment.

References Iterator::Swap().

◆ operator==()

bool operator== ( const Iterator other) const

Compares two iterators.

◆ Swap()

void Swap ( Iterator other)

Swaps iterators, used for move semantics.

References Gorgon::Filesystem::swap().


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