Gazebo Common

API Reference

7.4.0
EnumIterator< Enum > Class Template Reference

An iterator over enum types. More...

#include <EnumIface.hh>

Public Types

using difference_type = std::ptrdiff_t
 
using iterator_category = std::bidirectional_iterator_tag
 
using pointer = Enum *
 
using reference = Enum &
 
using value_type = Enum
 

Public Member Functions

 EnumIterator ()=default
 Constructor.
 
 EnumIterator (const Enum &_c)
 Constructor.
 
Enum operator* () const
 Dereference operator.
 
EnumIteratoroperator++ ()
 Prefix increment operator.
 
EnumIterator operator++ (const int)
 Postfix increment operator.
 
EnumIteratoroperator-- ()
 Prefix decrement operator.
 
EnumIterator operator-- (const int)
 Postfix decrement operator.
 
EnumIteratoroperator= (const Enum &_c)
 Equal operator.
 
Enum Value () const
 Get the enum value.
 

Detailed Description

template<typename Enum>
class gz::common::EnumIterator< Enum >

An iterator over enum types.

Example:

/// enum MyType
/// {
///   MY_TYPE_BEGIN = 0,
///   TYPE1 = MY_TYPE_BEGIN,
///   TYPE2 = 1,
///   MY_TYPE_END
/// };
///
/// auto myTypeIface = gzEnum(MY_TYPE_BEGIN, MY_TYPE_END,
///  {"TYPE1",
///  "TYPE2",
///  "MY_TYPE_END"});
///
/// int main()
/// {
///   EnumIterator<MyType> i = MY_TYPE_BEGIN;
///   std::cout << "Type Number[" << *i << "]\n";
///   std::cout << "Type Name[" << myTypeIface.Str(*i) << "]\n";
///   i++;
///   std::cout << "Type++ Number[" << *i << "]\n";
///   std::cout << "Type++ Name[" << myTypeIface.Str(*i) << "]\n";
/// }
/// 

Member Typedef Documentation

◆ difference_type

template<typename Enum >
using difference_type = std::ptrdiff_t

◆ iterator_category

template<typename Enum >
using iterator_category = std::bidirectional_iterator_tag

◆ pointer

template<typename Enum >
using pointer = Enum*

◆ reference

template<typename Enum >
using reference = Enum&

◆ value_type

template<typename Enum >
using value_type = Enum

Constructor & Destructor Documentation

◆ EnumIterator() [1/2]

template<typename Enum >
EnumIterator ( )
default

Constructor.

◆ EnumIterator() [2/2]

template<typename Enum >
EnumIterator ( const Enum &  _c)
inlineexplicit

Constructor.

Parameters
[in]_cEnum value

Member Function Documentation

◆ operator*()

template<typename Enum >
Enum operator* ( ) const
inline

Dereference operator.

Returns
Value of the iterator

◆ operator++() [1/2]

template<typename Enum >
EnumIterator & operator++ ( )
inline

Prefix increment operator.

Returns
Iterator pointing to the next value in the enum.

◆ operator++() [2/2]

template<typename Enum >
EnumIterator operator++ ( const int  )
inline

Postfix increment operator.

Returns
Iterator pointing to the next value in the enum.

◆ operator--() [1/2]

template<typename Enum >
EnumIterator & operator-- ( )
inline

Prefix decrement operator.

Returns
Iterator pointing to the previous value in the enum

◆ operator--() [2/2]

template<typename Enum >
EnumIterator operator-- ( const int  )
inline

Postfix decrement operator.

Returns
Iterator pointing to the previous value in the enum

◆ operator=()

template<typename Enum >
EnumIterator & operator= ( const Enum &  _c)
inline

Equal operator.

Parameters
[in]_cEnum value to copy

◆ Value()

template<typename Enum >
Enum Value ( ) const
inline

Get the enum value.

Returns
Value of the iterator

Referenced by gz::common::operator==().


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