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_DEFAULTVALUE_H__
00024 #define __PLCORE_DEFAULTVALUE_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include "PLCore/String/String.h"
00032 #include "PLCore/Base/Tools/TypeTraits.h"
00033
00034
00035
00036
00037
00038 namespace PLCore {
00039
00040
00041
00042
00043
00044
00045 template <typename T>
00046 class EnumType;
00047
00048
00049 template <typename T>
00050 class FlagType;
00051
00052 template <typename T>
00053 struct CheckType;
00054
00055
00056
00057
00058
00059 template <typename T>
00060 class DefaultValue : public DefaultValue< typename CheckType<T>::Type > {
00061 };
00062
00063 template <>
00064 class DefaultValue<bool> {
00065 public:
00066 static bool Default() {
00067 return false;
00068 }
00069 };
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 template <>
00082 class DefaultValue<int8> {
00083 public:
00084 static int8 Default() {
00085 return 0;
00086 }
00087 };
00088
00089 template <>
00090 class DefaultValue<int16> {
00091 public:
00092 static int16 Default() {
00093 return 0;
00094 }
00095 };
00096
00097 template <>
00098 class DefaultValue<int32> {
00099 public:
00100 static int32 Default() {
00101 return 0;
00102 }
00103 };
00104
00105 template <>
00106 class DefaultValue<int64> {
00107 public:
00108 static int64 Default() {
00109 return 0;
00110 }
00111 };
00112
00113 template <>
00114 class DefaultValue<uint8> {
00115 public:
00116 static uint8 Default() {
00117 return 0;
00118 }
00119 };
00120
00121 template <>
00122 class DefaultValue<uint16> {
00123 public:
00124 static uint16 Default() {
00125 return 0;
00126 }
00127 };
00128
00129 template <>
00130 class DefaultValue<uint32> {
00131 public:
00132 static uint32 Default() {
00133 return 0;
00134 }
00135 };
00136
00137 template <>
00138 class DefaultValue<uint64> {
00139 public:
00140 static uint64 Default() {
00141 return 0;
00142 }
00143 };
00144
00145 template <>
00146 class DefaultValue<float> {
00147 public:
00148 static float Default() {
00149 return 0.0f;
00150 }
00151 };
00152
00153 template <>
00154 class DefaultValue<double> {
00155 public:
00156 static double Default() {
00157 return 0.0;
00158 }
00159 };
00160
00161 template <>
00162 class DefaultValue<String> {
00163 public:
00164 static String Default() {
00165 return "";
00166 }
00167 };
00168
00169 template <typename T>
00170 class DefaultValue<T*> {
00171 public:
00172 static T* Default() {
00173 return nullptr;
00174 }
00175 };
00176
00177 template <typename T>
00178 class DefaultValue<T&> {
00179 public:
00180 static T& Default() {
00181 return *static_cast<T*>(nullptr);
00182 }
00183 };
00184
00185 template <typename ENUM>
00186 class DefaultValue< EnumTypePlain<ENUM> > {
00187 public:
00188 static ENUM Default() {
00189 return static_cast<ENUM>(0);
00190 }
00191 };
00192
00193 template <typename ENUM>
00194 class DefaultValue< EnumType<ENUM> > {
00195 public:
00196
00197 typedef typename ENUM::_Type _Type;
00198
00199 static _Type Default() {
00200 return DefaultValue<_Type>::Default();
00201 }
00202 };
00203
00204 template <typename ENUM>
00205 class DefaultValue< FlagType<ENUM> > {
00206 public:
00207
00208 typedef typename ENUM::_Type _Type;
00209
00210 static _Type Default() {
00211 return DefaultValue<_Type>::Default();
00212 }
00213 };
00214
00215
00216
00217
00218
00219 }
00220
00221
00222 #endif // __PLCORE_DEFAULTVALUE_H__