| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "core/fxcrt/fx_ext.h" | 9 #include "core/fxcrt/fx_ext.h" |
| 10 #include "core/fxcrt/fx_xml.h" | 10 #include "core/fxcrt/fx_xml.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 CFX_LCNumeric(int64_t integral, | 92 CFX_LCNumeric(int64_t integral, |
| 93 uint32_t fractional = 0, | 93 uint32_t fractional = 0, |
| 94 int32_t exponent = 0); | 94 int32_t exponent = 0); |
| 95 CFX_LCNumeric(FX_FLOAT dbRetValue); | 95 CFX_LCNumeric(FX_FLOAT dbRetValue); |
| 96 CFX_LCNumeric(double dbvalue); | 96 CFX_LCNumeric(double dbvalue); |
| 97 CFX_LCNumeric(CFX_WideString& wsNumeric); | 97 CFX_LCNumeric(CFX_WideString& wsNumeric); |
| 98 | 98 |
| 99 FX_FLOAT GetFloat() const; | 99 FX_FLOAT GetFloat() const; |
| 100 double GetDouble() const; | 100 double GetDouble() const; |
| 101 CFX_WideString ToString() const; | 101 CFX_WideString ToString() const; |
| 102 CFX_WideString ToString(int32_t nTreading, FX_BOOL bTrimTailZeros) const; | 102 CFX_WideString ToString(int32_t nTreading, bool bTrimTailZeros) const; |
| 103 | 103 |
| 104 int64_t m_Integral; | 104 int64_t m_Integral; |
| 105 uint32_t m_Fractional; | 105 uint32_t m_Fractional; |
| 106 int32_t m_Exponent; | 106 int32_t m_Exponent; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 static FX_BOOL FX_WStringToNumeric(const CFX_WideString& wsValue, | 109 static bool FX_WStringToNumeric(const CFX_WideString& wsValue, |
| 110 CFX_LCNumeric& lcnum) { | 110 CFX_LCNumeric& lcnum) { |
| 111 lcnum.m_Integral = 0; | 111 lcnum.m_Integral = 0; |
| 112 lcnum.m_Fractional = 0; | 112 lcnum.m_Fractional = 0; |
| 113 lcnum.m_Exponent = 0; | 113 lcnum.m_Exponent = 0; |
| 114 | 114 |
| 115 if (wsValue.IsEmpty()) | 115 if (wsValue.IsEmpty()) |
| 116 return FALSE; | 116 return false; |
| 117 | 117 |
| 118 const int32_t nIntegralMaxLen = 17; | 118 const int32_t nIntegralMaxLen = 17; |
| 119 int32_t cc = 0; | 119 int32_t cc = 0; |
| 120 bool bNegative = false; | 120 bool bNegative = false; |
| 121 bool bExpSign = false; | 121 bool bExpSign = false; |
| 122 const FX_WCHAR* str = wsValue.c_str(); | 122 const FX_WCHAR* str = wsValue.c_str(); |
| 123 int32_t len = wsValue.GetLength(); | 123 int32_t len = wsValue.GetLength(); |
| 124 while (cc < len && FXSYS_iswspace(str[cc])) | 124 while (cc < len && FXSYS_iswspace(str[cc])) |
| 125 cc++; | 125 cc++; |
| 126 | 126 |
| 127 if (cc >= len) | 127 if (cc >= len) |
| 128 return FALSE; | 128 return false; |
| 129 | 129 |
| 130 if (str[cc] == '+') { | 130 if (str[cc] == '+') { |
| 131 cc++; | 131 cc++; |
| 132 } else if (str[cc] == '-') { | 132 } else if (str[cc] == '-') { |
| 133 bNegative = true; | 133 bNegative = true; |
| 134 cc++; | 134 cc++; |
| 135 } | 135 } |
| 136 int32_t nIntegralLen = 0; | 136 int32_t nIntegralLen = 0; |
| 137 while (cc < len) { | 137 while (cc < len) { |
| 138 if (str[cc] == '.') | 138 if (str[cc] == '.') |
| 139 break; | 139 break; |
| 140 | 140 |
| 141 if (!FXSYS_isDecimalDigit(str[cc])) { | 141 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 142 if ((str[cc] == 'E' || str[cc] == 'e')) | 142 if ((str[cc] == 'E' || str[cc] == 'e')) |
| 143 break; | 143 break; |
| 144 return FALSE; | 144 return false; |
| 145 } | 145 } |
| 146 if (nIntegralLen < nIntegralMaxLen) { | 146 if (nIntegralLen < nIntegralMaxLen) { |
| 147 lcnum.m_Integral = lcnum.m_Integral * 10 + str[cc] - '0'; | 147 lcnum.m_Integral = lcnum.m_Integral * 10 + str[cc] - '0'; |
| 148 nIntegralLen++; | 148 nIntegralLen++; |
| 149 } | 149 } |
| 150 cc++; | 150 cc++; |
| 151 } | 151 } |
| 152 | 152 |
| 153 lcnum.m_Integral = bNegative ? -lcnum.m_Integral : lcnum.m_Integral; | 153 lcnum.m_Integral = bNegative ? -lcnum.m_Integral : lcnum.m_Integral; |
| 154 if (cc < len && str[cc] == '.') { | 154 if (cc < len && str[cc] == '.') { |
| 155 int scale = 0; | 155 int scale = 0; |
| 156 double fraction = 0.0; | 156 double fraction = 0.0; |
| 157 cc++; | 157 cc++; |
| 158 while (cc < len) { | 158 while (cc < len) { |
| 159 if (scale >= FXSYS_FractionalScaleCount()) { | 159 if (scale >= FXSYS_FractionalScaleCount()) { |
| 160 while (cc < len) { | 160 while (cc < len) { |
| 161 if (!FXSYS_isDecimalDigit(str[cc])) | 161 if (!FXSYS_isDecimalDigit(str[cc])) |
| 162 break; | 162 break; |
| 163 cc++; | 163 cc++; |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 if (!FXSYS_isDecimalDigit(str[cc])) { | 166 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 167 if ((str[cc] == 'E' || str[cc] == 'e')) | 167 if ((str[cc] == 'E' || str[cc] == 'e')) |
| 168 break; | 168 break; |
| 169 return FALSE; | 169 return false; |
| 170 } | 170 } |
| 171 fraction += FXSYS_FractionalScale(scale, FXSYS_toDecimalDigit(str[cc])); | 171 fraction += FXSYS_FractionalScale(scale, FXSYS_toDecimalDigit(str[cc])); |
| 172 scale++; | 172 scale++; |
| 173 cc++; | 173 cc++; |
| 174 } | 174 } |
| 175 lcnum.m_Fractional = (uint32_t)(fraction * 4294967296.0); | 175 lcnum.m_Fractional = (uint32_t)(fraction * 4294967296.0); |
| 176 } | 176 } |
| 177 if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { | 177 if (cc < len && (str[cc] == 'E' || str[cc] == 'e')) { |
| 178 cc++; | 178 cc++; |
| 179 if (cc < len) { | 179 if (cc < len) { |
| 180 if (str[cc] == '+') { | 180 if (str[cc] == '+') { |
| 181 cc++; | 181 cc++; |
| 182 } else if (str[cc] == '-') { | 182 } else if (str[cc] == '-') { |
| 183 bExpSign = true; | 183 bExpSign = true; |
| 184 cc++; | 184 cc++; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 while (cc < len) { | 187 while (cc < len) { |
| 188 if (FXSYS_isDecimalDigit(str[cc])) | 188 if (FXSYS_isDecimalDigit(str[cc])) |
| 189 return FALSE; | 189 return false; |
| 190 lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0'; | 190 lcnum.m_Exponent = lcnum.m_Exponent * 10 + str[cc] - '0'; |
| 191 cc++; | 191 cc++; |
| 192 } | 192 } |
| 193 lcnum.m_Exponent = bExpSign ? -lcnum.m_Exponent : lcnum.m_Exponent; | 193 lcnum.m_Exponent = bExpSign ? -lcnum.m_Exponent : lcnum.m_Exponent; |
| 194 } | 194 } |
| 195 return TRUE; | 195 return true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 CFX_LCNumeric::CFX_LCNumeric() { | 198 CFX_LCNumeric::CFX_LCNumeric() { |
| 199 m_Integral = 0; | 199 m_Integral = 0; |
| 200 m_Fractional = 0; | 200 m_Fractional = 0; |
| 201 m_Exponent = 0; | 201 m_Exponent = 0; |
| 202 } | 202 } |
| 203 CFX_LCNumeric::CFX_LCNumeric(int64_t integral, | 203 CFX_LCNumeric::CFX_LCNumeric(int64_t integral, |
| 204 uint32_t fractional, | 204 uint32_t fractional, |
| 205 int32_t exponent) { | 205 int32_t exponent) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 235 double CFX_LCNumeric::GetDouble() const { | 235 double CFX_LCNumeric::GetDouble() const { |
| 236 double value = m_Fractional / 4294967296.0; | 236 double value = m_Fractional / 4294967296.0; |
| 237 value = m_Integral + (m_Integral >= 0 ? value : -value); | 237 value = m_Integral + (m_Integral >= 0 ? value : -value); |
| 238 if (m_Exponent != 0) { | 238 if (m_Exponent != 0) { |
| 239 value *= FXSYS_pow(10, (FX_FLOAT)m_Exponent); | 239 value *= FXSYS_pow(10, (FX_FLOAT)m_Exponent); |
| 240 } | 240 } |
| 241 return value; | 241 return value; |
| 242 } | 242 } |
| 243 | 243 |
| 244 CFX_WideString CFX_LCNumeric::ToString() const { | 244 CFX_WideString CFX_LCNumeric::ToString() const { |
| 245 return ToString(8, TRUE); | 245 return ToString(8, true); |
| 246 } | 246 } |
| 247 | 247 |
| 248 CFX_WideString CFX_LCNumeric::ToString(int32_t nTreading, | 248 CFX_WideString CFX_LCNumeric::ToString(int32_t nTreading, |
| 249 FX_BOOL bTrimTailZeros) const { | 249 bool bTrimTailZeros) const { |
| 250 CFX_WideString wsFormat; | 250 CFX_WideString wsFormat; |
| 251 wsFormat.Format(L"%%.%df", nTreading); | 251 wsFormat.Format(L"%%.%df", nTreading); |
| 252 CFX_WideString wsResult; | 252 CFX_WideString wsResult; |
| 253 wsResult.Format(wsFormat.c_str(), GetDouble()); | 253 wsResult.Format(wsFormat.c_str(), GetDouble()); |
| 254 if (bTrimTailZeros && nTreading > 0) { | 254 if (bTrimTailZeros && nTreading > 0) { |
| 255 wsResult.TrimRight(L"0"); | 255 wsResult.TrimRight(L"0"); |
| 256 wsResult.TrimRight(L"."); | 256 wsResult.TrimRight(L"."); |
| 257 } | 257 } |
| 258 return wsResult; | 258 return wsResult; |
| 259 } | 259 } |
| 260 | 260 |
| 261 CFX_FormatString::CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, FX_BOOL bUseLCID) | 261 CFX_FormatString::CFX_FormatString(IFX_LocaleMgr* pLocaleMgr, bool bUseLCID) |
| 262 : m_pLocaleMgr(pLocaleMgr), m_bUseLCID(bUseLCID) {} | 262 : m_pLocaleMgr(pLocaleMgr), m_bUseLCID(bUseLCID) {} |
| 263 CFX_FormatString::~CFX_FormatString() {} | 263 CFX_FormatString::~CFX_FormatString() {} |
| 264 void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString, | 264 void CFX_FormatString::SplitFormatString(const CFX_WideString& wsFormatString, |
| 265 CFX_WideStringArray& wsPatterns) { | 265 CFX_WideStringArray& wsPatterns) { |
| 266 int32_t iStrLen = wsFormatString.GetLength(); | 266 int32_t iStrLen = wsFormatString.GetLength(); |
| 267 const FX_WCHAR* pStr = wsFormatString.c_str(); | 267 const FX_WCHAR* pStr = wsFormatString.c_str(); |
| 268 const FX_WCHAR* pToken = pStr; | 268 const FX_WCHAR* pToken = pStr; |
| 269 const FX_WCHAR* pEnd = pStr + iStrLen; | 269 const FX_WCHAR* pEnd = pStr + iStrLen; |
| 270 FX_BOOL iQuote = FALSE; | 270 bool iQuote = false; |
| 271 while (TRUE) { | 271 while (true) { |
| 272 if (pStr >= pEnd) { | 272 if (pStr >= pEnd) { |
| 273 CFX_WideString sub(pToken, pStr - pToken); | 273 CFX_WideString sub(pToken, pStr - pToken); |
| 274 wsPatterns.Add(sub); | 274 wsPatterns.Add(sub); |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 if (*pStr == '\'') { | 277 if (*pStr == '\'') { |
| 278 iQuote = !iQuote; | 278 iQuote = !iQuote; |
| 279 } else if (*pStr == L'|' && !iQuote) { | 279 } else if (*pStr == L'|' && !iQuote) { |
| 280 CFX_WideString sub(pToken, pStr - pToken); | 280 CFX_WideString sub(pToken, pStr - pToken); |
| 281 wsPatterns.Add(sub); | 281 wsPatterns.Add(sub); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 wsOutput = pStrPattern[iPattern--] + wsOutput; | 369 wsOutput = pStrPattern[iPattern--] + wsOutput; |
| 370 } | 370 } |
| 371 return wsOutput; | 371 return wsOutput; |
| 372 } | 372 } |
| 373 FX_LOCALECATEGORY CFX_FormatString::GetCategory( | 373 FX_LOCALECATEGORY CFX_FormatString::GetCategory( |
| 374 const CFX_WideString& wsPattern) { | 374 const CFX_WideString& wsPattern) { |
| 375 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; | 375 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; |
| 376 int32_t ccf = 0; | 376 int32_t ccf = 0; |
| 377 int32_t iLenf = wsPattern.GetLength(); | 377 int32_t iLenf = wsPattern.GetLength(); |
| 378 const FX_WCHAR* pStr = wsPattern.c_str(); | 378 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 379 FX_BOOL bBraceOpen = FALSE; | 379 bool bBraceOpen = false; |
| 380 CFX_WideStringC wsConstChars(gs_wsConstChars); | 380 CFX_WideStringC wsConstChars(gs_wsConstChars); |
| 381 while (ccf < iLenf) { | 381 while (ccf < iLenf) { |
| 382 if (pStr[ccf] == '\'') { | 382 if (pStr[ccf] == '\'') { |
| 383 FX_GetLiteralText(pStr, ccf, iLenf); | 383 FX_GetLiteralText(pStr, ccf, iLenf); |
| 384 } else if (!bBraceOpen && wsConstChars.Find(pStr[ccf]) == -1) { | 384 } else if (!bBraceOpen && wsConstChars.Find(pStr[ccf]) == -1) { |
| 385 CFX_WideString wsCategory(pStr[ccf]); | 385 CFX_WideString wsCategory(pStr[ccf]); |
| 386 ccf++; | 386 ccf++; |
| 387 while (TRUE) { | 387 while (true) { |
| 388 if (ccf == iLenf) { | 388 if (ccf == iLenf) { |
| 389 return eCategory; | 389 return eCategory; |
| 390 } | 390 } |
| 391 if (pStr[ccf] == '.' || pStr[ccf] == '(') { | 391 if (pStr[ccf] == '.' || pStr[ccf] == '(') { |
| 392 break; | 392 break; |
| 393 } | 393 } |
| 394 if (pStr[ccf] == '{') { | 394 if (pStr[ccf] == '{') { |
| 395 bBraceOpen = TRUE; | 395 bBraceOpen = true; |
| 396 break; | 396 break; |
| 397 } | 397 } |
| 398 wsCategory += pStr[ccf]; | 398 wsCategory += pStr[ccf]; |
| 399 ccf++; | 399 ccf++; |
| 400 } | 400 } |
| 401 uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringC(), false); | 401 uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringC(), false); |
| 402 if (dwHash == FX_LOCALECATEGORY_DateHash) { | 402 if (dwHash == FX_LOCALECATEGORY_DateHash) { |
| 403 if (eCategory == FX_LOCALECATEGORY_Time) { | 403 if (eCategory == FX_LOCALECATEGORY_Time) { |
| 404 return FX_LOCALECATEGORY_DateTime; | 404 return FX_LOCALECATEGORY_DateTime; |
| 405 } | 405 } |
| 406 eCategory = FX_LOCALECATEGORY_Date; | 406 eCategory = FX_LOCALECATEGORY_Date; |
| 407 } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { | 407 } else if (dwHash == FX_LOCALECATEGORY_TimeHash) { |
| 408 if (eCategory == FX_LOCALECATEGORY_Date) { | 408 if (eCategory == FX_LOCALECATEGORY_Date) { |
| 409 return FX_LOCALECATEGORY_DateTime; | 409 return FX_LOCALECATEGORY_DateTime; |
| 410 } | 410 } |
| 411 eCategory = FX_LOCALECATEGORY_Time; | 411 eCategory = FX_LOCALECATEGORY_Time; |
| 412 } else if (dwHash == FX_LOCALECATEGORY_DateTimeHash) { | 412 } else if (dwHash == FX_LOCALECATEGORY_DateTimeHash) { |
| 413 return FX_LOCALECATEGORY_DateTime; | 413 return FX_LOCALECATEGORY_DateTime; |
| 414 } else if (dwHash == FX_LOCALECATEGORY_TextHash) { | 414 } else if (dwHash == FX_LOCALECATEGORY_TextHash) { |
| 415 return FX_LOCALECATEGORY_Text; | 415 return FX_LOCALECATEGORY_Text; |
| 416 } else if (dwHash == FX_LOCALECATEGORY_NumHash) { | 416 } else if (dwHash == FX_LOCALECATEGORY_NumHash) { |
| 417 return FX_LOCALECATEGORY_Num; | 417 return FX_LOCALECATEGORY_Num; |
| 418 } else if (dwHash == FX_LOCALECATEGORY_ZeroHash) { | 418 } else if (dwHash == FX_LOCALECATEGORY_ZeroHash) { |
| 419 return FX_LOCALECATEGORY_Zero; | 419 return FX_LOCALECATEGORY_Zero; |
| 420 } else if (dwHash == FX_LOCALECATEGORY_NullHash) { | 420 } else if (dwHash == FX_LOCALECATEGORY_NullHash) { |
| 421 return FX_LOCALECATEGORY_Null; | 421 return FX_LOCALECATEGORY_Null; |
| 422 } | 422 } |
| 423 } else if (pStr[ccf] == '}') { | 423 } else if (pStr[ccf] == '}') { |
| 424 bBraceOpen = FALSE; | 424 bBraceOpen = false; |
| 425 } | 425 } |
| 426 ccf++; | 426 ccf++; |
| 427 } | 427 } |
| 428 return eCategory; | 428 return eCategory; |
| 429 } | 429 } |
| 430 static uint16_t FX_WStringToLCID(const FX_WCHAR* pstrLCID) { | 430 static uint16_t FX_WStringToLCID(const FX_WCHAR* pstrLCID) { |
| 431 if (!pstrLCID) { | 431 if (!pstrLCID) { |
| 432 return 0; | 432 return 0; |
| 433 } | 433 } |
| 434 wchar_t* pEnd; | 434 wchar_t* pEnd; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 457 } | 457 } |
| 458 return CFX_WideString(); | 458 return CFX_WideString(); |
| 459 } | 459 } |
| 460 IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, | 460 IFX_Locale* CFX_FormatString::GetTextFormat(const CFX_WideString& wsPattern, |
| 461 const CFX_WideStringC& wsCategory, | 461 const CFX_WideStringC& wsCategory, |
| 462 CFX_WideString& wsPurgePattern) { | 462 CFX_WideString& wsPurgePattern) { |
| 463 IFX_Locale* pLocale = nullptr; | 463 IFX_Locale* pLocale = nullptr; |
| 464 int32_t ccf = 0; | 464 int32_t ccf = 0; |
| 465 int32_t iLenf = wsPattern.GetLength(); | 465 int32_t iLenf = wsPattern.GetLength(); |
| 466 const FX_WCHAR* pStr = wsPattern.c_str(); | 466 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 467 FX_BOOL bBrackOpen = FALSE; | 467 bool bBrackOpen = false; |
| 468 CFX_WideStringC wsConstChars(gs_wsConstChars); | 468 CFX_WideStringC wsConstChars(gs_wsConstChars); |
| 469 while (ccf < iLenf) { | 469 while (ccf < iLenf) { |
| 470 if (pStr[ccf] == '\'') { | 470 if (pStr[ccf] == '\'') { |
| 471 int32_t iCurChar = ccf; | 471 int32_t iCurChar = ccf; |
| 472 FX_GetLiteralText(pStr, ccf, iLenf); | 472 FX_GetLiteralText(pStr, ccf, iLenf); |
| 473 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); | 473 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); |
| 474 } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) { | 474 } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) { |
| 475 CFX_WideString wsSearchCategory(pStr[ccf]); | 475 CFX_WideString wsSearchCategory(pStr[ccf]); |
| 476 ccf++; | 476 ccf++; |
| 477 while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && | 477 while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && |
| 478 pStr[ccf] != '(') { | 478 pStr[ccf] != '(') { |
| 479 wsSearchCategory += pStr[ccf]; | 479 wsSearchCategory += pStr[ccf]; |
| 480 ccf++; | 480 ccf++; |
| 481 } | 481 } |
| 482 if (wsSearchCategory != wsCategory) { | 482 if (wsSearchCategory != wsCategory) { |
| 483 continue; | 483 continue; |
| 484 } | 484 } |
| 485 while (ccf < iLenf) { | 485 while (ccf < iLenf) { |
| 486 if (pStr[ccf] == '(') { | 486 if (pStr[ccf] == '(') { |
| 487 ccf++; | 487 ccf++; |
| 488 CFX_WideString wsLCID; | 488 CFX_WideString wsLCID; |
| 489 while (ccf < iLenf && pStr[ccf] != ')') { | 489 while (ccf < iLenf && pStr[ccf] != ')') { |
| 490 wsLCID += pStr[ccf++]; | 490 wsLCID += pStr[ccf++]; |
| 491 } | 491 } |
| 492 pLocale = GetPatternLocale(wsLCID); | 492 pLocale = GetPatternLocale(wsLCID); |
| 493 } else if (pStr[ccf] == '{') { | 493 } else if (pStr[ccf] == '{') { |
| 494 bBrackOpen = TRUE; | 494 bBrackOpen = true; |
| 495 break; | 495 break; |
| 496 } | 496 } |
| 497 ccf++; | 497 ccf++; |
| 498 } | 498 } |
| 499 } else if (pStr[ccf] != '}') { | 499 } else if (pStr[ccf] != '}') { |
| 500 wsPurgePattern += pStr[ccf]; | 500 wsPurgePattern += pStr[ccf]; |
| 501 } | 501 } |
| 502 ccf++; | 502 ccf++; |
| 503 } | 503 } |
| 504 if (!bBrackOpen) { | 504 if (!bBrackOpen) { |
| 505 wsPurgePattern = wsPattern; | 505 wsPurgePattern = wsPattern; |
| 506 } | 506 } |
| 507 if (!pLocale) { | 507 if (!pLocale) { |
| 508 pLocale = m_pLocaleMgr->GetDefLocale(); | 508 pLocale = m_pLocaleMgr->GetDefLocale(); |
| 509 } | 509 } |
| 510 return pLocale; | 510 return pLocale; |
| 511 } | 511 } |
| 512 #define FX_NUMSTYLE_Percent 0x01 | 512 #define FX_NUMSTYLE_Percent 0x01 |
| 513 #define FX_NUMSTYLE_Exponent 0x02 | 513 #define FX_NUMSTYLE_Exponent 0x02 |
| 514 #define FX_NUMSTYLE_DotVorv 0x04 | 514 #define FX_NUMSTYLE_DotVorv 0x04 |
| 515 IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, | 515 IFX_Locale* CFX_FormatString::GetNumericFormat(const CFX_WideString& wsPattern, |
| 516 int32_t& iDotIndex, | 516 int32_t& iDotIndex, |
| 517 uint32_t& dwStyle, | 517 uint32_t& dwStyle, |
| 518 CFX_WideString& wsPurgePattern) { | 518 CFX_WideString& wsPurgePattern) { |
| 519 dwStyle = 0; | 519 dwStyle = 0; |
| 520 IFX_Locale* pLocale = nullptr; | 520 IFX_Locale* pLocale = nullptr; |
| 521 int32_t ccf = 0; | 521 int32_t ccf = 0; |
| 522 int32_t iLenf = wsPattern.GetLength(); | 522 int32_t iLenf = wsPattern.GetLength(); |
| 523 const FX_WCHAR* pStr = wsPattern.c_str(); | 523 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 524 FX_BOOL bFindDot = FALSE; | 524 bool bFindDot = false; |
| 525 FX_BOOL bBrackOpen = FALSE; | 525 bool bBrackOpen = false; |
| 526 CFX_WideStringC wsConstChars(gs_wsConstChars); | 526 CFX_WideStringC wsConstChars(gs_wsConstChars); |
| 527 while (ccf < iLenf) { | 527 while (ccf < iLenf) { |
| 528 if (pStr[ccf] == '\'') { | 528 if (pStr[ccf] == '\'') { |
| 529 int32_t iCurChar = ccf; | 529 int32_t iCurChar = ccf; |
| 530 FX_GetLiteralText(pStr, ccf, iLenf); | 530 FX_GetLiteralText(pStr, ccf, iLenf); |
| 531 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); | 531 wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); |
| 532 } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) { | 532 } else if (!bBrackOpen && wsConstChars.Find(pStr[ccf]) == -1) { |
| 533 CFX_WideString wsCategory(pStr[ccf]); | 533 CFX_WideString wsCategory(pStr[ccf]); |
| 534 ccf++; | 534 ccf++; |
| 535 while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && | 535 while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' && |
| 536 pStr[ccf] != '(') { | 536 pStr[ccf] != '(') { |
| 537 wsCategory += pStr[ccf]; | 537 wsCategory += pStr[ccf]; |
| 538 ccf++; | 538 ccf++; |
| 539 } | 539 } |
| 540 if (wsCategory != FX_WSTRC(L"num")) { | 540 if (wsCategory != FX_WSTRC(L"num")) { |
| 541 bBrackOpen = TRUE; | 541 bBrackOpen = true; |
| 542 ccf = 0; | 542 ccf = 0; |
| 543 continue; | 543 continue; |
| 544 } | 544 } |
| 545 while (ccf < iLenf) { | 545 while (ccf < iLenf) { |
| 546 if (pStr[ccf] == '(') { | 546 if (pStr[ccf] == '(') { |
| 547 ccf++; | 547 ccf++; |
| 548 CFX_WideString wsLCID; | 548 CFX_WideString wsLCID; |
| 549 while (ccf < iLenf && pStr[ccf] != ')') { | 549 while (ccf < iLenf && pStr[ccf] != ')') { |
| 550 wsLCID += pStr[ccf++]; | 550 wsLCID += pStr[ccf++]; |
| 551 } | 551 } |
| 552 pLocale = GetPatternLocale(wsLCID); | 552 pLocale = GetPatternLocale(wsLCID); |
| 553 } else if (pStr[ccf] == '{') { | 553 } else if (pStr[ccf] == '{') { |
| 554 bBrackOpen = TRUE; | 554 bBrackOpen = true; |
| 555 break; | 555 break; |
| 556 } else if (pStr[ccf] == '.') { | 556 } else if (pStr[ccf] == '.') { |
| 557 CFX_WideString wsSubCategory; | 557 CFX_WideString wsSubCategory; |
| 558 ccf++; | 558 ccf++; |
| 559 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 559 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 560 wsSubCategory += pStr[ccf++]; | 560 wsSubCategory += pStr[ccf++]; |
| 561 } | 561 } |
| 562 uint32_t dwSubHash = | 562 uint32_t dwSubHash = |
| 563 FX_HashCode_GetW(wsSubCategory.AsStringC(), false); | 563 FX_HashCode_GetW(wsSubCategory.AsStringC(), false); |
| 564 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; | 564 FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal; |
| 565 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { | 565 for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) { |
| 566 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { | 566 if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) { |
| 567 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] | 567 eSubCategory = (FX_LOCALENUMSUBCATEGORY)g_FXLocaleNumSubCatData[i] |
| 568 .eSubCategory; | 568 .eSubCategory; |
| 569 break; | 569 break; |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 wsSubCategory.clear(); | 572 wsSubCategory.clear(); |
| 573 if (!pLocale) { | 573 if (!pLocale) { |
| 574 pLocale = m_pLocaleMgr->GetDefLocale(); | 574 pLocale = m_pLocaleMgr->GetDefLocale(); |
| 575 } | 575 } |
| 576 ASSERT(pLocale); | 576 ASSERT(pLocale); |
| 577 pLocale->GetNumPattern(eSubCategory, wsSubCategory); | 577 pLocale->GetNumPattern(eSubCategory, wsSubCategory); |
| 578 iDotIndex = wsSubCategory.Find('.'); | 578 iDotIndex = wsSubCategory.Find('.'); |
| 579 if (iDotIndex > 0) { | 579 if (iDotIndex > 0) { |
| 580 iDotIndex += wsPurgePattern.GetLength(); | 580 iDotIndex += wsPurgePattern.GetLength(); |
| 581 bFindDot = TRUE; | 581 bFindDot = true; |
| 582 dwStyle |= FX_NUMSTYLE_DotVorv; | 582 dwStyle |= FX_NUMSTYLE_DotVorv; |
| 583 } | 583 } |
| 584 wsPurgePattern += wsSubCategory; | 584 wsPurgePattern += wsSubCategory; |
| 585 if (eSubCategory == FX_LOCALENUMPATTERN_Percent) { | 585 if (eSubCategory == FX_LOCALENUMPATTERN_Percent) { |
| 586 dwStyle |= FX_NUMSTYLE_Percent; | 586 dwStyle |= FX_NUMSTYLE_Percent; |
| 587 } | 587 } |
| 588 continue; | 588 continue; |
| 589 } | 589 } |
| 590 ccf++; | 590 ccf++; |
| 591 } | 591 } |
| 592 } else if (pStr[ccf] == 'E') { | 592 } else if (pStr[ccf] == 'E') { |
| 593 dwStyle |= FX_NUMSTYLE_Exponent; | 593 dwStyle |= FX_NUMSTYLE_Exponent; |
| 594 wsPurgePattern += pStr[ccf]; | 594 wsPurgePattern += pStr[ccf]; |
| 595 } else if (pStr[ccf] == '%') { | 595 } else if (pStr[ccf] == '%') { |
| 596 dwStyle |= FX_NUMSTYLE_Percent; | 596 dwStyle |= FX_NUMSTYLE_Percent; |
| 597 wsPurgePattern += pStr[ccf]; | 597 wsPurgePattern += pStr[ccf]; |
| 598 } else if (pStr[ccf] != '}') { | 598 } else if (pStr[ccf] != '}') { |
| 599 wsPurgePattern += pStr[ccf]; | 599 wsPurgePattern += pStr[ccf]; |
| 600 } | 600 } |
| 601 if (!bFindDot) { | 601 if (!bFindDot) { |
| 602 if (pStr[ccf] == '.' || pStr[ccf] == 'V' || pStr[ccf] == 'v') { | 602 if (pStr[ccf] == '.' || pStr[ccf] == 'V' || pStr[ccf] == 'v') { |
| 603 bFindDot = TRUE; | 603 bFindDot = true; |
| 604 iDotIndex = wsPurgePattern.GetLength() - 1; | 604 iDotIndex = wsPurgePattern.GetLength() - 1; |
| 605 dwStyle |= FX_NUMSTYLE_DotVorv; | 605 dwStyle |= FX_NUMSTYLE_DotVorv; |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 ccf++; | 608 ccf++; |
| 609 } | 609 } |
| 610 if (!bFindDot) { | 610 if (!bFindDot) { |
| 611 iDotIndex = wsPurgePattern.GetLength(); | 611 iDotIndex = wsPurgePattern.GetLength(); |
| 612 } | 612 } |
| 613 if (!pLocale) { | 613 if (!pLocale) { |
| 614 pLocale = m_pLocaleMgr->GetDefLocale(); | 614 pLocale = m_pLocaleMgr->GetDefLocale(); |
| 615 } | 615 } |
| 616 return pLocale; | 616 return pLocale; |
| 617 } | 617 } |
| 618 static FX_BOOL FX_GetNumericDotIndex(const CFX_WideString& wsNum, | 618 static bool FX_GetNumericDotIndex(const CFX_WideString& wsNum, |
| 619 const CFX_WideString& wsDotSymbol, | 619 const CFX_WideString& wsDotSymbol, |
| 620 int32_t& iDotIndex) { | 620 int32_t& iDotIndex) { |
| 621 int32_t ccf = 0; | 621 int32_t ccf = 0; |
| 622 int32_t iLenf = wsNum.GetLength(); | 622 int32_t iLenf = wsNum.GetLength(); |
| 623 const FX_WCHAR* pStr = wsNum.c_str(); | 623 const FX_WCHAR* pStr = wsNum.c_str(); |
| 624 int32_t iLenDot = wsDotSymbol.GetLength(); | 624 int32_t iLenDot = wsDotSymbol.GetLength(); |
| 625 while (ccf < iLenf) { | 625 while (ccf < iLenf) { |
| 626 if (pStr[ccf] == '\'') { | 626 if (pStr[ccf] == '\'') { |
| 627 FX_GetLiteralText(pStr, ccf, iLenf); | 627 FX_GetLiteralText(pStr, ccf, iLenf); |
| 628 } else if (ccf + iLenDot <= iLenf && | 628 } else if (ccf + iLenDot <= iLenf && |
| 629 !FXSYS_wcsncmp(pStr + ccf, wsDotSymbol.c_str(), iLenDot)) { | 629 !FXSYS_wcsncmp(pStr + ccf, wsDotSymbol.c_str(), iLenDot)) { |
| 630 iDotIndex = ccf; | 630 iDotIndex = ccf; |
| 631 return TRUE; | 631 return true; |
| 632 } | 632 } |
| 633 ccf++; | 633 ccf++; |
| 634 } | 634 } |
| 635 iDotIndex = wsNum.Find('.'); | 635 iDotIndex = wsNum.Find('.'); |
| 636 if (iDotIndex < 0) { | 636 if (iDotIndex < 0) { |
| 637 iDotIndex = iLenf; | 637 iDotIndex = iLenf; |
| 638 return FALSE; | 638 return false; |
| 639 } | 639 } |
| 640 return TRUE; | 640 return true; |
| 641 } | 641 } |
| 642 FX_BOOL CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, | 642 bool CFX_FormatString::ParseText(const CFX_WideString& wsSrcText, |
| 643 const CFX_WideString& wsPattern, | 643 const CFX_WideString& wsPattern, |
| 644 CFX_WideString& wsValue) { | 644 CFX_WideString& wsValue) { |
| 645 wsValue.clear(); | 645 wsValue.clear(); |
| 646 if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { | 646 if (wsSrcText.IsEmpty() || wsPattern.IsEmpty()) { |
| 647 return FALSE; | 647 return false; |
| 648 } | 648 } |
| 649 CFX_WideString wsTextFormat; | 649 CFX_WideString wsTextFormat; |
| 650 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); | 650 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); |
| 651 if (wsTextFormat.IsEmpty()) { | 651 if (wsTextFormat.IsEmpty()) { |
| 652 return FALSE; | 652 return false; |
| 653 } | 653 } |
| 654 int32_t iText = 0, iPattern = 0; | 654 int32_t iText = 0, iPattern = 0; |
| 655 const FX_WCHAR* pStrText = wsSrcText.c_str(); | 655 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 656 int32_t iLenText = wsSrcText.GetLength(); | 656 int32_t iLenText = wsSrcText.GetLength(); |
| 657 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); | 657 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 658 int32_t iLenPattern = wsTextFormat.GetLength(); | 658 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 659 while (iPattern < iLenPattern && iText < iLenText) { | 659 while (iPattern < iLenPattern && iText < iLenText) { |
| 660 switch (pStrPattern[iPattern]) { | 660 switch (pStrPattern[iPattern]) { |
| 661 case '\'': { | 661 case '\'': { |
| 662 CFX_WideString wsLiteral = | 662 CFX_WideString wsLiteral = |
| 663 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 663 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 664 int32_t iLiteralLen = wsLiteral.GetLength(); | 664 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 665 if (iText + iLiteralLen > iLenText || | 665 if (iText + iLiteralLen > iLenText || |
| 666 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { | 666 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { |
| 667 wsValue = wsSrcText; | 667 wsValue = wsSrcText; |
| 668 return FALSE; | 668 return false; |
| 669 } | 669 } |
| 670 iText += iLiteralLen; | 670 iText += iLiteralLen; |
| 671 iPattern++; | 671 iPattern++; |
| 672 break; | 672 break; |
| 673 } | 673 } |
| 674 case 'A': | 674 case 'A': |
| 675 if (FXSYS_iswalpha(pStrText[iText])) { | 675 if (FXSYS_iswalpha(pStrText[iText])) { |
| 676 wsValue += pStrText[iText]; | 676 wsValue += pStrText[iText]; |
| 677 iText++; | 677 iText++; |
| 678 } | 678 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 695 case '9': | 695 case '9': |
| 696 if (FXSYS_isDecimalDigit(pStrText[iText])) { | 696 if (FXSYS_isDecimalDigit(pStrText[iText])) { |
| 697 wsValue += pStrText[iText]; | 697 wsValue += pStrText[iText]; |
| 698 iText++; | 698 iText++; |
| 699 } | 699 } |
| 700 iPattern++; | 700 iPattern++; |
| 701 break; | 701 break; |
| 702 default: | 702 default: |
| 703 if (pStrPattern[iPattern] != pStrText[iText]) { | 703 if (pStrPattern[iPattern] != pStrText[iText]) { |
| 704 wsValue = wsSrcText; | 704 wsValue = wsSrcText; |
| 705 return FALSE; | 705 return false; |
| 706 } | 706 } |
| 707 iPattern++; | 707 iPattern++; |
| 708 iText++; | 708 iText++; |
| 709 break; | 709 break; |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 return iPattern == iLenPattern && iText == iLenText; | 712 return iPattern == iLenPattern && iText == iLenText; |
| 713 } | 713 } |
| 714 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, | 714 bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, |
| 715 const CFX_WideString& wsPattern, | 715 const CFX_WideString& wsPattern, |
| 716 FX_FLOAT& fValue) { | 716 FX_FLOAT& fValue) { |
| 717 fValue = 0.0f; | 717 fValue = 0.0f; |
| 718 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 718 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 719 return FALSE; | 719 return false; |
| 720 } | 720 } |
| 721 int32_t dot_index_f = -1; | 721 int32_t dot_index_f = -1; |
| 722 uint32_t dwFormatStyle = 0; | 722 uint32_t dwFormatStyle = 0; |
| 723 CFX_WideString wsNumFormat; | 723 CFX_WideString wsNumFormat; |
| 724 IFX_Locale* pLocale = | 724 IFX_Locale* pLocale = |
| 725 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); | 725 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); |
| 726 if (!pLocale || wsNumFormat.IsEmpty()) { | 726 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 727 return FALSE; | 727 return false; |
| 728 } | 728 } |
| 729 int32_t iExponent = 0; | 729 int32_t iExponent = 0; |
| 730 CFX_WideString wsDotSymbol; | 730 CFX_WideString wsDotSymbol; |
| 731 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 731 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 732 CFX_WideString wsGroupSymbol; | 732 CFX_WideString wsGroupSymbol; |
| 733 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 733 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 734 int32_t iGroupLen = wsGroupSymbol.GetLength(); | 734 int32_t iGroupLen = wsGroupSymbol.GetLength(); |
| 735 CFX_WideString wsMinus; | 735 CFX_WideString wsMinus; |
| 736 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); | 736 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); |
| 737 int32_t iMinusLen = wsMinus.GetLength(); | 737 int32_t iMinusLen = wsMinus.GetLength(); |
| 738 int cc = 0, ccf = 0; | 738 int cc = 0, ccf = 0; |
| 739 const FX_WCHAR* str = wsSrcNum.c_str(); | 739 const FX_WCHAR* str = wsSrcNum.c_str(); |
| 740 int len = wsSrcNum.GetLength(); | 740 int len = wsSrcNum.GetLength(); |
| 741 const FX_WCHAR* strf = wsNumFormat.c_str(); | 741 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 742 int lenf = wsNumFormat.GetLength(); | 742 int lenf = wsNumFormat.GetLength(); |
| 743 double dbRetValue = 0; | 743 double dbRetValue = 0; |
| 744 double coeff = 1; | 744 double coeff = 1; |
| 745 FX_BOOL bHavePercentSymbol = FALSE; | 745 bool bHavePercentSymbol = false; |
| 746 FX_BOOL bNeg = FALSE; | 746 bool bNeg = false; |
| 747 FX_BOOL bReverseParse = FALSE; | 747 bool bReverseParse = false; |
| 748 int32_t dot_index = 0; | 748 int32_t dot_index = 0; |
| 749 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && | 749 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && |
| 750 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { | 750 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { |
| 751 bReverseParse = TRUE; | 751 bReverseParse = true; |
| 752 } | 752 } |
| 753 bReverseParse = FALSE; | 753 bReverseParse = false; |
| 754 if (bReverseParse) { | 754 if (bReverseParse) { |
| 755 ccf = lenf - 1; | 755 ccf = lenf - 1; |
| 756 cc = len - 1; | 756 cc = len - 1; |
| 757 while (ccf > dot_index_f && cc >= 0) { | 757 while (ccf > dot_index_f && cc >= 0) { |
| 758 switch (strf[ccf]) { | 758 switch (strf[ccf]) { |
| 759 case '\'': { | 759 case '\'': { |
| 760 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); | 760 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); |
| 761 int32_t iLiteralLen = wsLiteral.GetLength(); | 761 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 762 cc -= iLiteralLen - 1; | 762 cc -= iLiteralLen - 1; |
| 763 if (cc < 0 || | 763 if (cc < 0 || |
| 764 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 764 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 765 return FALSE; | 765 return false; |
| 766 } | 766 } |
| 767 cc--; | 767 cc--; |
| 768 ccf--; | 768 ccf--; |
| 769 break; | 769 break; |
| 770 } | 770 } |
| 771 case '9': | 771 case '9': |
| 772 if (!FXSYS_isDecimalDigit(str[cc])) { | 772 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 773 return FALSE; | 773 return false; |
| 774 } | 774 } |
| 775 dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; | 775 dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; |
| 776 coeff *= 0.1; | 776 coeff *= 0.1; |
| 777 cc--; | 777 cc--; |
| 778 ccf--; | 778 ccf--; |
| 779 break; | 779 break; |
| 780 case 'z': | 780 case 'z': |
| 781 if (cc >= 0) { | 781 if (cc >= 0) { |
| 782 dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; | 782 dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; |
| 783 coeff *= 0.1; | 783 coeff *= 0.1; |
| 784 cc--; | 784 cc--; |
| 785 } | 785 } |
| 786 ccf--; | 786 ccf--; |
| 787 break; | 787 break; |
| 788 case 'Z': | 788 case 'Z': |
| 789 if (str[cc] != ' ') { | 789 if (str[cc] != ' ') { |
| 790 dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; | 790 dbRetValue = dbRetValue * coeff + (str[cc] - '0') * 0.1; |
| 791 coeff *= 0.1; | 791 coeff *= 0.1; |
| 792 } | 792 } |
| 793 cc--; | 793 cc--; |
| 794 ccf--; | 794 ccf--; |
| 795 break; | 795 break; |
| 796 case 'S': | 796 case 'S': |
| 797 if (str[cc] == '+' || str[cc] == ' ') { | 797 if (str[cc] == '+' || str[cc] == ' ') { |
| 798 cc--; | 798 cc--; |
| 799 } else { | 799 } else { |
| 800 cc -= iMinusLen - 1; | 800 cc -= iMinusLen - 1; |
| 801 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 801 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 802 return FALSE; | 802 return false; |
| 803 } | 803 } |
| 804 cc--; | 804 cc--; |
| 805 bNeg = TRUE; | 805 bNeg = true; |
| 806 } | 806 } |
| 807 ccf--; | 807 ccf--; |
| 808 break; | 808 break; |
| 809 case 's': | 809 case 's': |
| 810 if (str[cc] == '+') { | 810 if (str[cc] == '+') { |
| 811 cc--; | 811 cc--; |
| 812 } else { | 812 } else { |
| 813 cc -= iMinusLen - 1; | 813 cc -= iMinusLen - 1; |
| 814 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 814 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 815 return FALSE; | 815 return false; |
| 816 } | 816 } |
| 817 cc--; | 817 cc--; |
| 818 bNeg = TRUE; | 818 bNeg = true; |
| 819 } | 819 } |
| 820 ccf--; | 820 ccf--; |
| 821 break; | 821 break; |
| 822 case 'E': { | 822 case 'E': { |
| 823 if (cc >= dot_index) { | 823 if (cc >= dot_index) { |
| 824 return FALSE; | 824 return false; |
| 825 } | 825 } |
| 826 FX_BOOL bExpSign = FALSE; | 826 bool bExpSign = false; |
| 827 while (cc >= 0) { | 827 while (cc >= 0) { |
| 828 if (str[cc] == 'E' || str[cc] == 'e') { | 828 if (str[cc] == 'E' || str[cc] == 'e') { |
| 829 break; | 829 break; |
| 830 } | 830 } |
| 831 if (FXSYS_isDecimalDigit(str[cc])) { | 831 if (FXSYS_isDecimalDigit(str[cc])) { |
| 832 iExponent = iExponent + (str[cc] - '0') * 10; | 832 iExponent = iExponent + (str[cc] - '0') * 10; |
| 833 cc--; | 833 cc--; |
| 834 continue; | 834 continue; |
| 835 } else if (str[cc] == '+') { | 835 } else if (str[cc] == '+') { |
| 836 cc--; | 836 cc--; |
| 837 continue; | 837 continue; |
| 838 } else if (cc - iMinusLen + 1 > 0 && | 838 } else if (cc - iMinusLen + 1 > 0 && |
| 839 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), | 839 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), |
| 840 wsMinus.c_str(), iMinusLen)) { | 840 wsMinus.c_str(), iMinusLen)) { |
| 841 bExpSign = TRUE; | 841 bExpSign = true; |
| 842 cc -= iMinusLen; | 842 cc -= iMinusLen; |
| 843 } else { | 843 } else { |
| 844 return FALSE; | 844 return false; |
| 845 } | 845 } |
| 846 } | 846 } |
| 847 cc--; | 847 cc--; |
| 848 iExponent = bExpSign ? -iExponent : iExponent; | 848 iExponent = bExpSign ? -iExponent : iExponent; |
| 849 ccf--; | 849 ccf--; |
| 850 } break; | 850 } break; |
| 851 case '$': { | 851 case '$': { |
| 852 CFX_WideString wsSymbol; | 852 CFX_WideString wsSymbol; |
| 853 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, | 853 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, |
| 854 wsSymbol); | 854 wsSymbol); |
| 855 int32_t iSymbolLen = wsSymbol.GetLength(); | 855 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 856 cc -= iSymbolLen - 1; | 856 cc -= iSymbolLen - 1; |
| 857 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { | 857 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 858 return FALSE; | 858 return false; |
| 859 } | 859 } |
| 860 cc--; | 860 cc--; |
| 861 ccf--; | 861 ccf--; |
| 862 } break; | 862 } break; |
| 863 case 'r': | 863 case 'r': |
| 864 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 864 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 865 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 865 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 866 bNeg = TRUE; | 866 bNeg = true; |
| 867 cc -= 2; | 867 cc -= 2; |
| 868 } | 868 } |
| 869 ccf -= 2; | 869 ccf -= 2; |
| 870 } else { | 870 } else { |
| 871 ccf--; | 871 ccf--; |
| 872 } | 872 } |
| 873 break; | 873 break; |
| 874 case 'R': | 874 case 'R': |
| 875 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { | 875 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { |
| 876 if (str[cc] == ' ') { | 876 if (str[cc] == ' ') { |
| 877 cc++; | 877 cc++; |
| 878 } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 878 } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 879 bNeg = TRUE; | 879 bNeg = true; |
| 880 cc -= 2; | 880 cc -= 2; |
| 881 } | 881 } |
| 882 ccf -= 2; | 882 ccf -= 2; |
| 883 } else { | 883 } else { |
| 884 ccf--; | 884 ccf--; |
| 885 } | 885 } |
| 886 break; | 886 break; |
| 887 case 'b': | 887 case 'b': |
| 888 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { | 888 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { |
| 889 if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { | 889 if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { |
| 890 bNeg = TRUE; | 890 bNeg = true; |
| 891 cc -= 2; | 891 cc -= 2; |
| 892 } | 892 } |
| 893 ccf -= 2; | 893 ccf -= 2; |
| 894 } else { | 894 } else { |
| 895 ccf--; | 895 ccf--; |
| 896 } | 896 } |
| 897 break; | 897 break; |
| 898 case 'B': | 898 case 'B': |
| 899 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { | 899 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { |
| 900 if (str[cc] == ' ') { | 900 if (str[cc] == ' ') { |
| 901 cc++; | 901 cc++; |
| 902 } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { | 902 } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { |
| 903 bNeg = TRUE; | 903 bNeg = true; |
| 904 cc -= 2; | 904 cc -= 2; |
| 905 } | 905 } |
| 906 ccf -= 2; | 906 ccf -= 2; |
| 907 } else { | 907 } else { |
| 908 ccf--; | 908 ccf--; |
| 909 } | 909 } |
| 910 break; | 910 break; |
| 911 case '.': | 911 case '.': |
| 912 case 'V': | 912 case 'V': |
| 913 case 'v': | 913 case 'v': |
| 914 return FALSE; | 914 return false; |
| 915 case '%': { | 915 case '%': { |
| 916 CFX_WideString wsSymbol; | 916 CFX_WideString wsSymbol; |
| 917 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 917 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 918 int32_t iSysmbolLen = wsSymbol.GetLength(); | 918 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 919 cc -= iSysmbolLen - 1; | 919 cc -= iSysmbolLen - 1; |
| 920 if (cc < 0 || | 920 if (cc < 0 || |
| 921 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { | 921 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 922 return FALSE; | 922 return false; |
| 923 } | 923 } |
| 924 cc--; | 924 cc--; |
| 925 ccf--; | 925 ccf--; |
| 926 bHavePercentSymbol = TRUE; | 926 bHavePercentSymbol = true; |
| 927 } break; | 927 } break; |
| 928 case '8': | 928 case '8': |
| 929 while (ccf < lenf && strf[ccf] == '8') { | 929 while (ccf < lenf && strf[ccf] == '8') { |
| 930 ccf++; | 930 ccf++; |
| 931 } | 931 } |
| 932 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 932 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 933 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; | 933 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; |
| 934 coeff *= 0.1; | 934 coeff *= 0.1; |
| 935 cc++; | 935 cc++; |
| 936 } | 936 } |
| 937 break; | 937 break; |
| 938 case ',': { | 938 case ',': { |
| 939 if (cc >= 0) { | 939 if (cc >= 0) { |
| 940 cc -= iGroupLen - 1; | 940 cc -= iGroupLen - 1; |
| 941 if (cc >= 0 && | 941 if (cc >= 0 && |
| 942 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == | 942 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == |
| 943 0) { | 943 0) { |
| 944 cc--; | 944 cc--; |
| 945 } else { | 945 } else { |
| 946 cc += iGroupLen - 1; | 946 cc += iGroupLen - 1; |
| 947 } | 947 } |
| 948 } | 948 } |
| 949 ccf--; | 949 ccf--; |
| 950 } break; | 950 } break; |
| 951 case '(': | 951 case '(': |
| 952 if (str[cc] == L'(') { | 952 if (str[cc] == L'(') { |
| 953 bNeg = TRUE; | 953 bNeg = true; |
| 954 } else if (str[cc] != L' ') { | 954 } else if (str[cc] != L' ') { |
| 955 return FALSE; | 955 return false; |
| 956 } | 956 } |
| 957 cc--; | 957 cc--; |
| 958 ccf--; | 958 ccf--; |
| 959 break; | 959 break; |
| 960 case ')': | 960 case ')': |
| 961 if (str[cc] == L')') { | 961 if (str[cc] == L')') { |
| 962 bNeg = TRUE; | 962 bNeg = true; |
| 963 } else if (str[cc] != L' ') { | 963 } else if (str[cc] != L' ') { |
| 964 return FALSE; | 964 return false; |
| 965 } | 965 } |
| 966 cc--; | 966 cc--; |
| 967 ccf--; | 967 ccf--; |
| 968 break; | 968 break; |
| 969 default: | 969 default: |
| 970 if (strf[ccf] != str[cc]) { | 970 if (strf[ccf] != str[cc]) { |
| 971 return FALSE; | 971 return false; |
| 972 } | 972 } |
| 973 cc--; | 973 cc--; |
| 974 ccf--; | 974 ccf--; |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 dot_index = cc + 1; | 977 dot_index = cc + 1; |
| 978 } | 978 } |
| 979 ccf = dot_index_f - 1; | 979 ccf = dot_index_f - 1; |
| 980 cc = dot_index - 1; | 980 cc = dot_index - 1; |
| 981 coeff = 1; | 981 coeff = 1; |
| 982 while (ccf >= 0 && cc >= 0) { | 982 while (ccf >= 0 && cc >= 0) { |
| 983 switch (strf[ccf]) { | 983 switch (strf[ccf]) { |
| 984 case '\'': { | 984 case '\'': { |
| 985 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); | 985 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); |
| 986 int32_t iLiteralLen = wsLiteral.GetLength(); | 986 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 987 cc -= iLiteralLen - 1; | 987 cc -= iLiteralLen - 1; |
| 988 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 988 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 989 return FALSE; | 989 return false; |
| 990 } | 990 } |
| 991 cc--; | 991 cc--; |
| 992 ccf--; | 992 ccf--; |
| 993 break; | 993 break; |
| 994 } | 994 } |
| 995 case '9': | 995 case '9': |
| 996 if (!FXSYS_isDecimalDigit(str[cc])) { | 996 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 997 return FALSE; | 997 return false; |
| 998 } | 998 } |
| 999 dbRetValue = dbRetValue + (str[cc] - '0') * coeff; | 999 dbRetValue = dbRetValue + (str[cc] - '0') * coeff; |
| 1000 coeff *= 10; | 1000 coeff *= 10; |
| 1001 cc--; | 1001 cc--; |
| 1002 ccf--; | 1002 ccf--; |
| 1003 break; | 1003 break; |
| 1004 case 'z': | 1004 case 'z': |
| 1005 if (FXSYS_isDecimalDigit(str[cc])) { | 1005 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1006 dbRetValue = dbRetValue + (str[cc] - '0') * coeff; | 1006 dbRetValue = dbRetValue + (str[cc] - '0') * coeff; |
| 1007 coeff *= 10; | 1007 coeff *= 10; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1020 cc--; | 1020 cc--; |
| 1021 } | 1021 } |
| 1022 ccf--; | 1022 ccf--; |
| 1023 break; | 1023 break; |
| 1024 case 'S': | 1024 case 'S': |
| 1025 if (str[cc] == '+' || str[cc] == ' ') { | 1025 if (str[cc] == '+' || str[cc] == ' ') { |
| 1026 cc--; | 1026 cc--; |
| 1027 } else { | 1027 } else { |
| 1028 cc -= iMinusLen - 1; | 1028 cc -= iMinusLen - 1; |
| 1029 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1029 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1030 return FALSE; | 1030 return false; |
| 1031 } | 1031 } |
| 1032 cc--; | 1032 cc--; |
| 1033 bNeg = TRUE; | 1033 bNeg = true; |
| 1034 } | 1034 } |
| 1035 ccf--; | 1035 ccf--; |
| 1036 break; | 1036 break; |
| 1037 case 's': | 1037 case 's': |
| 1038 if (str[cc] == '+') { | 1038 if (str[cc] == '+') { |
| 1039 cc--; | 1039 cc--; |
| 1040 } else { | 1040 } else { |
| 1041 cc -= iMinusLen - 1; | 1041 cc -= iMinusLen - 1; |
| 1042 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1042 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1043 return FALSE; | 1043 return false; |
| 1044 } | 1044 } |
| 1045 cc--; | 1045 cc--; |
| 1046 bNeg = TRUE; | 1046 bNeg = true; |
| 1047 } | 1047 } |
| 1048 ccf--; | 1048 ccf--; |
| 1049 break; | 1049 break; |
| 1050 case 'E': { | 1050 case 'E': { |
| 1051 if (cc >= dot_index) { | 1051 if (cc >= dot_index) { |
| 1052 return FALSE; | 1052 return false; |
| 1053 } | 1053 } |
| 1054 FX_BOOL bExpSign = FALSE; | 1054 bool bExpSign = false; |
| 1055 while (cc >= 0) { | 1055 while (cc >= 0) { |
| 1056 if (str[cc] == 'E' || str[cc] == 'e') { | 1056 if (str[cc] == 'E' || str[cc] == 'e') { |
| 1057 break; | 1057 break; |
| 1058 } | 1058 } |
| 1059 if (FXSYS_isDecimalDigit(str[cc])) { | 1059 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1060 iExponent = iExponent + (str[cc] - '0') * 10; | 1060 iExponent = iExponent + (str[cc] - '0') * 10; |
| 1061 cc--; | 1061 cc--; |
| 1062 continue; | 1062 continue; |
| 1063 } else if (str[cc] == '+') { | 1063 } else if (str[cc] == '+') { |
| 1064 cc--; | 1064 cc--; |
| 1065 continue; | 1065 continue; |
| 1066 } else if (cc - iMinusLen + 1 > 0 && | 1066 } else if (cc - iMinusLen + 1 > 0 && |
| 1067 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(), | 1067 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(), |
| 1068 iMinusLen)) { | 1068 iMinusLen)) { |
| 1069 bExpSign = TRUE; | 1069 bExpSign = true; |
| 1070 cc -= iMinusLen; | 1070 cc -= iMinusLen; |
| 1071 } else { | 1071 } else { |
| 1072 return FALSE; | 1072 return false; |
| 1073 } | 1073 } |
| 1074 } | 1074 } |
| 1075 cc--; | 1075 cc--; |
| 1076 iExponent = bExpSign ? -iExponent : iExponent; | 1076 iExponent = bExpSign ? -iExponent : iExponent; |
| 1077 ccf--; | 1077 ccf--; |
| 1078 } break; | 1078 } break; |
| 1079 case '$': { | 1079 case '$': { |
| 1080 CFX_WideString wsSymbol; | 1080 CFX_WideString wsSymbol; |
| 1081 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 1081 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 1082 int32_t iSymbolLen = wsSymbol.GetLength(); | 1082 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1083 cc -= iSymbolLen - 1; | 1083 cc -= iSymbolLen - 1; |
| 1084 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { | 1084 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1085 return FALSE; | 1085 return false; |
| 1086 } | 1086 } |
| 1087 cc--; | 1087 cc--; |
| 1088 ccf--; | 1088 ccf--; |
| 1089 } break; | 1089 } break; |
| 1090 case 'r': | 1090 case 'r': |
| 1091 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 1091 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 1092 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1092 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1093 bNeg = TRUE; | 1093 bNeg = true; |
| 1094 cc -= 2; | 1094 cc -= 2; |
| 1095 } | 1095 } |
| 1096 ccf -= 2; | 1096 ccf -= 2; |
| 1097 } else { | 1097 } else { |
| 1098 ccf--; | 1098 ccf--; |
| 1099 } | 1099 } |
| 1100 break; | 1100 break; |
| 1101 case 'R': | 1101 case 'R': |
| 1102 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { | 1102 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { |
| 1103 if (str[cc] == ' ') { | 1103 if (str[cc] == ' ') { |
| 1104 cc++; | 1104 cc++; |
| 1105 } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1105 } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1106 bNeg = TRUE; | 1106 bNeg = true; |
| 1107 cc -= 2; | 1107 cc -= 2; |
| 1108 } | 1108 } |
| 1109 ccf -= 2; | 1109 ccf -= 2; |
| 1110 } else { | 1110 } else { |
| 1111 ccf--; | 1111 ccf--; |
| 1112 } | 1112 } |
| 1113 break; | 1113 break; |
| 1114 case 'b': | 1114 case 'b': |
| 1115 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { | 1115 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { |
| 1116 if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { | 1116 if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { |
| 1117 bNeg = TRUE; | 1117 bNeg = true; |
| 1118 cc -= 2; | 1118 cc -= 2; |
| 1119 } | 1119 } |
| 1120 ccf -= 2; | 1120 ccf -= 2; |
| 1121 } else { | 1121 } else { |
| 1122 ccf--; | 1122 ccf--; |
| 1123 } | 1123 } |
| 1124 break; | 1124 break; |
| 1125 case 'B': | 1125 case 'B': |
| 1126 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { | 1126 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { |
| 1127 if (str[cc] == ' ') { | 1127 if (str[cc] == ' ') { |
| 1128 cc++; | 1128 cc++; |
| 1129 } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { | 1129 } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { |
| 1130 bNeg = TRUE; | 1130 bNeg = true; |
| 1131 cc -= 2; | 1131 cc -= 2; |
| 1132 } | 1132 } |
| 1133 ccf -= 2; | 1133 ccf -= 2; |
| 1134 } else { | 1134 } else { |
| 1135 ccf--; | 1135 ccf--; |
| 1136 } | 1136 } |
| 1137 break; | 1137 break; |
| 1138 case '.': | 1138 case '.': |
| 1139 case 'V': | 1139 case 'V': |
| 1140 case 'v': | 1140 case 'v': |
| 1141 return FALSE; | 1141 return false; |
| 1142 case '%': { | 1142 case '%': { |
| 1143 CFX_WideString wsSymbol; | 1143 CFX_WideString wsSymbol; |
| 1144 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1144 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1145 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1145 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1146 cc -= iSysmbolLen - 1; | 1146 cc -= iSysmbolLen - 1; |
| 1147 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { | 1147 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1148 return FALSE; | 1148 return false; |
| 1149 } | 1149 } |
| 1150 cc--; | 1150 cc--; |
| 1151 ccf--; | 1151 ccf--; |
| 1152 bHavePercentSymbol = TRUE; | 1152 bHavePercentSymbol = true; |
| 1153 } break; | 1153 } break; |
| 1154 case '8': | 1154 case '8': |
| 1155 return FALSE; | 1155 return false; |
| 1156 case ',': { | 1156 case ',': { |
| 1157 if (cc >= 0) { | 1157 if (cc >= 0) { |
| 1158 cc -= iGroupLen - 1; | 1158 cc -= iGroupLen - 1; |
| 1159 if (cc >= 0 && | 1159 if (cc >= 0 && |
| 1160 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { | 1160 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1161 cc--; | 1161 cc--; |
| 1162 } else { | 1162 } else { |
| 1163 cc += iGroupLen - 1; | 1163 cc += iGroupLen - 1; |
| 1164 } | 1164 } |
| 1165 } | 1165 } |
| 1166 ccf--; | 1166 ccf--; |
| 1167 } break; | 1167 } break; |
| 1168 case '(': | 1168 case '(': |
| 1169 if (str[cc] == L'(') { | 1169 if (str[cc] == L'(') { |
| 1170 bNeg = TRUE; | 1170 bNeg = true; |
| 1171 } else if (str[cc] != L' ') { | 1171 } else if (str[cc] != L' ') { |
| 1172 return FALSE; | 1172 return false; |
| 1173 } | 1173 } |
| 1174 cc--; | 1174 cc--; |
| 1175 ccf--; | 1175 ccf--; |
| 1176 break; | 1176 break; |
| 1177 case ')': | 1177 case ')': |
| 1178 if (str[cc] == L')') { | 1178 if (str[cc] == L')') { |
| 1179 bNeg = TRUE; | 1179 bNeg = true; |
| 1180 } else if (str[cc] != L' ') { | 1180 } else if (str[cc] != L' ') { |
| 1181 return FALSE; | 1181 return false; |
| 1182 } | 1182 } |
| 1183 cc--; | 1183 cc--; |
| 1184 ccf--; | 1184 ccf--; |
| 1185 break; | 1185 break; |
| 1186 default: | 1186 default: |
| 1187 if (strf[ccf] != str[cc]) { | 1187 if (strf[ccf] != str[cc]) { |
| 1188 return FALSE; | 1188 return false; |
| 1189 } | 1189 } |
| 1190 cc--; | 1190 cc--; |
| 1191 ccf--; | 1191 ccf--; |
| 1192 } | 1192 } |
| 1193 } | 1193 } |
| 1194 if (cc >= 0) { | 1194 if (cc >= 0) { |
| 1195 return FALSE; | 1195 return false; |
| 1196 } | 1196 } |
| 1197 if (!bReverseParse) { | 1197 if (!bReverseParse) { |
| 1198 ccf = dot_index_f + 1; | 1198 ccf = dot_index_f + 1; |
| 1199 cc = (dot_index == len) ? len : dot_index + 1; | 1199 cc = (dot_index == len) ? len : dot_index + 1; |
| 1200 coeff = 0.1; | 1200 coeff = 0.1; |
| 1201 while (cc < len && ccf < lenf) { | 1201 while (cc < len && ccf < lenf) { |
| 1202 switch (strf[ccf]) { | 1202 switch (strf[ccf]) { |
| 1203 case '\'': { | 1203 case '\'': { |
| 1204 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 1204 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 1205 int32_t iLiteralLen = wsLiteral.GetLength(); | 1205 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1206 if (cc + iLiteralLen > len || | 1206 if (cc + iLiteralLen > len || |
| 1207 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 1207 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1208 return FALSE; | 1208 return false; |
| 1209 } | 1209 } |
| 1210 cc += iLiteralLen; | 1210 cc += iLiteralLen; |
| 1211 ccf++; | 1211 ccf++; |
| 1212 break; | 1212 break; |
| 1213 } | 1213 } |
| 1214 case '9': | 1214 case '9': |
| 1215 if (!FXSYS_isDecimalDigit(str[cc])) { | 1215 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 1216 return FALSE; | 1216 return false; |
| 1217 } | 1217 } |
| 1218 { | 1218 { |
| 1219 dbRetValue = dbRetValue + (str[cc] - '0') * coeff; | 1219 dbRetValue = dbRetValue + (str[cc] - '0') * coeff; |
| 1220 coeff *= 0.1; | 1220 coeff *= 0.1; |
| 1221 } | 1221 } |
| 1222 cc++; | 1222 cc++; |
| 1223 ccf++; | 1223 ccf++; |
| 1224 break; | 1224 break; |
| 1225 case 'z': | 1225 case 'z': |
| 1226 if (FXSYS_isDecimalDigit(str[cc])) { | 1226 if (FXSYS_isDecimalDigit(str[cc])) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1241 cc++; | 1241 cc++; |
| 1242 } | 1242 } |
| 1243 ccf++; | 1243 ccf++; |
| 1244 break; | 1244 break; |
| 1245 case 'S': | 1245 case 'S': |
| 1246 if (str[cc] == '+' || str[cc] == ' ') { | 1246 if (str[cc] == '+' || str[cc] == ' ') { |
| 1247 cc++; | 1247 cc++; |
| 1248 } else { | 1248 } else { |
| 1249 if (cc + iMinusLen > len || | 1249 if (cc + iMinusLen > len || |
| 1250 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1250 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1251 return FALSE; | 1251 return false; |
| 1252 } | 1252 } |
| 1253 bNeg = TRUE; | 1253 bNeg = true; |
| 1254 cc += iMinusLen; | 1254 cc += iMinusLen; |
| 1255 } | 1255 } |
| 1256 ccf++; | 1256 ccf++; |
| 1257 break; | 1257 break; |
| 1258 case 's': | 1258 case 's': |
| 1259 if (str[cc] == '+') { | 1259 if (str[cc] == '+') { |
| 1260 cc++; | 1260 cc++; |
| 1261 } else { | 1261 } else { |
| 1262 if (cc + iMinusLen > len || | 1262 if (cc + iMinusLen > len || |
| 1263 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1263 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1264 return FALSE; | 1264 return false; |
| 1265 } | 1265 } |
| 1266 bNeg = TRUE; | 1266 bNeg = true; |
| 1267 cc += iMinusLen; | 1267 cc += iMinusLen; |
| 1268 } | 1268 } |
| 1269 ccf++; | 1269 ccf++; |
| 1270 break; | 1270 break; |
| 1271 case 'E': { | 1271 case 'E': { |
| 1272 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { | 1272 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { |
| 1273 return FALSE; | 1273 return false; |
| 1274 } | 1274 } |
| 1275 FX_BOOL bExpSign = FALSE; | 1275 bool bExpSign = false; |
| 1276 cc++; | 1276 cc++; |
| 1277 if (cc < len) { | 1277 if (cc < len) { |
| 1278 if (str[cc] == '+') { | 1278 if (str[cc] == '+') { |
| 1279 cc++; | 1279 cc++; |
| 1280 } else if (str[cc] == '-') { | 1280 } else if (str[cc] == '-') { |
| 1281 bExpSign = TRUE; | 1281 bExpSign = true; |
| 1282 cc++; | 1282 cc++; |
| 1283 } | 1283 } |
| 1284 } | 1284 } |
| 1285 while (cc < len) { | 1285 while (cc < len) { |
| 1286 if (!FXSYS_isDecimalDigit(str[cc])) { | 1286 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 1287 break; | 1287 break; |
| 1288 } | 1288 } |
| 1289 iExponent = iExponent * 10 + str[cc] - '0'; | 1289 iExponent = iExponent * 10 + str[cc] - '0'; |
| 1290 cc++; | 1290 cc++; |
| 1291 } | 1291 } |
| 1292 iExponent = bExpSign ? -iExponent : iExponent; | 1292 iExponent = bExpSign ? -iExponent : iExponent; |
| 1293 ccf++; | 1293 ccf++; |
| 1294 } break; | 1294 } break; |
| 1295 case '$': { | 1295 case '$': { |
| 1296 CFX_WideString wsSymbol; | 1296 CFX_WideString wsSymbol; |
| 1297 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, | 1297 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, |
| 1298 wsSymbol); | 1298 wsSymbol); |
| 1299 int32_t iSymbolLen = wsSymbol.GetLength(); | 1299 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1300 if (cc + iSymbolLen > len || | 1300 if (cc + iSymbolLen > len || |
| 1301 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { | 1301 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1302 return FALSE; | 1302 return false; |
| 1303 } | 1303 } |
| 1304 cc += iSymbolLen; | 1304 cc += iSymbolLen; |
| 1305 ccf++; | 1305 ccf++; |
| 1306 } break; | 1306 } break; |
| 1307 case 'c': | 1307 case 'c': |
| 1308 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { | 1308 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { |
| 1309 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { | 1309 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { |
| 1310 bNeg = TRUE; | 1310 bNeg = true; |
| 1311 cc += 2; | 1311 cc += 2; |
| 1312 } | 1312 } |
| 1313 ccf += 2; | 1313 ccf += 2; |
| 1314 } | 1314 } |
| 1315 break; | 1315 break; |
| 1316 case 'C': | 1316 case 'C': |
| 1317 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { | 1317 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { |
| 1318 if (str[cc] == ' ') { | 1318 if (str[cc] == ' ') { |
| 1319 cc++; | 1319 cc++; |
| 1320 } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { | 1320 } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { |
| 1321 bNeg = TRUE; | 1321 bNeg = true; |
| 1322 cc += 2; | 1322 cc += 2; |
| 1323 } | 1323 } |
| 1324 ccf += 2; | 1324 ccf += 2; |
| 1325 } | 1325 } |
| 1326 break; | 1326 break; |
| 1327 case 'd': | 1327 case 'd': |
| 1328 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { | 1328 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { |
| 1329 if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { | 1329 if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { |
| 1330 bNeg = TRUE; | 1330 bNeg = true; |
| 1331 cc += 2; | 1331 cc += 2; |
| 1332 } | 1332 } |
| 1333 ccf += 2; | 1333 ccf += 2; |
| 1334 } | 1334 } |
| 1335 break; | 1335 break; |
| 1336 case 'D': | 1336 case 'D': |
| 1337 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { | 1337 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { |
| 1338 if (str[cc] == ' ') { | 1338 if (str[cc] == ' ') { |
| 1339 cc++; | 1339 cc++; |
| 1340 } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { | 1340 } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { |
| 1341 bNeg = TRUE; | 1341 bNeg = true; |
| 1342 cc += 2; | 1342 cc += 2; |
| 1343 } | 1343 } |
| 1344 ccf += 2; | 1344 ccf += 2; |
| 1345 } | 1345 } |
| 1346 break; | 1346 break; |
| 1347 case '.': | 1347 case '.': |
| 1348 case 'V': | 1348 case 'V': |
| 1349 case 'v': | 1349 case 'v': |
| 1350 return FALSE; | 1350 return false; |
| 1351 case '%': { | 1351 case '%': { |
| 1352 CFX_WideString wsSymbol; | 1352 CFX_WideString wsSymbol; |
| 1353 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1353 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1354 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1354 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1355 if (cc + iSysmbolLen <= len && | 1355 if (cc + iSysmbolLen <= len && |
| 1356 !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { | 1356 !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1357 cc += iSysmbolLen; | 1357 cc += iSysmbolLen; |
| 1358 } | 1358 } |
| 1359 ccf++; | 1359 ccf++; |
| 1360 bHavePercentSymbol = TRUE; | 1360 bHavePercentSymbol = true; |
| 1361 } break; | 1361 } break; |
| 1362 case '8': { | 1362 case '8': { |
| 1363 while (ccf < lenf && strf[ccf] == '8') { | 1363 while (ccf < lenf && strf[ccf] == '8') { |
| 1364 ccf++; | 1364 ccf++; |
| 1365 } | 1365 } |
| 1366 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 1366 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 1367 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; | 1367 dbRetValue = (str[cc] - '0') * coeff + dbRetValue; |
| 1368 coeff *= 0.1; | 1368 coeff *= 0.1; |
| 1369 cc++; | 1369 cc++; |
| 1370 } | 1370 } |
| 1371 } break; | 1371 } break; |
| 1372 case ',': { | 1372 case ',': { |
| 1373 if (cc + iGroupLen <= len && | 1373 if (cc + iGroupLen <= len && |
| 1374 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { | 1374 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1375 cc += iGroupLen; | 1375 cc += iGroupLen; |
| 1376 } | 1376 } |
| 1377 ccf++; | 1377 ccf++; |
| 1378 } break; | 1378 } break; |
| 1379 case '(': | 1379 case '(': |
| 1380 if (str[cc] == L'(') { | 1380 if (str[cc] == L'(') { |
| 1381 bNeg = TRUE; | 1381 bNeg = true; |
| 1382 } else if (str[cc] != L' ') { | 1382 } else if (str[cc] != L' ') { |
| 1383 return FALSE; | 1383 return false; |
| 1384 } | 1384 } |
| 1385 cc++; | 1385 cc++; |
| 1386 ccf++; | 1386 ccf++; |
| 1387 break; | 1387 break; |
| 1388 case ')': | 1388 case ')': |
| 1389 if (str[cc] == L')') { | 1389 if (str[cc] == L')') { |
| 1390 bNeg = TRUE; | 1390 bNeg = true; |
| 1391 } else if (str[cc] != L' ') { | 1391 } else if (str[cc] != L' ') { |
| 1392 return FALSE; | 1392 return false; |
| 1393 } | 1393 } |
| 1394 cc++; | 1394 cc++; |
| 1395 ccf++; | 1395 ccf++; |
| 1396 break; | 1396 break; |
| 1397 default: | 1397 default: |
| 1398 if (strf[ccf] != str[cc]) { | 1398 if (strf[ccf] != str[cc]) { |
| 1399 return FALSE; | 1399 return false; |
| 1400 } | 1400 } |
| 1401 cc++; | 1401 cc++; |
| 1402 ccf++; | 1402 ccf++; |
| 1403 } | 1403 } |
| 1404 } | 1404 } |
| 1405 if (cc != len) { | 1405 if (cc != len) { |
| 1406 return FALSE; | 1406 return false; |
| 1407 } | 1407 } |
| 1408 } | 1408 } |
| 1409 if (iExponent) { | 1409 if (iExponent) { |
| 1410 dbRetValue *= FXSYS_pow(10, (FX_FLOAT)iExponent); | 1410 dbRetValue *= FXSYS_pow(10, (FX_FLOAT)iExponent); |
| 1411 } | 1411 } |
| 1412 if (bHavePercentSymbol) { | 1412 if (bHavePercentSymbol) { |
| 1413 dbRetValue /= 100.0; | 1413 dbRetValue /= 100.0; |
| 1414 } | 1414 } |
| 1415 if (bNeg) { | 1415 if (bNeg) { |
| 1416 dbRetValue = -dbRetValue; | 1416 dbRetValue = -dbRetValue; |
| 1417 } | 1417 } |
| 1418 fValue = (FX_FLOAT)dbRetValue; | 1418 fValue = (FX_FLOAT)dbRetValue; |
| 1419 return TRUE; | 1419 return true; |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 FX_BOOL CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, | 1422 bool CFX_FormatString::ParseNum(const CFX_WideString& wsSrcNum, |
| 1423 const CFX_WideString& wsPattern, | 1423 const CFX_WideString& wsPattern, |
| 1424 CFX_WideString& wsValue) { | 1424 CFX_WideString& wsValue) { |
| 1425 wsValue.clear(); | 1425 wsValue.clear(); |
| 1426 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 1426 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 1427 return FALSE; | 1427 return false; |
| 1428 } | 1428 } |
| 1429 int32_t dot_index_f = -1; | 1429 int32_t dot_index_f = -1; |
| 1430 uint32_t dwFormatStyle = 0; | 1430 uint32_t dwFormatStyle = 0; |
| 1431 CFX_WideString wsNumFormat; | 1431 CFX_WideString wsNumFormat; |
| 1432 IFX_Locale* pLocale = | 1432 IFX_Locale* pLocale = |
| 1433 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); | 1433 GetNumericFormat(wsPattern, dot_index_f, dwFormatStyle, wsNumFormat); |
| 1434 if (!pLocale || wsNumFormat.IsEmpty()) { | 1434 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 1435 return FALSE; | 1435 return false; |
| 1436 } | 1436 } |
| 1437 int32_t iExponent = 0; | 1437 int32_t iExponent = 0; |
| 1438 CFX_WideString wsDotSymbol; | 1438 CFX_WideString wsDotSymbol; |
| 1439 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 1439 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 1440 CFX_WideString wsGroupSymbol; | 1440 CFX_WideString wsGroupSymbol; |
| 1441 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 1441 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 1442 int32_t iGroupLen = wsGroupSymbol.GetLength(); | 1442 int32_t iGroupLen = wsGroupSymbol.GetLength(); |
| 1443 CFX_WideString wsMinus; | 1443 CFX_WideString wsMinus; |
| 1444 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); | 1444 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinus); |
| 1445 int32_t iMinusLen = wsMinus.GetLength(); | 1445 int32_t iMinusLen = wsMinus.GetLength(); |
| 1446 int cc = 0, ccf = 0; | 1446 int cc = 0, ccf = 0; |
| 1447 const FX_WCHAR* str = wsSrcNum.c_str(); | 1447 const FX_WCHAR* str = wsSrcNum.c_str(); |
| 1448 int len = wsSrcNum.GetLength(); | 1448 int len = wsSrcNum.GetLength(); |
| 1449 const FX_WCHAR* strf = wsNumFormat.c_str(); | 1449 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 1450 int lenf = wsNumFormat.GetLength(); | 1450 int lenf = wsNumFormat.GetLength(); |
| 1451 FX_BOOL bHavePercentSymbol = FALSE; | 1451 bool bHavePercentSymbol = false; |
| 1452 FX_BOOL bNeg = FALSE; | 1452 bool bNeg = false; |
| 1453 FX_BOOL bReverseParse = FALSE; | 1453 bool bReverseParse = false; |
| 1454 int32_t dot_index = 0; | 1454 int32_t dot_index = 0; |
| 1455 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && | 1455 if (!FX_GetNumericDotIndex(wsSrcNum, wsDotSymbol, dot_index) && |
| 1456 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { | 1456 (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { |
| 1457 bReverseParse = TRUE; | 1457 bReverseParse = true; |
| 1458 } | 1458 } |
| 1459 bReverseParse = FALSE; | 1459 bReverseParse = false; |
| 1460 ccf = dot_index_f - 1; | 1460 ccf = dot_index_f - 1; |
| 1461 cc = dot_index - 1; | 1461 cc = dot_index - 1; |
| 1462 while (ccf >= 0 && cc >= 0) { | 1462 while (ccf >= 0 && cc >= 0) { |
| 1463 switch (strf[ccf]) { | 1463 switch (strf[ccf]) { |
| 1464 case '\'': { | 1464 case '\'': { |
| 1465 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); | 1465 CFX_WideString wsLiteral = FX_GetLiteralTextReverse(strf, ccf); |
| 1466 int32_t iLiteralLen = wsLiteral.GetLength(); | 1466 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1467 cc -= iLiteralLen - 1; | 1467 cc -= iLiteralLen - 1; |
| 1468 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 1468 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1469 return FALSE; | 1469 return false; |
| 1470 } | 1470 } |
| 1471 cc--; | 1471 cc--; |
| 1472 ccf--; | 1472 ccf--; |
| 1473 break; | 1473 break; |
| 1474 } | 1474 } |
| 1475 case '9': | 1475 case '9': |
| 1476 if (!FXSYS_isDecimalDigit(str[cc])) { | 1476 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 1477 return FALSE; | 1477 return false; |
| 1478 } | 1478 } |
| 1479 wsValue = str[cc] + wsValue; | 1479 wsValue = str[cc] + wsValue; |
| 1480 cc--; | 1480 cc--; |
| 1481 ccf--; | 1481 ccf--; |
| 1482 break; | 1482 break; |
| 1483 case 'z': | 1483 case 'z': |
| 1484 if (FXSYS_isDecimalDigit(str[cc])) { | 1484 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1485 wsValue = str[cc] + wsValue; | 1485 wsValue = str[cc] + wsValue; |
| 1486 cc--; | 1486 cc--; |
| 1487 } | 1487 } |
| 1488 ccf--; | 1488 ccf--; |
| 1489 break; | 1489 break; |
| 1490 case 'Z': | 1490 case 'Z': |
| 1491 if (str[cc] != ' ') { | 1491 if (str[cc] != ' ') { |
| 1492 if (FXSYS_isDecimalDigit(str[cc])) { | 1492 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1493 wsValue = str[cc] + wsValue; | 1493 wsValue = str[cc] + wsValue; |
| 1494 cc--; | 1494 cc--; |
| 1495 } | 1495 } |
| 1496 } else { | 1496 } else { |
| 1497 cc--; | 1497 cc--; |
| 1498 } | 1498 } |
| 1499 ccf--; | 1499 ccf--; |
| 1500 break; | 1500 break; |
| 1501 case 'S': | 1501 case 'S': |
| 1502 if (str[cc] == '+' || str[cc] == ' ') { | 1502 if (str[cc] == '+' || str[cc] == ' ') { |
| 1503 cc--; | 1503 cc--; |
| 1504 } else { | 1504 } else { |
| 1505 cc -= iMinusLen - 1; | 1505 cc -= iMinusLen - 1; |
| 1506 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1506 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1507 return FALSE; | 1507 return false; |
| 1508 } | 1508 } |
| 1509 cc--; | 1509 cc--; |
| 1510 bNeg = TRUE; | 1510 bNeg = true; |
| 1511 } | 1511 } |
| 1512 ccf--; | 1512 ccf--; |
| 1513 break; | 1513 break; |
| 1514 case 's': | 1514 case 's': |
| 1515 if (str[cc] == '+') { | 1515 if (str[cc] == '+') { |
| 1516 cc--; | 1516 cc--; |
| 1517 } else { | 1517 } else { |
| 1518 cc -= iMinusLen - 1; | 1518 cc -= iMinusLen - 1; |
| 1519 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1519 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1520 return FALSE; | 1520 return false; |
| 1521 } | 1521 } |
| 1522 cc--; | 1522 cc--; |
| 1523 bNeg = TRUE; | 1523 bNeg = true; |
| 1524 } | 1524 } |
| 1525 ccf--; | 1525 ccf--; |
| 1526 break; | 1526 break; |
| 1527 case 'E': { | 1527 case 'E': { |
| 1528 if (cc >= dot_index) { | 1528 if (cc >= dot_index) { |
| 1529 return FALSE; | 1529 return false; |
| 1530 } | 1530 } |
| 1531 FX_BOOL bExpSign = FALSE; | 1531 bool bExpSign = false; |
| 1532 while (cc >= 0) { | 1532 while (cc >= 0) { |
| 1533 if (str[cc] == 'E' || str[cc] == 'e') { | 1533 if (str[cc] == 'E' || str[cc] == 'e') { |
| 1534 break; | 1534 break; |
| 1535 } | 1535 } |
| 1536 if (FXSYS_isDecimalDigit(str[cc])) { | 1536 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1537 iExponent = iExponent + (str[cc] - '0') * 10; | 1537 iExponent = iExponent + (str[cc] - '0') * 10; |
| 1538 cc--; | 1538 cc--; |
| 1539 continue; | 1539 continue; |
| 1540 } else if (str[cc] == '+') { | 1540 } else if (str[cc] == '+') { |
| 1541 cc--; | 1541 cc--; |
| 1542 continue; | 1542 continue; |
| 1543 } else if (cc - iMinusLen + 1 > 0 && | 1543 } else if (cc - iMinusLen + 1 > 0 && |
| 1544 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(), | 1544 !FXSYS_wcsncmp(str + (cc - iMinusLen + 1), wsMinus.c_str(), |
| 1545 iMinusLen)) { | 1545 iMinusLen)) { |
| 1546 bExpSign = TRUE; | 1546 bExpSign = true; |
| 1547 cc -= iMinusLen; | 1547 cc -= iMinusLen; |
| 1548 } else { | 1548 } else { |
| 1549 return FALSE; | 1549 return false; |
| 1550 } | 1550 } |
| 1551 } | 1551 } |
| 1552 cc--; | 1552 cc--; |
| 1553 iExponent = bExpSign ? -iExponent : iExponent; | 1553 iExponent = bExpSign ? -iExponent : iExponent; |
| 1554 ccf--; | 1554 ccf--; |
| 1555 } break; | 1555 } break; |
| 1556 case '$': { | 1556 case '$': { |
| 1557 CFX_WideString wsSymbol; | 1557 CFX_WideString wsSymbol; |
| 1558 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 1558 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 1559 int32_t iSymbolLen = wsSymbol.GetLength(); | 1559 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1560 cc -= iSymbolLen - 1; | 1560 cc -= iSymbolLen - 1; |
| 1561 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { | 1561 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1562 return FALSE; | 1562 return false; |
| 1563 } | 1563 } |
| 1564 cc--; | 1564 cc--; |
| 1565 ccf--; | 1565 ccf--; |
| 1566 } break; | 1566 } break; |
| 1567 case 'r': | 1567 case 'r': |
| 1568 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 1568 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 1569 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1569 if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1570 bNeg = TRUE; | 1570 bNeg = true; |
| 1571 cc -= 2; | 1571 cc -= 2; |
| 1572 } | 1572 } |
| 1573 ccf -= 2; | 1573 ccf -= 2; |
| 1574 } else { | 1574 } else { |
| 1575 ccf--; | 1575 ccf--; |
| 1576 } | 1576 } |
| 1577 break; | 1577 break; |
| 1578 case 'R': | 1578 case 'R': |
| 1579 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { | 1579 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { |
| 1580 if (str[cc] == ' ') { | 1580 if (str[cc] == ' ') { |
| 1581 cc++; | 1581 cc++; |
| 1582 } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { | 1582 } else if (str[cc] == 'R' && cc - 1 >= 0 && str[cc - 1] == 'C') { |
| 1583 bNeg = TRUE; | 1583 bNeg = true; |
| 1584 cc -= 2; | 1584 cc -= 2; |
| 1585 } | 1585 } |
| 1586 ccf -= 2; | 1586 ccf -= 2; |
| 1587 } else { | 1587 } else { |
| 1588 ccf--; | 1588 ccf--; |
| 1589 } | 1589 } |
| 1590 break; | 1590 break; |
| 1591 case 'b': | 1591 case 'b': |
| 1592 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { | 1592 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { |
| 1593 if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { | 1593 if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { |
| 1594 bNeg = TRUE; | 1594 bNeg = true; |
| 1595 cc -= 2; | 1595 cc -= 2; |
| 1596 } | 1596 } |
| 1597 ccf -= 2; | 1597 ccf -= 2; |
| 1598 } else { | 1598 } else { |
| 1599 ccf--; | 1599 ccf--; |
| 1600 } | 1600 } |
| 1601 break; | 1601 break; |
| 1602 case 'B': | 1602 case 'B': |
| 1603 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { | 1603 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { |
| 1604 if (str[cc] == ' ') { | 1604 if (str[cc] == ' ') { |
| 1605 cc++; | 1605 cc++; |
| 1606 } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { | 1606 } else if (str[cc] == 'B' && cc - 1 >= 0 && str[cc - 1] == 'D') { |
| 1607 bNeg = TRUE; | 1607 bNeg = true; |
| 1608 cc -= 2; | 1608 cc -= 2; |
| 1609 } | 1609 } |
| 1610 ccf -= 2; | 1610 ccf -= 2; |
| 1611 } else { | 1611 } else { |
| 1612 ccf--; | 1612 ccf--; |
| 1613 } | 1613 } |
| 1614 break; | 1614 break; |
| 1615 case '.': | 1615 case '.': |
| 1616 case 'V': | 1616 case 'V': |
| 1617 case 'v': | 1617 case 'v': |
| 1618 return FALSE; | 1618 return false; |
| 1619 case '%': { | 1619 case '%': { |
| 1620 CFX_WideString wsSymbol; | 1620 CFX_WideString wsSymbol; |
| 1621 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1621 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1622 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1622 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1623 cc -= iSysmbolLen - 1; | 1623 cc -= iSysmbolLen - 1; |
| 1624 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { | 1624 if (cc < 0 || FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1625 return FALSE; | 1625 return false; |
| 1626 } | 1626 } |
| 1627 cc--; | 1627 cc--; |
| 1628 ccf--; | 1628 ccf--; |
| 1629 bHavePercentSymbol = TRUE; | 1629 bHavePercentSymbol = true; |
| 1630 } break; | 1630 } break; |
| 1631 case '8': | 1631 case '8': |
| 1632 return FALSE; | 1632 return false; |
| 1633 case ',': { | 1633 case ',': { |
| 1634 if (cc >= 0) { | 1634 if (cc >= 0) { |
| 1635 cc -= iGroupLen - 1; | 1635 cc -= iGroupLen - 1; |
| 1636 if (cc >= 0 && | 1636 if (cc >= 0 && |
| 1637 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { | 1637 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1638 cc--; | 1638 cc--; |
| 1639 } else { | 1639 } else { |
| 1640 cc += iGroupLen - 1; | 1640 cc += iGroupLen - 1; |
| 1641 } | 1641 } |
| 1642 } | 1642 } |
| 1643 ccf--; | 1643 ccf--; |
| 1644 } break; | 1644 } break; |
| 1645 case '(': | 1645 case '(': |
| 1646 if (str[cc] == L'(') { | 1646 if (str[cc] == L'(') { |
| 1647 bNeg = TRUE; | 1647 bNeg = true; |
| 1648 } else if (str[cc] != L' ') { | 1648 } else if (str[cc] != L' ') { |
| 1649 return FALSE; | 1649 return false; |
| 1650 } | 1650 } |
| 1651 cc--; | 1651 cc--; |
| 1652 ccf--; | 1652 ccf--; |
| 1653 break; | 1653 break; |
| 1654 case ')': | 1654 case ')': |
| 1655 if (str[cc] == L')') { | 1655 if (str[cc] == L')') { |
| 1656 bNeg = TRUE; | 1656 bNeg = true; |
| 1657 } else if (str[cc] != L' ') { | 1657 } else if (str[cc] != L' ') { |
| 1658 return FALSE; | 1658 return false; |
| 1659 } | 1659 } |
| 1660 cc--; | 1660 cc--; |
| 1661 ccf--; | 1661 ccf--; |
| 1662 break; | 1662 break; |
| 1663 default: | 1663 default: |
| 1664 if (strf[ccf] != str[cc]) { | 1664 if (strf[ccf] != str[cc]) { |
| 1665 return FALSE; | 1665 return false; |
| 1666 } | 1666 } |
| 1667 cc--; | 1667 cc--; |
| 1668 ccf--; | 1668 ccf--; |
| 1669 } | 1669 } |
| 1670 } | 1670 } |
| 1671 if (cc >= 0) { | 1671 if (cc >= 0) { |
| 1672 if (str[cc] == '-') { | 1672 if (str[cc] == '-') { |
| 1673 bNeg = TRUE; | 1673 bNeg = true; |
| 1674 cc--; | 1674 cc--; |
| 1675 } | 1675 } |
| 1676 if (cc >= 0) { | 1676 if (cc >= 0) { |
| 1677 return FALSE; | 1677 return false; |
| 1678 } | 1678 } |
| 1679 } | 1679 } |
| 1680 if (dot_index < len && (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { | 1680 if (dot_index < len && (dwFormatStyle & FX_NUMSTYLE_DotVorv)) { |
| 1681 wsValue += '.'; | 1681 wsValue += '.'; |
| 1682 } | 1682 } |
| 1683 if (!bReverseParse) { | 1683 if (!bReverseParse) { |
| 1684 ccf = dot_index_f + 1; | 1684 ccf = dot_index_f + 1; |
| 1685 cc = (dot_index == len) ? len : dot_index + 1; | 1685 cc = (dot_index == len) ? len : dot_index + 1; |
| 1686 while (cc < len && ccf < lenf) { | 1686 while (cc < len && ccf < lenf) { |
| 1687 switch (strf[ccf]) { | 1687 switch (strf[ccf]) { |
| 1688 case '\'': { | 1688 case '\'': { |
| 1689 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 1689 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 1690 int32_t iLiteralLen = wsLiteral.GetLength(); | 1690 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 1691 if (cc + iLiteralLen > len || | 1691 if (cc + iLiteralLen > len || |
| 1692 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 1692 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 1693 return FALSE; | 1693 return false; |
| 1694 } | 1694 } |
| 1695 cc += iLiteralLen; | 1695 cc += iLiteralLen; |
| 1696 ccf++; | 1696 ccf++; |
| 1697 break; | 1697 break; |
| 1698 } | 1698 } |
| 1699 case '9': | 1699 case '9': |
| 1700 if (!FXSYS_isDecimalDigit(str[cc])) { | 1700 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 1701 return FALSE; | 1701 return false; |
| 1702 } | 1702 } |
| 1703 { wsValue += str[cc]; } | 1703 { wsValue += str[cc]; } |
| 1704 cc++; | 1704 cc++; |
| 1705 ccf++; | 1705 ccf++; |
| 1706 break; | 1706 break; |
| 1707 case 'z': | 1707 case 'z': |
| 1708 if (FXSYS_isDecimalDigit(str[cc])) { | 1708 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1709 wsValue += str[cc]; | 1709 wsValue += str[cc]; |
| 1710 cc++; | 1710 cc++; |
| 1711 } | 1711 } |
| 1712 ccf++; | 1712 ccf++; |
| 1713 break; | 1713 break; |
| 1714 case 'Z': | 1714 case 'Z': |
| 1715 if (str[cc] != ' ') { | 1715 if (str[cc] != ' ') { |
| 1716 if (FXSYS_isDecimalDigit(str[cc])) { | 1716 if (FXSYS_isDecimalDigit(str[cc])) { |
| 1717 wsValue += str[cc]; | 1717 wsValue += str[cc]; |
| 1718 cc++; | 1718 cc++; |
| 1719 } | 1719 } |
| 1720 } else { | 1720 } else { |
| 1721 cc++; | 1721 cc++; |
| 1722 } | 1722 } |
| 1723 ccf++; | 1723 ccf++; |
| 1724 break; | 1724 break; |
| 1725 case 'S': | 1725 case 'S': |
| 1726 if (str[cc] == '+' || str[cc] == ' ') { | 1726 if (str[cc] == '+' || str[cc] == ' ') { |
| 1727 cc++; | 1727 cc++; |
| 1728 } else { | 1728 } else { |
| 1729 if (cc + iMinusLen > len || | 1729 if (cc + iMinusLen > len || |
| 1730 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1730 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1731 return FALSE; | 1731 return false; |
| 1732 } | 1732 } |
| 1733 bNeg = TRUE; | 1733 bNeg = true; |
| 1734 cc += iMinusLen; | 1734 cc += iMinusLen; |
| 1735 } | 1735 } |
| 1736 ccf++; | 1736 ccf++; |
| 1737 break; | 1737 break; |
| 1738 case 's': | 1738 case 's': |
| 1739 if (str[cc] == '+') { | 1739 if (str[cc] == '+') { |
| 1740 cc++; | 1740 cc++; |
| 1741 } else { | 1741 } else { |
| 1742 if (cc + iMinusLen > len || | 1742 if (cc + iMinusLen > len || |
| 1743 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { | 1743 FXSYS_wcsncmp(str + cc, wsMinus.c_str(), iMinusLen)) { |
| 1744 return FALSE; | 1744 return false; |
| 1745 } | 1745 } |
| 1746 bNeg = TRUE; | 1746 bNeg = true; |
| 1747 cc += iMinusLen; | 1747 cc += iMinusLen; |
| 1748 } | 1748 } |
| 1749 ccf++; | 1749 ccf++; |
| 1750 break; | 1750 break; |
| 1751 case 'E': { | 1751 case 'E': { |
| 1752 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { | 1752 if (cc >= len || (str[cc] != 'E' && str[cc] != 'e')) { |
| 1753 return FALSE; | 1753 return false; |
| 1754 } | 1754 } |
| 1755 FX_BOOL bExpSign = FALSE; | 1755 bool bExpSign = false; |
| 1756 cc++; | 1756 cc++; |
| 1757 if (cc < len) { | 1757 if (cc < len) { |
| 1758 if (str[cc] == '+') { | 1758 if (str[cc] == '+') { |
| 1759 cc++; | 1759 cc++; |
| 1760 } else if (str[cc] == '-') { | 1760 } else if (str[cc] == '-') { |
| 1761 bExpSign = TRUE; | 1761 bExpSign = true; |
| 1762 cc++; | 1762 cc++; |
| 1763 } | 1763 } |
| 1764 } | 1764 } |
| 1765 while (cc < len) { | 1765 while (cc < len) { |
| 1766 if (!FXSYS_isDecimalDigit(str[cc])) { | 1766 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 1767 break; | 1767 break; |
| 1768 } | 1768 } |
| 1769 iExponent = iExponent * 10 + str[cc] - '0'; | 1769 iExponent = iExponent * 10 + str[cc] - '0'; |
| 1770 cc++; | 1770 cc++; |
| 1771 } | 1771 } |
| 1772 iExponent = bExpSign ? -iExponent : iExponent; | 1772 iExponent = bExpSign ? -iExponent : iExponent; |
| 1773 ccf++; | 1773 ccf++; |
| 1774 } break; | 1774 } break; |
| 1775 case '$': { | 1775 case '$': { |
| 1776 CFX_WideString wsSymbol; | 1776 CFX_WideString wsSymbol; |
| 1777 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, | 1777 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, |
| 1778 wsSymbol); | 1778 wsSymbol); |
| 1779 int32_t iSymbolLen = wsSymbol.GetLength(); | 1779 int32_t iSymbolLen = wsSymbol.GetLength(); |
| 1780 if (cc + iSymbolLen > len || | 1780 if (cc + iSymbolLen > len || |
| 1781 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { | 1781 FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSymbolLen)) { |
| 1782 return FALSE; | 1782 return false; |
| 1783 } | 1783 } |
| 1784 cc += iSymbolLen; | 1784 cc += iSymbolLen; |
| 1785 ccf++; | 1785 ccf++; |
| 1786 } break; | 1786 } break; |
| 1787 case 'c': | 1787 case 'c': |
| 1788 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { | 1788 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { |
| 1789 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { | 1789 if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { |
| 1790 bNeg = TRUE; | 1790 bNeg = true; |
| 1791 cc += 2; | 1791 cc += 2; |
| 1792 } | 1792 } |
| 1793 ccf += 2; | 1793 ccf += 2; |
| 1794 } | 1794 } |
| 1795 break; | 1795 break; |
| 1796 case 'C': | 1796 case 'C': |
| 1797 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { | 1797 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { |
| 1798 if (str[cc] == ' ') { | 1798 if (str[cc] == ' ') { |
| 1799 cc++; | 1799 cc++; |
| 1800 } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { | 1800 } else if (str[cc] == 'C' && cc + 1 < len && str[cc + 1] == 'R') { |
| 1801 bNeg = TRUE; | 1801 bNeg = true; |
| 1802 cc += 2; | 1802 cc += 2; |
| 1803 } | 1803 } |
| 1804 ccf += 2; | 1804 ccf += 2; |
| 1805 } | 1805 } |
| 1806 break; | 1806 break; |
| 1807 case 'd': | 1807 case 'd': |
| 1808 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { | 1808 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { |
| 1809 if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { | 1809 if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { |
| 1810 bNeg = TRUE; | 1810 bNeg = true; |
| 1811 cc += 2; | 1811 cc += 2; |
| 1812 } | 1812 } |
| 1813 ccf += 2; | 1813 ccf += 2; |
| 1814 } | 1814 } |
| 1815 break; | 1815 break; |
| 1816 case 'D': | 1816 case 'D': |
| 1817 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { | 1817 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { |
| 1818 if (str[cc] == ' ') { | 1818 if (str[cc] == ' ') { |
| 1819 cc++; | 1819 cc++; |
| 1820 } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { | 1820 } else if (str[cc] == 'D' && cc + 1 < len && str[cc + 1] == 'B') { |
| 1821 bNeg = TRUE; | 1821 bNeg = true; |
| 1822 cc += 2; | 1822 cc += 2; |
| 1823 } | 1823 } |
| 1824 ccf += 2; | 1824 ccf += 2; |
| 1825 } | 1825 } |
| 1826 break; | 1826 break; |
| 1827 case '.': | 1827 case '.': |
| 1828 case 'V': | 1828 case 'V': |
| 1829 case 'v': | 1829 case 'v': |
| 1830 return FALSE; | 1830 return false; |
| 1831 case '%': { | 1831 case '%': { |
| 1832 CFX_WideString wsSymbol; | 1832 CFX_WideString wsSymbol; |
| 1833 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 1833 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 1834 int32_t iSysmbolLen = wsSymbol.GetLength(); | 1834 int32_t iSysmbolLen = wsSymbol.GetLength(); |
| 1835 if (cc + iSysmbolLen <= len && | 1835 if (cc + iSysmbolLen <= len && |
| 1836 !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { | 1836 !FXSYS_wcsncmp(str + cc, wsSymbol.c_str(), iSysmbolLen)) { |
| 1837 cc += iSysmbolLen; | 1837 cc += iSysmbolLen; |
| 1838 } | 1838 } |
| 1839 ccf++; | 1839 ccf++; |
| 1840 bHavePercentSymbol = TRUE; | 1840 bHavePercentSymbol = true; |
| 1841 } break; | 1841 } break; |
| 1842 case '8': { | 1842 case '8': { |
| 1843 while (ccf < lenf && strf[ccf] == '8') { | 1843 while (ccf < lenf && strf[ccf] == '8') { |
| 1844 ccf++; | 1844 ccf++; |
| 1845 } | 1845 } |
| 1846 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 1846 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 1847 wsValue += str[cc]; | 1847 wsValue += str[cc]; |
| 1848 cc++; | 1848 cc++; |
| 1849 } | 1849 } |
| 1850 } break; | 1850 } break; |
| 1851 case ',': { | 1851 case ',': { |
| 1852 if (cc + iGroupLen <= len && | 1852 if (cc + iGroupLen <= len && |
| 1853 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { | 1853 FXSYS_wcsncmp(str + cc, wsGroupSymbol.c_str(), iGroupLen) == 0) { |
| 1854 cc += iGroupLen; | 1854 cc += iGroupLen; |
| 1855 } | 1855 } |
| 1856 ccf++; | 1856 ccf++; |
| 1857 } break; | 1857 } break; |
| 1858 case '(': | 1858 case '(': |
| 1859 if (str[cc] == L'(') { | 1859 if (str[cc] == L'(') { |
| 1860 bNeg = TRUE; | 1860 bNeg = true; |
| 1861 } else if (str[cc] != L' ') { | 1861 } else if (str[cc] != L' ') { |
| 1862 return FALSE; | 1862 return false; |
| 1863 } | 1863 } |
| 1864 cc++; | 1864 cc++; |
| 1865 ccf++; | 1865 ccf++; |
| 1866 break; | 1866 break; |
| 1867 case ')': | 1867 case ')': |
| 1868 if (str[cc] == L')') { | 1868 if (str[cc] == L')') { |
| 1869 bNeg = TRUE; | 1869 bNeg = true; |
| 1870 } else if (str[cc] != L' ') { | 1870 } else if (str[cc] != L' ') { |
| 1871 return FALSE; | 1871 return false; |
| 1872 } | 1872 } |
| 1873 cc++; | 1873 cc++; |
| 1874 ccf++; | 1874 ccf++; |
| 1875 break; | 1875 break; |
| 1876 default: | 1876 default: |
| 1877 if (strf[ccf] != str[cc]) { | 1877 if (strf[ccf] != str[cc]) { |
| 1878 return FALSE; | 1878 return false; |
| 1879 } | 1879 } |
| 1880 cc++; | 1880 cc++; |
| 1881 ccf++; | 1881 ccf++; |
| 1882 } | 1882 } |
| 1883 } | 1883 } |
| 1884 if (cc != len) { | 1884 if (cc != len) { |
| 1885 return FALSE; | 1885 return false; |
| 1886 } | 1886 } |
| 1887 } | 1887 } |
| 1888 if (iExponent || bHavePercentSymbol) { | 1888 if (iExponent || bHavePercentSymbol) { |
| 1889 CFX_Decimal decimal = CFX_Decimal(wsValue.AsStringC()); | 1889 CFX_Decimal decimal = CFX_Decimal(wsValue.AsStringC()); |
| 1890 if (iExponent) { | 1890 if (iExponent) { |
| 1891 decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); | 1891 decimal = decimal * CFX_Decimal(FXSYS_pow(10, (FX_FLOAT)iExponent)); |
| 1892 } | 1892 } |
| 1893 if (bHavePercentSymbol) { | 1893 if (bHavePercentSymbol) { |
| 1894 decimal = decimal / CFX_Decimal(100); | 1894 decimal = decimal / CFX_Decimal(100); |
| 1895 } | 1895 } |
| 1896 wsValue = decimal; | 1896 wsValue = decimal; |
| 1897 } | 1897 } |
| 1898 if (bNeg) { | 1898 if (bNeg) { |
| 1899 wsValue = L'-' + wsValue; | 1899 wsValue = L'-' + wsValue; |
| 1900 } | 1900 } |
| 1901 return TRUE; | 1901 return true; |
| 1902 } | 1902 } |
| 1903 FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( | 1903 FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( |
| 1904 const CFX_WideString& wsPattern, | 1904 const CFX_WideString& wsPattern, |
| 1905 IFX_Locale*& pLocale, | 1905 IFX_Locale*& pLocale, |
| 1906 CFX_WideString& wsDatePattern, | 1906 CFX_WideString& wsDatePattern, |
| 1907 CFX_WideString& wsTimePattern) { | 1907 CFX_WideString& wsTimePattern) { |
| 1908 pLocale = nullptr; | 1908 pLocale = nullptr; |
| 1909 CFX_WideString wsTempPattern; | 1909 CFX_WideString wsTempPattern; |
| 1910 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; | 1910 FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown; |
| 1911 int32_t ccf = 0; | 1911 int32_t ccf = 0; |
| 1912 int32_t iLenf = wsPattern.GetLength(); | 1912 int32_t iLenf = wsPattern.GetLength(); |
| 1913 const FX_WCHAR* pStr = wsPattern.c_str(); | 1913 const FX_WCHAR* pStr = wsPattern.c_str(); |
| 1914 int32_t iFindCategory = 0; | 1914 int32_t iFindCategory = 0; |
| 1915 FX_BOOL bBraceOpen = FALSE; | 1915 bool bBraceOpen = false; |
| 1916 CFX_WideStringC wsConstChars(gs_wsConstChars); | 1916 CFX_WideStringC wsConstChars(gs_wsConstChars); |
| 1917 while (ccf < iLenf) { | 1917 while (ccf < iLenf) { |
| 1918 if (pStr[ccf] == '\'') { | 1918 if (pStr[ccf] == '\'') { |
| 1919 int32_t iCurChar = ccf; | 1919 int32_t iCurChar = ccf; |
| 1920 FX_GetLiteralText(pStr, ccf, iLenf); | 1920 FX_GetLiteralText(pStr, ccf, iLenf); |
| 1921 wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); | 1921 wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1); |
| 1922 } else if (!bBraceOpen && iFindCategory != 3 && | 1922 } else if (!bBraceOpen && iFindCategory != 3 && |
| 1923 wsConstChars.Find(pStr[ccf]) == -1) { | 1923 wsConstChars.Find(pStr[ccf]) == -1) { |
| 1924 CFX_WideString wsCategory(pStr[ccf]); | 1924 CFX_WideString wsCategory(pStr[ccf]); |
| 1925 ccf++; | 1925 ccf++; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1954 } | 1954 } |
| 1955 while (ccf < iLenf) { | 1955 while (ccf < iLenf) { |
| 1956 if (pStr[ccf] == '(') { | 1956 if (pStr[ccf] == '(') { |
| 1957 ccf++; | 1957 ccf++; |
| 1958 CFX_WideString wsLCID; | 1958 CFX_WideString wsLCID; |
| 1959 while (ccf < iLenf && pStr[ccf] != ')') { | 1959 while (ccf < iLenf && pStr[ccf] != ')') { |
| 1960 wsLCID += pStr[ccf++]; | 1960 wsLCID += pStr[ccf++]; |
| 1961 } | 1961 } |
| 1962 pLocale = GetPatternLocale(wsLCID); | 1962 pLocale = GetPatternLocale(wsLCID); |
| 1963 } else if (pStr[ccf] == '{') { | 1963 } else if (pStr[ccf] == '{') { |
| 1964 bBraceOpen = TRUE; | 1964 bBraceOpen = true; |
| 1965 break; | 1965 break; |
| 1966 } else if (pStr[ccf] == '.') { | 1966 } else if (pStr[ccf] == '.') { |
| 1967 CFX_WideString wsSubCategory; | 1967 CFX_WideString wsSubCategory; |
| 1968 ccf++; | 1968 ccf++; |
| 1969 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { | 1969 while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{') { |
| 1970 wsSubCategory += pStr[ccf++]; | 1970 wsSubCategory += pStr[ccf++]; |
| 1971 } | 1971 } |
| 1972 uint32_t dwSubHash = | 1972 uint32_t dwSubHash = |
| 1973 FX_HashCode_GetW(wsSubCategory.AsStringC(), false); | 1973 FX_HashCode_GetW(wsSubCategory.AsStringC(), false); |
| 1974 FX_LOCALEDATETIMESUBCATEGORY eSubCategory = | 1974 FX_LOCALEDATETIMESUBCATEGORY eSubCategory = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2001 break; | 2001 break; |
| 2002 default: | 2002 default: |
| 2003 break; | 2003 break; |
| 2004 } | 2004 } |
| 2005 wsTempPattern.clear(); | 2005 wsTempPattern.clear(); |
| 2006 continue; | 2006 continue; |
| 2007 } | 2007 } |
| 2008 ccf++; | 2008 ccf++; |
| 2009 } | 2009 } |
| 2010 } else if (pStr[ccf] == '}') { | 2010 } else if (pStr[ccf] == '}') { |
| 2011 bBraceOpen = FALSE; | 2011 bBraceOpen = false; |
| 2012 if (!wsTempPattern.IsEmpty()) { | 2012 if (!wsTempPattern.IsEmpty()) { |
| 2013 if (eCategory == FX_LOCALECATEGORY_Time) { | 2013 if (eCategory == FX_LOCALECATEGORY_Time) { |
| 2014 wsTimePattern = wsTempPattern; | 2014 wsTimePattern = wsTempPattern; |
| 2015 } else if (eCategory == FX_LOCALECATEGORY_Date) { | 2015 } else if (eCategory == FX_LOCALECATEGORY_Date) { |
| 2016 wsDatePattern = wsTempPattern; | 2016 wsDatePattern = wsTempPattern; |
| 2017 } | 2017 } |
| 2018 wsTempPattern.clear(); | 2018 wsTempPattern.clear(); |
| 2019 } | 2019 } |
| 2020 } else { | 2020 } else { |
| 2021 wsTempPattern += pStr[ccf]; | 2021 wsTempPattern += pStr[ccf]; |
| 2022 } | 2022 } |
| 2023 ccf++; | 2023 ccf++; |
| 2024 } | 2024 } |
| 2025 if (!wsTempPattern.IsEmpty()) { | 2025 if (!wsTempPattern.IsEmpty()) { |
| 2026 if (eCategory == FX_LOCALECATEGORY_Date) { | 2026 if (eCategory == FX_LOCALECATEGORY_Date) { |
| 2027 wsDatePattern += wsTempPattern; | 2027 wsDatePattern += wsTempPattern; |
| 2028 } else { | 2028 } else { |
| 2029 wsTimePattern += wsTempPattern; | 2029 wsTimePattern += wsTempPattern; |
| 2030 } | 2030 } |
| 2031 } | 2031 } |
| 2032 if (!pLocale) { | 2032 if (!pLocale) { |
| 2033 pLocale = m_pLocaleMgr->GetDefLocale(); | 2033 pLocale = m_pLocaleMgr->GetDefLocale(); |
| 2034 } | 2034 } |
| 2035 if (!iFindCategory) { | 2035 if (!iFindCategory) { |
| 2036 wsTimePattern.clear(); | 2036 wsTimePattern.clear(); |
| 2037 wsDatePattern = wsPattern; | 2037 wsDatePattern = wsPattern; |
| 2038 } | 2038 } |
| 2039 return (FX_DATETIMETYPE)iFindCategory; | 2039 return (FX_DATETIMETYPE)iFindCategory; |
| 2040 } | 2040 } |
| 2041 static FX_BOOL FX_ParseLocaleDate(const CFX_WideString& wsDate, | 2041 static bool FX_ParseLocaleDate(const CFX_WideString& wsDate, |
| 2042 const CFX_WideString& wsDatePattern, | 2042 const CFX_WideString& wsDatePattern, |
| 2043 IFX_Locale* pLocale, | 2043 IFX_Locale* pLocale, |
| 2044 CFX_Unitime& datetime, | 2044 CFX_Unitime& datetime, |
| 2045 int32_t& cc) { | 2045 int32_t& cc) { |
| 2046 int32_t year = 1900; | 2046 int32_t year = 1900; |
| 2047 int32_t month = 1; | 2047 int32_t month = 1; |
| 2048 int32_t day = 1; | 2048 int32_t day = 1; |
| 2049 int32_t ccf = 0; | 2049 int32_t ccf = 0; |
| 2050 const FX_WCHAR* str = wsDate.c_str(); | 2050 const FX_WCHAR* str = wsDate.c_str(); |
| 2051 int32_t len = wsDate.GetLength(); | 2051 int32_t len = wsDate.GetLength(); |
| 2052 const FX_WCHAR* strf = wsDatePattern.c_str(); | 2052 const FX_WCHAR* strf = wsDatePattern.c_str(); |
| 2053 int32_t lenf = wsDatePattern.GetLength(); | 2053 int32_t lenf = wsDatePattern.GetLength(); |
| 2054 CFX_WideStringC wsDateSymbols(gs_wsDateSymbols); | 2054 CFX_WideStringC wsDateSymbols(gs_wsDateSymbols); |
| 2055 while (cc < len && ccf < lenf) { | 2055 while (cc < len && ccf < lenf) { |
| 2056 if (strf[ccf] == '\'') { | 2056 if (strf[ccf] == '\'') { |
| 2057 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 2057 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 2058 int32_t iLiteralLen = wsLiteral.GetLength(); | 2058 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2059 if (cc + iLiteralLen > len || | 2059 if (cc + iLiteralLen > len || |
| 2060 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 2060 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 2061 return FALSE; | 2061 return false; |
| 2062 } | 2062 } |
| 2063 cc += iLiteralLen; | 2063 cc += iLiteralLen; |
| 2064 ccf++; | 2064 ccf++; |
| 2065 continue; | 2065 continue; |
| 2066 } else if (wsDateSymbols.Find(strf[ccf]) == -1) { | 2066 } else if (wsDateSymbols.Find(strf[ccf]) == -1) { |
| 2067 if (strf[ccf] != str[cc]) | 2067 if (strf[ccf] != str[cc]) |
| 2068 return FALSE; | 2068 return false; |
| 2069 cc++; | 2069 cc++; |
| 2070 ccf++; | 2070 ccf++; |
| 2071 continue; | 2071 continue; |
| 2072 } | 2072 } |
| 2073 uint32_t dwSymbolNum = 1; | 2073 uint32_t dwSymbolNum = 1; |
| 2074 FX_WCHAR dwCharSymbol = strf[ccf++]; | 2074 FX_WCHAR dwCharSymbol = strf[ccf++]; |
| 2075 while (ccf < lenf && strf[ccf] == dwCharSymbol) { | 2075 while (ccf < lenf && strf[ccf] == dwCharSymbol) { |
| 2076 ccf++; | 2076 ccf++; |
| 2077 dwSymbolNum++; | 2077 dwSymbolNum++; |
| 2078 } | 2078 } |
| 2079 uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0'); | 2079 uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0'); |
| 2080 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { | 2080 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { |
| 2081 if (!FXSYS_isDecimalDigit(str[cc])) { | 2081 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2082 return FALSE; | 2082 return false; |
| 2083 } | 2083 } |
| 2084 day = str[cc++] - '0'; | 2084 day = str[cc++] - '0'; |
| 2085 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 2085 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 2086 day = day * 10 + str[cc++] - '0'; | 2086 day = day * 10 + str[cc++] - '0'; |
| 2087 } | 2087 } |
| 2088 } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { | 2088 } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { |
| 2089 if (!FXSYS_isDecimalDigit(str[cc])) { | 2089 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2090 return FALSE; | 2090 return false; |
| 2091 } | 2091 } |
| 2092 day = str[cc++] - '0'; | 2092 day = str[cc++] - '0'; |
| 2093 if (cc < len) { | 2093 if (cc < len) { |
| 2094 day = day * 10 + str[cc++] - '0'; | 2094 day = day * 10 + str[cc++] - '0'; |
| 2095 } | 2095 } |
| 2096 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { | 2096 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { |
| 2097 int i = 0; | 2097 int i = 0; |
| 2098 while (cc < len && i < 3 && FXSYS_isDecimalDigit(str[cc])) { | 2098 while (cc < len && i < 3 && FXSYS_isDecimalDigit(str[cc])) { |
| 2099 cc++; | 2099 cc++; |
| 2100 i++; | 2100 i++; |
| 2101 } | 2101 } |
| 2102 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { | 2102 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { |
| 2103 cc += 3; | 2103 cc += 3; |
| 2104 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { | 2104 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { |
| 2105 if (!FXSYS_isDecimalDigit(str[cc])) { | 2105 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2106 return FALSE; | 2106 return false; |
| 2107 } | 2107 } |
| 2108 month = str[cc++] - '0'; | 2108 month = str[cc++] - '0'; |
| 2109 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 2109 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 2110 month = month * 10 + str[cc++] - '0'; | 2110 month = month * 10 + str[cc++] - '0'; |
| 2111 } | 2111 } |
| 2112 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { | 2112 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { |
| 2113 if (!FXSYS_isDecimalDigit(str[cc])) { | 2113 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2114 return FALSE; | 2114 return false; |
| 2115 } | 2115 } |
| 2116 month = str[cc++] - '0'; | 2116 month = str[cc++] - '0'; |
| 2117 if (cc < len) { | 2117 if (cc < len) { |
| 2118 month = month * 10 + str[cc++] - '0'; | 2118 month = month * 10 + str[cc++] - '0'; |
| 2119 } | 2119 } |
| 2120 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { | 2120 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { |
| 2121 CFX_WideString wsMonthNameAbbr; | 2121 CFX_WideString wsMonthNameAbbr; |
| 2122 uint16_t i = 0; | 2122 uint16_t i = 0; |
| 2123 for (; i < 12; i++) { | 2123 for (; i < 12; i++) { |
| 2124 pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); | 2124 pLocale->GetMonthName(i, wsMonthNameAbbr, true); |
| 2125 if (wsMonthNameAbbr.IsEmpty()) { | 2125 if (wsMonthNameAbbr.IsEmpty()) { |
| 2126 continue; | 2126 continue; |
| 2127 } | 2127 } |
| 2128 if (!FXSYS_wcsncmp(wsMonthNameAbbr.c_str(), str + cc, | 2128 if (!FXSYS_wcsncmp(wsMonthNameAbbr.c_str(), str + cc, |
| 2129 wsMonthNameAbbr.GetLength())) { | 2129 wsMonthNameAbbr.GetLength())) { |
| 2130 break; | 2130 break; |
| 2131 } | 2131 } |
| 2132 } | 2132 } |
| 2133 if (i < 12) { | 2133 if (i < 12) { |
| 2134 cc += wsMonthNameAbbr.GetLength(); | 2134 cc += wsMonthNameAbbr.GetLength(); |
| 2135 month = i + 1; | 2135 month = i + 1; |
| 2136 } | 2136 } |
| 2137 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { | 2137 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { |
| 2138 CFX_WideString wsMonthName; | 2138 CFX_WideString wsMonthName; |
| 2139 uint16_t i = 0; | 2139 uint16_t i = 0; |
| 2140 for (; i < 12; i++) { | 2140 for (; i < 12; i++) { |
| 2141 pLocale->GetMonthName(i, wsMonthName, FALSE); | 2141 pLocale->GetMonthName(i, wsMonthName, false); |
| 2142 if (wsMonthName.IsEmpty()) { | 2142 if (wsMonthName.IsEmpty()) { |
| 2143 continue; | 2143 continue; |
| 2144 } | 2144 } |
| 2145 if (!FXSYS_wcsncmp(wsMonthName.c_str(), str + cc, | 2145 if (!FXSYS_wcsncmp(wsMonthName.c_str(), str + cc, |
| 2146 wsMonthName.GetLength())) { | 2146 wsMonthName.GetLength())) { |
| 2147 break; | 2147 break; |
| 2148 } | 2148 } |
| 2149 } | 2149 } |
| 2150 if (i < 12) { | 2150 if (i < 12) { |
| 2151 cc += wsMonthName.GetLength(); | 2151 cc += wsMonthName.GetLength(); |
| 2152 month = i + 1; | 2152 month = i + 1; |
| 2153 } | 2153 } |
| 2154 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { | 2154 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { |
| 2155 cc += 1; | 2155 cc += 1; |
| 2156 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { | 2156 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { |
| 2157 CFX_WideString wsDayNameAbbr; | 2157 CFX_WideString wsDayNameAbbr; |
| 2158 uint16_t i = 0; | 2158 uint16_t i = 0; |
| 2159 for (; i < 7; i++) { | 2159 for (; i < 7; i++) { |
| 2160 pLocale->GetDayName(i, wsDayNameAbbr, TRUE); | 2160 pLocale->GetDayName(i, wsDayNameAbbr, true); |
| 2161 if (wsDayNameAbbr.IsEmpty()) { | 2161 if (wsDayNameAbbr.IsEmpty()) { |
| 2162 continue; | 2162 continue; |
| 2163 } | 2163 } |
| 2164 if (!FXSYS_wcsncmp(wsDayNameAbbr.c_str(), str + cc, | 2164 if (!FXSYS_wcsncmp(wsDayNameAbbr.c_str(), str + cc, |
| 2165 wsDayNameAbbr.GetLength())) { | 2165 wsDayNameAbbr.GetLength())) { |
| 2166 break; | 2166 break; |
| 2167 } | 2167 } |
| 2168 } | 2168 } |
| 2169 if (i < 12) { | 2169 if (i < 12) { |
| 2170 cc += wsDayNameAbbr.GetLength(); | 2170 cc += wsDayNameAbbr.GetLength(); |
| 2171 } | 2171 } |
| 2172 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { | 2172 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { |
| 2173 CFX_WideString wsDayName; | 2173 CFX_WideString wsDayName; |
| 2174 int32_t i = 0; | 2174 int32_t i = 0; |
| 2175 for (; i < 7; i++) { | 2175 for (; i < 7; i++) { |
| 2176 pLocale->GetDayName(i, wsDayName, FALSE); | 2176 pLocale->GetDayName(i, wsDayName, false); |
| 2177 if (wsDayName == L"") { | 2177 if (wsDayName == L"") { |
| 2178 continue; | 2178 continue; |
| 2179 } | 2179 } |
| 2180 if (!FXSYS_wcsncmp(wsDayName.c_str(), str + cc, | 2180 if (!FXSYS_wcsncmp(wsDayName.c_str(), str + cc, |
| 2181 wsDayName.GetLength())) { | 2181 wsDayName.GetLength())) { |
| 2182 break; | 2182 break; |
| 2183 } | 2183 } |
| 2184 } | 2184 } |
| 2185 if (i < 12) { | 2185 if (i < 12) { |
| 2186 cc += wsDayName.GetLength(); | 2186 cc += wsDayName.GetLength(); |
| 2187 } | 2187 } |
| 2188 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { | 2188 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { |
| 2189 cc += 1; | 2189 cc += 1; |
| 2190 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { | 2190 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { |
| 2191 cc += 2; | 2191 cc += 2; |
| 2192 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { | 2192 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { |
| 2193 if (cc + 2 > len) { | 2193 if (cc + 2 > len) { |
| 2194 return FALSE; | 2194 return false; |
| 2195 } | 2195 } |
| 2196 if (!FXSYS_isDecimalDigit(str[cc])) { | 2196 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2197 return FALSE; | 2197 return false; |
| 2198 } | 2198 } |
| 2199 year = str[cc++] - '0'; | 2199 year = str[cc++] - '0'; |
| 2200 if (cc >= len || !FXSYS_isDecimalDigit(str[cc])) { | 2200 if (cc >= len || !FXSYS_isDecimalDigit(str[cc])) { |
| 2201 return FALSE; | 2201 return false; |
| 2202 } | 2202 } |
| 2203 year = year * 10 + str[cc++] - '0'; | 2203 year = year * 10 + str[cc++] - '0'; |
| 2204 if (year <= 29) { | 2204 if (year <= 29) { |
| 2205 year += 2000; | 2205 year += 2000; |
| 2206 } else { | 2206 } else { |
| 2207 year += 1900; | 2207 year += 1900; |
| 2208 } | 2208 } |
| 2209 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { | 2209 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { |
| 2210 int i = 0; | 2210 int i = 0; |
| 2211 year = 0; | 2211 year = 0; |
| 2212 if (cc + 4 > len) { | 2212 if (cc + 4 > len) { |
| 2213 return FALSE; | 2213 return false; |
| 2214 } | 2214 } |
| 2215 while (i < 4) { | 2215 while (i < 4) { |
| 2216 if (!FXSYS_isDecimalDigit(str[cc])) { | 2216 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2217 return FALSE; | 2217 return false; |
| 2218 } | 2218 } |
| 2219 year = year * 10 + str[cc] - '0'; | 2219 year = year * 10 + str[cc] - '0'; |
| 2220 cc++; | 2220 cc++; |
| 2221 i++; | 2221 i++; |
| 2222 } | 2222 } |
| 2223 } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { | 2223 } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { |
| 2224 cc += 1; | 2224 cc += 1; |
| 2225 } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { | 2225 } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { |
| 2226 cc += 2; | 2226 cc += 2; |
| 2227 } | 2227 } |
| 2228 } | 2228 } |
| 2229 if (cc < len) { | 2229 if (cc < len) { |
| 2230 return FALSE; | 2230 return false; |
| 2231 } | 2231 } |
| 2232 CFX_Unitime ut; | 2232 CFX_Unitime ut; |
| 2233 ut.Set(year, month, day); | 2233 ut.Set(year, month, day); |
| 2234 datetime = datetime + ut; | 2234 datetime = datetime + ut; |
| 2235 return !!cc; | 2235 return !!cc; |
| 2236 } | 2236 } |
| 2237 | 2237 |
| 2238 static void FX_ResolveZone(uint8_t& wHour, | 2238 static void FX_ResolveZone(uint8_t& wHour, |
| 2239 uint8_t& wMinute, | 2239 uint8_t& wMinute, |
| 2240 FX_TIMEZONE tzDiff, | 2240 FX_TIMEZONE tzDiff, |
| 2241 IFX_Locale* pLocale) { | 2241 IFX_Locale* pLocale) { |
| 2242 int32_t iMinuteDiff = wHour * 60 + wMinute; | 2242 int32_t iMinuteDiff = wHour * 60 + wMinute; |
| 2243 FX_TIMEZONE tzLocale; | 2243 FX_TIMEZONE tzLocale; |
| 2244 pLocale->GetTimeZone(tzLocale); | 2244 pLocale->GetTimeZone(tzLocale); |
| 2245 iMinuteDiff += tzLocale.tzHour * 60 + | 2245 iMinuteDiff += tzLocale.tzHour * 60 + |
| 2246 (tzLocale.tzHour < 0 ? -tzLocale.tzMinute : tzLocale.tzMinute); | 2246 (tzLocale.tzHour < 0 ? -tzLocale.tzMinute : tzLocale.tzMinute); |
| 2247 iMinuteDiff -= tzDiff.tzHour * 60 + | 2247 iMinuteDiff -= tzDiff.tzHour * 60 + |
| 2248 (tzDiff.tzHour < 0 ? -tzDiff.tzMinute : tzDiff.tzMinute); | 2248 (tzDiff.tzHour < 0 ? -tzDiff.tzMinute : tzDiff.tzMinute); |
| 2249 while (iMinuteDiff > 1440) { | 2249 while (iMinuteDiff > 1440) { |
| 2250 iMinuteDiff -= 1440; | 2250 iMinuteDiff -= 1440; |
| 2251 } | 2251 } |
| 2252 while (iMinuteDiff < 0) { | 2252 while (iMinuteDiff < 0) { |
| 2253 iMinuteDiff += 1440; | 2253 iMinuteDiff += 1440; |
| 2254 } | 2254 } |
| 2255 wHour = iMinuteDiff / 60; | 2255 wHour = iMinuteDiff / 60; |
| 2256 wMinute = iMinuteDiff % 60; | 2256 wMinute = iMinuteDiff % 60; |
| 2257 } | 2257 } |
| 2258 static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, | 2258 static bool FX_ParseLocaleTime(const CFX_WideString& wsTime, |
| 2259 const CFX_WideString& wsTimePattern, | 2259 const CFX_WideString& wsTimePattern, |
| 2260 IFX_Locale* pLocale, | 2260 IFX_Locale* pLocale, |
| 2261 CFX_Unitime& datetime, | 2261 CFX_Unitime& datetime, |
| 2262 int32_t& cc) { | 2262 int32_t& cc) { |
| 2263 uint8_t hour = 0; | 2263 uint8_t hour = 0; |
| 2264 uint8_t minute = 0; | 2264 uint8_t minute = 0; |
| 2265 uint8_t second = 0; | 2265 uint8_t second = 0; |
| 2266 uint16_t millisecond = 0; | 2266 uint16_t millisecond = 0; |
| 2267 int32_t ccf = 0; | 2267 int32_t ccf = 0; |
| 2268 const FX_WCHAR* str = wsTime.c_str(); | 2268 const FX_WCHAR* str = wsTime.c_str(); |
| 2269 int len = wsTime.GetLength(); | 2269 int len = wsTime.GetLength(); |
| 2270 const FX_WCHAR* strf = wsTimePattern.c_str(); | 2270 const FX_WCHAR* strf = wsTimePattern.c_str(); |
| 2271 int lenf = wsTimePattern.GetLength(); | 2271 int lenf = wsTimePattern.GetLength(); |
| 2272 FX_BOOL bHasA = FALSE; | 2272 bool bHasA = false; |
| 2273 FX_BOOL bPM = FALSE; | 2273 bool bPM = false; |
| 2274 CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols); | 2274 CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols); |
| 2275 while (cc < len && ccf < lenf) { | 2275 while (cc < len && ccf < lenf) { |
| 2276 if (strf[ccf] == '\'') { | 2276 if (strf[ccf] == '\'') { |
| 2277 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 2277 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
| 2278 int32_t iLiteralLen = wsLiteral.GetLength(); | 2278 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2279 if (cc + iLiteralLen > len || | 2279 if (cc + iLiteralLen > len || |
| 2280 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { | 2280 FXSYS_wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) { |
| 2281 return FALSE; | 2281 return false; |
| 2282 } | 2282 } |
| 2283 cc += iLiteralLen; | 2283 cc += iLiteralLen; |
| 2284 ccf++; | 2284 ccf++; |
| 2285 continue; | 2285 continue; |
| 2286 } else if (wsTimeSymbols.Find(strf[ccf]) == -1) { | 2286 } else if (wsTimeSymbols.Find(strf[ccf]) == -1) { |
| 2287 if (strf[ccf] != str[cc]) | 2287 if (strf[ccf] != str[cc]) |
| 2288 return FALSE; | 2288 return false; |
| 2289 cc++; | 2289 cc++; |
| 2290 ccf++; | 2290 ccf++; |
| 2291 continue; | 2291 continue; |
| 2292 } | 2292 } |
| 2293 uint32_t dwSymbolNum = 1; | 2293 uint32_t dwSymbolNum = 1; |
| 2294 FX_WCHAR dwCharSymbol = strf[ccf++]; | 2294 FX_WCHAR dwCharSymbol = strf[ccf++]; |
| 2295 while (ccf < lenf && strf[ccf] == dwCharSymbol) { | 2295 while (ccf < lenf && strf[ccf] == dwCharSymbol) { |
| 2296 ccf++; | 2296 ccf++; |
| 2297 dwSymbolNum++; | 2297 dwSymbolNum++; |
| 2298 } | 2298 } |
| 2299 uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0'); | 2299 uint32_t dwSymbol = (dwCharSymbol << 8) | (dwSymbolNum + '0'); |
| 2300 if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1') || | 2300 if (dwSymbol == FXBSTR_ID(0, 0, 'k', '1') || |
| 2301 dwSymbol == FXBSTR_ID(0, 0, 'H', '1') || | 2301 dwSymbol == FXBSTR_ID(0, 0, 'H', '1') || |
| 2302 dwSymbol == FXBSTR_ID(0, 0, 'h', '1') || | 2302 dwSymbol == FXBSTR_ID(0, 0, 'h', '1') || |
| 2303 dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { | 2303 dwSymbol == FXBSTR_ID(0, 0, 'K', '1')) { |
| 2304 if (!FXSYS_isDecimalDigit(str[cc])) { | 2304 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2305 return FALSE; | 2305 return false; |
| 2306 } | 2306 } |
| 2307 hour = str[cc++] - '0'; | 2307 hour = str[cc++] - '0'; |
| 2308 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 2308 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 2309 hour = hour * 10 + str[cc++] - '0'; | 2309 hour = hour * 10 + str[cc++] - '0'; |
| 2310 } | 2310 } |
| 2311 if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1') && hour == 24) { | 2311 if (dwSymbol == FXBSTR_ID(0, 0, 'K', '1') && hour == 24) { |
| 2312 hour = 0; | 2312 hour = 0; |
| 2313 } | 2313 } |
| 2314 } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '2') || | 2314 } else if (dwSymbol == FXBSTR_ID(0, 0, 'k', '2') || |
| 2315 dwSymbol == FXBSTR_ID(0, 0, 'H', '2') || | 2315 dwSymbol == FXBSTR_ID(0, 0, 'H', '2') || |
| 2316 dwSymbol == FXBSTR_ID(0, 0, 'h', '2') || | 2316 dwSymbol == FXBSTR_ID(0, 0, 'h', '2') || |
| 2317 dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) { | 2317 dwSymbol == FXBSTR_ID(0, 0, 'K', '2')) { |
| 2318 if (!FXSYS_isDecimalDigit(str[cc])) { | 2318 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2319 return FALSE; | 2319 return false; |
| 2320 } | 2320 } |
| 2321 hour = str[cc++] - '0'; | 2321 hour = str[cc++] - '0'; |
| 2322 if (cc >= len) { | 2322 if (cc >= len) { |
| 2323 return FALSE; | 2323 return false; |
| 2324 } | 2324 } |
| 2325 if (!FXSYS_isDecimalDigit(str[cc])) { | 2325 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2326 return FALSE; | 2326 return false; |
| 2327 } | 2327 } |
| 2328 hour = hour * 10 + str[cc++] - '0'; | 2328 hour = hour * 10 + str[cc++] - '0'; |
| 2329 if (dwSymbol == FXBSTR_ID(0, 0, 'K', '2') && hour == 24) { | 2329 if (dwSymbol == FXBSTR_ID(0, 0, 'K', '2') && hour == 24) { |
| 2330 hour = 0; | 2330 hour = 0; |
| 2331 } | 2331 } |
| 2332 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { | 2332 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { |
| 2333 if (!FXSYS_isDecimalDigit(str[cc])) { | 2333 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2334 return FALSE; | 2334 return false; |
| 2335 } | 2335 } |
| 2336 minute = str[cc++] - '0'; | 2336 minute = str[cc++] - '0'; |
| 2337 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 2337 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 2338 minute = minute * 10 + str[cc++] - '0'; | 2338 minute = minute * 10 + str[cc++] - '0'; |
| 2339 } | 2339 } |
| 2340 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { | 2340 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { |
| 2341 if (!FXSYS_isDecimalDigit(str[cc])) { | 2341 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2342 return FALSE; | 2342 return false; |
| 2343 } | 2343 } |
| 2344 minute = str[cc++] - '0'; | 2344 minute = str[cc++] - '0'; |
| 2345 if (cc >= len) { | 2345 if (cc >= len) { |
| 2346 return FALSE; | 2346 return false; |
| 2347 } | 2347 } |
| 2348 if (!FXSYS_isDecimalDigit(str[cc])) { | 2348 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2349 return FALSE; | 2349 return false; |
| 2350 } | 2350 } |
| 2351 minute = minute * 10 + str[cc++] - '0'; | 2351 minute = minute * 10 + str[cc++] - '0'; |
| 2352 } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) { | 2352 } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '1')) { |
| 2353 if (!FXSYS_isDecimalDigit(str[cc])) { | 2353 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2354 return FALSE; | 2354 return false; |
| 2355 } | 2355 } |
| 2356 second = str[cc++] - '0'; | 2356 second = str[cc++] - '0'; |
| 2357 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 2357 if (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 2358 second = second * 10 + str[cc++] - '0'; | 2358 second = second * 10 + str[cc++] - '0'; |
| 2359 } | 2359 } |
| 2360 } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) { | 2360 } else if (dwSymbol == FXBSTR_ID(0, 0, 'S', '2')) { |
| 2361 if (!FXSYS_isDecimalDigit(str[cc])) { | 2361 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2362 return FALSE; | 2362 return false; |
| 2363 } | 2363 } |
| 2364 second = str[cc++] - '0'; | 2364 second = str[cc++] - '0'; |
| 2365 if (cc >= len) { | 2365 if (cc >= len) { |
| 2366 return FALSE; | 2366 return false; |
| 2367 } | 2367 } |
| 2368 if (!FXSYS_isDecimalDigit(str[cc])) { | 2368 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2369 return FALSE; | 2369 return false; |
| 2370 } | 2370 } |
| 2371 second = second * 10 + str[cc++] - '0'; | 2371 second = second * 10 + str[cc++] - '0'; |
| 2372 } else if (dwSymbol == FXBSTR_ID(0, 0, 'F', '3')) { | 2372 } else if (dwSymbol == FXBSTR_ID(0, 0, 'F', '3')) { |
| 2373 if (cc + 3 >= len) { | 2373 if (cc + 3 >= len) { |
| 2374 return FALSE; | 2374 return false; |
| 2375 } | 2375 } |
| 2376 int i = 0; | 2376 int i = 0; |
| 2377 while (i < 3) { | 2377 while (i < 3) { |
| 2378 if (!FXSYS_isDecimalDigit(str[cc])) { | 2378 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2379 return FALSE; | 2379 return false; |
| 2380 } | 2380 } |
| 2381 millisecond = millisecond * 10 + str[cc++] - '0'; | 2381 millisecond = millisecond * 10 + str[cc++] - '0'; |
| 2382 i++; | 2382 i++; |
| 2383 } | 2383 } |
| 2384 } else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) { | 2384 } else if (dwSymbol == FXBSTR_ID(0, 0, 'A', '1')) { |
| 2385 CFX_WideString wsAM; | 2385 CFX_WideString wsAM; |
| 2386 pLocale->GetMeridiemName(wsAM, TRUE); | 2386 pLocale->GetMeridiemName(wsAM, true); |
| 2387 CFX_WideString wsPM; | 2387 CFX_WideString wsPM; |
| 2388 pLocale->GetMeridiemName(wsPM, FALSE); | 2388 pLocale->GetMeridiemName(wsPM, false); |
| 2389 if ((cc + wsAM.GetLength() <= len) && | 2389 if ((cc + wsAM.GetLength() <= len) && |
| 2390 (CFX_WideStringC(str + cc, wsAM.GetLength()) == wsAM)) { | 2390 (CFX_WideStringC(str + cc, wsAM.GetLength()) == wsAM)) { |
| 2391 cc += wsAM.GetLength(); | 2391 cc += wsAM.GetLength(); |
| 2392 bHasA = TRUE; | 2392 bHasA = true; |
| 2393 } else if ((cc + wsPM.GetLength() <= len) && | 2393 } else if ((cc + wsPM.GetLength() <= len) && |
| 2394 (CFX_WideStringC(str + cc, wsPM.GetLength()) == wsPM)) { | 2394 (CFX_WideStringC(str + cc, wsPM.GetLength()) == wsPM)) { |
| 2395 cc += wsPM.GetLength(); | 2395 cc += wsPM.GetLength(); |
| 2396 bHasA = TRUE; | 2396 bHasA = true; |
| 2397 bPM = TRUE; | 2397 bPM = true; |
| 2398 } | 2398 } |
| 2399 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { | 2399 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Z', '1')) { |
| 2400 if (cc + 3 > len) { | 2400 if (cc + 3 > len) { |
| 2401 continue; | 2401 continue; |
| 2402 } | 2402 } |
| 2403 uint32_t dwHash = str[cc++]; | 2403 uint32_t dwHash = str[cc++]; |
| 2404 dwHash = (dwHash << 8) | str[cc++]; | 2404 dwHash = (dwHash << 8) | str[cc++]; |
| 2405 dwHash = (dwHash << 8) | str[cc++]; | 2405 dwHash = (dwHash << 8) | str[cc++]; |
| 2406 if (dwHash == FXBSTR_ID(0, 'G', 'M', 'T')) { | 2406 if (dwHash == FXBSTR_ID(0, 'G', 'M', 'T')) { |
| 2407 FX_TIMEZONE tzDiff; | 2407 FX_TIMEZONE tzDiff; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 hour = 0; | 2445 hour = 0; |
| 2446 } | 2446 } |
| 2447 } | 2447 } |
| 2448 } | 2448 } |
| 2449 CFX_Unitime ut; | 2449 CFX_Unitime ut; |
| 2450 ut.Set(0, 0, 0, hour, minute, second, millisecond); | 2450 ut.Set(0, 0, 0, hour, minute, second, millisecond); |
| 2451 datetime = datetime + ut; | 2451 datetime = datetime + ut; |
| 2452 return !!cc; | 2452 return !!cc; |
| 2453 } | 2453 } |
| 2454 | 2454 |
| 2455 FX_BOOL CFX_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime, | 2455 bool CFX_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime, |
| 2456 const CFX_WideString& wsPattern, | 2456 const CFX_WideString& wsPattern, |
| 2457 FX_DATETIMETYPE eDateTimeType, | 2457 FX_DATETIMETYPE eDateTimeType, |
| 2458 CFX_Unitime& dtValue) { | 2458 CFX_Unitime& dtValue) { |
| 2459 dtValue.Set(0); | 2459 dtValue.Set(0); |
| 2460 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { | 2460 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { |
| 2461 return FALSE; | 2461 return false; |
| 2462 } | 2462 } |
| 2463 CFX_WideString wsDatePattern, wsTimePattern; | 2463 CFX_WideString wsDatePattern, wsTimePattern; |
| 2464 IFX_Locale* pLocale = nullptr; | 2464 IFX_Locale* pLocale = nullptr; |
| 2465 FX_DATETIMETYPE eCategory = | 2465 FX_DATETIMETYPE eCategory = |
| 2466 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 2466 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
| 2467 if (!pLocale) { | 2467 if (!pLocale) { |
| 2468 return FALSE; | 2468 return false; |
| 2469 } | 2469 } |
| 2470 if (eCategory == FX_DATETIMETYPE_Unknown) { | 2470 if (eCategory == FX_DATETIMETYPE_Unknown) { |
| 2471 eCategory = eDateTimeType; | 2471 eCategory = eDateTimeType; |
| 2472 } | 2472 } |
| 2473 if (eCategory == FX_DATETIMETYPE_Unknown) { | 2473 if (eCategory == FX_DATETIMETYPE_Unknown) { |
| 2474 return FALSE; | 2474 return false; |
| 2475 } | 2475 } |
| 2476 if (eCategory == FX_DATETIMETYPE_TimeDate) { | 2476 if (eCategory == FX_DATETIMETYPE_TimeDate) { |
| 2477 int32_t iStart = 0; | 2477 int32_t iStart = 0; |
| 2478 if (!FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, | 2478 if (!FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, |
| 2479 iStart)) { | 2479 iStart)) { |
| 2480 return FALSE; | 2480 return false; |
| 2481 } | 2481 } |
| 2482 if (!FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, | 2482 if (!FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, |
| 2483 iStart)) { | 2483 iStart)) { |
| 2484 return FALSE; | 2484 return false; |
| 2485 } | 2485 } |
| 2486 } else { | 2486 } else { |
| 2487 int32_t iStart = 0; | 2487 int32_t iStart = 0; |
| 2488 if ((eCategory & FX_DATETIMETYPE_Date) && | 2488 if ((eCategory & FX_DATETIMETYPE_Date) && |
| 2489 !FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, | 2489 !FX_ParseLocaleDate(wsSrcDateTime, wsDatePattern, pLocale, dtValue, |
| 2490 iStart)) { | 2490 iStart)) { |
| 2491 return FALSE; | 2491 return false; |
| 2492 } | 2492 } |
| 2493 if ((eCategory & FX_DATETIMETYPE_Time) && | 2493 if ((eCategory & FX_DATETIMETYPE_Time) && |
| 2494 !FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, | 2494 !FX_ParseLocaleTime(wsSrcDateTime, wsTimePattern, pLocale, dtValue, |
| 2495 iStart)) { | 2495 iStart)) { |
| 2496 return FALSE; | 2496 return false; |
| 2497 } | 2497 } |
| 2498 } | 2498 } |
| 2499 return TRUE; | 2499 return true; |
| 2500 } | 2500 } |
| 2501 FX_BOOL CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText, | 2501 bool CFX_FormatString::ParseZero(const CFX_WideString& wsSrcText, |
| 2502 const CFX_WideString& wsPattern) { | 2502 const CFX_WideString& wsPattern) { |
| 2503 CFX_WideString wsTextFormat; | 2503 CFX_WideString wsTextFormat; |
| 2504 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); | 2504 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); |
| 2505 int32_t iText = 0, iPattern = 0; | 2505 int32_t iText = 0, iPattern = 0; |
| 2506 const FX_WCHAR* pStrText = wsSrcText.c_str(); | 2506 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 2507 int32_t iLenText = wsSrcText.GetLength(); | 2507 int32_t iLenText = wsSrcText.GetLength(); |
| 2508 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); | 2508 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 2509 int32_t iLenPattern = wsTextFormat.GetLength(); | 2509 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 2510 while (iPattern < iLenPattern && iText < iLenText) { | 2510 while (iPattern < iLenPattern && iText < iLenText) { |
| 2511 if (pStrPattern[iPattern] == '\'') { | 2511 if (pStrPattern[iPattern] == '\'') { |
| 2512 CFX_WideString wsLiteral = | 2512 CFX_WideString wsLiteral = |
| 2513 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 2513 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 2514 int32_t iLiteralLen = wsLiteral.GetLength(); | 2514 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2515 if (iText + iLiteralLen > iLenText || | 2515 if (iText + iLiteralLen > iLenText || |
| 2516 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { | 2516 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { |
| 2517 return FALSE; | 2517 return false; |
| 2518 } | 2518 } |
| 2519 iText += iLiteralLen; | 2519 iText += iLiteralLen; |
| 2520 iPattern++; | 2520 iPattern++; |
| 2521 continue; | 2521 continue; |
| 2522 } else if (pStrPattern[iPattern] != pStrText[iText]) { | 2522 } else if (pStrPattern[iPattern] != pStrText[iText]) { |
| 2523 return FALSE; | 2523 return false; |
| 2524 } else { | 2524 } else { |
| 2525 iText++; | 2525 iText++; |
| 2526 iPattern++; | 2526 iPattern++; |
| 2527 } | 2527 } |
| 2528 } | 2528 } |
| 2529 return iPattern == iLenPattern && iText == iLenText; | 2529 return iPattern == iLenPattern && iText == iLenText; |
| 2530 } | 2530 } |
| 2531 FX_BOOL CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText, | 2531 bool CFX_FormatString::ParseNull(const CFX_WideString& wsSrcText, |
| 2532 const CFX_WideString& wsPattern) { | 2532 const CFX_WideString& wsPattern) { |
| 2533 CFX_WideString wsTextFormat; | 2533 CFX_WideString wsTextFormat; |
| 2534 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); | 2534 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); |
| 2535 int32_t iText = 0, iPattern = 0; | 2535 int32_t iText = 0, iPattern = 0; |
| 2536 const FX_WCHAR* pStrText = wsSrcText.c_str(); | 2536 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 2537 int32_t iLenText = wsSrcText.GetLength(); | 2537 int32_t iLenText = wsSrcText.GetLength(); |
| 2538 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); | 2538 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 2539 int32_t iLenPattern = wsTextFormat.GetLength(); | 2539 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 2540 while (iPattern < iLenPattern && iText < iLenText) { | 2540 while (iPattern < iLenPattern && iText < iLenText) { |
| 2541 if (pStrPattern[iPattern] == '\'') { | 2541 if (pStrPattern[iPattern] == '\'') { |
| 2542 CFX_WideString wsLiteral = | 2542 CFX_WideString wsLiteral = |
| 2543 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 2543 FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 2544 int32_t iLiteralLen = wsLiteral.GetLength(); | 2544 int32_t iLiteralLen = wsLiteral.GetLength(); |
| 2545 if (iText + iLiteralLen > iLenText || | 2545 if (iText + iLiteralLen > iLenText || |
| 2546 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { | 2546 FXSYS_wcsncmp(pStrText + iText, wsLiteral.c_str(), iLiteralLen)) { |
| 2547 return FALSE; | 2547 return false; |
| 2548 } | 2548 } |
| 2549 iText += iLiteralLen; | 2549 iText += iLiteralLen; |
| 2550 iPattern++; | 2550 iPattern++; |
| 2551 continue; | 2551 continue; |
| 2552 } else if (pStrPattern[iPattern] != pStrText[iText]) { | 2552 } else if (pStrPattern[iPattern] != pStrText[iText]) { |
| 2553 return FALSE; | 2553 return false; |
| 2554 } else { | 2554 } else { |
| 2555 iText++; | 2555 iText++; |
| 2556 iPattern++; | 2556 iPattern++; |
| 2557 } | 2557 } |
| 2558 } | 2558 } |
| 2559 return iPattern == iLenPattern && iText == iLenText; | 2559 return iPattern == iLenPattern && iText == iLenText; |
| 2560 } | 2560 } |
| 2561 FX_BOOL CFX_FormatString::FormatText(const CFX_WideString& wsSrcText, | 2561 bool CFX_FormatString::FormatText(const CFX_WideString& wsSrcText, |
| 2562 const CFX_WideString& wsPattern, | 2562 const CFX_WideString& wsPattern, |
| 2563 CFX_WideString& wsOutput) { | 2563 CFX_WideString& wsOutput) { |
| 2564 if (wsPattern.IsEmpty()) { | 2564 if (wsPattern.IsEmpty()) { |
| 2565 return FALSE; | 2565 return false; |
| 2566 } | 2566 } |
| 2567 int32_t iLenText = wsSrcText.GetLength(); | 2567 int32_t iLenText = wsSrcText.GetLength(); |
| 2568 if (iLenText == 0) { | 2568 if (iLenText == 0) { |
| 2569 return FALSE; | 2569 return false; |
| 2570 } | 2570 } |
| 2571 CFX_WideString wsTextFormat; | 2571 CFX_WideString wsTextFormat; |
| 2572 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); | 2572 GetTextFormat(wsPattern, FX_WSTRC(L"text"), wsTextFormat); |
| 2573 int32_t iText = 0, iPattern = 0; | 2573 int32_t iText = 0, iPattern = 0; |
| 2574 const FX_WCHAR* pStrText = wsSrcText.c_str(); | 2574 const FX_WCHAR* pStrText = wsSrcText.c_str(); |
| 2575 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); | 2575 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 2576 int32_t iLenPattern = wsTextFormat.GetLength(); | 2576 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 2577 while (iPattern < iLenPattern) { | 2577 while (iPattern < iLenPattern) { |
| 2578 switch (pStrPattern[iPattern]) { | 2578 switch (pStrPattern[iPattern]) { |
| 2579 case '\'': { | 2579 case '\'': { |
| 2580 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 2580 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 2581 iPattern++; | 2581 iPattern++; |
| 2582 break; | 2582 break; |
| 2583 } | 2583 } |
| 2584 case 'A': | 2584 case 'A': |
| 2585 if (iText >= iLenText || !FXSYS_iswalpha(pStrText[iText])) { | 2585 if (iText >= iLenText || !FXSYS_iswalpha(pStrText[iText])) { |
| 2586 return FALSE; | 2586 return false; |
| 2587 } | 2587 } |
| 2588 wsOutput += pStrText[iText++]; | 2588 wsOutput += pStrText[iText++]; |
| 2589 iPattern++; | 2589 iPattern++; |
| 2590 break; | 2590 break; |
| 2591 case 'X': | 2591 case 'X': |
| 2592 if (iText >= iLenText) { | 2592 if (iText >= iLenText) { |
| 2593 return FALSE; | 2593 return false; |
| 2594 } | 2594 } |
| 2595 wsOutput += pStrText[iText++]; | 2595 wsOutput += pStrText[iText++]; |
| 2596 iPattern++; | 2596 iPattern++; |
| 2597 break; | 2597 break; |
| 2598 case 'O': | 2598 case 'O': |
| 2599 case '0': | 2599 case '0': |
| 2600 if (iText >= iLenText || (!FXSYS_isDecimalDigit(pStrText[iText]) && | 2600 if (iText >= iLenText || (!FXSYS_isDecimalDigit(pStrText[iText]) && |
| 2601 !FXSYS_iswalpha(pStrText[iText]))) { | 2601 !FXSYS_iswalpha(pStrText[iText]))) { |
| 2602 return FALSE; | 2602 return false; |
| 2603 } | 2603 } |
| 2604 wsOutput += pStrText[iText++]; | 2604 wsOutput += pStrText[iText++]; |
| 2605 iPattern++; | 2605 iPattern++; |
| 2606 break; | 2606 break; |
| 2607 case '9': | 2607 case '9': |
| 2608 if (iText >= iLenText || !FXSYS_isDecimalDigit(pStrText[iText])) { | 2608 if (iText >= iLenText || !FXSYS_isDecimalDigit(pStrText[iText])) { |
| 2609 return FALSE; | 2609 return false; |
| 2610 } | 2610 } |
| 2611 wsOutput += pStrText[iText++]; | 2611 wsOutput += pStrText[iText++]; |
| 2612 iPattern++; | 2612 iPattern++; |
| 2613 break; | 2613 break; |
| 2614 default: | 2614 default: |
| 2615 wsOutput += pStrPattern[iPattern++]; | 2615 wsOutput += pStrPattern[iPattern++]; |
| 2616 break; | 2616 break; |
| 2617 } | 2617 } |
| 2618 } | 2618 } |
| 2619 return iText == iLenText; | 2619 return iText == iLenText; |
| 2620 } | 2620 } |
| 2621 static int32_t FX_GetNumTrailingLimit(const CFX_WideString& wsFormat, | 2621 static int32_t FX_GetNumTrailingLimit(const CFX_WideString& wsFormat, |
| 2622 int iDotPos, | 2622 int iDotPos, |
| 2623 FX_BOOL& bTrimTailZeros) { | 2623 bool& bTrimTailZeros) { |
| 2624 if (iDotPos < 0) { | 2624 if (iDotPos < 0) { |
| 2625 return 0; | 2625 return 0; |
| 2626 } | 2626 } |
| 2627 int32_t iCount = wsFormat.GetLength(); | 2627 int32_t iCount = wsFormat.GetLength(); |
| 2628 int32_t iTreading = 0; | 2628 int32_t iTreading = 0; |
| 2629 for (iDotPos++; iDotPos < iCount; iDotPos++) { | 2629 for (iDotPos++; iDotPos < iCount; iDotPos++) { |
| 2630 FX_WCHAR wc = wsFormat[iDotPos]; | 2630 FX_WCHAR wc = wsFormat[iDotPos]; |
| 2631 if (wc == L'z' || wc == L'9' || wc == 'Z') { | 2631 if (wc == L'z' || wc == L'9' || wc == 'Z') { |
| 2632 iTreading++; | 2632 iTreading++; |
| 2633 bTrimTailZeros = (wc == L'9' ? FALSE : TRUE); | 2633 bTrimTailZeros = (wc == L'9' ? false : true); |
| 2634 } | 2634 } |
| 2635 } | 2635 } |
| 2636 return iTreading; | 2636 return iTreading; |
| 2637 } | 2637 } |
| 2638 FX_BOOL CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum, | 2638 bool CFX_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum, |
| 2639 const CFX_WideString& wsPattern, | 2639 const CFX_WideString& wsPattern, |
| 2640 CFX_WideString& wsOutput) { | 2640 CFX_WideString& wsOutput) { |
| 2641 if (wsInputNum.IsEmpty() || wsPattern.IsEmpty()) { | 2641 if (wsInputNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 2642 return FALSE; | 2642 return false; |
| 2643 } | 2643 } |
| 2644 int32_t dot_index_f = -1; | 2644 int32_t dot_index_f = -1; |
| 2645 uint32_t dwNumStyle = 0; | 2645 uint32_t dwNumStyle = 0; |
| 2646 CFX_WideString wsNumFormat; | 2646 CFX_WideString wsNumFormat; |
| 2647 IFX_Locale* pLocale = | 2647 IFX_Locale* pLocale = |
| 2648 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 2648 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 2649 if (!pLocale || wsNumFormat.IsEmpty()) { | 2649 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 2650 return FALSE; | 2650 return false; |
| 2651 } | 2651 } |
| 2652 int32_t cc = 0, ccf = 0; | 2652 int32_t cc = 0, ccf = 0; |
| 2653 const FX_WCHAR* strf = wsNumFormat.c_str(); | 2653 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 2654 int lenf = wsNumFormat.GetLength(); | 2654 int lenf = wsNumFormat.GetLength(); |
| 2655 CFX_WideString wsSrcNum(wsInputNum); | 2655 CFX_WideString wsSrcNum(wsInputNum); |
| 2656 wsSrcNum.TrimLeft('0'); | 2656 wsSrcNum.TrimLeft('0'); |
| 2657 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { | 2657 if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.') { |
| 2658 wsSrcNum.Insert(0, '0'); | 2658 wsSrcNum.Insert(0, '0'); |
| 2659 } | 2659 } |
| 2660 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); | 2660 CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 } | 2693 } |
| 2694 } else if (decimal > CFX_Decimal(threshold)) { | 2694 } else if (decimal > CFX_Decimal(threshold)) { |
| 2695 threshold *= 10; | 2695 threshold *= 10; |
| 2696 while (decimal > CFX_Decimal(threshold)) { | 2696 while (decimal > CFX_Decimal(threshold)) { |
| 2697 decimal = decimal / CFX_Decimal(10); | 2697 decimal = decimal / CFX_Decimal(10); |
| 2698 exponent += 1; | 2698 exponent += 1; |
| 2699 } | 2699 } |
| 2700 } | 2700 } |
| 2701 } | 2701 } |
| 2702 } | 2702 } |
| 2703 FX_BOOL bTrimTailZeros = FALSE; | 2703 bool bTrimTailZeros = false; |
| 2704 int32_t iTreading = | 2704 int32_t iTreading = |
| 2705 FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); | 2705 FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); |
| 2706 int32_t scale = decimal.GetScale(); | 2706 int32_t scale = decimal.GetScale(); |
| 2707 if (iTreading < scale) { | 2707 if (iTreading < scale) { |
| 2708 decimal.SetScale(iTreading); | 2708 decimal.SetScale(iTreading); |
| 2709 wsSrcNum = decimal; | 2709 wsSrcNum = decimal; |
| 2710 } | 2710 } |
| 2711 if (bTrimTailZeros && scale > 0 && iTreading > 0) { | 2711 if (bTrimTailZeros && scale > 0 && iTreading > 0) { |
| 2712 wsSrcNum.TrimRight(L"0"); | 2712 wsSrcNum.TrimRight(L"0"); |
| 2713 wsSrcNum.TrimRight(L"."); | 2713 wsSrcNum.TrimRight(L"."); |
| 2714 } | 2714 } |
| 2715 CFX_WideString wsGroupSymbol; | 2715 CFX_WideString wsGroupSymbol; |
| 2716 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 2716 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 2717 FX_BOOL bNeg = FALSE; | 2717 bool bNeg = false; |
| 2718 if (wsSrcNum[0] == '-') { | 2718 if (wsSrcNum[0] == '-') { |
| 2719 bNeg = TRUE; | 2719 bNeg = true; |
| 2720 wsSrcNum.Delete(0, 1); | 2720 wsSrcNum.Delete(0, 1); |
| 2721 } | 2721 } |
| 2722 FX_BOOL bAddNeg = FALSE; | 2722 bool bAddNeg = false; |
| 2723 const FX_WCHAR* str = wsSrcNum.c_str(); | 2723 const FX_WCHAR* str = wsSrcNum.c_str(); |
| 2724 int len = wsSrcNum.GetLength(); | 2724 int len = wsSrcNum.GetLength(); |
| 2725 int dot_index = wsSrcNum.Find('.'); | 2725 int dot_index = wsSrcNum.Find('.'); |
| 2726 if (dot_index == -1) { | 2726 if (dot_index == -1) { |
| 2727 dot_index = len; | 2727 dot_index = len; |
| 2728 } | 2728 } |
| 2729 ccf = dot_index_f - 1; | 2729 ccf = dot_index_f - 1; |
| 2730 cc = dot_index - 1; | 2730 cc = dot_index - 1; |
| 2731 while (ccf >= 0) { | 2731 while (ccf >= 0) { |
| 2732 switch (strf[ccf]) { | 2732 switch (strf[ccf]) { |
| 2733 case '9': | 2733 case '9': |
| 2734 if (cc >= 0) { | 2734 if (cc >= 0) { |
| 2735 if (!FXSYS_isDecimalDigit(str[cc])) { | 2735 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2736 return FALSE; | 2736 return false; |
| 2737 } | 2737 } |
| 2738 wsOutput = str[cc] + wsOutput; | 2738 wsOutput = str[cc] + wsOutput; |
| 2739 cc--; | 2739 cc--; |
| 2740 } else { | 2740 } else { |
| 2741 wsOutput = L'0' + wsOutput; | 2741 wsOutput = L'0' + wsOutput; |
| 2742 } | 2742 } |
| 2743 ccf--; | 2743 ccf--; |
| 2744 break; | 2744 break; |
| 2745 case 'z': | 2745 case 'z': |
| 2746 if (cc >= 0) { | 2746 if (cc >= 0) { |
| 2747 if (!FXSYS_isDecimalDigit(str[cc])) { | 2747 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2748 return FALSE; | 2748 return false; |
| 2749 } | 2749 } |
| 2750 if (str[0] != '0') { | 2750 if (str[0] != '0') { |
| 2751 wsOutput = str[cc] + wsOutput; | 2751 wsOutput = str[cc] + wsOutput; |
| 2752 } | 2752 } |
| 2753 cc--; | 2753 cc--; |
| 2754 } | 2754 } |
| 2755 ccf--; | 2755 ccf--; |
| 2756 break; | 2756 break; |
| 2757 case 'Z': | 2757 case 'Z': |
| 2758 if (cc >= 0) { | 2758 if (cc >= 0) { |
| 2759 if (!FXSYS_isDecimalDigit(str[cc])) { | 2759 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2760 return FALSE; | 2760 return false; |
| 2761 } | 2761 } |
| 2762 if (str[0] == '0') { | 2762 if (str[0] == '0') { |
| 2763 wsOutput = L' ' + wsOutput; | 2763 wsOutput = L' ' + wsOutput; |
| 2764 } else { | 2764 } else { |
| 2765 wsOutput = str[cc] + wsOutput; | 2765 wsOutput = str[cc] + wsOutput; |
| 2766 } | 2766 } |
| 2767 cc--; | 2767 cc--; |
| 2768 } else { | 2768 } else { |
| 2769 wsOutput = L' ' + wsOutput; | 2769 wsOutput = L' ' + wsOutput; |
| 2770 } | 2770 } |
| 2771 ccf--; | 2771 ccf--; |
| 2772 break; | 2772 break; |
| 2773 case 'S': | 2773 case 'S': |
| 2774 if (bNeg) { | 2774 if (bNeg) { |
| 2775 CFX_WideString wsMinusSymbol; | 2775 CFX_WideString wsMinusSymbol; |
| 2776 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 2776 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 2777 wsOutput = wsMinusSymbol + wsOutput; | 2777 wsOutput = wsMinusSymbol + wsOutput; |
| 2778 bAddNeg = TRUE; | 2778 bAddNeg = true; |
| 2779 } else { | 2779 } else { |
| 2780 wsOutput = L' ' + wsOutput; | 2780 wsOutput = L' ' + wsOutput; |
| 2781 } | 2781 } |
| 2782 ccf--; | 2782 ccf--; |
| 2783 break; | 2783 break; |
| 2784 case 's': | 2784 case 's': |
| 2785 if (bNeg) { | 2785 if (bNeg) { |
| 2786 CFX_WideString wsMinusSymbol; | 2786 CFX_WideString wsMinusSymbol; |
| 2787 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 2787 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 2788 wsOutput = wsMinusSymbol + wsOutput; | 2788 wsOutput = wsMinusSymbol + wsOutput; |
| 2789 bAddNeg = TRUE; | 2789 bAddNeg = true; |
| 2790 } | 2790 } |
| 2791 ccf--; | 2791 ccf--; |
| 2792 break; | 2792 break; |
| 2793 case 'E': { | 2793 case 'E': { |
| 2794 CFX_WideString wsExp; | 2794 CFX_WideString wsExp; |
| 2795 wsExp.Format(L"E%+d", exponent); | 2795 wsExp.Format(L"E%+d", exponent); |
| 2796 wsOutput = wsExp + wsOutput; | 2796 wsOutput = wsExp + wsOutput; |
| 2797 } | 2797 } |
| 2798 ccf--; | 2798 ccf--; |
| 2799 break; | 2799 break; |
| 2800 case '$': { | 2800 case '$': { |
| 2801 CFX_WideString wsSymbol; | 2801 CFX_WideString wsSymbol; |
| 2802 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 2802 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 2803 wsOutput = wsSymbol + wsOutput; | 2803 wsOutput = wsSymbol + wsOutput; |
| 2804 } | 2804 } |
| 2805 ccf--; | 2805 ccf--; |
| 2806 break; | 2806 break; |
| 2807 case 'r': | 2807 case 'r': |
| 2808 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 2808 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 2809 if (bNeg) { | 2809 if (bNeg) { |
| 2810 wsOutput = L"CR" + wsOutput; | 2810 wsOutput = L"CR" + wsOutput; |
| 2811 } | 2811 } |
| 2812 ccf -= 2; | 2812 ccf -= 2; |
| 2813 bAddNeg = TRUE; | 2813 bAddNeg = true; |
| 2814 } | 2814 } |
| 2815 break; | 2815 break; |
| 2816 case 'R': | 2816 case 'R': |
| 2817 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { | 2817 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { |
| 2818 if (bNeg) { | 2818 if (bNeg) { |
| 2819 wsOutput = L"CR" + wsOutput; | 2819 wsOutput = L"CR" + wsOutput; |
| 2820 } else { | 2820 } else { |
| 2821 wsOutput = L" " + wsOutput; | 2821 wsOutput = L" " + wsOutput; |
| 2822 } | 2822 } |
| 2823 ccf -= 2; | 2823 ccf -= 2; |
| 2824 bAddNeg = TRUE; | 2824 bAddNeg = true; |
| 2825 } | 2825 } |
| 2826 break; | 2826 break; |
| 2827 case 'b': | 2827 case 'b': |
| 2828 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { | 2828 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { |
| 2829 if (bNeg) { | 2829 if (bNeg) { |
| 2830 wsOutput = L"db" + wsOutput; | 2830 wsOutput = L"db" + wsOutput; |
| 2831 } | 2831 } |
| 2832 ccf -= 2; | 2832 ccf -= 2; |
| 2833 bAddNeg = TRUE; | 2833 bAddNeg = true; |
| 2834 } | 2834 } |
| 2835 break; | 2835 break; |
| 2836 case 'B': | 2836 case 'B': |
| 2837 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { | 2837 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { |
| 2838 if (bNeg) { | 2838 if (bNeg) { |
| 2839 wsOutput = L"DB" + wsOutput; | 2839 wsOutput = L"DB" + wsOutput; |
| 2840 } else { | 2840 } else { |
| 2841 wsOutput = L" " + wsOutput; | 2841 wsOutput = L" " + wsOutput; |
| 2842 } | 2842 } |
| 2843 ccf -= 2; | 2843 ccf -= 2; |
| 2844 bAddNeg = TRUE; | 2844 bAddNeg = true; |
| 2845 } | 2845 } |
| 2846 break; | 2846 break; |
| 2847 case '%': { | 2847 case '%': { |
| 2848 CFX_WideString wsSymbol; | 2848 CFX_WideString wsSymbol; |
| 2849 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 2849 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 2850 wsOutput = wsSymbol + wsOutput; | 2850 wsOutput = wsSymbol + wsOutput; |
| 2851 } | 2851 } |
| 2852 ccf--; | 2852 ccf--; |
| 2853 break; | 2853 break; |
| 2854 case ',': | 2854 case ',': |
| 2855 if (cc >= 0) { | 2855 if (cc >= 0) { |
| 2856 wsOutput = wsGroupSymbol + wsOutput; | 2856 wsOutput = wsGroupSymbol + wsOutput; |
| 2857 } | 2857 } |
| 2858 ccf--; | 2858 ccf--; |
| 2859 break; | 2859 break; |
| 2860 case '(': | 2860 case '(': |
| 2861 if (bNeg) { | 2861 if (bNeg) { |
| 2862 wsOutput = L"(" + wsOutput; | 2862 wsOutput = L"(" + wsOutput; |
| 2863 } else { | 2863 } else { |
| 2864 wsOutput = L" " + wsOutput; | 2864 wsOutput = L" " + wsOutput; |
| 2865 } | 2865 } |
| 2866 bAddNeg = TRUE; | 2866 bAddNeg = true; |
| 2867 ccf--; | 2867 ccf--; |
| 2868 break; | 2868 break; |
| 2869 case ')': | 2869 case ')': |
| 2870 if (bNeg) { | 2870 if (bNeg) { |
| 2871 wsOutput = L")" + wsOutput; | 2871 wsOutput = L")" + wsOutput; |
| 2872 } else { | 2872 } else { |
| 2873 wsOutput = L" " + wsOutput; | 2873 wsOutput = L" " + wsOutput; |
| 2874 } | 2874 } |
| 2875 ccf--; | 2875 ccf--; |
| 2876 break; | 2876 break; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2896 CFX_WideString wsSymbol; | 2896 CFX_WideString wsSymbol; |
| 2897 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); | 2897 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); |
| 2898 wsOutput += wsSymbol; | 2898 wsOutput += wsSymbol; |
| 2899 wsOutput += wsSrcNum.Right(len - dot_index - 1); | 2899 wsOutput += wsSrcNum.Right(len - dot_index - 1); |
| 2900 } | 2900 } |
| 2901 if (bNeg) { | 2901 if (bNeg) { |
| 2902 CFX_WideString wsMinusymbol; | 2902 CFX_WideString wsMinusymbol; |
| 2903 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 2903 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 2904 wsOutput = wsMinusymbol + wsOutput; | 2904 wsOutput = wsMinusymbol + wsOutput; |
| 2905 } | 2905 } |
| 2906 return FALSE; | 2906 return false; |
| 2907 } | 2907 } |
| 2908 if (dot_index_f == wsNumFormat.GetLength()) { | 2908 if (dot_index_f == wsNumFormat.GetLength()) { |
| 2909 if (!bAddNeg && bNeg) { | 2909 if (!bAddNeg && bNeg) { |
| 2910 CFX_WideString wsMinusymbol; | 2910 CFX_WideString wsMinusymbol; |
| 2911 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 2911 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 2912 wsOutput = wsMinusymbol + wsOutput; | 2912 wsOutput = wsMinusymbol + wsOutput; |
| 2913 } | 2913 } |
| 2914 return TRUE; | 2914 return true; |
| 2915 } | 2915 } |
| 2916 CFX_WideString wsDotSymbol; | 2916 CFX_WideString wsDotSymbol; |
| 2917 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 2917 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 2918 if (strf[dot_index_f] == 'V') { | 2918 if (strf[dot_index_f] == 'V') { |
| 2919 wsOutput += wsDotSymbol; | 2919 wsOutput += wsDotSymbol; |
| 2920 } else if (strf[dot_index_f] == '.') { | 2920 } else if (strf[dot_index_f] == '.') { |
| 2921 if (dot_index < len) { | 2921 if (dot_index < len) { |
| 2922 wsOutput += wsDotSymbol; | 2922 wsOutput += wsDotSymbol; |
| 2923 } else { | 2923 } else { |
| 2924 if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { | 2924 if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { |
| 2925 wsOutput += wsDotSymbol; | 2925 wsOutput += wsDotSymbol; |
| 2926 } | 2926 } |
| 2927 } | 2927 } |
| 2928 } | 2928 } |
| 2929 ccf = dot_index_f + 1; | 2929 ccf = dot_index_f + 1; |
| 2930 cc = dot_index + 1; | 2930 cc = dot_index + 1; |
| 2931 while (ccf < lenf) { | 2931 while (ccf < lenf) { |
| 2932 switch (strf[ccf]) { | 2932 switch (strf[ccf]) { |
| 2933 case '\'': | 2933 case '\'': |
| 2934 wsOutput += FX_GetLiteralText(strf, ccf, lenf); | 2934 wsOutput += FX_GetLiteralText(strf, ccf, lenf); |
| 2935 ccf++; | 2935 ccf++; |
| 2936 break; | 2936 break; |
| 2937 case '9': | 2937 case '9': |
| 2938 if (cc < len) { | 2938 if (cc < len) { |
| 2939 if (!FXSYS_isDecimalDigit(str[cc])) { | 2939 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2940 return FALSE; | 2940 return false; |
| 2941 } | 2941 } |
| 2942 wsOutput += str[cc]; | 2942 wsOutput += str[cc]; |
| 2943 cc++; | 2943 cc++; |
| 2944 } else { | 2944 } else { |
| 2945 wsOutput += L'0'; | 2945 wsOutput += L'0'; |
| 2946 } | 2946 } |
| 2947 ccf++; | 2947 ccf++; |
| 2948 break; | 2948 break; |
| 2949 case 'z': | 2949 case 'z': |
| 2950 if (cc < len) { | 2950 if (cc < len) { |
| 2951 if (!FXSYS_isDecimalDigit(str[cc])) { | 2951 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2952 return FALSE; | 2952 return false; |
| 2953 } | 2953 } |
| 2954 wsOutput += str[cc]; | 2954 wsOutput += str[cc]; |
| 2955 cc++; | 2955 cc++; |
| 2956 } | 2956 } |
| 2957 ccf++; | 2957 ccf++; |
| 2958 break; | 2958 break; |
| 2959 case 'Z': | 2959 case 'Z': |
| 2960 if (cc < len) { | 2960 if (cc < len) { |
| 2961 if (!FXSYS_isDecimalDigit(str[cc])) { | 2961 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 2962 return FALSE; | 2962 return false; |
| 2963 } | 2963 } |
| 2964 wsOutput += str[cc]; | 2964 wsOutput += str[cc]; |
| 2965 cc++; | 2965 cc++; |
| 2966 } else { | 2966 } else { |
| 2967 wsOutput += L'0'; | 2967 wsOutput += L'0'; |
| 2968 } | 2968 } |
| 2969 ccf++; | 2969 ccf++; |
| 2970 break; | 2970 break; |
| 2971 case 'E': { | 2971 case 'E': { |
| 2972 CFX_WideString wsExp; | 2972 CFX_WideString wsExp; |
| 2973 wsExp.Format(L"E%+d", exponent); | 2973 wsExp.Format(L"E%+d", exponent); |
| 2974 wsOutput += wsExp; | 2974 wsOutput += wsExp; |
| 2975 } | 2975 } |
| 2976 ccf++; | 2976 ccf++; |
| 2977 break; | 2977 break; |
| 2978 case '$': { | 2978 case '$': { |
| 2979 CFX_WideString wsSymbol; | 2979 CFX_WideString wsSymbol; |
| 2980 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 2980 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 2981 wsOutput += wsSymbol; | 2981 wsOutput += wsSymbol; |
| 2982 } | 2982 } |
| 2983 ccf++; | 2983 ccf++; |
| 2984 break; | 2984 break; |
| 2985 case 'c': | 2985 case 'c': |
| 2986 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { | 2986 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { |
| 2987 if (bNeg) { | 2987 if (bNeg) { |
| 2988 wsOutput += L"CR"; | 2988 wsOutput += L"CR"; |
| 2989 } | 2989 } |
| 2990 ccf += 2; | 2990 ccf += 2; |
| 2991 bAddNeg = TRUE; | 2991 bAddNeg = true; |
| 2992 } | 2992 } |
| 2993 break; | 2993 break; |
| 2994 case 'C': | 2994 case 'C': |
| 2995 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { | 2995 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { |
| 2996 if (bNeg) { | 2996 if (bNeg) { |
| 2997 wsOutput += L"CR"; | 2997 wsOutput += L"CR"; |
| 2998 } else { | 2998 } else { |
| 2999 wsOutput += L" "; | 2999 wsOutput += L" "; |
| 3000 } | 3000 } |
| 3001 ccf += 2; | 3001 ccf += 2; |
| 3002 bAddNeg = TRUE; | 3002 bAddNeg = true; |
| 3003 } | 3003 } |
| 3004 break; | 3004 break; |
| 3005 case 'd': | 3005 case 'd': |
| 3006 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { | 3006 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { |
| 3007 if (bNeg) { | 3007 if (bNeg) { |
| 3008 wsOutput += L"db"; | 3008 wsOutput += L"db"; |
| 3009 } | 3009 } |
| 3010 ccf += 2; | 3010 ccf += 2; |
| 3011 bAddNeg = TRUE; | 3011 bAddNeg = true; |
| 3012 } | 3012 } |
| 3013 break; | 3013 break; |
| 3014 case 'D': | 3014 case 'D': |
| 3015 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { | 3015 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { |
| 3016 if (bNeg) { | 3016 if (bNeg) { |
| 3017 wsOutput += L"DB"; | 3017 wsOutput += L"DB"; |
| 3018 } else { | 3018 } else { |
| 3019 wsOutput += L" "; | 3019 wsOutput += L" "; |
| 3020 } | 3020 } |
| 3021 ccf += 2; | 3021 ccf += 2; |
| 3022 bAddNeg = TRUE; | 3022 bAddNeg = true; |
| 3023 } | 3023 } |
| 3024 break; | 3024 break; |
| 3025 case '%': { | 3025 case '%': { |
| 3026 CFX_WideString wsSymbol; | 3026 CFX_WideString wsSymbol; |
| 3027 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 3027 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 3028 wsOutput += wsSymbol; | 3028 wsOutput += wsSymbol; |
| 3029 } | 3029 } |
| 3030 ccf++; | 3030 ccf++; |
| 3031 break; | 3031 break; |
| 3032 case '8': { | 3032 case '8': { |
| 3033 while (ccf < lenf && strf[ccf] == '8') { | 3033 while (ccf < lenf && strf[ccf] == '8') { |
| 3034 ccf++; | 3034 ccf++; |
| 3035 } | 3035 } |
| 3036 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 3036 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 3037 wsOutput += str[cc]; | 3037 wsOutput += str[cc]; |
| 3038 cc++; | 3038 cc++; |
| 3039 } | 3039 } |
| 3040 } break; | 3040 } break; |
| 3041 case ',': | 3041 case ',': |
| 3042 wsOutput += wsGroupSymbol; | 3042 wsOutput += wsGroupSymbol; |
| 3043 ccf++; | 3043 ccf++; |
| 3044 break; | 3044 break; |
| 3045 case '(': | 3045 case '(': |
| 3046 if (bNeg) { | 3046 if (bNeg) { |
| 3047 wsOutput += '('; | 3047 wsOutput += '('; |
| 3048 } else { | 3048 } else { |
| 3049 wsOutput += ' '; | 3049 wsOutput += ' '; |
| 3050 } | 3050 } |
| 3051 bAddNeg = TRUE; | 3051 bAddNeg = true; |
| 3052 ccf++; | 3052 ccf++; |
| 3053 break; | 3053 break; |
| 3054 case ')': | 3054 case ')': |
| 3055 if (bNeg) { | 3055 if (bNeg) { |
| 3056 wsOutput += ')'; | 3056 wsOutput += ')'; |
| 3057 } else { | 3057 } else { |
| 3058 wsOutput += ' '; | 3058 wsOutput += ' '; |
| 3059 } | 3059 } |
| 3060 ccf++; | 3060 ccf++; |
| 3061 break; | 3061 break; |
| 3062 default: | 3062 default: |
| 3063 ccf++; | 3063 ccf++; |
| 3064 } | 3064 } |
| 3065 } | 3065 } |
| 3066 if (!bAddNeg && bNeg) { | 3066 if (!bAddNeg && bNeg) { |
| 3067 CFX_WideString wsMinusymbol; | 3067 CFX_WideString wsMinusymbol; |
| 3068 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 3068 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 3069 wsOutput = | 3069 wsOutput = |
| 3070 wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1); | 3070 wsMinusymbol + wsOutput[0] + wsOutput.Mid(1, wsOutput.GetLength() - 1); |
| 3071 } | 3071 } |
| 3072 return TRUE; | 3072 return true; |
| 3073 } | 3073 } |
| 3074 FX_BOOL CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum, | 3074 bool CFX_FormatString::FormatLCNumeric(CFX_LCNumeric& lcNum, |
| 3075 const CFX_WideString& wsPattern, | 3075 const CFX_WideString& wsPattern, |
| 3076 CFX_WideString& wsOutput) { | 3076 CFX_WideString& wsOutput) { |
| 3077 int32_t dot_index_f = -1; | 3077 int32_t dot_index_f = -1; |
| 3078 uint32_t dwNumStyle = 0; | 3078 uint32_t dwNumStyle = 0; |
| 3079 CFX_WideString wsNumFormat; | 3079 CFX_WideString wsNumFormat; |
| 3080 IFX_Locale* pLocale = | 3080 IFX_Locale* pLocale = |
| 3081 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); | 3081 GetNumericFormat(wsPattern, dot_index_f, dwNumStyle, wsNumFormat); |
| 3082 if (!pLocale || wsNumFormat.IsEmpty()) { | 3082 if (!pLocale || wsNumFormat.IsEmpty()) { |
| 3083 return FALSE; | 3083 return false; |
| 3084 } | 3084 } |
| 3085 int32_t cc = 0, ccf = 0; | 3085 int32_t cc = 0, ccf = 0; |
| 3086 const FX_WCHAR* strf = wsNumFormat.c_str(); | 3086 const FX_WCHAR* strf = wsNumFormat.c_str(); |
| 3087 int lenf = wsNumFormat.GetLength(); | 3087 int lenf = wsNumFormat.GetLength(); |
| 3088 double dbOrgRaw = lcNum.GetDouble(); | 3088 double dbOrgRaw = lcNum.GetDouble(); |
| 3089 double dbRetValue = dbOrgRaw; | 3089 double dbRetValue = dbOrgRaw; |
| 3090 if (dwNumStyle & FX_NUMSTYLE_Percent) { | 3090 if (dwNumStyle & FX_NUMSTYLE_Percent) { |
| 3091 dbRetValue *= 100; | 3091 dbRetValue *= 100; |
| 3092 } | 3092 } |
| 3093 int32_t exponent = 0; | 3093 int32_t exponent = 0; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3124 while (dbRetValue > threshold) { | 3124 while (dbRetValue > threshold) { |
| 3125 dbRetValue /= 10; | 3125 dbRetValue /= 10; |
| 3126 exponent += 1; | 3126 exponent += 1; |
| 3127 } | 3127 } |
| 3128 } | 3128 } |
| 3129 } | 3129 } |
| 3130 } | 3130 } |
| 3131 if (dwNumStyle & (FX_NUMSTYLE_Percent | FX_NUMSTYLE_Exponent)) { | 3131 if (dwNumStyle & (FX_NUMSTYLE_Percent | FX_NUMSTYLE_Exponent)) { |
| 3132 lcNum = CFX_LCNumeric(dbRetValue); | 3132 lcNum = CFX_LCNumeric(dbRetValue); |
| 3133 } | 3133 } |
| 3134 FX_BOOL bTrimTailZeros = FALSE; | 3134 bool bTrimTailZeros = false; |
| 3135 int32_t iTreading = | 3135 int32_t iTreading = |
| 3136 FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); | 3136 FX_GetNumTrailingLimit(wsNumFormat, dot_index_f, bTrimTailZeros); |
| 3137 CFX_WideString wsNumeric = lcNum.ToString(iTreading, bTrimTailZeros); | 3137 CFX_WideString wsNumeric = lcNum.ToString(iTreading, bTrimTailZeros); |
| 3138 if (wsNumeric.IsEmpty()) { | 3138 if (wsNumeric.IsEmpty()) { |
| 3139 return FALSE; | 3139 return false; |
| 3140 } | 3140 } |
| 3141 CFX_WideString wsGroupSymbol; | 3141 CFX_WideString wsGroupSymbol; |
| 3142 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); | 3142 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping, wsGroupSymbol); |
| 3143 FX_BOOL bNeg = FALSE; | 3143 bool bNeg = false; |
| 3144 if (wsNumeric[0] == '-') { | 3144 if (wsNumeric[0] == '-') { |
| 3145 bNeg = TRUE; | 3145 bNeg = true; |
| 3146 wsNumeric.Delete(0, 1); | 3146 wsNumeric.Delete(0, 1); |
| 3147 } | 3147 } |
| 3148 FX_BOOL bAddNeg = FALSE; | 3148 bool bAddNeg = false; |
| 3149 const FX_WCHAR* str = wsNumeric.c_str(); | 3149 const FX_WCHAR* str = wsNumeric.c_str(); |
| 3150 int len = wsNumeric.GetLength(); | 3150 int len = wsNumeric.GetLength(); |
| 3151 int dot_index = wsNumeric.Find('.'); | 3151 int dot_index = wsNumeric.Find('.'); |
| 3152 if (dot_index == -1) { | 3152 if (dot_index == -1) { |
| 3153 dot_index = len; | 3153 dot_index = len; |
| 3154 } | 3154 } |
| 3155 ccf = dot_index_f - 1; | 3155 ccf = dot_index_f - 1; |
| 3156 cc = dot_index - 1; | 3156 cc = dot_index - 1; |
| 3157 while (ccf >= 0) { | 3157 while (ccf >= 0) { |
| 3158 switch (strf[ccf]) { | 3158 switch (strf[ccf]) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3185 } else { | 3185 } else { |
| 3186 wsOutput = L' ' + wsOutput; | 3186 wsOutput = L' ' + wsOutput; |
| 3187 } | 3187 } |
| 3188 ccf--; | 3188 ccf--; |
| 3189 break; | 3189 break; |
| 3190 case 'S': | 3190 case 'S': |
| 3191 if (bNeg) { | 3191 if (bNeg) { |
| 3192 CFX_WideString wsMinusSymbol; | 3192 CFX_WideString wsMinusSymbol; |
| 3193 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 3193 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 3194 wsOutput = wsMinusSymbol + wsOutput; | 3194 wsOutput = wsMinusSymbol + wsOutput; |
| 3195 bAddNeg = TRUE; | 3195 bAddNeg = true; |
| 3196 } else { | 3196 } else { |
| 3197 wsOutput = L' ' + wsOutput; | 3197 wsOutput = L' ' + wsOutput; |
| 3198 } | 3198 } |
| 3199 ccf--; | 3199 ccf--; |
| 3200 break; | 3200 break; |
| 3201 case 's': | 3201 case 's': |
| 3202 if (bNeg) { | 3202 if (bNeg) { |
| 3203 CFX_WideString wsMinusSymbol; | 3203 CFX_WideString wsMinusSymbol; |
| 3204 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); | 3204 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusSymbol); |
| 3205 wsOutput = wsMinusSymbol + wsOutput; | 3205 wsOutput = wsMinusSymbol + wsOutput; |
| 3206 bAddNeg = TRUE; | 3206 bAddNeg = true; |
| 3207 } | 3207 } |
| 3208 ccf--; | 3208 ccf--; |
| 3209 break; | 3209 break; |
| 3210 case 'E': { | 3210 case 'E': { |
| 3211 CFX_WideString wsExp; | 3211 CFX_WideString wsExp; |
| 3212 wsExp.Format(L"E%+d", exponent); | 3212 wsExp.Format(L"E%+d", exponent); |
| 3213 wsOutput = wsExp + wsOutput; | 3213 wsOutput = wsExp + wsOutput; |
| 3214 } | 3214 } |
| 3215 ccf--; | 3215 ccf--; |
| 3216 break; | 3216 break; |
| 3217 case '$': { | 3217 case '$': { |
| 3218 CFX_WideString wsSymbol; | 3218 CFX_WideString wsSymbol; |
| 3219 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); | 3219 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol, wsSymbol); |
| 3220 wsOutput = wsSymbol + wsOutput; | 3220 wsOutput = wsSymbol + wsOutput; |
| 3221 } | 3221 } |
| 3222 ccf--; | 3222 ccf--; |
| 3223 break; | 3223 break; |
| 3224 case 'r': | 3224 case 'r': |
| 3225 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { | 3225 if (ccf - 1 >= 0 && strf[ccf - 1] == 'c') { |
| 3226 if (bNeg) { | 3226 if (bNeg) { |
| 3227 wsOutput = L"CR" + wsOutput; | 3227 wsOutput = L"CR" + wsOutput; |
| 3228 } | 3228 } |
| 3229 ccf -= 2; | 3229 ccf -= 2; |
| 3230 bAddNeg = TRUE; | 3230 bAddNeg = true; |
| 3231 } | 3231 } |
| 3232 break; | 3232 break; |
| 3233 case 'R': | 3233 case 'R': |
| 3234 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { | 3234 if (ccf - 1 >= 0 && strf[ccf - 1] == 'C') { |
| 3235 if (bNeg) { | 3235 if (bNeg) { |
| 3236 wsOutput = L"CR" + wsOutput; | 3236 wsOutput = L"CR" + wsOutput; |
| 3237 } else { | 3237 } else { |
| 3238 wsOutput = L" " + wsOutput; | 3238 wsOutput = L" " + wsOutput; |
| 3239 } | 3239 } |
| 3240 ccf -= 2; | 3240 ccf -= 2; |
| 3241 bAddNeg = TRUE; | 3241 bAddNeg = true; |
| 3242 } | 3242 } |
| 3243 break; | 3243 break; |
| 3244 case 'b': | 3244 case 'b': |
| 3245 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { | 3245 if (ccf - 1 >= 0 && strf[ccf - 1] == 'd') { |
| 3246 if (bNeg) { | 3246 if (bNeg) { |
| 3247 wsOutput = L"db" + wsOutput; | 3247 wsOutput = L"db" + wsOutput; |
| 3248 } | 3248 } |
| 3249 ccf -= 2; | 3249 ccf -= 2; |
| 3250 bAddNeg = TRUE; | 3250 bAddNeg = true; |
| 3251 } | 3251 } |
| 3252 break; | 3252 break; |
| 3253 case 'B': | 3253 case 'B': |
| 3254 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { | 3254 if (ccf - 1 >= 0 && strf[ccf - 1] == 'D') { |
| 3255 if (bNeg) { | 3255 if (bNeg) { |
| 3256 wsOutput = L"DB" + wsOutput; | 3256 wsOutput = L"DB" + wsOutput; |
| 3257 } else { | 3257 } else { |
| 3258 wsOutput = L" " + wsOutput; | 3258 wsOutput = L" " + wsOutput; |
| 3259 } | 3259 } |
| 3260 ccf -= 2; | 3260 ccf -= 2; |
| 3261 bAddNeg = TRUE; | 3261 bAddNeg = true; |
| 3262 } | 3262 } |
| 3263 break; | 3263 break; |
| 3264 case '%': { | 3264 case '%': { |
| 3265 CFX_WideString wsSymbol; | 3265 CFX_WideString wsSymbol; |
| 3266 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 3266 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 3267 wsOutput = wsSymbol + wsOutput; | 3267 wsOutput = wsSymbol + wsOutput; |
| 3268 } | 3268 } |
| 3269 ccf--; | 3269 ccf--; |
| 3270 break; | 3270 break; |
| 3271 case ',': | 3271 case ',': |
| 3272 if (cc >= 0) { | 3272 if (cc >= 0) { |
| 3273 wsOutput = wsGroupSymbol + wsOutput; | 3273 wsOutput = wsGroupSymbol + wsOutput; |
| 3274 } | 3274 } |
| 3275 ccf--; | 3275 ccf--; |
| 3276 break; | 3276 break; |
| 3277 case '(': | 3277 case '(': |
| 3278 if (bNeg) { | 3278 if (bNeg) { |
| 3279 wsOutput = L"(" + wsOutput; | 3279 wsOutput = L"(" + wsOutput; |
| 3280 } else { | 3280 } else { |
| 3281 wsOutput = L" " + wsOutput; | 3281 wsOutput = L" " + wsOutput; |
| 3282 } | 3282 } |
| 3283 bAddNeg = TRUE; | 3283 bAddNeg = true; |
| 3284 ccf--; | 3284 ccf--; |
| 3285 break; | 3285 break; |
| 3286 case ')': | 3286 case ')': |
| 3287 if (bNeg) { | 3287 if (bNeg) { |
| 3288 wsOutput = L")" + wsOutput; | 3288 wsOutput = L")" + wsOutput; |
| 3289 } else { | 3289 } else { |
| 3290 wsOutput = L" " + wsOutput; | 3290 wsOutput = L" " + wsOutput; |
| 3291 } | 3291 } |
| 3292 ccf--; | 3292 ccf--; |
| 3293 break; | 3293 break; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3313 CFX_WideString wsSymbol; | 3313 CFX_WideString wsSymbol; |
| 3314 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); | 3314 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsSymbol); |
| 3315 wsOutput += wsSymbol; | 3315 wsOutput += wsSymbol; |
| 3316 wsOutput += wsNumeric.Right(len - dot_index - 1); | 3316 wsOutput += wsNumeric.Right(len - dot_index - 1); |
| 3317 } | 3317 } |
| 3318 if (bNeg) { | 3318 if (bNeg) { |
| 3319 CFX_WideString wsMinusymbol; | 3319 CFX_WideString wsMinusymbol; |
| 3320 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 3320 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 3321 wsOutput = wsMinusymbol + wsOutput; | 3321 wsOutput = wsMinusymbol + wsOutput; |
| 3322 } | 3322 } |
| 3323 return FALSE; | 3323 return false; |
| 3324 } | 3324 } |
| 3325 if (dot_index_f == wsNumFormat.GetLength()) { | 3325 if (dot_index_f == wsNumFormat.GetLength()) { |
| 3326 if (!bAddNeg && bNeg) { | 3326 if (!bAddNeg && bNeg) { |
| 3327 CFX_WideString wsMinusymbol; | 3327 CFX_WideString wsMinusymbol; |
| 3328 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 3328 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 3329 wsOutput = wsMinusymbol + wsOutput; | 3329 wsOutput = wsMinusymbol + wsOutput; |
| 3330 } | 3330 } |
| 3331 return TRUE; | 3331 return true; |
| 3332 } | 3332 } |
| 3333 CFX_WideString wsDotSymbol; | 3333 CFX_WideString wsDotSymbol; |
| 3334 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); | 3334 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal, wsDotSymbol); |
| 3335 if (strf[dot_index_f] == 'V') { | 3335 if (strf[dot_index_f] == 'V') { |
| 3336 wsOutput += wsDotSymbol; | 3336 wsOutput += wsDotSymbol; |
| 3337 } else if (strf[dot_index_f] == '.') { | 3337 } else if (strf[dot_index_f] == '.') { |
| 3338 if (dot_index < len) { | 3338 if (dot_index < len) { |
| 3339 wsOutput += wsDotSymbol; | 3339 wsOutput += wsDotSymbol; |
| 3340 } else { | 3340 } else { |
| 3341 if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { | 3341 if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z') { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3389 wsOutput += wsSymbol; | 3389 wsOutput += wsSymbol; |
| 3390 } | 3390 } |
| 3391 ccf++; | 3391 ccf++; |
| 3392 break; | 3392 break; |
| 3393 case 'c': | 3393 case 'c': |
| 3394 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { | 3394 if (ccf + 1 < lenf && strf[ccf + 1] == 'r') { |
| 3395 if (bNeg) { | 3395 if (bNeg) { |
| 3396 wsOutput += L"CR"; | 3396 wsOutput += L"CR"; |
| 3397 } | 3397 } |
| 3398 ccf += 2; | 3398 ccf += 2; |
| 3399 bAddNeg = TRUE; | 3399 bAddNeg = true; |
| 3400 } | 3400 } |
| 3401 break; | 3401 break; |
| 3402 case 'C': | 3402 case 'C': |
| 3403 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { | 3403 if (ccf + 1 < lenf && strf[ccf + 1] == 'R') { |
| 3404 if (bNeg) { | 3404 if (bNeg) { |
| 3405 wsOutput += L"CR"; | 3405 wsOutput += L"CR"; |
| 3406 } else { | 3406 } else { |
| 3407 wsOutput += L" "; | 3407 wsOutput += L" "; |
| 3408 } | 3408 } |
| 3409 ccf += 2; | 3409 ccf += 2; |
| 3410 bAddNeg = TRUE; | 3410 bAddNeg = true; |
| 3411 } | 3411 } |
| 3412 break; | 3412 break; |
| 3413 case 'd': | 3413 case 'd': |
| 3414 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { | 3414 if (ccf + 1 < lenf && strf[ccf + 1] == 'b') { |
| 3415 if (bNeg) { | 3415 if (bNeg) { |
| 3416 wsOutput += L"db"; | 3416 wsOutput += L"db"; |
| 3417 } | 3417 } |
| 3418 ccf += 2; | 3418 ccf += 2; |
| 3419 bAddNeg = TRUE; | 3419 bAddNeg = true; |
| 3420 } | 3420 } |
| 3421 break; | 3421 break; |
| 3422 case 'D': | 3422 case 'D': |
| 3423 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { | 3423 if (ccf + 1 < lenf && strf[ccf + 1] == 'B') { |
| 3424 if (bNeg) { | 3424 if (bNeg) { |
| 3425 wsOutput += L"DB"; | 3425 wsOutput += L"DB"; |
| 3426 } else { | 3426 } else { |
| 3427 wsOutput += L" "; | 3427 wsOutput += L" "; |
| 3428 } | 3428 } |
| 3429 ccf += 2; | 3429 ccf += 2; |
| 3430 bAddNeg = TRUE; | 3430 bAddNeg = true; |
| 3431 } | 3431 } |
| 3432 break; | 3432 break; |
| 3433 case '%': { | 3433 case '%': { |
| 3434 CFX_WideString wsSymbol; | 3434 CFX_WideString wsSymbol; |
| 3435 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); | 3435 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent, wsSymbol); |
| 3436 wsOutput += wsSymbol; | 3436 wsOutput += wsSymbol; |
| 3437 } | 3437 } |
| 3438 ccf++; | 3438 ccf++; |
| 3439 break; | 3439 break; |
| 3440 case '8': { | 3440 case '8': { |
| 3441 while (ccf < lenf && strf[ccf] == '8') { | 3441 while (ccf < lenf && strf[ccf] == '8') { |
| 3442 ccf++; | 3442 ccf++; |
| 3443 } | 3443 } |
| 3444 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { | 3444 while (cc < len && FXSYS_isDecimalDigit(str[cc])) { |
| 3445 wsOutput += str[cc]; | 3445 wsOutput += str[cc]; |
| 3446 cc++; | 3446 cc++; |
| 3447 } | 3447 } |
| 3448 } break; | 3448 } break; |
| 3449 case ',': | 3449 case ',': |
| 3450 wsOutput += wsGroupSymbol; | 3450 wsOutput += wsGroupSymbol; |
| 3451 ccf++; | 3451 ccf++; |
| 3452 break; | 3452 break; |
| 3453 case '(': | 3453 case '(': |
| 3454 if (bNeg) { | 3454 if (bNeg) { |
| 3455 wsOutput += '('; | 3455 wsOutput += '('; |
| 3456 } else { | 3456 } else { |
| 3457 wsOutput += ' '; | 3457 wsOutput += ' '; |
| 3458 } | 3458 } |
| 3459 bAddNeg = TRUE; | 3459 bAddNeg = true; |
| 3460 ccf++; | 3460 ccf++; |
| 3461 break; | 3461 break; |
| 3462 case ')': | 3462 case ')': |
| 3463 if (bNeg) { | 3463 if (bNeg) { |
| 3464 wsOutput += ')'; | 3464 wsOutput += ')'; |
| 3465 } else { | 3465 } else { |
| 3466 wsOutput += ' '; | 3466 wsOutput += ' '; |
| 3467 } | 3467 } |
| 3468 ccf++; | 3468 ccf++; |
| 3469 break; | 3469 break; |
| 3470 default: | 3470 default: |
| 3471 ccf++; | 3471 ccf++; |
| 3472 } | 3472 } |
| 3473 } | 3473 } |
| 3474 if (!bAddNeg && bNeg) { | 3474 if (!bAddNeg && bNeg) { |
| 3475 CFX_WideString wsMinusymbol; | 3475 CFX_WideString wsMinusymbol; |
| 3476 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); | 3476 pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus, wsMinusymbol); |
| 3477 wsOutput = | 3477 wsOutput = |
| 3478 wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); | 3478 wsOutput[0] + wsMinusymbol + wsOutput.Mid(1, wsOutput.GetLength() - 1); |
| 3479 } | 3479 } |
| 3480 return TRUE; | 3480 return true; |
| 3481 } | 3481 } |
| 3482 FX_BOOL CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, | 3482 bool CFX_FormatString::FormatNum(const CFX_WideString& wsSrcNum, |
| 3483 const CFX_WideString& wsPattern, | 3483 const CFX_WideString& wsPattern, |
| 3484 CFX_WideString& wsOutput) { | 3484 CFX_WideString& wsOutput) { |
| 3485 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { | 3485 if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty()) { |
| 3486 return FALSE; | 3486 return false; |
| 3487 } | 3487 } |
| 3488 return FormatStrNum(wsSrcNum.AsStringC(), wsPattern, wsOutput); | 3488 return FormatStrNum(wsSrcNum.AsStringC(), wsPattern, wsOutput); |
| 3489 } | 3489 } |
| 3490 FX_BOOL CFX_FormatString::FormatNum(FX_FLOAT fNum, | 3490 bool CFX_FormatString::FormatNum(FX_FLOAT fNum, |
| 3491 const CFX_WideString& wsPattern, | 3491 const CFX_WideString& wsPattern, |
| 3492 CFX_WideString& wsOutput) { | 3492 CFX_WideString& wsOutput) { |
| 3493 if (wsPattern.IsEmpty()) { | 3493 if (wsPattern.IsEmpty()) { |
| 3494 return FALSE; | 3494 return false; |
| 3495 } | 3495 } |
| 3496 CFX_LCNumeric lcNum(fNum); | 3496 CFX_LCNumeric lcNum(fNum); |
| 3497 return FormatLCNumeric(lcNum, wsPattern, wsOutput); | 3497 return FormatLCNumeric(lcNum, wsPattern, wsOutput); |
| 3498 } | 3498 } |
| 3499 FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, | 3499 bool FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime& datetime) { |
| 3500 CFX_Unitime& datetime) { | |
| 3501 int32_t year = 1900; | 3500 int32_t year = 1900; |
| 3502 int32_t month = 1; | 3501 int32_t month = 1; |
| 3503 int32_t day = 1; | 3502 int32_t day = 1; |
| 3504 uint16_t wYear = 0; | 3503 uint16_t wYear = 0; |
| 3505 int cc_start = 0, cc = 0; | 3504 int cc_start = 0, cc = 0; |
| 3506 const FX_WCHAR* str = wsDate.c_str(); | 3505 const FX_WCHAR* str = wsDate.c_str(); |
| 3507 int len = wsDate.GetLength(); | 3506 int len = wsDate.GetLength(); |
| 3508 if (len > 10) { | 3507 if (len > 10) { |
| 3509 return FALSE; | 3508 return false; |
| 3510 } | 3509 } |
| 3511 while (cc < len && cc < 4) { | 3510 while (cc < len && cc < 4) { |
| 3512 if (!FXSYS_isDecimalDigit(str[cc])) { | 3511 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3513 return FALSE; | 3512 return false; |
| 3514 } | 3513 } |
| 3515 wYear = wYear * 10 + str[cc++] - '0'; | 3514 wYear = wYear * 10 + str[cc++] - '0'; |
| 3516 } | 3515 } |
| 3517 year = wYear; | 3516 year = wYear; |
| 3518 if (cc < 4 || wYear < 1900) { | 3517 if (cc < 4 || wYear < 1900) { |
| 3519 return FALSE; | 3518 return false; |
| 3520 } | 3519 } |
| 3521 if (cc < len) { | 3520 if (cc < len) { |
| 3522 if (str[cc] == '-') { | 3521 if (str[cc] == '-') { |
| 3523 cc++; | 3522 cc++; |
| 3524 } | 3523 } |
| 3525 cc_start = cc; | 3524 cc_start = cc; |
| 3526 uint8_t tmpM = 0; | 3525 uint8_t tmpM = 0; |
| 3527 while (cc < len && cc < cc_start + 2) { | 3526 while (cc < len && cc < cc_start + 2) { |
| 3528 if (!FXSYS_isDecimalDigit(str[cc])) { | 3527 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3529 return FALSE; | 3528 return false; |
| 3530 } | 3529 } |
| 3531 tmpM = tmpM * 10 + str[cc++] - '0'; | 3530 tmpM = tmpM * 10 + str[cc++] - '0'; |
| 3532 } | 3531 } |
| 3533 month = tmpM; | 3532 month = tmpM; |
| 3534 if (cc == cc_start + 1 || tmpM > 12 || tmpM < 1) { | 3533 if (cc == cc_start + 1 || tmpM > 12 || tmpM < 1) { |
| 3535 return FALSE; | 3534 return false; |
| 3536 } | 3535 } |
| 3537 if (cc < len) { | 3536 if (cc < len) { |
| 3538 if (str[cc] == '-') { | 3537 if (str[cc] == '-') { |
| 3539 cc++; | 3538 cc++; |
| 3540 } | 3539 } |
| 3541 uint8_t tmpD = 0; | 3540 uint8_t tmpD = 0; |
| 3542 cc_start = cc; | 3541 cc_start = cc; |
| 3543 while (cc < len && cc < cc_start + 2) { | 3542 while (cc < len && cc < cc_start + 2) { |
| 3544 if (!FXSYS_isDecimalDigit(str[cc])) { | 3543 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3545 return FALSE; | 3544 return false; |
| 3546 } | 3545 } |
| 3547 tmpD = tmpD * 10 + str[cc++] - '0'; | 3546 tmpD = tmpD * 10 + str[cc++] - '0'; |
| 3548 } | 3547 } |
| 3549 day = tmpD; | 3548 day = tmpD; |
| 3550 if (tmpD < 1) { | 3549 if (tmpD < 1) { |
| 3551 return FALSE; | 3550 return false; |
| 3552 } | 3551 } |
| 3553 if ((tmpM == 1 || tmpM == 3 || tmpM == 5 || tmpM == 7 || tmpM == 8 || | 3552 if ((tmpM == 1 || tmpM == 3 || tmpM == 5 || tmpM == 7 || tmpM == 8 || |
| 3554 tmpM == 10 || tmpM == 12) && | 3553 tmpM == 10 || tmpM == 12) && |
| 3555 tmpD > 31) { | 3554 tmpD > 31) { |
| 3556 return FALSE; | 3555 return false; |
| 3557 } | 3556 } |
| 3558 if ((tmpM == 4 || tmpM == 6 || tmpM == 9 || tmpM == 11) && tmpD > 30) { | 3557 if ((tmpM == 4 || tmpM == 6 || tmpM == 9 || tmpM == 11) && tmpD > 30) { |
| 3559 return FALSE; | 3558 return false; |
| 3560 } | 3559 } |
| 3561 FX_BOOL iLeapYear; | 3560 bool iLeapYear; |
| 3562 if ((wYear % 4 == 0 && wYear % 100 != 0) || wYear % 400 == 0) { | 3561 if ((wYear % 4 == 0 && wYear % 100 != 0) || wYear % 400 == 0) { |
| 3563 iLeapYear = TRUE; | 3562 iLeapYear = true; |
| 3564 } else { | 3563 } else { |
| 3565 iLeapYear = FALSE; | 3564 iLeapYear = false; |
| 3566 } | 3565 } |
| 3567 if ((iLeapYear && tmpM == 2 && tmpD > 29) || | 3566 if ((iLeapYear && tmpM == 2 && tmpD > 29) || |
| 3568 (!iLeapYear && tmpM == 2 && tmpD > 28)) { | 3567 (!iLeapYear && tmpM == 2 && tmpD > 28)) { |
| 3569 return FALSE; | 3568 return false; |
| 3570 } | 3569 } |
| 3571 } | 3570 } |
| 3572 } | 3571 } |
| 3573 CFX_Unitime ut; | 3572 CFX_Unitime ut; |
| 3574 ut.Set(year, month, day); | 3573 ut.Set(year, month, day); |
| 3575 datetime = datetime + ut; | 3574 datetime = datetime + ut; |
| 3576 return TRUE; | 3575 return true; |
| 3577 } | 3576 } |
| 3578 FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime, | 3577 bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime, |
| 3579 CFX_Unitime& datetime, | 3578 CFX_Unitime& datetime, |
| 3580 IFX_Locale* pLocale) { | 3579 IFX_Locale* pLocale) { |
| 3581 if (wsTime.GetLength() == 0) { | 3580 if (wsTime.GetLength() == 0) { |
| 3582 return FALSE; | 3581 return false; |
| 3583 } | 3582 } |
| 3584 uint8_t hour = 0; | 3583 uint8_t hour = 0; |
| 3585 uint8_t minute = 0; | 3584 uint8_t minute = 0; |
| 3586 uint8_t second = 0; | 3585 uint8_t second = 0; |
| 3587 uint16_t millisecond = 0; | 3586 uint16_t millisecond = 0; |
| 3588 int cc_start = 0, cc = cc_start; | 3587 int cc_start = 0, cc = cc_start; |
| 3589 const FX_WCHAR* str = wsTime.c_str(); | 3588 const FX_WCHAR* str = wsTime.c_str(); |
| 3590 int len = wsTime.GetLength(); | 3589 int len = wsTime.GetLength(); |
| 3591 while (cc < len && cc < 2) { | 3590 while (cc < len && cc < 2) { |
| 3592 if (!FXSYS_isDecimalDigit(str[cc])) { | 3591 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3593 return FALSE; | 3592 return false; |
| 3594 } | 3593 } |
| 3595 hour = hour * 10 + str[cc++] - '0'; | 3594 hour = hour * 10 + str[cc++] - '0'; |
| 3596 } | 3595 } |
| 3597 if (cc < 2 || hour >= 24) { | 3596 if (cc < 2 || hour >= 24) { |
| 3598 return FALSE; | 3597 return false; |
| 3599 } | 3598 } |
| 3600 if (cc < len) { | 3599 if (cc < len) { |
| 3601 if (str[cc] == ':') { | 3600 if (str[cc] == ':') { |
| 3602 cc++; | 3601 cc++; |
| 3603 } | 3602 } |
| 3604 cc_start = cc; | 3603 cc_start = cc; |
| 3605 while (cc < len && cc < cc_start + 2) { | 3604 while (cc < len && cc < cc_start + 2) { |
| 3606 if (!FXSYS_isDecimalDigit(str[cc])) { | 3605 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3607 return FALSE; | 3606 return false; |
| 3608 } | 3607 } |
| 3609 minute = minute * 10 + str[cc++] - '0'; | 3608 minute = minute * 10 + str[cc++] - '0'; |
| 3610 } | 3609 } |
| 3611 if (cc == cc_start + 1 || minute >= 60) { | 3610 if (cc == cc_start + 1 || minute >= 60) { |
| 3612 return FALSE; | 3611 return false; |
| 3613 } | 3612 } |
| 3614 if (cc < len) { | 3613 if (cc < len) { |
| 3615 if (str[cc] == ':') { | 3614 if (str[cc] == ':') { |
| 3616 cc++; | 3615 cc++; |
| 3617 } | 3616 } |
| 3618 cc_start = cc; | 3617 cc_start = cc; |
| 3619 while (cc < len && cc < cc_start + 2) { | 3618 while (cc < len && cc < cc_start + 2) { |
| 3620 if (!FXSYS_isDecimalDigit(str[cc])) { | 3619 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3621 return FALSE; | 3620 return false; |
| 3622 } | 3621 } |
| 3623 second = second * 10 + str[cc++] - '0'; | 3622 second = second * 10 + str[cc++] - '0'; |
| 3624 } | 3623 } |
| 3625 if (cc == cc_start + 1 || second >= 60) { | 3624 if (cc == cc_start + 1 || second >= 60) { |
| 3626 return FALSE; | 3625 return false; |
| 3627 } | 3626 } |
| 3628 if (cc < len) { | 3627 if (cc < len) { |
| 3629 if (str[cc] == '.') { | 3628 if (str[cc] == '.') { |
| 3630 cc++; | 3629 cc++; |
| 3631 cc_start = cc; | 3630 cc_start = cc; |
| 3632 while (cc < len && cc < cc_start + 3) { | 3631 while (cc < len && cc < cc_start + 3) { |
| 3633 if (!FXSYS_isDecimalDigit(str[cc])) { | 3632 if (!FXSYS_isDecimalDigit(str[cc])) { |
| 3634 return FALSE; | 3633 return false; |
| 3635 } | 3634 } |
| 3636 millisecond = millisecond * 10 + str[cc++] - '0'; | 3635 millisecond = millisecond * 10 + str[cc++] - '0'; |
| 3637 } | 3636 } |
| 3638 if (cc < cc_start + 3) | 3637 if (cc < cc_start + 3) |
| 3639 return FALSE; | 3638 return false; |
| 3640 } | 3639 } |
| 3641 if (cc < len) { | 3640 if (cc < len) { |
| 3642 FX_TIMEZONE tzDiff; | 3641 FX_TIMEZONE tzDiff; |
| 3643 tzDiff.tzHour = 0; | 3642 tzDiff.tzHour = 0; |
| 3644 tzDiff.tzMinute = 0; | 3643 tzDiff.tzMinute = 0; |
| 3645 if (str[cc] != 'Z') { | 3644 if (str[cc] != 'Z') { |
| 3646 cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); | 3645 cc += FX_ParseTimeZone(str + cc, len - cc, tzDiff); |
| 3647 } | 3646 } |
| 3648 FX_ResolveZone(hour, minute, tzDiff, pLocale); | 3647 FX_ResolveZone(hour, minute, tzDiff, pLocale); |
| 3649 } | 3648 } |
| 3650 } | 3649 } |
| 3651 } | 3650 } |
| 3652 } | 3651 } |
| 3653 CFX_Unitime ut; | 3652 CFX_Unitime ut; |
| 3654 ut.Set(0, 0, 0, hour, minute, second, millisecond); | 3653 ut.Set(0, 0, 0, hour, minute, second, millisecond); |
| 3655 datetime = datetime + ut; | 3654 datetime = datetime + ut; |
| 3656 return TRUE; | 3655 return true; |
| 3657 } | 3656 } |
| 3658 static uint16_t FX_GetSolarMonthDays(uint16_t year, uint16_t month) { | 3657 static uint16_t FX_GetSolarMonthDays(uint16_t year, uint16_t month) { |
| 3659 if (month % 2) { | 3658 if (month % 2) { |
| 3660 return 31; | 3659 return 31; |
| 3661 } else if (month == 2) { | 3660 } else if (month == 2) { |
| 3662 return FX_IsLeapYear(year) ? 29 : 28; | 3661 return FX_IsLeapYear(year) ? 29 : 28; |
| 3663 } | 3662 } |
| 3664 return 30; | 3663 return 30; |
| 3665 } | 3664 } |
| 3666 static uint16_t FX_GetWeekDay(uint16_t year, uint16_t month, uint16_t day) { | 3665 static uint16_t FX_GetWeekDay(uint16_t year, uint16_t month, uint16_t day) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3691 nDays += day; | 3690 nDays += day; |
| 3692 uint16_t week_day = FX_GetWeekDay(year, 1, 1); | 3691 uint16_t week_day = FX_GetWeekDay(year, 1, 1); |
| 3693 uint16_t week_index = 1; | 3692 uint16_t week_index = 1; |
| 3694 week_index += nDays / 7; | 3693 week_index += nDays / 7; |
| 3695 nDays = nDays % 7; | 3694 nDays = nDays % 7; |
| 3696 if (week_day + nDays > 7) { | 3695 if (week_day + nDays > 7) { |
| 3697 week_index++; | 3696 week_index++; |
| 3698 } | 3697 } |
| 3699 return week_index; | 3698 return week_index; |
| 3700 } | 3699 } |
| 3701 static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, | 3700 static bool FX_DateFormat(const CFX_WideString& wsDatePattern, |
| 3702 IFX_Locale* pLocale, | 3701 IFX_Locale* pLocale, |
| 3703 const CFX_Unitime& datetime, | 3702 const CFX_Unitime& datetime, |
| 3704 CFX_WideString& wsResult) { | 3703 CFX_WideString& wsResult) { |
| 3705 FX_BOOL bRet = TRUE; | 3704 bool bRet = true; |
| 3706 int32_t year = datetime.GetYear(); | 3705 int32_t year = datetime.GetYear(); |
| 3707 uint8_t month = datetime.GetMonth(); | 3706 uint8_t month = datetime.GetMonth(); |
| 3708 uint8_t day = datetime.GetDay(); | 3707 uint8_t day = datetime.GetDay(); |
| 3709 int32_t ccf = 0; | 3708 int32_t ccf = 0; |
| 3710 const FX_WCHAR* strf = wsDatePattern.c_str(); | 3709 const FX_WCHAR* strf = wsDatePattern.c_str(); |
| 3711 int32_t lenf = wsDatePattern.GetLength(); | 3710 int32_t lenf = wsDatePattern.GetLength(); |
| 3712 CFX_WideStringC wsDateSymbols(gs_wsDateSymbols); | 3711 CFX_WideStringC wsDateSymbols(gs_wsDateSymbols); |
| 3713 while (ccf < lenf) { | 3712 while (ccf < lenf) { |
| 3714 if (strf[ccf] == '\'') { | 3713 if (strf[ccf] == '\'') { |
| 3715 wsResult += FX_GetLiteralText(strf, ccf, lenf); | 3714 wsResult += FX_GetLiteralText(strf, ccf, lenf); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3755 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { | 3754 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { |
| 3756 CFX_WideString wsMonth; | 3755 CFX_WideString wsMonth; |
| 3757 wsMonth.Format(L"%d", month); | 3756 wsMonth.Format(L"%d", month); |
| 3758 wsResult += wsMonth; | 3757 wsResult += wsMonth; |
| 3759 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { | 3758 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { |
| 3760 CFX_WideString wsMonth; | 3759 CFX_WideString wsMonth; |
| 3761 wsMonth.Format(L"%02d", month); | 3760 wsMonth.Format(L"%02d", month); |
| 3762 wsResult += wsMonth; | 3761 wsResult += wsMonth; |
| 3763 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { | 3762 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { |
| 3764 CFX_WideString wsTemp; | 3763 CFX_WideString wsTemp; |
| 3765 pLocale->GetMonthName(month - 1, wsTemp, TRUE); | 3764 pLocale->GetMonthName(month - 1, wsTemp, true); |
| 3766 wsResult += wsTemp; | 3765 wsResult += wsTemp; |
| 3767 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { | 3766 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { |
| 3768 CFX_WideString wsTemp; | 3767 CFX_WideString wsTemp; |
| 3769 pLocale->GetMonthName(month - 1, wsTemp, FALSE); | 3768 pLocale->GetMonthName(month - 1, wsTemp, false); |
| 3770 wsResult += wsTemp; | 3769 wsResult += wsTemp; |
| 3771 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { | 3770 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { |
| 3772 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); | 3771 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
| 3773 CFX_WideString wsWeekDay; | 3772 CFX_WideString wsWeekDay; |
| 3774 wsWeekDay.Format(L"%d", wWeekDay + 1); | 3773 wsWeekDay.Format(L"%d", wWeekDay + 1); |
| 3775 wsResult += wsWeekDay; | 3774 wsResult += wsWeekDay; |
| 3776 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { | 3775 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { |
| 3777 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); | 3776 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
| 3778 CFX_WideString wsTemp; | 3777 CFX_WideString wsTemp; |
| 3779 pLocale->GetDayName(wWeekDay, wsTemp, TRUE); | 3778 pLocale->GetDayName(wWeekDay, wsTemp, true); |
| 3780 wsResult += wsTemp; | 3779 wsResult += wsTemp; |
| 3781 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { | 3780 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { |
| 3782 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); | 3781 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
| 3783 if (pLocale) { | 3782 if (pLocale) { |
| 3784 CFX_WideString wsTemp; | 3783 CFX_WideString wsTemp; |
| 3785 pLocale->GetDayName(wWeekDay, wsTemp, FALSE); | 3784 pLocale->GetDayName(wWeekDay, wsTemp, false); |
| 3786 wsResult += wsTemp; | 3785 wsResult += wsTemp; |
| 3787 } | 3786 } |
| 3788 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { | 3787 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { |
| 3789 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); | 3788 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
| 3790 CFX_WideString wsWeekDay; | 3789 CFX_WideString wsWeekDay; |
| 3791 wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7); | 3790 wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7); |
| 3792 wsResult += wsWeekDay; | 3791 wsResult += wsWeekDay; |
| 3793 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { | 3792 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { |
| 3794 CFX_WideString wsTemp; | 3793 CFX_WideString wsTemp; |
| 3795 pLocale->GetEraName(wsTemp, year < 0); | 3794 pLocale->GetEraName(wsTemp, year < 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3809 wsResult += wsWeekInMonth; | 3808 wsResult += wsWeekInMonth; |
| 3810 } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { | 3809 } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { |
| 3811 uint16_t week_index = FX_GetWeekOfYear(year, month, day); | 3810 uint16_t week_index = FX_GetWeekOfYear(year, month, day); |
| 3812 CFX_WideString wsWeekInYear; | 3811 CFX_WideString wsWeekInYear; |
| 3813 wsWeekInYear.Format(L"%02d", week_index); | 3812 wsWeekInYear.Format(L"%02d", week_index); |
| 3814 wsResult += wsWeekInYear; | 3813 wsResult += wsWeekInYear; |
| 3815 } | 3814 } |
| 3816 } | 3815 } |
| 3817 return bRet; | 3816 return bRet; |
| 3818 } | 3817 } |
| 3819 static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern, | 3818 static bool FX_TimeFormat(const CFX_WideString& wsTimePattern, |
| 3820 IFX_Locale* pLocale, | 3819 IFX_Locale* pLocale, |
| 3821 const CFX_Unitime& datetime, | 3820 const CFX_Unitime& datetime, |
| 3822 CFX_WideString& wsResult) { | 3821 CFX_WideString& wsResult) { |
| 3823 FX_BOOL bGMT = FALSE; | 3822 bool bGMT = false; |
| 3824 FX_BOOL bRet = TRUE; | 3823 bool bRet = true; |
| 3825 uint8_t hour = datetime.GetHour(); | 3824 uint8_t hour = datetime.GetHour(); |
| 3826 uint8_t minute = datetime.GetMinute(); | 3825 uint8_t minute = datetime.GetMinute(); |
| 3827 uint8_t second = datetime.GetSecond(); | 3826 uint8_t second = datetime.GetSecond(); |
| 3828 uint16_t millisecond = datetime.GetMillisecond(); | 3827 uint16_t millisecond = datetime.GetMillisecond(); |
| 3829 int32_t ccf = 0; | 3828 int32_t ccf = 0; |
| 3830 const FX_WCHAR* strf = wsTimePattern.c_str(); | 3829 const FX_WCHAR* strf = wsTimePattern.c_str(); |
| 3831 int32_t lenf = wsTimePattern.GetLength(); | 3830 int32_t lenf = wsTimePattern.GetLength(); |
| 3832 uint16_t wHour = hour; | 3831 uint16_t wHour = hour; |
| 3833 FX_BOOL bPM = FALSE; | 3832 bool bPM = false; |
| 3834 if (wsTimePattern.Find('A') != -1) { | 3833 if (wsTimePattern.Find('A') != -1) { |
| 3835 if (wHour >= 12) { | 3834 if (wHour >= 12) { |
| 3836 bPM = TRUE; | 3835 bPM = true; |
| 3837 } | 3836 } |
| 3838 } | 3837 } |
| 3839 CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols); | 3838 CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols); |
| 3840 while (ccf < lenf) { | 3839 while (ccf < lenf) { |
| 3841 if (strf[ccf] == '\'') { | 3840 if (strf[ccf] == '\'') { |
| 3842 wsResult += FX_GetLiteralText(strf, ccf, lenf); | 3841 wsResult += FX_GetLiteralText(strf, ccf, lenf); |
| 3843 ccf++; | 3842 ccf++; |
| 3844 continue; | 3843 continue; |
| 3845 } else if (wsTimeSymbols.Find(strf[ccf]) == -1) { | 3844 } else if (wsTimeSymbols.Find(strf[ccf]) == -1) { |
| 3846 wsResult += strf[ccf++]; | 3845 wsResult += strf[ccf++]; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3945 wsResult += FX_WSTRC(L"+"); | 3944 wsResult += FX_WSTRC(L"+"); |
| 3946 } | 3945 } |
| 3947 CFX_WideString wsTimezone; | 3946 CFX_WideString wsTimezone; |
| 3948 wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); | 3947 wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); |
| 3949 wsResult += wsTimezone; | 3948 wsResult += wsTimezone; |
| 3950 } | 3949 } |
| 3951 } | 3950 } |
| 3952 } | 3951 } |
| 3953 return bRet; | 3952 return bRet; |
| 3954 } | 3953 } |
| 3955 static FX_BOOL FX_FormatDateTime(const CFX_Unitime& dt, | 3954 static bool FX_FormatDateTime(const CFX_Unitime& dt, |
| 3956 const CFX_WideString& wsDatePattern, | 3955 const CFX_WideString& wsDatePattern, |
| 3957 const CFX_WideString& wsTimePattern, | 3956 const CFX_WideString& wsTimePattern, |
| 3958 FX_BOOL bDateFirst, | 3957 bool bDateFirst, |
| 3959 IFX_Locale* pLocale, | 3958 IFX_Locale* pLocale, |
| 3960 CFX_WideString& wsOutput) { | 3959 CFX_WideString& wsOutput) { |
| 3961 FX_BOOL bRet = TRUE; | 3960 bool bRet = true; |
| 3962 CFX_WideString wsDateOut, wsTimeOut; | 3961 CFX_WideString wsDateOut, wsTimeOut; |
| 3963 if (!wsDatePattern.IsEmpty()) { | 3962 if (!wsDatePattern.IsEmpty()) { |
| 3964 bRet &= FX_DateFormat(wsDatePattern, pLocale, dt, wsDateOut); | 3963 bRet &= FX_DateFormat(wsDatePattern, pLocale, dt, wsDateOut); |
| 3965 } | 3964 } |
| 3966 if (!wsTimePattern.IsEmpty()) { | 3965 if (!wsTimePattern.IsEmpty()) { |
| 3967 bRet &= FX_TimeFormat(wsTimePattern, pLocale, dt, wsTimeOut); | 3966 bRet &= FX_TimeFormat(wsTimePattern, pLocale, dt, wsTimeOut); |
| 3968 } | 3967 } |
| 3969 wsOutput = bDateFirst ? wsDateOut + wsTimeOut : wsTimeOut + wsDateOut; | 3968 wsOutput = bDateFirst ? wsDateOut + wsTimeOut : wsTimeOut + wsDateOut; |
| 3970 return bRet; | 3969 return bRet; |
| 3971 } | 3970 } |
| 3972 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, | 3971 bool CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, |
| 3973 const CFX_WideString& wsPattern, | 3972 const CFX_WideString& wsPattern, |
| 3974 CFX_WideString& wsOutput) { | 3973 CFX_WideString& wsOutput) { |
| 3975 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { | 3974 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { |
| 3976 return FALSE; | 3975 return false; |
| 3977 } | 3976 } |
| 3978 CFX_WideString wsDatePattern, wsTimePattern; | 3977 CFX_WideString wsDatePattern, wsTimePattern; |
| 3979 IFX_Locale* pLocale = nullptr; | 3978 IFX_Locale* pLocale = nullptr; |
| 3980 FX_DATETIMETYPE eCategory = | 3979 FX_DATETIMETYPE eCategory = |
| 3981 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 3980 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
| 3982 if (!pLocale || eCategory == FX_DATETIMETYPE_Unknown) { | 3981 if (!pLocale || eCategory == FX_DATETIMETYPE_Unknown) { |
| 3983 return FALSE; | 3982 return false; |
| 3984 } | 3983 } |
| 3985 CFX_Unitime dt(0); | 3984 CFX_Unitime dt(0); |
| 3986 int32_t iT = wsSrcDateTime.Find(L"T"); | 3985 int32_t iT = wsSrcDateTime.Find(L"T"); |
| 3987 if (iT < 0) { | 3986 if (iT < 0) { |
| 3988 if (eCategory == FX_DATETIMETYPE_Date) { | 3987 if (eCategory == FX_DATETIMETYPE_Date) { |
| 3989 FX_DateFromCanonical(wsSrcDateTime, dt); | 3988 FX_DateFromCanonical(wsSrcDateTime, dt); |
| 3990 } else if (eCategory == FX_DATETIMETYPE_Time) { | 3989 } else if (eCategory == FX_DATETIMETYPE_Time) { |
| 3991 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale); | 3990 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale); |
| 3992 } | 3991 } |
| 3993 } else { | 3992 } else { |
| 3994 FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); | 3993 FX_DateFromCanonical(wsSrcDateTime.Left(iT), dt); |
| 3995 FX_TimeFromCanonical( | 3994 FX_TimeFromCanonical( |
| 3996 wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsStringC(), dt, | 3995 wsSrcDateTime.Right(wsSrcDateTime.GetLength() - iT - 1).AsStringC(), dt, |
| 3997 pLocale); | 3996 pLocale); |
| 3998 } | 3997 } |
| 3999 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, | 3998 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, |
| 4000 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 3999 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
| 4001 wsOutput); | 4000 wsOutput); |
| 4002 } | 4001 } |
| 4003 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, | 4002 bool CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, |
| 4004 const CFX_WideString& wsPattern, | 4003 const CFX_WideString& wsPattern, |
| 4005 CFX_WideString& wsOutput, | 4004 CFX_WideString& wsOutput, |
| 4006 FX_DATETIMETYPE eDateTimeType) { | 4005 FX_DATETIMETYPE eDateTimeType) { |
| 4007 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { | 4006 if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { |
| 4008 return FALSE; | 4007 return false; |
| 4009 } | 4008 } |
| 4010 CFX_WideString wsDatePattern, wsTimePattern; | 4009 CFX_WideString wsDatePattern, wsTimePattern; |
| 4011 IFX_Locale* pLocale = nullptr; | 4010 IFX_Locale* pLocale = nullptr; |
| 4012 FX_DATETIMETYPE eCategory = | 4011 FX_DATETIMETYPE eCategory = |
| 4013 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 4012 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
| 4014 if (!pLocale) { | 4013 if (!pLocale) { |
| 4015 return FALSE; | 4014 return false; |
| 4016 } | 4015 } |
| 4017 if (eCategory == FX_DATETIMETYPE_Unknown) { | 4016 if (eCategory == FX_DATETIMETYPE_Unknown) { |
| 4018 if (eDateTimeType == FX_DATETIMETYPE_Time) { | 4017 if (eDateTimeType == FX_DATETIMETYPE_Time) { |
| 4019 wsTimePattern = wsDatePattern; | 4018 wsTimePattern = wsDatePattern; |
| 4020 wsDatePattern.clear(); | 4019 wsDatePattern.clear(); |
| 4021 } | 4020 } |
| 4022 eCategory = eDateTimeType; | 4021 eCategory = eDateTimeType; |
| 4023 } | 4022 } |
| 4024 if (eCategory == FX_DATETIMETYPE_Unknown) { | 4023 if (eCategory == FX_DATETIMETYPE_Unknown) { |
| 4025 return FALSE; | 4024 return false; |
| 4026 } | 4025 } |
| 4027 CFX_Unitime dt(0); | 4026 CFX_Unitime dt(0); |
| 4028 int32_t iT = wsSrcDateTime.Find(L"T"); | 4027 int32_t iT = wsSrcDateTime.Find(L"T"); |
| 4029 if (iT < 0) { | 4028 if (iT < 0) { |
| 4030 if (eCategory == FX_DATETIMETYPE_Date && | 4029 if (eCategory == FX_DATETIMETYPE_Date && |
| 4031 FX_DateFromCanonical(wsSrcDateTime, dt)) { | 4030 FX_DateFromCanonical(wsSrcDateTime, dt)) { |
| 4032 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4031 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, true, pLocale, |
| 4033 wsOutput); | 4032 wsOutput); |
| 4034 } else if (eCategory == FX_DATETIMETYPE_Time && | 4033 } else if (eCategory == FX_DATETIMETYPE_Time && |
| 4035 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { | 4034 FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), dt, pLocale)) { |
| 4036 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, TRUE, pLocale, | 4035 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, true, pLocale, |
| 4037 wsOutput); | 4036 wsOutput); |
| 4038 } | 4037 } |
| 4039 } else { | 4038 } else { |
| 4040 CFX_WideString wsSrcDate(wsSrcDateTime.c_str(), iT); | 4039 CFX_WideString wsSrcDate(wsSrcDateTime.c_str(), iT); |
| 4041 CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT + 1, | 4040 CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT + 1, |
| 4042 wsSrcDateTime.GetLength() - iT - 1); | 4041 wsSrcDateTime.GetLength() - iT - 1); |
| 4043 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { | 4042 if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty()) { |
| 4044 return FALSE; | 4043 return false; |
| 4045 } | 4044 } |
| 4046 if (FX_DateFromCanonical(wsSrcDate, dt) && | 4045 if (FX_DateFromCanonical(wsSrcDate, dt) && |
| 4047 FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { | 4046 FX_TimeFromCanonical(wsSrcTime, dt, pLocale)) { |
| 4048 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, | 4047 return FX_FormatDateTime(dt, wsDatePattern, wsTimePattern, |
| 4049 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 4048 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
| 4050 wsOutput); | 4049 wsOutput); |
| 4051 } | 4050 } |
| 4052 } | 4051 } |
| 4053 return FALSE; | 4052 return false; |
| 4054 } | 4053 } |
| 4055 FX_BOOL CFX_FormatString::FormatDateTime(const CFX_Unitime& dt, | 4054 bool CFX_FormatString::FormatDateTime(const CFX_Unitime& dt, |
| 4056 const CFX_WideString& wsPattern, | 4055 const CFX_WideString& wsPattern, |
| 4057 CFX_WideString& wsOutput) { | 4056 CFX_WideString& wsOutput) { |
| 4058 if (wsPattern.IsEmpty()) { | 4057 if (wsPattern.IsEmpty()) { |
| 4059 return FALSE; | 4058 return false; |
| 4060 } | 4059 } |
| 4061 CFX_WideString wsDatePattern, wsTimePattern; | 4060 CFX_WideString wsDatePattern, wsTimePattern; |
| 4062 IFX_Locale* pLocale = nullptr; | 4061 IFX_Locale* pLocale = nullptr; |
| 4063 FX_DATETIMETYPE eCategory = | 4062 FX_DATETIMETYPE eCategory = |
| 4064 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); | 4063 GetDateTimeFormat(wsPattern, pLocale, wsDatePattern, wsTimePattern); |
| 4065 if (!pLocale) { | 4064 if (!pLocale) { |
| 4066 return FALSE; | 4065 return false; |
| 4067 } | 4066 } |
| 4068 return FX_FormatDateTime(dt, wsPattern, wsTimePattern, | 4067 return FX_FormatDateTime(dt, wsPattern, wsTimePattern, |
| 4069 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, | 4068 eCategory != FX_DATETIMETYPE_TimeDate, pLocale, |
| 4070 wsOutput); | 4069 wsOutput); |
| 4071 } | 4070 } |
| 4072 FX_BOOL CFX_FormatString::FormatZero(const CFX_WideString& wsPattern, | 4071 bool CFX_FormatString::FormatZero(const CFX_WideString& wsPattern, |
| 4073 CFX_WideString& wsOutput) { | 4072 CFX_WideString& wsOutput) { |
| 4074 if (wsPattern.IsEmpty()) { | 4073 if (wsPattern.IsEmpty()) { |
| 4075 return FALSE; | 4074 return false; |
| 4076 } | 4075 } |
| 4077 CFX_WideString wsTextFormat; | 4076 CFX_WideString wsTextFormat; |
| 4078 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); | 4077 GetTextFormat(wsPattern, FX_WSTRC(L"zero"), wsTextFormat); |
| 4079 int32_t iPattern = 0; | 4078 int32_t iPattern = 0; |
| 4080 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); | 4079 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 4081 int32_t iLenPattern = wsTextFormat.GetLength(); | 4080 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 4082 while (iPattern < iLenPattern) { | 4081 while (iPattern < iLenPattern) { |
| 4083 if (pStrPattern[iPattern] == '\'') { | 4082 if (pStrPattern[iPattern] == '\'') { |
| 4084 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 4083 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 4085 iPattern++; | 4084 iPattern++; |
| 4086 continue; | 4085 continue; |
| 4087 } else { | 4086 } else { |
| 4088 wsOutput += pStrPattern[iPattern++]; | 4087 wsOutput += pStrPattern[iPattern++]; |
| 4089 continue; | 4088 continue; |
| 4090 } | 4089 } |
| 4091 } | 4090 } |
| 4092 return TRUE; | 4091 return true; |
| 4093 } | 4092 } |
| 4094 FX_BOOL CFX_FormatString::FormatNull(const CFX_WideString& wsPattern, | 4093 bool CFX_FormatString::FormatNull(const CFX_WideString& wsPattern, |
| 4095 CFX_WideString& wsOutput) { | 4094 CFX_WideString& wsOutput) { |
| 4096 if (wsPattern.IsEmpty()) { | 4095 if (wsPattern.IsEmpty()) { |
| 4097 return FALSE; | 4096 return false; |
| 4098 } | 4097 } |
| 4099 CFX_WideString wsTextFormat; | 4098 CFX_WideString wsTextFormat; |
| 4100 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); | 4099 GetTextFormat(wsPattern, FX_WSTRC(L"null"), wsTextFormat); |
| 4101 int32_t iPattern = 0; | 4100 int32_t iPattern = 0; |
| 4102 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); | 4101 const FX_WCHAR* pStrPattern = wsTextFormat.c_str(); |
| 4103 int32_t iLenPattern = wsTextFormat.GetLength(); | 4102 int32_t iLenPattern = wsTextFormat.GetLength(); |
| 4104 while (iPattern < iLenPattern) { | 4103 while (iPattern < iLenPattern) { |
| 4105 if (pStrPattern[iPattern] == '\'') { | 4104 if (pStrPattern[iPattern] == '\'') { |
| 4106 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); | 4105 wsOutput += FX_GetLiteralText(pStrPattern, iPattern, iLenPattern); |
| 4107 iPattern++; | 4106 iPattern++; |
| 4108 continue; | 4107 continue; |
| 4109 } else { | 4108 } else { |
| 4110 wsOutput += pStrPattern[iPattern++]; | 4109 wsOutput += pStrPattern[iPattern++]; |
| 4111 continue; | 4110 continue; |
| 4112 } | 4111 } |
| 4113 } | 4112 } |
| 4114 return TRUE; | 4113 return true; |
| 4115 } | 4114 } |
| 4116 IFX_Locale* CFX_FormatString::GetPatternLocale(const CFX_WideString& wsLocale) { | 4115 IFX_Locale* CFX_FormatString::GetPatternLocale(const CFX_WideString& wsLocale) { |
| 4117 return m_pLocaleMgr->GetLocaleByName(wsLocale); | 4116 return m_pLocaleMgr->GetLocaleByName(wsLocale); |
| 4118 } | 4117 } |
| 4119 #define FXMATH_DECIMAL_SCALELIMIT 0x1c | 4118 #define FXMATH_DECIMAL_SCALELIMIT 0x1c |
| 4120 #define FXMATH_DECIMAL_NEGMASK (0x80000000L) | 4119 #define FXMATH_DECIMAL_NEGMASK (0x80000000L) |
| 4121 #define FXMATH_DECIMAL_FORCEBOOL(x) (!(!(x))) | 4120 #define FXMATH_DECIMAL_FORCEBOOL(x) (!(!(x))) |
| 4122 #define FXMATH_DECIMAL_MAKEFLAGS(NEG, SCALE) \ | 4121 #define FXMATH_DECIMAL_MAKEFLAGS(NEG, SCALE) \ |
| 4123 (((SCALE) << 0x10) | ((NEG) ? FXMATH_DECIMAL_NEGMASK : 0)) | 4122 (((SCALE) << 0x10) | ((NEG) ? FXMATH_DECIMAL_NEGMASK : 0)) |
| 4124 #define FXMATH_DECIMAL_FLAGS2NEG(FLAGS) \ | 4123 #define FXMATH_DECIMAL_FLAGS2NEG(FLAGS) \ |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4321 for (i = 0; i < std::min(al, cl); i++) { | 4320 for (i = 0; i < std::min(al, cl); i++) { |
| 4322 c[i] = cur[i]; | 4321 c[i] = cur[i]; |
| 4323 } | 4322 } |
| 4324 return; | 4323 return; |
| 4325 } | 4324 } |
| 4326 } | 4325 } |
| 4327 for (i = 0; i < std::min(al, cl); i++) { | 4326 for (i = 0; i < std::min(al, cl); i++) { |
| 4328 c[i] = left[i]; | 4327 c[i] = left[i]; |
| 4329 } | 4328 } |
| 4330 } | 4329 } |
| 4331 static inline FX_BOOL fxmath_decimal_helper_outofrange(uint64_t a[], | 4330 static inline bool fxmath_decimal_helper_outofrange(uint64_t a[], |
| 4332 uint8_t al, | 4331 uint8_t al, |
| 4333 uint8_t goal) { | 4332 uint8_t goal) { |
| 4334 for (int i = goal; i < al; i++) { | 4333 for (int i = goal; i < al; i++) { |
| 4335 if (a[i]) { | 4334 if (a[i]) { |
| 4336 return TRUE; | 4335 return true; |
| 4337 } | 4336 } |
| 4338 } | 4337 } |
| 4339 return FALSE; | 4338 return false; |
| 4340 } | 4339 } |
| 4341 static inline void fxmath_decimal_helper_shrinkintorange(uint64_t a[], | 4340 static inline void fxmath_decimal_helper_shrinkintorange(uint64_t a[], |
| 4342 uint8_t al, | 4341 uint8_t al, |
| 4343 uint8_t goal, | 4342 uint8_t goal, |
| 4344 uint8_t& scale) { | 4343 uint8_t& scale) { |
| 4345 FX_BOOL bRoundUp = FALSE; | 4344 bool bRoundUp = false; |
| 4346 while (scale != 0 && (scale > FXMATH_DECIMAL_SCALELIMIT || | 4345 while (scale != 0 && (scale > FXMATH_DECIMAL_SCALELIMIT || |
| 4347 fxmath_decimal_helper_outofrange(a, al, goal))) { | 4346 fxmath_decimal_helper_outofrange(a, al, goal))) { |
| 4348 bRoundUp = fxmath_decimal_helper_div10_any(a, al) >= 5; | 4347 bRoundUp = fxmath_decimal_helper_div10_any(a, al) >= 5; |
| 4349 scale--; | 4348 scale--; |
| 4350 } | 4349 } |
| 4351 if (bRoundUp) { | 4350 if (bRoundUp) { |
| 4352 fxmath_decimal_helper_normalize_any(a, goal); | 4351 fxmath_decimal_helper_normalize_any(a, goal); |
| 4353 fxmath_decimal_helper_inc_any(a, goal); | 4352 fxmath_decimal_helper_inc_any(a, goal); |
| 4354 } | 4353 } |
| 4355 } | 4354 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4377 m_uFlags = 0; | 4376 m_uFlags = 0; |
| 4378 } | 4377 } |
| 4379 CFX_Decimal::CFX_Decimal(uint32_t val) { | 4378 CFX_Decimal::CFX_Decimal(uint32_t val) { |
| 4380 m_uLo = (uint32_t)val; | 4379 m_uLo = (uint32_t)val; |
| 4381 m_uMid = m_uHi = 0; | 4380 m_uMid = m_uHi = 0; |
| 4382 m_uFlags = 0; | 4381 m_uFlags = 0; |
| 4383 } | 4382 } |
| 4384 CFX_Decimal::CFX_Decimal(uint32_t lo, | 4383 CFX_Decimal::CFX_Decimal(uint32_t lo, |
| 4385 uint32_t mid, | 4384 uint32_t mid, |
| 4386 uint32_t hi, | 4385 uint32_t hi, |
| 4387 FX_BOOL neg, | 4386 bool neg, |
| 4388 uint8_t scale) { | 4387 uint8_t scale) { |
| 4389 scale = (scale > FXMATH_DECIMAL_SCALELIMIT ? 0 : scale); | 4388 scale = (scale > FXMATH_DECIMAL_SCALELIMIT ? 0 : scale); |
| 4390 m_uLo = lo; | 4389 m_uLo = lo; |
| 4391 m_uMid = mid; | 4390 m_uMid = mid; |
| 4392 m_uHi = hi; | 4391 m_uHi = hi; |
| 4393 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(neg && IsNotZero(), scale); | 4392 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(neg && IsNotZero(), scale); |
| 4394 } | 4393 } |
| 4395 CFX_Decimal::CFX_Decimal(int32_t val) { | 4394 CFX_Decimal::CFX_Decimal(int32_t val) { |
| 4396 if (val >= 0) { | 4395 if (val >= 0) { |
| 4397 *this = CFX_Decimal((uint32_t)val); | 4396 *this = CFX_Decimal((uint32_t)val); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4424 plo += FXSYS_round(newval); | 4423 plo += FXSYS_round(newval); |
| 4425 fxmath_decimal_helper_normalize(phi, pmid, plo); | 4424 fxmath_decimal_helper_normalize(phi, pmid, plo); |
| 4426 m_uHi = (uint32_t)phi; | 4425 m_uHi = (uint32_t)phi; |
| 4427 m_uMid = (uint32_t)pmid; | 4426 m_uMid = (uint32_t)pmid; |
| 4428 m_uLo = (uint32_t)plo; | 4427 m_uLo = (uint32_t)plo; |
| 4429 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(val < 0 && IsNotZero(), scale); | 4428 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS(val < 0 && IsNotZero(), scale); |
| 4430 } | 4429 } |
| 4431 CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) { | 4430 CFX_Decimal::CFX_Decimal(const CFX_WideStringC& strObj) { |
| 4432 const FX_WCHAR* str = strObj.c_str(); | 4431 const FX_WCHAR* str = strObj.c_str(); |
| 4433 const FX_WCHAR* strBound = str + strObj.GetLength(); | 4432 const FX_WCHAR* strBound = str + strObj.GetLength(); |
| 4434 FX_BOOL pointmet = 0; | 4433 bool pointmet = 0; |
| 4435 FX_BOOL negmet = 0; | 4434 bool negmet = 0; |
| 4436 uint8_t scale = 0; | 4435 uint8_t scale = 0; |
| 4437 m_uHi = m_uMid = m_uLo = 0; | 4436 m_uHi = m_uMid = m_uLo = 0; |
| 4438 while (str != strBound && *str == ' ') { | 4437 while (str != strBound && *str == ' ') { |
| 4439 str++; | 4438 str++; |
| 4440 } | 4439 } |
| 4441 if (str != strBound && *str == '-') { | 4440 if (str != strBound && *str == '-') { |
| 4442 negmet = 1; | 4441 negmet = 1; |
| 4443 str++; | 4442 str++; |
| 4444 } else if (str != strBound && *str == '+') { | 4443 } else if (str != strBound && *str == '+') { |
| 4445 str++; | 4444 str++; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4491 } | 4490 } |
| 4492 retString += tmpbuf[outputlen - 1 - idx]; | 4491 retString += tmpbuf[outputlen - 1 - idx]; |
| 4493 } | 4492 } |
| 4494 return retString; | 4493 return retString; |
| 4495 } | 4494 } |
| 4496 CFX_Decimal::operator double() const { | 4495 CFX_Decimal::operator double() const { |
| 4497 double pow = (double)(1 << 16) * (1 << 16); | 4496 double pow = (double)(1 << 16) * (1 << 16); |
| 4498 double base = | 4497 double base = |
| 4499 ((double)m_uHi) * pow * pow + ((double)m_uMid) * pow + ((double)m_uLo); | 4498 ((double)m_uHi) * pow * pow + ((double)m_uMid) * pow + ((double)m_uLo); |
| 4500 int8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); | 4499 int8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); |
| 4501 FX_BOOL bNeg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags); | 4500 bool bNeg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags); |
| 4502 return (bNeg ? -1 : 1) * base * ::pow(10.0, -scale); | 4501 return (bNeg ? -1 : 1) * base * ::pow(10.0, -scale); |
| 4503 } | 4502 } |
| 4504 void CFX_Decimal::SetScale(uint8_t newscale) { | 4503 void CFX_Decimal::SetScale(uint8_t newscale) { |
| 4505 uint8_t oldscale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); | 4504 uint8_t oldscale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); |
| 4506 if (newscale > oldscale) { | 4505 if (newscale > oldscale) { |
| 4507 uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; | 4506 uint64_t phi = m_uHi, pmid = m_uMid, plo = m_uLo; |
| 4508 for (uint8_t iter = 0; iter < newscale - oldscale; iter++) { | 4507 for (uint8_t iter = 0; iter < newscale - oldscale; iter++) { |
| 4509 fxmath_decimal_helper_mul10(phi, pmid, plo); | 4508 fxmath_decimal_helper_mul10(phi, pmid, plo); |
| 4510 } | 4509 } |
| 4511 m_uHi = (uint32_t)phi; | 4510 m_uHi = (uint32_t)phi; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4542 return oldscale; | 4541 return oldscale; |
| 4543 } | 4542 } |
| 4544 void CFX_Decimal::SetAbs() { | 4543 void CFX_Decimal::SetAbs() { |
| 4545 m_uFlags &= ~FXMATH_DECIMAL_NEGMASK; | 4544 m_uFlags &= ~FXMATH_DECIMAL_NEGMASK; |
| 4546 } | 4545 } |
| 4547 void CFX_Decimal::SetNegate() { | 4546 void CFX_Decimal::SetNegate() { |
| 4548 if (IsNotZero()) { | 4547 if (IsNotZero()) { |
| 4549 m_uFlags ^= FXMATH_DECIMAL_NEGMASK; | 4548 m_uFlags ^= FXMATH_DECIMAL_NEGMASK; |
| 4550 } | 4549 } |
| 4551 } | 4550 } |
| 4552 void CFX_Decimal::FloorOrCeil(FX_BOOL bFloor) { | 4551 void CFX_Decimal::FloorOrCeil(bool bFloor) { |
| 4553 uint64_t nums[3] = {m_uLo, m_uMid, m_uHi}; | 4552 uint64_t nums[3] = {m_uLo, m_uMid, m_uHi}; |
| 4554 FX_BOOL bDataLoss = FALSE; | 4553 bool bDataLoss = false; |
| 4555 for (int i = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); i > 0; i--) { | 4554 for (int i = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); i > 0; i--) { |
| 4556 bDataLoss = fxmath_decimal_helper_div10_any(nums, 3) || bDataLoss; | 4555 bDataLoss = fxmath_decimal_helper_div10_any(nums, 3) || bDataLoss; |
| 4557 } | 4556 } |
| 4558 if (bDataLoss && (bFloor ? FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) | 4557 if (bDataLoss && (bFloor ? FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) |
| 4559 : !FXMATH_DECIMAL_FLAGS2NEG(m_uFlags))) { | 4558 : !FXMATH_DECIMAL_FLAGS2NEG(m_uFlags))) { |
| 4560 fxmath_decimal_helper_inc_any(nums, 3); | 4559 fxmath_decimal_helper_inc_any(nums, 3); |
| 4561 } | 4560 } |
| 4562 m_uHi = (uint32_t)nums[2]; | 4561 m_uHi = (uint32_t)nums[2]; |
| 4563 m_uMid = (uint32_t)nums[1]; | 4562 m_uMid = (uint32_t)nums[1]; |
| 4564 m_uLo = (uint32_t)nums[0]; | 4563 m_uLo = (uint32_t)nums[0]; |
| 4565 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( | 4564 m_uFlags = FXMATH_DECIMAL_MAKEFLAGS( |
| 4566 FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), 0); | 4565 FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) && IsNotZero(), 0); |
| 4567 } | 4566 } |
| 4568 void CFX_Decimal::SetFloor() { | 4567 void CFX_Decimal::SetFloor() { |
| 4569 FloorOrCeil(TRUE); | 4568 FloorOrCeil(true); |
| 4570 } | 4569 } |
| 4571 void CFX_Decimal::SetCeiling() { | 4570 void CFX_Decimal::SetCeiling() { |
| 4572 FloorOrCeil(FALSE); | 4571 FloorOrCeil(false); |
| 4573 } | 4572 } |
| 4574 void CFX_Decimal::SetTruncate() { | 4573 void CFX_Decimal::SetTruncate() { |
| 4575 FloorOrCeil(!FXMATH_DECIMAL_FLAGS2NEG(m_uFlags)); | 4574 FloorOrCeil(!FXMATH_DECIMAL_FLAGS2NEG(m_uFlags)); |
| 4576 } | 4575 } |
| 4577 void CFX_Decimal::Swap(CFX_Decimal& val) { | 4576 void CFX_Decimal::Swap(CFX_Decimal& val) { |
| 4578 uint32_t tmp; | 4577 uint32_t tmp; |
| 4579 tmp = m_uHi; | 4578 tmp = m_uHi; |
| 4580 m_uHi = val.m_uHi; | 4579 m_uHi = val.m_uHi; |
| 4581 val.m_uHi = tmp; | 4580 val.m_uHi = tmp; |
| 4582 tmp = m_uMid; | 4581 tmp = m_uMid; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4602 retVal = -(FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) - | 4601 retVal = -(FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) - |
| 4603 FXMATH_DECIMAL_FLAGS2NEG(rhs.m_uFlags)); | 4602 FXMATH_DECIMAL_FLAGS2NEG(rhs.m_uFlags)); |
| 4604 if (retVal) { | 4603 if (retVal) { |
| 4605 return retVal; | 4604 return retVal; |
| 4606 } | 4605 } |
| 4607 retVal = fxmath_decimal_helper_raw_compare(lhs.m_uHi, lhs.m_uMid, lhs.m_uLo, | 4606 retVal = fxmath_decimal_helper_raw_compare(lhs.m_uHi, lhs.m_uMid, lhs.m_uLo, |
| 4608 rhs.m_uHi, rhs.m_uMid, rhs.m_uLo); | 4607 rhs.m_uHi, rhs.m_uMid, rhs.m_uLo); |
| 4609 return (FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) ? -retVal : retVal); | 4608 return (FXMATH_DECIMAL_FLAGS2NEG(lhs.m_uFlags) ? -retVal : retVal); |
| 4610 } | 4609 } |
| 4611 CFX_Decimal CFX_Decimal::AddOrMinus(const CFX_Decimal& val, | 4610 CFX_Decimal CFX_Decimal::AddOrMinus(const CFX_Decimal& val, |
| 4612 FX_BOOL isAdding) const { | 4611 bool isAdding) const { |
| 4613 CFX_Decimal lhs = *this, rhs = val; | 4612 CFX_Decimal lhs = *this, rhs = val; |
| 4614 if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != | 4613 if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != |
| 4615 FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { | 4614 FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { |
| 4616 uint8_t scale = std::max(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), | 4615 uint8_t scale = std::max(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), |
| 4617 FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); | 4616 FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); |
| 4618 lhs.SetScale(scale); | 4617 lhs.SetScale(scale); |
| 4619 rhs.SetScale(scale); | 4618 rhs.SetScale(scale); |
| 4620 } | 4619 } |
| 4621 if (!isAdding) { | 4620 if (!isAdding) { |
| 4622 rhs.SetNegate(); | 4621 rhs.SetNegate(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4658 } | 4657 } |
| 4659 lhs.m_uLo -= rhs.m_uLo; | 4658 lhs.m_uLo -= rhs.m_uLo; |
| 4660 return lhs; | 4659 return lhs; |
| 4661 } | 4660 } |
| 4662 } | 4661 } |
| 4663 CFX_Decimal CFX_Decimal::Multiply(const CFX_Decimal& val) const { | 4662 CFX_Decimal CFX_Decimal::Multiply(const CFX_Decimal& val) const { |
| 4664 uint64_t a[3] = {m_uLo, m_uMid, m_uHi}, | 4663 uint64_t a[3] = {m_uLo, m_uMid, m_uHi}, |
| 4665 b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}; | 4664 b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}; |
| 4666 uint64_t c[6]; | 4665 uint64_t c[6]; |
| 4667 fxmath_decimal_helper_raw_mul(a, 3, b, 3, c, 6); | 4666 fxmath_decimal_helper_raw_mul(a, 3, b, 3, c, 6); |
| 4668 FX_BOOL neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ | 4667 bool neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ |
| 4669 FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); | 4668 FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); |
| 4670 uint8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) + | 4669 uint8_t scale = FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) + |
| 4671 FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags); | 4670 FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags); |
| 4672 fxmath_decimal_helper_shrinkintorange(c, 6, 3, scale); | 4671 fxmath_decimal_helper_shrinkintorange(c, 6, 3, scale); |
| 4673 return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, | 4672 return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, |
| 4674 scale); | 4673 scale); |
| 4675 } | 4674 } |
| 4676 CFX_Decimal CFX_Decimal::Divide(const CFX_Decimal& val) const { | 4675 CFX_Decimal CFX_Decimal::Divide(const CFX_Decimal& val) const { |
| 4677 if (!val.IsNotZero()) { | 4676 if (!val.IsNotZero()) { |
| 4678 return CFX_Decimal(); | 4677 return CFX_Decimal(); |
| 4679 } | 4678 } |
| 4680 FX_BOOL neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ | 4679 bool neg = FXMATH_DECIMAL_FLAGS2NEG(m_uFlags) ^ |
| 4681 FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); | 4680 FXMATH_DECIMAL_FLAGS2NEG(val.m_uFlags); |
| 4682 uint64_t a[7] = {m_uLo, m_uMid, m_uHi}, | 4681 uint64_t a[7] = {m_uLo, m_uMid, m_uHi}, |
| 4683 b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}, c[7] = {0}; | 4682 b[3] = {val.m_uLo, val.m_uMid, val.m_uHi}, c[7] = {0}; |
| 4684 uint8_t scale = 0; | 4683 uint8_t scale = 0; |
| 4685 if (FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) < | 4684 if (FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags) < |
| 4686 FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags)) { | 4685 FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags)) { |
| 4687 for (int i = FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags) - | 4686 for (int i = FXMATH_DECIMAL_FLAGS2SCALE(val.m_uFlags) - |
| 4688 FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); | 4687 FXMATH_DECIMAL_FLAGS2SCALE(m_uFlags); |
| 4689 i > 0; i--) { | 4688 i > 0; i--) { |
| 4690 fxmath_decimal_helper_mul10_any(a, 7); | 4689 fxmath_decimal_helper_mul10_any(a, 7); |
| 4691 } | 4690 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4708 fxmath_decimal_helper_truncate(c[2], c[1], c[0], scale, minscale); | 4707 fxmath_decimal_helper_truncate(c[2], c[1], c[0], scale, minscale); |
| 4709 return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, | 4708 return CFX_Decimal((uint32_t)c[0], (uint32_t)c[1], (uint32_t)c[2], neg, |
| 4710 scale); | 4709 scale); |
| 4711 } | 4710 } |
| 4712 CFX_Decimal CFX_Decimal::Modulus(const CFX_Decimal& val) const { | 4711 CFX_Decimal CFX_Decimal::Modulus(const CFX_Decimal& val) const { |
| 4713 CFX_Decimal lhs = *this, rhs_abs = val; | 4712 CFX_Decimal lhs = *this, rhs_abs = val; |
| 4714 rhs_abs.SetAbs(); | 4713 rhs_abs.SetAbs(); |
| 4715 if (!rhs_abs.IsNotZero()) { | 4714 if (!rhs_abs.IsNotZero()) { |
| 4716 return *this; | 4715 return *this; |
| 4717 } | 4716 } |
| 4718 while (TRUE) { | 4717 while (true) { |
| 4719 CFX_Decimal lhs_abs = lhs; | 4718 CFX_Decimal lhs_abs = lhs; |
| 4720 lhs_abs.SetAbs(); | 4719 lhs_abs.SetAbs(); |
| 4721 if (lhs_abs < rhs_abs) { | 4720 if (lhs_abs < rhs_abs) { |
| 4722 break; | 4721 break; |
| 4723 } | 4722 } |
| 4724 CFX_Decimal quot = lhs / rhs_abs; | 4723 CFX_Decimal quot = lhs / rhs_abs; |
| 4725 quot.SetTruncate(); | 4724 quot.SetTruncate(); |
| 4726 lhs = lhs - quot * rhs_abs; | 4725 lhs = lhs - quot * rhs_abs; |
| 4727 } | 4726 } |
| 4728 return lhs; | 4727 return lhs; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4739 bool CFX_Decimal::operator!=(const CFX_Decimal& val) const { | 4738 bool CFX_Decimal::operator!=(const CFX_Decimal& val) const { |
| 4740 return Compare(val) != 0; | 4739 return Compare(val) != 0; |
| 4741 } | 4740 } |
| 4742 bool CFX_Decimal::operator<(const CFX_Decimal& val) const { | 4741 bool CFX_Decimal::operator<(const CFX_Decimal& val) const { |
| 4743 return Compare(val) < 0; | 4742 return Compare(val) < 0; |
| 4744 } | 4743 } |
| 4745 bool CFX_Decimal::operator>(const CFX_Decimal& val) const { | 4744 bool CFX_Decimal::operator>(const CFX_Decimal& val) const { |
| 4746 return Compare(val) > 0; | 4745 return Compare(val) > 0; |
| 4747 } | 4746 } |
| 4748 CFX_Decimal CFX_Decimal::operator+(const CFX_Decimal& val) const { | 4747 CFX_Decimal CFX_Decimal::operator+(const CFX_Decimal& val) const { |
| 4749 return AddOrMinus(val, TRUE); | 4748 return AddOrMinus(val, true); |
| 4750 } | 4749 } |
| 4751 CFX_Decimal CFX_Decimal::operator-(const CFX_Decimal& val) const { | 4750 CFX_Decimal CFX_Decimal::operator-(const CFX_Decimal& val) const { |
| 4752 return AddOrMinus(val, FALSE); | 4751 return AddOrMinus(val, false); |
| 4753 } | 4752 } |
| 4754 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 4753 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
| 4755 return Multiply(val); | 4754 return Multiply(val); |
| 4756 } | 4755 } |
| 4757 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 4756 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
| 4758 return Divide(val); | 4757 return Divide(val); |
| 4759 } | 4758 } |
| 4760 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 4759 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
| 4761 return Modulus(val); | 4760 return Modulus(val); |
| 4762 } | 4761 } |
| OLD | NEW |