35template <
typename Derived>
40 using StorageType =
typename Derived::StorageType;
44 : m_Value((StorageType)Derived::Default)
55 PL_ALWAYS_INLINE
plEnum(
typename Derived::Enum init)
56 : m_Value((StorageType)init)
67 PL_ALWAYS_INLINE
void operator=(
const typename Derived::Enum value)
69 m_Value = (StorageType)value;
74 PL_ALWAYS_INLINE
bool operator!=(
const SelfType& rhs)
const {
return m_Value != rhs.m_Value; }
75 PL_ALWAYS_INLINE
bool operator>(
const SelfType& rhs)
const {
return m_Value > rhs.m_Value; }
76 PL_ALWAYS_INLINE
bool operator<(
const SelfType& rhs)
const {
return m_Value < rhs.m_Value; }
77 PL_ALWAYS_INLINE
bool operator>=(
const SelfType& rhs)
const {
return m_Value >= rhs.m_Value; }
78 PL_ALWAYS_INLINE
bool operator<=(
const SelfType& rhs)
const {
return m_Value <= rhs.m_Value; }
80 PL_ALWAYS_INLINE
bool operator==(
typename Derived::Enum value)
const {
return m_Value == value; }
81 PL_ALWAYS_INLINE
bool operator!=(
typename Derived::Enum value)
const {
return m_Value != value; }
82 PL_ALWAYS_INLINE
bool operator>(
typename Derived::Enum value)
const {
return m_Value > value; }
83 PL_ALWAYS_INLINE
bool operator<(
typename Derived::Enum value)
const {
return m_Value < value; }
84 PL_ALWAYS_INLINE
bool operator>=(
typename Derived::Enum value)
const {
return m_Value >= value; }
85 PL_ALWAYS_INLINE
bool operator<=(
typename Derived::Enum value)
const {
return m_Value <= value; }
88 PL_ALWAYS_INLINE
SelfType operator|(
const SelfType& rhs)
const {
return static_cast<typename Derived::Enum
>(m_Value | rhs.m_Value); }
89 PL_ALWAYS_INLINE SelfType operator&(
const SelfType& rhs)
const {
return static_cast<typename Derived::Enum
>(m_Value & rhs.m_Value); }
92 PL_ALWAYS_INLINE
operator typename Derived::Enum() const
94 return static_cast<typename Derived::Enum
>(m_Value);
114#define PL_ENUM_VALUE_TO_STRING(name) \
116 return PL_PP_STRINGIFY(name);
134#define PL_ENUM_TO_STRING(...) \
135 const char* ToString(plUInt32 value) \
139 PL_EXPAND_ARGS(PL_ENUM_VALUE_TO_STRING, ##__VA_ARGS__) \
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
PL_ALWAYS_INLINE StorageType GetValue() const
Returns the enum value as an integer.
Definition Enum.h:98
PL_ALWAYS_INLINE plEnum()
Default constructor.
Definition Enum.h:43
PL_ALWAYS_INLINE void SetValue(StorageType value)
Sets the enum value through an integer.
Definition Enum.h:104
PL_ALWAYS_INLINE void operator=(const SelfType &rh)
Assignment operator.
Definition Enum.h:61
PL_ALWAYS_INLINE bool operator==(const SelfType &rhs) const
Comparison operators.
Definition Enum.h:73
PL_ALWAYS_INLINE plEnum(const SelfType &rh)
Copy constructor.
Definition Enum.h:49
PL_ALWAYS_INLINE void operator=(const typename Derived::Enum value)
Assignment operator.
Definition Enum.h:67
PL_ALWAYS_INLINE plEnum(typename Derived::Enum init)
Construct from a C++ enum, and implicit conversion from enum type.
Definition Enum.h:55
PL_ALWAYS_INLINE SelfType operator|(const SelfType &rhs) const
brief Bitwise operators
Definition Enum.h:88