aboutsummaryrefslogtreecommitdiff
path: root/source/10-common/Enum.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2023-10-19 22:50:07 -0700
committerrtk0c <[email protected]>2023-10-19 22:50:07 -0700
commit2c92e07f337e42cf58970443f9de678f85a9b2a4 (patch)
tree075d5407e1e12a9d35cbee6e4c20ad34e0765c42 /source/10-common/Enum.hpp
parent615809c036f604bce4582cea8ad49c64693f4f45 (diff)
The great renaming: switch to "module style"
Diffstat (limited to 'source/10-common/Enum.hpp')
-rw-r--r--source/10-common/Enum.hpp110
1 files changed, 0 insertions, 110 deletions
diff --git a/source/10-common/Enum.hpp b/source/10-common/Enum.hpp
deleted file mode 100644
index 7afbe8e..0000000
--- a/source/10-common/Enum.hpp
+++ /dev/null
@@ -1,110 +0,0 @@
-#pragma once
-
-#include <initializer_list>
-#include <type_traits>
-
-template <typename TEnum>
-class EnumFlags {
-public:
- using Enum = TEnum;
- using Underlying = std::underlying_type_t<TEnum>;
-
-private:
- Underlying mValue;
-
-public:
- EnumFlags()
- : mValue{ 0 } {
- }
-
- EnumFlags(TEnum e)
- : mValue{ static_cast<Underlying>(1) << static_cast<Underlying>(e) } {
- }
-
- bool IsSet(EnumFlags mask) const {
- return (mValue & mask.mValue) == mask.mValue;
- }
-
- bool IsSet(std::initializer_list<TEnum> enums) {
- EnumFlags flags;
- for (auto& e : enums) {
- flags.mValue |= static_cast<Underlying>(e);
- }
- return IsSet(flags);
- }
-
- bool IsSetExclusive(EnumFlags mask) const {
- return mValue == mask.mValue;
- }
-
- bool IsSetExclusive(std::initializer_list<TEnum> enums) {
- EnumFlags flags;
- for (auto& e : enums) {
- flags.mValue |= static_cast<Underlying>(e);
- }
- return IsSetExclusive(flags);
- }
-
- void SetOn(EnumFlags mask) {
- mValue |= mask.mValue;
- }
-
- void SetOff(EnumFlags mask) {
- mValue &= ~mask.mValue;
- }
-
- void Set(EnumFlags mask, bool enabled) {
- if (enabled) {
- SetOn(mask);
- } else {
- SetOff(mask);
- }
- }
-
- EnumFlags& operator|=(EnumFlags that) const {
- mValue |= that.mValue;
- return *this;
- }
-
- EnumFlags& operator&=(EnumFlags that) const {
- mValue &= that.mValue;
- return *this;
- }
-
- EnumFlags& operator^=(EnumFlags that) const {
- mValue ^= that.mValue;
- return *this;
- }
-
- EnumFlags& operator|=(TEnum e) const {
- mValue |= 1 << static_cast<Underlying>(e);
- return *this;
- }
-
- EnumFlags& operator&=(TEnum e) const {
- mValue &= 1 << static_cast<Underlying>(e);
- return *this;
- }
-
- EnumFlags& operator^=(TEnum e) const {
- mValue ^= 1 << static_cast<Underlying>(e);
- return *this;
- }
-
- EnumFlags operator|(EnumFlags that) const { return EnumFlags(mValue | that.mValue); }
- EnumFlags operator&(EnumFlags that) const { return EnumFlags(mValue & that.mValue); }
- EnumFlags operator^(EnumFlags that) const { return EnumFlags(mValue ^ that.mValue); }
-
- EnumFlags operator|(TEnum e) const { return EnumFlags(mValue | 1 << static_cast<Underlying>(e)); }
- EnumFlags operator&(TEnum e) const { return EnumFlags(mValue & 1 << static_cast<Underlying>(e)); }
- EnumFlags operator^(TEnum e) const { return EnumFlags(mValue ^ 1 << static_cast<Underlying>(e)); }
-
- EnumFlags operator~() const { return EnumFlags(~mValue); }
-};
-
-// Helper class for enumerating enum elements for ImGui::Begin/EndCombo
-template <typename TEnum>
-struct EnumElement {
- const char* name;
- TEnum value;
-};