17 #ifndef GZ_COMMON_ENUMITERATOR_HH_
18 #define GZ_COMMON_ENUMITERATOR_HH_
24 #include <gz/common/Export.hh>
41 #define GZ_ENUM(name, enumType, begin, end, ...) \
42 static gz::common::EnumIface<enumType> name( \
43 begin, end, {__VA_ARGS__});
54 public: EnumIface(T _start, T _end,
58 this->range[0] = _start;
59 this->range[1] = _end;
83 if (
static_cast<unsigned int>(_e) < names.size())
84 return names[
static_cast<unsigned int>(_e)];
144 GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
145 template<
typename Enum>
150 public: EnumIterator()
157 public: EnumIterator(
const Enum &_c) : c(_c)
163 public: EnumIterator &operator=(
const Enum &_c)
171 public: EnumIterator &operator++()
173 this->c =
static_cast<Enum
>(
static_cast<int>(this->c) + 1);
179 public: EnumIterator operator++(
const int)
181 EnumIterator cpy(*
this);
188 public: EnumIterator &operator--()
190 this->c =
static_cast<Enum
>(
static_cast<int>(this->c) - 1);
196 public: EnumIterator operator--(
const int)
198 EnumIterator cpy(*
this);
205 public: Enum operator*()
const
212 public: Enum Value()
const
222 GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
228 template<
typename Enum>
229 bool operator==(EnumIterator<Enum> _e1, EnumIterator<Enum> _e2)
231 return _e1.Value() == _e2.Value();
238 template<
typename Enum>
239 bool operator!=(EnumIterator<Enum> _e1, EnumIterator<Enum> _e2)
241 return !(_e1 == _e2);