Evo C++ Library v0.5.1
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
EnumIterator< T, F, L > Class Template Reference

#include <evo/impl/iter.h>

Inheritance diagram for EnumIterator< T, F, L >:
Inheritance graph
[legend]

Detailed Description

template<class T, int F, int L>
class evo::EnumIterator< T, F, L >

Iterator template for sequential enum values.

Template Parameters
TEnum type to iterator values on
FFirst enum value to start iterator at
LLast enum value to end iterator at
Example

This simple example prints out enum number values

#include <evo/type.h>
#include <evo/io.h>
using namespace evo;
enum MyEnum {
ENUM_ONE,
ENUM_TWO,
ENUM_THREE
};
int main() {
Console& c = con();
for (MyEnumIter iter; iter; ++iter)
c.out << iter.value_num() << NL;
return 0;
}

Public Types

typedef T EnumType
 
typedef EnumIterator< T, F, L > This
 

Public Member Functions

 EnumIterator ()
 Constructor, sets to first enum value. More...
 
 EnumIterator (const This &src)
 Copy constructor. More...
 
 EnumIterator (EnumType value)
 Constructor to start at explicit enum value. More...
 
 EnumIterator (IteratorPos pos)
 Constructor to start at given position. More...
 
 operator SafeBoolType () const
 Safe (explicit) evaluation as bool type. More...
 
bool operator! () const
 Check whether iterator is at end. More...
 
bool operator!= (const This &oth) const
 Inequality operator to compare with another iterator to same enum. More...
 
EnumType operator* () const
 Dereference iterator to get current enum value. More...
 
Thisoperator++ ()
 Pre increment operator, moves to next enum value or end. More...
 
This operator++ (int)
 Post increment operator, moves to next enum value or end. More...
 
Thisoperator-- ()
 Pre decrement operator, moves to previous enum value or end. More...
 
This operator-- (int)
 Post decrement operator, moves to previous enum value or end. More...
 
Thisoperator= (const This &src)
 Assignment operator. More...
 
Thisoperator= (EnumType value)
 Assignment operator to set at explicit enum value. More...
 
Thisoperator= (IteratorPos pos)
 Assignment operator to set at given position. More...
 
bool operator== (const This &oth) const
 Equality operator to compare with another iterator to same enum. More...
 
EnumType value () const
 Get current enum value. More...
 
int value_num (int endvalue=0) const
 Get current enum number value. More...
 

Static Public Attributes

static const T FIRST = (T)F
 
static const T LAST = (T)L
 

Protected Member Functions

void next ()
 
void prev ()
 
void setpos (IteratorPos pos)
 

Protected Attributes

bool end_
 
EnumType value_
 

Member Typedef Documentation

◆ EnumType

typedef T EnumType

◆ This

typedef EnumIterator<T,F,L> This

Constructor & Destructor Documentation

◆ EnumIterator() [1/4]

EnumIterator ( )
inline

Constructor, sets to first enum value.

◆ EnumIterator() [2/4]

EnumIterator ( const This src)
inline

Copy constructor.

Parameters
srcSource to copy

◆ EnumIterator() [3/4]

EnumIterator ( EnumType  value)
inline

Constructor to start at explicit enum value.

Parameters
valueEnum value to start at

◆ EnumIterator() [4/4]

EnumIterator ( IteratorPos  pos)
inline

Constructor to start at given position.

Parameters
posPosition to start at, either: iterFIRST, iterLAST, or iterEND

Member Function Documentation

◆ next()

void next ( )
inlineprotected

◆ operator SafeBoolType()

operator SafeBoolType ( ) const
inlineinherited

Safe (explicit) evaluation as bool type.

  • This is called when object is directly evaluated as a bool, and is equivalent to: !operator!()
  • See SafeBool

◆ operator!()

bool operator! ( ) const
inline

Check whether iterator is at end.

Returns
Whether at end

◆ operator!=()

bool operator!= ( const This oth) const
inline

Inequality operator to compare with another iterator to same enum.

Parameters
othOther iterator to compare to
Returns
Whether inequal

◆ operator*()

EnumType operator* ( ) const
inline

Dereference iterator to get current enum value.

Returns
Current enum value

◆ operator++() [1/2]

This& operator++ ( )
inline

Pre increment operator, moves to next enum value or end.

Returns
This

◆ operator++() [2/2]

This operator++ ( int  )
inline

Post increment operator, moves to next enum value or end.

Returns
Iterator copy before increment

◆ operator--() [1/2]

This& operator-- ( )
inline

Pre decrement operator, moves to previous enum value or end.

Returns
This

◆ operator--() [2/2]

This operator-- ( int  )
inline

Post decrement operator, moves to previous enum value or end.

Returns
Iterator copy before decrement

◆ operator=() [1/3]

This& operator= ( const This src)
inline

Assignment operator.

Parameters
srcSource to copy
Returns
This

◆ operator=() [2/3]

This& operator= ( EnumType  value)
inline

Assignment operator to set at explicit enum value.

Parameters
valueEnum value to set at
Returns
This

◆ operator=() [3/3]

This& operator= ( IteratorPos  pos)
inline

Assignment operator to set at given position.

Parameters
posPosition to start at, either: iterFIRST, iterLAST, or iterEND
Returns
This

◆ operator==()

bool operator== ( const This oth) const
inline

Equality operator to compare with another iterator to same enum.

Parameters
othOther iterator to compare to
Returns
Whether equal

◆ prev()

void prev ( )
inlineprotected

◆ setpos()

void setpos ( IteratorPos  pos)
inlineprotected

◆ value()

EnumType value ( ) const
inline

Get current enum value.

Returns
Current enum value

◆ value_num()

int value_num ( int  endvalue = 0) const
inline

Get current enum number value.

Returns
Current enum number value

Member Data Documentation

◆ end_

bool end_
protected

◆ FIRST

const T FIRST = (T)F
static

◆ LAST

const T LAST = (T)L
static

◆ value_

EnumType value_
protected

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