Public Member Functions | Private Types | Private Attributes | List of all members
gnsstk::EnumIterator< C, beginVal, endVal > Class Template Reference

Detailed Description

template<typename C, C beginVal, C endVal>
class gnsstk::EnumIterator< C, beginVal, endVal >

This class simplifies the process of iterating over strongly typed enums. Example: typedef EnumIterator<enum, enum::firstVal, enum::lastVal> Iterator; for (enum x : Iterator()) { ... } Typically, the iterator will be defined in the include file that defines the enum. The endVal value should be first value that will NOT be processed in a loop. This means defining a final "Last" enumeration value in the enum that won't be iterated over. This is done to facilitate adding additional enumeration values without having to change the code that defines the iterator.

Warning
Do not attempt to use this on enumerations that have assigned values resulting in gaps. This will result in iterating over invalid enumeration values.
See also
CarrierBand.hpp

Definition at line 68 of file EnumIterator.hpp.

#include <EnumIterator.hpp>

Public Member Functions

EnumIterator begin ()
 
EnumIterator end ()
 Iterator end value. More...
 
 EnumIterator ()
 
 EnumIterator (const C &f)
 Initialize the iterator to a specific value. More...
 
bool operator!= (const EnumIterator &i)
 Comparison to assist in iteration. More...
 
operator* ()
 Dereference the iterator by returning the current enum value. More...
 
EnumIteratoroperator++ ()
 

Private Types

typedef std::underlying_type< C >::type ValType
 Value type as derived from the enum typename. More...
 

Private Attributes

ValType val
 Current iterator value. More...
 

Member Typedef Documentation

◆ ValType

template<typename C , C beginVal, C endVal>
typedef std::underlying_type<C>::type gnsstk::EnumIterator< C, beginVal, endVal >::ValType
private

Value type as derived from the enum typename.

Definition at line 71 of file EnumIterator.hpp.

Constructor & Destructor Documentation

◆ EnumIterator() [1/2]

template<typename C , C beginVal, C endVal>
gnsstk::EnumIterator< C, beginVal, endVal >::EnumIterator ( )
inline

Default iterator initializes to the beginVal specified in the template instantiation.

Definition at line 77 of file EnumIterator.hpp.

◆ EnumIterator() [2/2]

template<typename C , C beginVal, C endVal>
gnsstk::EnumIterator< C, beginVal, endVal >::EnumIterator ( const C &  f)
inline

Initialize the iterator to a specific value.

Definition at line 81 of file EnumIterator.hpp.

Member Function Documentation

◆ begin()

template<typename C , C beginVal, C endVal>
EnumIterator gnsstk::EnumIterator< C, beginVal, endVal >::begin ( )
inline

Iterator start value, which can be the value initialized from the value constructor.

Definition at line 99 of file EnumIterator.hpp.

◆ end()

template<typename C , C beginVal, C endVal>
EnumIterator gnsstk::EnumIterator< C, beginVal, endVal >::end ( )
inline

Iterator end value.

Definition at line 102 of file EnumIterator.hpp.

◆ operator!=()

template<typename C , C beginVal, C endVal>
bool gnsstk::EnumIterator< C, beginVal, endVal >::operator!= ( const EnumIterator< C, beginVal, endVal > &  i)
inline

Comparison to assist in iteration.

Definition at line 108 of file EnumIterator.hpp.

◆ operator*()

template<typename C , C beginVal, C endVal>
C gnsstk::EnumIterator< C, beginVal, endVal >::operator* ( )
inline

Dereference the iterator by returning the current enum value.

Definition at line 95 of file EnumIterator.hpp.

◆ operator++()

template<typename C , C beginVal, C endVal>
EnumIterator& gnsstk::EnumIterator< C, beginVal, endVal >::operator++ ( )
inline

Increment the iterator to the next enum

Note
This assumes that there are no gaps between enum values, otherwise it could not have a valid enumeration.
This is the prefix operator.

Definition at line 89 of file EnumIterator.hpp.

Member Data Documentation

◆ val

template<typename C , C beginVal, C endVal>
ValType gnsstk::EnumIterator< C, beginVal, endVal >::val
private

Current iterator value.

Definition at line 73 of file EnumIterator.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44