00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _convert_h
00018 #define _convert_h
00019
00020 #include <spl/IConvertable.h>
00021 #include <spl/Null.h>
00022 #include <spl/Undefined.h>
00023 #include <spl/interp/IJsObject.h>
00024
00034 class Convert
00035 {
00036 private:
00037 Convert() {}
00038 Convert(const Convert& c) {}
00039 Convert& operator =(const Convert& c) {}
00040
00041 public:
00042 inline static bool IsFloat(const Null& c) { return false; }
00043 inline static bool IsFloat(const Null *c) { return false; }
00044 inline static bool IsFloat(const Undefined& c) { return false; }
00045 inline static bool IsFloat(const Undefined *c) { return false; }
00046 inline static bool IsFloat(const IConvertable *c) { String typeName = c->TypeName(); return typeName == "float" || typeName == "double"; }
00047 inline static bool IsFloat(const IConvertable& c) { String typeName = c.TypeName(); return typeName == "float" || typeName == "double"; }
00048 inline static bool IsFloat(char c) { return false; }
00049 inline static bool IsFloat(bool c) { return false; }
00050 inline static bool IsFloat(byte c) { return false; }
00051 inline static bool IsFloat(int16 c) { return false; }
00052 inline static bool IsFloat(int32 c) { return false; }
00053 inline static bool IsFloat(int64 c) { return false; }
00054 inline static bool IsFloat(uint32 c) { return false; }
00055 inline static bool IsFloat(uint64 c) { return false; }
00056 inline static bool IsFloat(const BigInteger& c) { return false; }
00057 inline static bool IsFloat(float32 c) { return true;}
00058 inline static bool IsFloat(float64 c) { return true; }
00059 inline static bool IsFloat(const Decimal& c) { return true; }
00060 inline static bool IsFloat(const DateTime& c) { return false; }
00061 inline static bool IsFloat(const Date& c) { return false; }
00062 inline static bool IsFloat(const String& c) { return false; }
00063 inline static bool IsFloat(const IJsObject& c) { return false; }
00064 inline static bool IsFloat(const IJsObject* c) { return false; }
00065
00066 inline static bool IsInt(const Null& c) { return false; }
00067 inline static bool IsInt(const Null *c) { return false; }
00068 inline static bool IsInt(const Undefined& c) { return false; }
00069 inline static bool IsInt(const Undefined *c) { return false; }
00070 inline static bool IsInt(const IConvertable *c) { String typeName = c->TypeName(); return typeName == "int32" || typeName == "int32" || typeName == "int16"; }
00071 inline static bool IsInt(const IConvertable& c) { String typeName = c.TypeName(); return typeName == "int32" || typeName == "int32" || typeName == "int16"; }
00072 inline static bool IsInt(char c) { return false; }
00073 inline static bool IsInt(bool c) { return false; }
00074 inline static bool IsInt(byte c) { return false; }
00075 inline static bool IsInt(int16 c) { return true; }
00076 inline static bool IsInt(int32 c) { return true; }
00077 inline static bool IsInt(int64 c) { return true; }
00078 inline static bool IsInt(uint32 c) { return false; }
00079 inline static bool IsInt(uint64 c) { return false; }
00080 inline static bool IsInt(const BigInteger& c) { return false; }
00081 inline static bool IsInt(float32 c) { return true;}
00082 inline static bool IsInt(float64 c) { return true; }
00083 inline static bool IsInt(const Decimal& c) { return true; }
00084 inline static bool IsInt(const DateTime& c) { return false; }
00085 inline static bool IsInt(const Date& c) { return false; }
00086 inline static bool IsInt(const String& c) { return false; }
00087 inline static bool IsInt(const IJsObject& c) { return false; }
00088 inline static bool IsInt(const IJsObject* c) { return false; }
00089
00090 inline static bool IsObject(const Null& c) { return false; }
00091 inline static bool IsObject(const Null *c) { return false; }
00092 inline static bool IsObject(const Undefined& c) { return false; }
00093 inline static bool IsObject(const Undefined *c) { return false; }
00094 inline static bool IsObject(const IConvertable *c) { return false; }
00095 inline static bool IsObject(const IConvertable& c) { return false; }
00096 inline static bool IsObject(char c) { return false; }
00097 inline static bool IsObject(bool c) { return false; }
00098 inline static bool IsObject(byte c) { return false; }
00099 inline static bool IsObject(int16 c) { return false; }
00100 inline static bool IsObject(int32 c) { return false; }
00101 inline static bool IsObject(int64 c) { return false; }
00102 inline static bool IsObject(uint32 c) { return false; }
00103 inline static bool IsObject(uint64 c) { return false; }
00104 inline static bool IsObject(const BigInteger& c) { return false; }
00105 inline static bool IsObject(float32 c) { return false;}
00106 inline static bool IsObject(float64 c) { return false; }
00107 inline static bool IsObject(const Decimal& c) { return false; }
00108 inline static bool IsObject(const DateTime& c) { return false; }
00109 inline static bool IsObject(const Date& c) { return false; }
00110 inline static bool IsObject(const String& c) { return false; }
00111 inline static bool IsObject(const IJsObject& c) { return true; }
00112 inline static bool IsObject(const IJsObject* c) { return true; }
00113
00114 inline static bool CanConvertToFloat(const Null& c) { return false; }
00115 inline static bool CanConvertToFloat(const Null *c) { return false; }
00116 inline static bool CanConvertToFloat(const Undefined& c) { return false; }
00117 inline static bool CanConvertToFloat(const Undefined *c) { return false; }
00118 inline static bool CanConvertToFloat(const IConvertable *c) { float64 c2; return c->ToFloat64(c2); }
00119 inline static bool CanConvertToFloat(const IConvertable& c) { float64 c2; return c.ToFloat64(c2); }
00120 inline static bool CanConvertToFloat(char c) { return true; }
00121 inline static bool CanConvertToFloat(bool c) { return false; }
00122 inline static bool CanConvertToFloat(byte c) { return true; }
00123 inline static bool CanConvertToFloat(int16 c) { return true; }
00124 inline static bool CanConvertToFloat(int32 c) { return true; }
00125 inline static bool CanConvertToFloat(int64 c) { return true; }
00126 inline static bool CanConvertToFloat(uint32 c) { return true; }
00127 inline static bool CanConvertToFloat(uint64 c) { return true; }
00128 inline static bool CanConvertToFloat(const BigInteger& c) { return false; }
00129 inline static bool CanConvertToFloat(float32 c) { return true;}
00130 inline static bool CanConvertToFloat(float64 c) { return true; }
00131 inline static bool CanConvertToFloat(const Decimal& c) { return true; }
00132 inline static bool CanConvertToFloat(const DateTime& c) { return false; }
00133 inline static bool CanConvertToFloat(const Date& c) { return false; }
00134 inline static bool CanConvertToFloat(const String& c) { return false; }
00135 inline static bool CanConvertToFloat(const IJsObject& c) { return false; }
00136 inline static bool CanConvertToFloat(const IJsObject* c) { return false; }
00137
00138 inline static bool CanConvertToInt(const Null& c) { return false; }
00139 inline static bool CanConvertToInt(const Null *c) { return false; }
00140 inline static bool CanConvertToInt(const Undefined& c) { return false; }
00141 inline static bool CanConvertToInt(const Undefined *c) { return false; }
00142 inline static bool CanConvertToInt(const IConvertable *c) { int64 c2; return c->ToInt64(c2); }
00143 inline static bool CanConvertToInt(const IConvertable& c) { int64 c2; return c.ToInt64(c2); }
00144 inline static bool CanConvertToInt(char c) { return true; }
00145 inline static bool CanConvertToInt(bool c) { return false; }
00146 inline static bool CanConvertToInt(byte c) { return true; }
00147 inline static bool CanConvertToInt(int16 c) { return true; }
00148 inline static bool CanConvertToInt(int32 c) { return true; }
00149 inline static bool CanConvertToInt(int64 c) { return true; }
00150 inline static bool CanConvertToInt(uint32 c) { return true; }
00151 inline static bool CanConvertToInt(uint64 c) { return false; }
00152 inline static bool CanConvertToInt(const BigInteger& c) { return false; }
00153 inline static bool CanConvertToInt(float32 c) { return true;}
00154 inline static bool CanConvertToInt(float64 c) { return true; }
00155 inline static bool CanConvertToInt(const Decimal& c) { return true; }
00156 inline static bool CanConvertToInt(const DateTime& c) { return false; }
00157 inline static bool CanConvertToInt(const Date& c) { return false; }
00158 inline static bool CanConvertToInt(const String& c) { return false; }
00159 inline static bool CanConvertToInt(const IJsObject& c) { return false; }
00160 inline static bool CanConvertToInt(const IJsObject* c) { return false; }
00161
00162 inline static bool ToChar(const Null& c, char& c2) { c2 = 0; return true; }
00163 inline static bool ToChar(const Null *c, char& c2) { c2 = 0; return true; }
00164 inline static bool ToChar(const Undefined& c, char& c2) { return false; }
00165 inline static bool ToChar(const Undefined *c, char& c2) { return false; }
00166 inline static bool ToChar(const IConvertable *c, char& c2) { return c->ToChar(c2); }
00167 inline static bool ToChar(const IConvertable& c, char& c2) { return c.ToChar(c2); }
00168 inline static bool ToChar(char c, char& c2) { c2 = c; return true; }
00169 inline static bool ToChar(bool c, char& c2) { c2 = c ? 'T' : 'F'; return true; }
00170 inline static bool ToChar(byte c, char& c2) { c2 = (char)c; return true; }
00171 inline static bool ToChar(int16 c, char& c2) { c2 = (char)c; return true; }
00172 inline static bool ToChar(int32 c, char& c2) { c2 = (char)c; return true; }
00173 inline static bool ToChar(int64 c, char& c2) { c2 = (char)c; return true; }
00174 inline static bool ToChar(uint32 c, char& c2) { c2 = (char)c; return true; }
00175 inline static bool ToChar(uint64 c, char& c2) { c2 = (char)c; return true; }
00176 inline static bool ToChar(const BigInteger& c, char& c2) { return false; }
00177 inline static bool ToChar(float32 c, char& c2) { c2 = (char)(int)c; return true;}
00178 inline static bool ToChar(float64 c, char& c2) { c2 = (char)(int)c; return true; }
00179 inline static bool ToChar(const DateTime& c, char& c2) { return false; }
00180 inline static bool ToChar(const Date& c, char& c2) { return false; }
00181 inline static bool ToChar(const String& c, char& c2) { c2 = c.Length() == 0 ? '\0' : c.CharAt(0); return true; }
00182 inline static bool ToChar(const Decimal& c, char& c2) { return false; }
00183 inline static bool ToChar(const IJsObject& c, char& c2) { return false; }
00184 inline static bool ToChar(const IJsObject* c, char& c2) { return false; }
00185
00186 inline static bool ToBool(const Null& c, bool& c2) { c2 = false; return true; }
00187 inline static bool ToBool(const Null *c, bool& c2) { c2 = false; return true; }
00188 inline static bool ToBool(const Undefined& c, bool& c2) { return false; }
00189 inline static bool ToBool(const Undefined *c, bool& c2) { return false; }
00190 inline static bool ToBool(const IConvertable *c, bool& c2) { return c->ToBool(c2); }
00191 inline static bool ToBool(const IConvertable& c, bool& c2) { return c.ToBool(c2); }
00192 inline static bool ToBool(char c, bool& c2) { c2 = c != 0; return true; }
00193 inline static bool ToBool(bool c, bool& c2) { c2 = c; return true; }
00194 inline static bool ToBool(byte c, bool& c2) { c2 = c != 0; return true; }
00195 inline static bool ToBool(int16 c, bool& c2) { c2 = c != 0; return true; }
00196 inline static bool ToBool(int32 c, bool& c2) { c2 = c != 0; return true; }
00197 inline static bool ToBool(int64 c, bool& c2) { c2 = c != 0; return true; }
00198 inline static bool ToBool(uint32 c, bool& c2) { c2 = c != 0; return true; }
00199 inline static bool ToBool(uint64 c, bool& c2) { c2 = c != 0; return true; }
00200 inline static bool ToBool(BigInteger& c, bool& c2) { c2 = c != 0; return true; }
00201 inline static bool ToBool(float32 c, bool& c2) { c2 = c != 0; return true;}
00202 inline static bool ToBool(float64 c, bool& c2) { c2 = c != 0; return true; }
00203 inline static bool ToBool(const DateTime& c, bool& c2) { return false; }
00204 inline static bool ToBool(const Date& c, bool& c2) { return false; }
00205 inline static bool ToBool(const String& c, bool& b) { b = c.EqualsIgnoreCase("true"); return true; }
00206 inline static bool ToBool(const Decimal& c, bool& c2) { return false; }
00207 inline static bool ToBool(const IJsObject& c, bool& c2) { c2 = true; return true; }
00208 inline static bool ToBool(const IJsObject* c, bool& c2) { c2 = true; return true; }
00209
00210 inline static bool ToByte(const Null& c, byte& c2) { c2 = 0; return true; }
00211 inline static bool ToByte(const Null *c, byte& c2) { c2 = 0; return true; }
00212 inline static bool ToByte(const Undefined& c, byte& c2) { return false; }
00213 inline static bool ToByte(const Undefined *c, byte& c2) { return false; }
00214 inline static bool ToByte(const IConvertable *c, byte& c2) { return c->ToByte(c2); }
00215 inline static bool ToByte(const IConvertable& c, byte& c2) { return c.ToByte(c2); }
00216 inline static bool ToByte(char c, byte& c2) { c2 = (int8)c; return true; }
00217 inline static bool ToByte(bool c, byte& c2) { c2 = c ? 1 : 0; return true; }
00218 inline static bool ToByte(byte c, byte& c2) { c2 = (int8)c; return true; }
00219 inline static bool ToByte(int16 c, byte& c2) { c2 = (int8)c; return true; }
00220 inline static bool ToByte(int32 c, byte& c2) { c2 = (int8)c; return true; }
00221 inline static bool ToByte(int64 c, byte& c2) { c2 = (int8)c; return true; }
00222 inline static bool ToByte(uint32 c, byte& c2) { c2 = (int8)c; return true; }
00223 inline static bool ToByte(uint64 c, byte& c2) { c2 = (int8)c; return true; }
00224 inline static bool ToByte(BigInteger& c, byte& c2) { return false; }
00225 inline static bool ToByte(float32 c, byte& c2) { c2 = (int8)c; return true;}
00226 inline static bool ToByte(float64 c, byte& c2) { c2 = (int8)c; return true; }
00227 inline static bool ToByte(const DateTime& c, byte& c2) { return false; }
00228 inline static bool ToByte(const Date& c, byte& c2) { return false; }
00229 inline static bool ToByte(const String& c, byte& c2)
00230 {
00231 if (UInt32::IsInt(c))
00232 {
00233 c2 = (byte)UInt32::Parse(c);
00234 return true;
00235 }
00236 return false;
00237 }
00238 inline static bool ToByte(const Decimal& c, byte& c2) { return false; }
00239 inline static bool ToByte(const IJsObject& c, byte& c2) { return false; }
00240 inline static bool ToByte(const IJsObject* c, byte& c2) { return false; }
00241
00242 inline static bool ToInt16(const Null& c, int16& c2) { c2 = 0; return true; }
00243 inline static bool ToInt16(const Null *c, int16& c2) { c2 = 0; return true; }
00244 inline static bool ToInt16(const Undefined& c, int16& c2) { return false; }
00245 inline static bool ToInt16(const Undefined *c, int16& c2) { return false; }
00246 inline static bool ToInt16(const IConvertable *c, int16& c2) { return c->ToInt16(c2); }
00247 inline static bool ToInt16(const IConvertable& c, int16& c2) { return c.ToInt16(c2); }
00248 inline static bool ToInt16(char c, int16& c2) { c2 = c; return true; }
00249 inline static bool ToInt16(bool c, int16& c2) { c2 = c ? 1 : 0; return true; }
00250 inline static bool ToInt16(byte c, int16& c2) { c2 = (int16)c; return true; }
00251 inline static bool ToInt16(int16 c, int16& c2) { c2 = (int16)c; return true; }
00252 inline static bool ToInt16(int32 c, int16& c2) { c2 = (int16)c; return true; }
00253 inline static bool ToInt16(int64 c, int16& c2) { c2 = (int16)c; return true; }
00254 inline static bool ToInt16(uint32 c, int16& c2) { c2 = (int16)c; return true; }
00255 inline static bool ToInt16(uint64 c, int16& c2) { c2 = (int16)c; return true; }
00256 inline static bool ToInt16(BigInteger& c, int16& c2) { return false; }
00257 inline static bool ToInt16(float32 c, int16& c2) { c2 = (int16)c; return true;}
00258 inline static bool ToInt16(float64 c, int16& c2) { c2 = (int16)c; return true; }
00259 inline static bool ToInt16(const DateTime& c, int16& c2) { return false; }
00260 inline static bool ToInt16(const Date& c, int16& c2) { return false; }
00261 inline static bool ToInt16(const String& c, int16& c2)
00262 {
00263 if (Int32::IsInt(c))
00264 {
00265 c2 = Int32::Parse(c);
00266 return true;
00267 }
00268 return false;
00269 }
00270 inline static bool ToInt16(const Decimal& c, int16& c2) { c2 = c.ToInt(); return true; }
00271 inline static bool ToInt16(const IJsObject& c, int16& c2) { return false; }
00272 inline static bool ToInt16(const IJsObject* c, int16& c2) { return false; }
00273
00274 inline static bool ToInt32(const Null& c, int32& c2) { c2 = 0; return true; }
00275 inline static bool Toint32(const Null *c, int32& c2) { c2 = 0; return true; }
00276 inline static bool ToInt32(const Undefined& c, int32& c2) { return false; }
00277 inline static bool Toint32(const Undefined *c, int32& c2) { return false; }
00278 inline static bool ToInt32(const IConvertable *c, int32& c2) { return c->ToInt32(c2); }
00279 inline static bool ToInt32(const IConvertable& c, int32& c2) { return c.ToInt32(c2); }
00280 inline static bool ToInt32(char c, int32& c2) { c2 = c; return true; }
00281 inline static bool ToInt32(bool c, int32& c2) { c2 = c ? 1 : 0; return true; }
00282 inline static bool ToInt32(byte c, int32& c2) { c2 = (int32)c; return true; }
00283 inline static bool ToInt32(int16 c, int32& c2) { c2 = (int32)c; return true; }
00284 inline static bool ToInt32(int32 c, int32& c2) { c2 = (int32)c; return true; }
00285 inline static bool ToInt32(int64 c, int32& c2) { c2 = (int32)c; return true; }
00286 inline static bool ToInt32(uint32 c, int32& c2) { c2 = (int32)c; return true; }
00287 inline static bool ToInt32(uint64 c, int32& c2) { c2 = (int32)c; return true; }
00288 inline static bool ToInt32(BigInteger& c, int32& c2) { c2 = (int32)c.ToInt(); return true; }
00289 inline static bool ToInt32(float32 c, int32& c2) { c2 = (int32)c; return true;}
00290 inline static bool ToInt32(float64 c, int32& c2) { c2 = (int32)c; return true; }
00291 inline static bool ToInt32(const DateTime& c, int32& c2) { return false; }
00292 inline static bool ToInt32(const Date& c, int32& c2) { c2 = c.ToRevInt(); return true; }
00293 inline static bool ToInt32(const String& c, int32& c2)
00294 {
00295 if (Int32::IsInt(c))
00296 {
00297 c2 = Int32::Parse(c);
00298 return true;
00299 }
00300 return false;
00301 }
00302 inline static bool ToInt32(const Decimal& c, int32& c2) { c2 = c.ToInt(); return true; }
00303 inline static bool ToInt32(const IJsObject& c, int32& c2) { return false; }
00304 inline static bool ToInt32(const IJsObject* c, int32& c2) { return false; }
00305
00306 inline static bool ToInt64(const Null& c, int64& c2) { c2 = 0; return true; }
00307 inline static bool ToInt64(const Null *c, int64& c2) { c2 = 0; return true; }
00308 inline static bool ToInt64(const Undefined& c, int64& c2) { return false; }
00309 inline static bool ToInt64(const Undefined *c, int64& c2) { return false; }
00310 inline static bool ToInt64(const IConvertable *c, int64& c2) { return c->ToInt64(c2); }
00311 inline static bool ToInt64(const IConvertable& c, int64& c2) { return c.ToInt64(c2); }
00312 inline static bool ToInt64(char c, int64& c2) { c2 = c; return true; }
00313 inline static bool ToInt64(bool c, int64& c2) { c2 = c ? 1 : 0; return true; }
00314 inline static bool ToInt64(byte c, int64& c2) { c2 = (int64)c; return true; }
00315 inline static bool ToInt64(int16 c, int64& c2) { c2 = (int64)c; return true; }
00316 inline static bool ToInt64(int32 c, int64& c2) { c2 = (int64)c; return true; }
00317 inline static bool ToInt64(int64 c, int64& c2) { c2 = (int64)c; return true; }
00318 inline static bool ToInt64(uint32 c, int64& c2) { c2 = (int64)c; return true; }
00319 inline static bool ToInt64(uint64 c, int64& c2) { c2 = (int64)c; return true; }
00320 inline static bool ToInt64(BigInteger& c, int64& c2) { c2 = c.ToInt(); return true; }
00321 inline static bool ToInt64(float32 c, int64& c2) { c2 = (int)c; return true;}
00322 inline static bool ToInt64(float64 c, int64& c2) { c2 = (int)c; return true; }
00323 inline static bool ToInt64(const DateTime& c, int64& c2) { return false; }
00324 inline static bool ToInt64(const Date& c, int64& c2) { c2 = c.ToRevInt(); return true; }
00325 inline static bool ToInt64(const String& c, int64& c2)
00326 {
00327 if (Int64::IsInt(c))
00328 {
00329 c2 = Int64::Parse(c);
00330 return true;
00331 }
00332 return false;
00333 }
00334 inline static bool ToInt64(const Decimal& c, int64& c2) { c2 = c.ToInt(); return true; }
00335 inline static bool ToInt64(const IJsObject& c, int64& c2) { return false; }
00336 inline static bool ToInt64(const IJsObject* c, int64& c2) { return false; }
00337
00338 inline static bool ToUInt32(const Null& c, uint32& c2) { c2 = 0; return true; }
00339 inline static bool ToUInt32(const Null *c, uint32& c2) { c2 = 0; return true; }
00340 inline static bool ToUInt32(const Undefined& c, uint32& c2) { return false; }
00341 inline static bool ToUInt32(const Undefined *c, uint32& c2) { return false; }
00342 inline static bool ToUInt32(const IConvertable *c, uint32& c2) { return c->ToUInt32(c2); }
00343 inline static bool ToUInt32(const IConvertable& c, uint32& c2) { return c.ToUInt32(c2); }
00344 inline static bool ToUInt32(char c, uint32& c2) { c2 = c; return true; }
00345 inline static bool ToUInt32(bool c, uint32& c2) { c2 = c ? 1 : 0; return true; }
00346 inline static bool ToUInt32(byte c, uint32& c2) { c2 = (uint32)c; return true; }
00347 inline static bool ToUInt32(int16 c, uint32& c2) { c2 = (uint32)c; return true; }
00348 inline static bool ToUInt32(int32 c, uint32& c2) { c2 = (uint32)c; return true; }
00349 inline static bool ToUInt32(int64 c, uint32& c2) { c2 = (uint32)c; return true; }
00350 inline static bool ToUInt32(uint32 c, uint32& c2) { c2 = (uint32)c; return true; }
00351 inline static bool ToUInt32(uint64 c, uint32& c2) { c2 = (uint32)c; return true; }
00352 inline static bool ToUInt32(BigInteger& c, uint32& c2) { c2 = (uint32)c.ToInt(); return true; }
00353 inline static bool ToUInt32(float32 c, uint32& c2) { c2 = (uint32)c; return true;}
00354 inline static bool ToUInt32(float64 c, uint32& c2) { c2 = (uint32)c; return true; }
00355 inline static bool ToUInt32(const DateTime& c, uint32& c2) { return false; }
00356 inline static bool ToUInt32(const Date& c, uint32& c2) { c2 = c.ToRevInt(); return true; }
00357 inline static bool ToUInt32(const String& c, uint32& c2)
00358 {
00359 if (UInt32::IsInt(c))
00360 {
00361 c2 = UInt32::Parse(c);
00362 return true;
00363 }
00364 return false;
00365 }
00366 inline static bool ToUInt32(const Decimal& c, uint32& c2) { c2 = c.ToInt(); return true; }
00367 inline static bool ToUInt32(const IJsObject& c, uint32& c2) { return false; }
00368 inline static bool ToUInt32(const IJsObject* c, uint32& c2) { return false; }
00369
00370 inline static bool ToUInt64(const Null& c, uint64& c2) { c2 = 0; return true; }
00371 inline static bool ToUInt64(const Null *c, uint64& c2) { c2 = 0; return true; }
00372 inline static bool ToUInt64(const Undefined& c, uint64& c2) { return false; }
00373 inline static bool ToUInt64(const Undefined *c, uint64& c2) { return false; }
00374 inline static bool ToUInt64(const IConvertable *c, uint64& c2) { return c->ToUInt64(c2); }
00375 inline static bool ToUInt64(const IConvertable& c, uint64& c2) { return c.ToUInt64(c2); }
00376 inline static bool ToUInt64(char c, uint64& c2) { c2 = c; return true; }
00377 inline static bool ToUInt64(bool c, uint64& c2) { c2 = c ? 1 : 0; return true; }
00378 inline static bool ToUInt64(byte c, uint64& c2) { c2 = (uint64)c; return true; }
00379 inline static bool ToUInt64(int16 c, uint64& c2) { c2 = (uint64)c; return true; }
00380 inline static bool ToUInt64(int32 c, uint64& c2) { c2 = (uint64)c; return true; }
00381 inline static bool ToUInt64(int64 c, uint64& c2) { c2 = (uint64)c; return true; }
00382 inline static bool ToUInt64(uint32 c, uint64& c2) { c2 = (uint64)c; return true; }
00383 inline static bool ToUInt64(uint64 c, uint64& c2) { c2 = (uint64)c; return true; }
00384 inline static bool ToUInt64(BigInteger& c, uint64& c2) { c2 = c.ToInt(); return true; }
00385 inline static bool ToUInt64(float32 c, uint64& c2) { c2 = (uint64)c; return true;}
00386 inline static bool ToUInt64(float64 c, uint64& c2) { c2 = (uint64)c; return true; }
00387 inline static bool ToUInt64(const DateTime& c, uint64& c2) { return false; }
00388 inline static bool ToUInt64(const Date& c, uint64& c2) { c2 = c.ToRevInt(); return true; }
00389 inline static bool ToUInt64(const String& c, uint64& c2)
00390 {
00391 if (UInt64::IsInt(c))
00392 {
00393 c2 = UInt64::Parse(c);
00394 return true;
00395 }
00396 return false;
00397 }
00398 inline static bool ToUInt64(const Decimal& c, uint64& c2) { c2 = c.ToInt(); return true; }
00399 inline static bool ToUInt64(const IJsObject& c, uint64& c2) { return false; }
00400 inline static bool ToUInt64(const IJsObject* c, uint64& c2) { return false; }
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433 inline static bool ToFloat32(const Null& c, float32& c2) { c2 = 0; return true; }
00434 inline static bool ToFloat32(const Null *c, float32& c2) { c2 = 0; return true; }
00435 inline static bool ToFloat32(const Undefined& c, float32& c2) { return false; }
00436 inline static bool ToFloat32(const Undefined *c, float32& c2) { return false; }
00437 inline static bool ToFloat32(const IConvertable *c, float32& c2) { return c->ToFloat32(c2); }
00438 inline static bool ToFloat32(const IConvertable& c, float32& c2) { return c.ToFloat32(c2); }
00439 inline static bool ToFloat32(char c, float32& c2) { c2 = c; return true; }
00440 inline static bool ToFloat32(bool c, float32& c2) { c2 = c ? 1.0f : 0.0f; return true; }
00441 inline static bool ToFloat32(byte c, float32& c2) { c2 = (float32)c; return true; }
00442 inline static bool ToFloat32(int16 c, float32& c2) { c2 = (float32)c; return true; }
00443 inline static bool ToFloat32(int32 c, float32& c2) { c2 = (float32)c; return true; }
00444 inline static bool ToFloat32(int64 c, float32& c2) { c2 = (float32)c; return true; }
00445 inline static bool ToFloat32(uint32 c, float32& c2) { c2 = (float32)c; return true; }
00446 inline static bool ToFloat32(uint64 c, float32& c2) { c2 = (float32)c; return true; }
00447 inline static bool ToFloat32(BigInteger& c, float32& c2) { c2 = (float32)c.ToInt(); return true; }
00448 inline static bool ToFloat32(float32 c, float32& c2) { c2 = (float32)c; return true;}
00449 inline static bool ToFloat32(float64 c, float32& c2) { c2 = (float32)c; return true; }
00450 inline static bool ToFloat32(const DateTime& c, float32& c2) { return false; }
00451 inline static bool ToFloat32(const Date& c, float32& c2) { c2 = (float32)c.ToRevInt(); return true; }
00452 inline static bool ToFloat32(const String& c, float32& c2)
00453 {
00454 if (Double::IsDouble(c))
00455 {
00456 c2 = (float32)Double::Parse(c);
00457 return true;
00458 }
00459 return false;
00460 }
00461 inline static bool ToFloat32(const Decimal& c, float32& c2) { c2 = (float32)c.ToDouble(); return true; }
00462 inline static bool ToFloat32(const IJsObject& c, float32& c2) { return false; }
00463 inline static bool ToFloat32(const IJsObject* c, float32& c2) { return false; }
00464
00465 inline static bool ToFloat64(const Null& c, float64& c2) { c2 = 0; return true; }
00466 inline static bool ToFloat64(const Null *c, float64& c2) { c2 = 0; return true; }
00467 inline static bool ToFloat64(const Undefined& c, float64& c2) { return false; }
00468 inline static bool ToFloat64(const Undefined *c, float64& c2) { return false; }
00469 inline static bool ToFloat64(const IConvertable *c, float64& c2) { return c->ToFloat64(c2); }
00470 inline static bool ToFloat64(const IConvertable& c, float64& c2) { return c.ToFloat64(c2); }
00471 inline static bool ToFloat64(char c, float64& c2) { c2 = c; return true; }
00472 inline static bool ToFloat64(bool c, float64& c2) { c2 = c ? 1.0 : 0.0; return true; }
00473 inline static bool ToFloat64(byte c, float64& c2) { c2 = (float64)c; return true; }
00474 inline static bool ToFloat64(int16 c, float64& c2) { c2 = (float64)c; return true; }
00475 inline static bool ToFloat64(int32 c, float64& c2) { c2 = (float64)c; return true; }
00476 inline static bool ToFloat64(int64 c, float64& c2) { c2 = (float64)c; return true; }
00477 inline static bool ToFloat64(uint32 c, float64& c2) { c2 = (float64)c; return true; }
00478 inline static bool ToFloat64(uint64 c, float64& c2) { c2 = (float64)c; return true; }
00479 inline static bool ToFloat64(BigInteger& c, float64& c2) { c2 = (float64)c.ToInt(); return true; }
00480 inline static bool ToFloat64(float32 c, float64& c2) { c2 = (float64)c; return true;}
00481 inline static bool ToFloat64(float64 c, float64& c2) { c2 = (float64)c; return true; }
00482 inline static bool ToFloat64(const DateTime& c, float64& c2) { return false; }
00483 inline static bool ToFloat64(const Date& c, float64& c2) { c2 = c.ToRevInt(); return true; }
00484 inline static bool ToFloat64(const String& c, float64& c2)
00485 {
00486 if (Double::IsDouble(c))
00487 {
00488 c2 = Double::Parse(c);
00489 return true;
00490 }
00491 return false;
00492 }
00493 inline static bool ToFloat64(const Decimal& c, float64& c2) { c2 = c.ToDouble(); return true; }
00494 inline static bool ToFloat64(const IJsObject& c, float64& c2) { return false; }
00495 inline static bool ToFloat64(const IJsObject* c, float64& c2) { return false; }
00496
00497 inline static bool ToDateTime(const Null& c, DateTime& c2) { return false; }
00498 inline static bool ToDateTime(const Null *c, DateTime& c2) { return false; }
00499 inline static bool ToDateTime(const Undefined& c, DateTime& c2) { return false; }
00500 inline static bool ToDateTime(const Undefined *c, DateTime& c2) { return false; }
00501 inline static bool ToDateTime(const IConvertable *c, DateTime& c2) { return c->ToDateTime(c2); }
00502 inline static bool ToDateTime(const IConvertable& c, DateTime& c2) { return c.ToDateTime(c2); }
00503 inline static bool ToDateTime(char c, DateTime& c2) { return false; }
00504 inline static bool ToDateTime(bool c, DateTime& c2) { return false; }
00505 inline static bool ToDateTime(byte c, DateTime& c2) { return false; }
00506 inline static bool ToDateTime(int16 c, DateTime& c2) { return false; }
00507 inline static bool ToDateTime(int32 c, DateTime& c2) { return false; }
00508 inline static bool ToDateTime(int64 c, DateTime& c2) { return false; }
00509 inline static bool ToDateTime(uint32 c, DateTime& c2) { return false; }
00510 inline static bool ToDateTime(uint64 c, DateTime& c2) { return false; }
00511 inline static bool ToDateTime(BigInteger& c, DateTime& c2) { return false; }
00512 inline static bool ToDateTime(float32 c, DateTime& c2) { return false; }
00513 inline static bool ToDateTime(float64 c, DateTime& c2) { return false; }
00514 inline static bool ToDateTime(const DateTime& c, DateTime& c2) { c2 = c; return true; }
00515 inline static bool ToDateTime(Date& c, DateTime& c2) { c2 = DateTime(c.ToSysTime()); return true; }
00516 inline static bool ToDateTime(const String& c, DateTime& c2)
00517 {
00518 if (DateTime::IsDateTime(c))
00519 {
00520 c2 = DateTime::Parse(c);
00521 return true;
00522 }
00523 return false;
00524 }
00525 inline static bool ToDateTime(const Decimal& c, DateTime& c2) { return false; }
00526 inline static bool ToDateTime(const IJsObject& c, DateTime& c2) { return false; }
00527 inline static bool ToDateTime(const IJsObject* c, DateTime& c2) { return false; }
00528
00529 inline static bool ToDate(const Null& c, Date& c2) { return false; }
00530 inline static bool ToDate(const Null *c, Date& c2) { return false; }
00531 inline static bool ToDate(const Undefined& c, Date& c2) { return false; }
00532 inline static bool ToDate(const Undefined *c, Date& c2) { return false; }
00533 inline static bool ToDate(const IConvertable *c, Date& c2) { return c->ToDate(c2); }
00534 inline static bool ToDate(const IConvertable& c, Date& c2) { return c.ToDate(c2); }
00535 inline static bool ToDate(char c, Date& c2) { return false; }
00536 inline static bool ToDate(bool c, Date& c2) { return false; }
00537 inline static bool ToDate(byte c, Date& c2) { return false; }
00538 inline static bool ToDate(int16 c, Date& c2) { return false; }
00539 inline static bool ToDate(int32 c, Date& c2) { return false; }
00540 inline static bool ToDate(int64 c, Date& c2) { return false; }
00541 inline static bool ToDate(uint32 c, Date& c2) { return false; }
00542 inline static bool ToDate(uint64 c, Date& c2) { return false; }
00543 inline static bool ToDate(BigInteger& c, Date& c2) { return false; }
00544 inline static bool ToDate(float32 c, Date& c2) { return false; }
00545 inline static bool ToDate(float64 c, Date& c2) { return false; }
00546 inline static bool ToDate(const DateTime& c, Date& c2) { c2 = c.DatePart(); return true; }
00547 inline static bool ToDate(const Date& c, Date& c2) { c2 = c; return true; }
00548 inline static bool ToDate(const String& c, Date& c2)
00549 {
00550 if (Date::IsDate(c))
00551 {
00552 c2 = Date::Parse(c);
00553 return true;
00554 }
00555 return false;
00556 }
00557 inline static bool ToDate(const Decimal& c, Date& c2) { return false; }
00558 inline static bool ToDate(const IJsObject& c, Date& c2) { return false; }
00559 inline static bool ToDate(const IJsObject* c, Date& c2) { return false; }
00560
00561 inline static bool ToDecimal(const Null& c, Decimal& c2) { c2 = 0; return true; }
00562 inline static bool ToDecimal(const Null *c, Decimal& c2) { c2 = 0; return true; }
00563 inline static bool ToDecimal(const Undefined& c, Decimal& c2) { return false; }
00564 inline static bool ToDecimal(const Undefined *c, Decimal& c2) { return false; }
00565 inline static bool ToDecimal(const IConvertable *c, Decimal& c2) { return c->ToDecimal(c2); }
00566 inline static bool ToDecimal(const IConvertable& c, Decimal& c2) { return c.ToDecimal(c2); }
00567 inline static bool ToDecimal(char c, Decimal& c2) { c2 = (int)c; return true; }
00568 inline static bool ToDecimal(bool c, Decimal& c2) { c2 = c ? 1 : 0; return true; }
00569 inline static bool ToDecimal(byte c, Decimal& c2) { c2 = (int)c; return true; }
00570 inline static bool ToDecimal(int16 c, Decimal& c2) { c2 = (int)c; return true; }
00571 inline static bool ToDecimal(int32 c, Decimal& c2) { c2 = (int)c; return true; }
00572 inline static bool ToDecimal(int64 c, Decimal& c2) { c2 = c; return true; }
00573 inline static bool ToDecimal(uint32 c, Decimal& c2) { c2 = (int64)c; return true; }
00574 inline static bool ToDecimal(uint64 c, Decimal& c2) { c2 = (int64)c; return true; }
00575 inline static bool ToDecimal(BigInteger& c, Decimal& c2) { c2 = c.ToInt(); return true; }
00576 inline static bool ToDecimal(float32 c, Decimal& c2) { c2 = c; return true;}
00577 inline static bool ToDecimal(float64 c, Decimal& c2) { c2 = c; return true; }
00578 inline static bool ToDecimal(const DateTime& c, Decimal& c2) { return false; }
00579 inline static bool ToDecimal(const Date& c, Decimal& c2) { return false; }
00580 inline static bool ToDecimal(const String& c, Decimal& c2)
00581 {
00582 if (Double::IsDouble(c))
00583 {
00584 c2 = Decimal::Parse(c);
00585 return true;
00586 }
00587 return false;
00588 }
00589 inline static bool ToDecimal(const Decimal& c, Decimal& c2) { c2 = c; return true; }
00590 inline static bool ToDecimal(const IJsObject& c, Decimal& c2) { return false; }
00591 inline static bool ToDecimal(const IJsObject* c, Decimal& c2) { return false; }
00592
00593 inline static bool ToString(const Null& c, String& c2) { c2 = "null"; return true; }
00594 inline static bool ToString(const Null *c, String& c2) { c2 = "null"; return true; }
00595 inline static bool ToString(const Undefined& c, String& c2) { c2 = "undefined"; return true; }
00596 inline static bool ToString(const Undefined *c, String& c2) { c2 = "undefined"; return true; }
00597 inline static bool ToString(const IConvertable *c, String& c2) { return c->ToString(c2); }
00598 inline static bool ToString(const IConvertable& c, String& c2) { return c.ToString(c2); }
00599 inline static bool ToString(char c, String& c2) { char cp[2]; cp[0] = c; cp[1] = 0; c2 = String(cp); return true; }
00600 inline static bool ToString(bool c, String& c2) { c2 = c ? "TRUE" : "FALSE"; return true; }
00601 inline static bool ToString(byte c, String& c2) { c2 = *Int32::ToString((int)c); return true; }
00602 inline static bool ToString(int16 c, String& c2) { c2 = *Int32::ToString((int)c); return true; }
00603 inline static bool ToString(int32 c, String& c2) { c2 = *Int32::ToString(c); return true; }
00604 inline static bool ToString(int64 c, String& c2) { c2 = *Int64::ToString(c); return true; }
00605 inline static bool ToString(uint32 c, String& c2) { c2 = *UInt32::ToString(c); return true; }
00606 inline static bool ToString(uint64 c, String& c2) { c2 = *UInt64::ToString(c); return true; }
00607 inline static bool ToString(BigInteger& c, String& c2) { c2 = c.ToString(); return true; }
00608 inline static bool ToString(float32 c, String& c2) { c2 = *Double::ToString(c); return true;}
00609 inline static bool ToString(float64 c, String& c2) { c2 = *Double::ToString(c); return true; }
00610 inline static bool ToString(const DateTime& c, String& c2) { c2 = *c.ToString(); return true; }
00611 inline static bool ToString(const Date& c, String& c2) { c2 = *c.ToString(); return true; }
00612 inline static bool ToString(const String& c, String& c2) { c2 = c; return true; }
00613 inline static bool ToString(const Decimal& c, String& c2) { c2 = *c.ToString(); return true; }
00614 inline static bool ToString(const IJsObject& c, String& c2) { c2 = *c.ToString(); return true; }
00615 inline static bool ToString(const IJsObject* c, String& c2) { c2 = *c->ToString(); return true; }
00616
00617 inline static bool ToObject(const Null& c, IJsObject& c2) { return false; }
00618 inline static bool ToObject(const Null *c, IJsObject& c2) { return false; }
00619 inline static bool ToObject(const Undefined& c, IJsObject& c2) { return false; }
00620 inline static bool ToObject(const Undefined *c, IJsObject& c2) { return false; }
00621 inline static bool ToObject(const IConvertable *c, IJsObject& c2) { return false; }
00622 inline static bool ToObject(const IConvertable& c, IJsObject& c2) { return false; }
00623 inline static bool ToObject(char c, IJsObject& c2) { return false; }
00624 inline static bool ToObject(bool c, IJsObject& c2) { return false; }
00625 inline static bool ToObject(byte c, IJsObject& c2) { return false; }
00626 inline static bool ToObject(int16 c, IJsObject& c2) { return false; }
00627 inline static bool ToObject(int32 c, IJsObject& c2) { return false; }
00628 inline static bool ToObject(int64 c, IJsObject& c2) { return false; }
00629 inline static bool ToObject(uint32 c, IJsObject& c2) { return false; }
00630 inline static bool ToObject(uint64 c, IJsObject& c2) { return false; }
00631 inline static bool ToObject(BigInteger& c, IJsObject& c2) { return false; }
00632 inline static bool ToObject(float32 c, IJsObject& c2) { return false; }
00633 inline static bool ToObject(float64 c, IJsObject& c2) { return false; }
00634 inline static bool ToObject(const DateTime& c, IJsObject& c2) { return false; }
00635 inline static bool ToObject(const Date& c, IJsObject& c2) { return false; }
00636 inline static bool ToObject(const String& c, IJsObject& c2) { return false; }
00637 inline static bool ToObject(const Decimal& c, IJsObject& c2) { return false; }
00638 inline static bool ToObject(const IJsObject& c, IJsObject& c2) { c2 = c; return true; }
00639 inline static bool ToObject(const IJsObject* c, IJsObject& c2) { c2 = *c; return true; }
00640
00641 inline static String TypeName(const Null& c) { return String("null"); }
00642 inline static String TypeName(const Null *c) { return String("null"); }
00643 inline static String TypeName(const Undefined& c) { return String("undefined"); }
00644 inline static String TypeName(const Undefined *c) { return String("undefined"); }
00645 inline static String TypeName(const IConvertable *c) { return c->TypeName(); }
00646 inline static String TypeName(const IConvertable& c) { return c.TypeName(); }
00647 inline static String TypeName(char c) { return String("char"); }
00648 inline static String TypeName(bool c) { return String("bool"); }
00649 inline static String TypeName(byte c) { return String("byte"); }
00650 inline static String TypeName(int16 c) { return String("int16"); }
00651 inline static String TypeName(int32 c) { return String("int32"); }
00652 inline static String TypeName(int64 c) { return String("int64"); }
00653 inline static String TypeName(uint32 c) { return String("uint32"); }
00654 inline static String TypeName(uint64 c) { return String("uint64"); }
00655 inline static String TypeName(BigInteger& c) { return String("BigInteger"); }
00656 inline static String TypeName(float32 c) { return String("float"); }
00657 inline static String TypeName(float64 c) { return String("double"); }
00658 inline static String TypeName(const DateTime& c) { return String("DateTime"); }
00659 inline static String TypeName(const Date& c) { return String("Date"); }
00660 inline static String TypeName(const String& c) { return String("String"); }
00661 inline static String TypeName(const Decimal& c) { return String("Decimal"); }
00662 inline static String TypeName(const IJsObject& c)
00663 {
00664 StringPtr typeName = c.ToString();
00665 if (typeName->CharAt(0) == '[')
00666 {
00667 return *c.ToString()->Substring(1)->Replace("]", "");
00668 }
00669 if (typeName->IndexOf('{') > -1)
00670 {
00671 return "Function";
00672 }
00673 return *typeName;
00674 }
00675 inline static String TypeName(const IJsObject* c)
00676 {
00677 return TypeName(*c);
00678 }
00679 };
00680
00683 #endif