OpenTTD: src/core/enum_type.hpp File Reference

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros
enum_type.hpp File Reference

Type (helpers) for enums. More...

Go to the source code of this file.

## Data Structures
struct | MakeEnumPropsT< Tenum_t, Tstorage_t, Tbegin, Tend, Tinvalid, Tnum_bits >
| Helper template class that makes basic properties of given enumeration type visible from outsize. More...
struct | TinyEnumT< Tenum_t >
| The general declaration of TinyEnumT<> (above) More...
struct | SimpleTinyEnumT< enum_type, storage_type >
| Template of struct holding enum types (on most archs, enums are stored in an int32). More...

## Macros
#define | DECLARE_POSTFIX_INCREMENT(type)
| Some enums need to have allowed incrementing (i.e.
#define | DECLARE_ENUM_AS_BIT_SET(mask_t)
| Operators to allow to work with enum as with type safe bit set in C++.

## Detailed Description

Type (helpers) for enums.

Definition in file enum_type.hpp.

## Macro Definition Documentation

#define DECLARE_ENUM_AS_BIT_SET | ( |  | mask_t | ) |

Value:
inline mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
inline mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
inline mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
inline mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
inline mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
inline mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
inline mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}

Operators to allow to work with enum as with type safe bit set in C++.

Definition at line 33 of file enum_type.hpp.

#define DECLARE_POSTFIX_INCREMENT | ( |  | type | ) |

Value:
inline type operator ++(type& e, int) \
{ \
type e_org = e; \
e = (type)((int)e + 1); \
return e_org; \
} \
inline type operator --(type& e, int) \
{ \
type e_org = e; \
e = (type)((int)e - 1); \
return e_org; \
}

Some enums need to have allowed incrementing (i.e.

StationClassID)

Definition at line 16 of file enum_type.hpp.