|
6 | 6 | // EnumNamespace = "Namespace::ToEnum::" |
7 | 7 | // example: ENUM_DECLARE_BASE(app::shortcut::, EShortcutId, Type, UNDEF); |
8 | 8 | // |
9 | | -#define ENUM_DECLARE_BASE(EnumNamespace, EnumNameStruct, eEnumType, _DefaultValue) \ |
10 | | -private: \ |
11 | | - typedef EnumNamespace EnumNameStruct EThis; /* CONCAT NAME */ \ |
12 | | -protected: \ |
13 | | - typedef eEnumType TEnum; \ |
14 | | - \ |
15 | | -public: \ |
16 | | - eEnumType mV; /* member */ \ |
17 | | - constexpr inline EnumNameStruct() \ |
18 | | - : mV(static_cast<TEnum>(_DefaultValue)) \ |
19 | | - {} \ |
20 | | - template<typename V> \ |
21 | | - constexpr inline EnumNameStruct(V Value) \ |
22 | | - : mV(static_cast<TEnum>(Value)) \ |
23 | | - {} \ |
24 | | - constexpr inline EnumNameStruct(const EnumNameStruct& r) \ |
25 | | - : mV(r.mV) \ |
26 | | - {} \ |
27 | | - constexpr inline EnumNameStruct& operator= (const EnumNameStruct& r) throw() \ |
28 | | - { \ |
29 | | - mV = r.mV; \ |
30 | | - return *this; \ |
31 | | - } \ |
32 | | - template<typename V> \ |
33 | | - inline constexpr EnumNameStruct& operator= (const V& Value) throw() \ |
34 | | - { \ |
35 | | - mV = static_cast<TEnum>(Value); \ |
36 | | - return *this; \ |
37 | | - } \ |
38 | | - inline constexpr operator TEnum () const \ |
39 | | - { \ |
40 | | - return mV; \ |
41 | | - } \ |
42 | | - inline constexpr EnumNameStruct& operator++ () /* ++ prefix */ throw() \ |
43 | | - { \ |
44 | | - mV = (TEnum)(mV + 1); /* -V1016 */ \ |
45 | | - return *this; \ |
46 | | - } \ |
47 | | - inline constexpr EnumNameStruct& operator-- () throw() \ |
48 | | - { \ |
49 | | - mV = (TEnum)(mV - 1); /* -V1016 */ \ |
50 | | - return *this; \ |
51 | | - } /* -- prefix */ \ |
52 | | - inline constexpr EnumNameStruct operator++ (int) /* postfix ++ */ throw() \ |
53 | | - { \ |
54 | | - EnumNameStruct t(mV); \ |
55 | | - mV = (TEnum)(mV + 1); /* -V1016 */ \ |
56 | | - return t; \ |
57 | | - } \ |
58 | | - inline constexpr EnumNameStruct operator-- (int) /* postfix -- */ throw() \ |
59 | | - { \ |
60 | | - EnumNameStruct t(mV); \ |
61 | | - mV = (TEnum)(mV - 1); /* -V1016 */ \ |
62 | | - return t; \ |
63 | | - } \ |
64 | | - template<typename V> \ |
65 | | - inline constexpr bool operator== (const V& Value) throw() \ |
66 | | - { \ |
67 | | - return (mV == (TEnum)Value); \ |
68 | | - } \ |
69 | | - template<typename V> \ |
70 | | - inline constexpr bool operator!= (const V& Value) throw() \ |
71 | | - { \ |
72 | | - return !(mV == (TEnum)Value); \ |
73 | | - } \ |
74 | | - template<typename V> \ |
75 | | - inline constexpr volatile EnumNameStruct& operator= (const V& Value) volatile throw() \ |
76 | | - { \ |
77 | | - mV = (TEnum)Value; \ |
78 | | - return *this; \ |
| 9 | +// clang-format off |
| 10 | +#define ENUM_DECLARE_BASE(EnumNamespace, EnumNameStruct, eEnumType, _DefaultValue) \ |
| 11 | +private: \ |
| 12 | + typedef EnumNamespace EnumNameStruct EThis; /* CONCAT NAME */ \ |
| 13 | +protected: \ |
| 14 | + typedef eEnumType TEnum; \ |
| 15 | + \ |
| 16 | +public: \ |
| 17 | + eEnumType mV; /* member */ \ |
| 18 | + constexpr inline EnumNameStruct() : mV(static_cast<TEnum>(_DefaultValue)) {} \ |
| 19 | + template<typename V> \ |
| 20 | + constexpr inline EnumNameStruct(V Value) : mV(static_cast<TEnum>(Value)) {} \ |
| 21 | + constexpr inline EnumNameStruct(const EnumNameStruct& r) : mV(r.mV) {} \ |
| 22 | + constexpr inline EnumNameStruct& operator= (const EnumNameStruct& r) throw() { \ |
| 23 | + mV = r.mV; \ |
| 24 | + return *this; \ |
| 25 | + } \ |
| 26 | + template<typename V> \ |
| 27 | + inline constexpr EnumNameStruct& operator= (const V& Value) throw() { \ |
| 28 | + mV = static_cast<TEnum>(Value); \ |
| 29 | + return *this; \ |
| 30 | + } \ |
| 31 | + inline constexpr operator TEnum () const throw() { return mV; } \ |
| 32 | + inline constexpr TEnum get() const throw() { return mV; } \ |
| 33 | + inline constexpr EnumNameStruct& operator++ () /* ++ prefix */ throw() { \ |
| 34 | + mV = (TEnum)(mV + 1); /* -V1016 */ \ |
| 35 | + return *this; \ |
| 36 | + } \ |
| 37 | + inline constexpr EnumNameStruct& operator-- () throw() { /* --prefix */ \ |
| 38 | + mV = (TEnum)(mV - 1); /* -V1016 */ \ |
| 39 | + return *this; \ |
| 40 | + } \ |
| 41 | + inline constexpr EnumNameStruct operator++ (int) /* postfix ++ */ throw() { \ |
| 42 | + EnumNameStruct t(mV); \ |
| 43 | + mV = (TEnum)(mV + 1); /* -V1016 */ \ |
| 44 | + return t; \ |
| 45 | + } \ |
| 46 | + inline constexpr EnumNameStruct operator-- (int) /* postfix -- */ throw() { \ |
| 47 | + EnumNameStruct t(mV); \ |
| 48 | + mV = (TEnum)(mV - 1); /* -V1016 */ \ |
| 49 | + return t; \ |
| 50 | + } \ |
| 51 | + template<typename V> \ |
| 52 | + inline constexpr bool operator== (const V& Value) throw() { return (mV == (TEnum)Value);} \ |
| 53 | + template<typename V> \ |
| 54 | + inline constexpr bool operator!= (const V& Value) throw() { \ |
| 55 | + return !(mV == (TEnum)Value); \ |
| 56 | + } \ |
| 57 | + template<typename V> \ |
| 58 | + inline constexpr volatile EnumNameStruct& operator= (const V& Value) volatile throw() { \ |
| 59 | + mV = (TEnum)Value; \ |
| 60 | + return *this; \ |
79 | 61 | } |
| 62 | +// clang-format on |
80 | 63 | ////////////////////////////////////////////////////////////////////////// |
81 | 64 |
|
82 | 65 |
|
|
0 commit comments