Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLCORE_ENUMTYPE_H__
00024 #define __PLCORE_ENUMTYPE_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include "PLCore/PLCore.h"
00032
00033
00034
00035
00036
00037 namespace PLCore {
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 template <typename ENUM>
00048 class EnumTypePlain {
00049 };
00050
00051
00052
00053
00054
00055
00056 template <typename ENUM>
00057 class EnumType {
00058
00059
00060
00061
00062
00063 public:
00064 typedef typename ENUM::_BaseType _BaseType;
00065 typedef typename ENUM::_Type _Type;
00066 typedef typename ENUM::_Type _StorageType;
00067
00068
00069
00070
00071
00072 public:
00073 static int GetNumOfEnumValues() {
00074 String sEnum, sDesc;
00075 _Type nValue;
00076 int nIndex = 0;
00077 for (nIndex=0; ENUM::GetEnumValue(nIndex, nValue, sEnum, sDesc); nIndex++)
00078 ;
00079 return nIndex;
00080 }
00081
00082 static String GetEnumName(int nIndex) {
00083 String sEnum, sDesc;
00084 _Type nValue;
00085 ENUM::GetEnumValue(nIndex, nValue, sEnum, sDesc);
00086 return sEnum;
00087 }
00088
00089 static _Type GetEnumValue(const String &sName) {
00090 String sEnum = sName;
00091 String sDesc;
00092 _Type nValue;
00093 ENUM::GetEnumValue(-1, nValue, sEnum, sDesc);
00094 return nValue;
00095 }
00096
00097 static String GetEnumDescription(const String &sName) {
00098 String sEnum = sName;
00099 String sDesc;
00100 _Type nValue;
00101 ENUM::GetEnumValue(-1, nValue, sEnum, sDesc);
00102 return sDesc;
00103 }
00104
00105
00106 };
00107
00108
00109
00110
00111
00112
00113 template <typename ENUM>
00114 class FlagType {
00115
00116
00117
00118
00119
00120 public:
00121 typedef typename PLCore::uint32 _BaseType;
00122 typedef typename ENUM::_Type _Type;
00123 typedef typename ENUM::_Type _StorageType;
00124
00125
00126
00127
00128
00129 public:
00130 static int GetNumOfEnumValues() {
00131 String sEnum, sDesc;
00132 _Type nValue;
00133 int nIndex = 0;
00134 for (nIndex=0; ENUM::GetEnumValue(nIndex, nValue, sEnum, sDesc); nIndex++)
00135 ;
00136 return nIndex;
00137 }
00138
00139 static String GetEnumName(int nIndex) {
00140 String sEnum, sDesc;
00141 _Type nValue;
00142 ENUM::GetEnumValue(nIndex, nValue, sEnum, sDesc);
00143 return sEnum;
00144 }
00145
00146 static _Type GetEnumValue(const String &sName) {
00147 String sEnum = sName;
00148 String sDesc;
00149 _Type nValue;
00150 ENUM::GetEnumValue(-1, nValue, sEnum, sDesc);
00151 return nValue;
00152 }
00153
00154 static String GetEnumDescription(const String &sName) {
00155 String sEnum = sName;
00156 String sDesc;
00157 _Type nValue;
00158 ENUM::GetEnumValue(-1, nValue, sEnum, sDesc);
00159 return sDesc;
00160 }
00161
00162
00163 };
00164
00165
00166
00167
00168
00169 }
00170
00171
00172 #endif // __PLCORE_ENUMTYPE_H__