summaryrefslogtreecommitdiff
path: root/xfa/fgas/crt/cfgas_formatstring.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-18 14:23:18 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-18 18:40:16 +0000
commit275e260a6cd4a8e506ba974feb85ebcd926c1739 (patch)
tree2029b9158ec044764ceff122fe5fb5d0a3f123d1 /xfa/fgas/crt/cfgas_formatstring.cpp
parent450fbeaaabf1ab340c1018de2e58f1950657517e (diff)
downloadpdfium-275e260a6cd4a8e506ba974feb85ebcd926c1739.tar.xz
Convert string class names
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fgas/crt/cfgas_formatstring.cpp')
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.cpp302
1 files changed, 149 insertions, 153 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index df95a3588a..87b07691a4 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -97,10 +97,10 @@ int32_t ConvertHex(int32_t iKeyValue, wchar_t ch) {
return iKeyValue;
}
-CFX_WideString GetLiteralText(const wchar_t* pStrPattern,
- int32_t* iPattern,
- int32_t iLenPattern) {
- CFX_WideString wsOutput;
+WideString GetLiteralText(const wchar_t* pStrPattern,
+ int32_t* iPattern,
+ int32_t iLenPattern) {
+ WideString wsOutput;
if (pStrPattern[*iPattern] != '\'')
return wsOutput;
@@ -135,9 +135,9 @@ CFX_WideString GetLiteralText(const wchar_t* pStrPattern,
return wsOutput;
}
-CFX_WideString GetLiteralTextReverse(const wchar_t* pStrPattern,
- int32_t* iPattern) {
- CFX_WideString wsOutput;
+WideString GetLiteralTextReverse(const wchar_t* pStrPattern,
+ int32_t* iPattern) {
+ WideString wsOutput;
if (pStrPattern[*iPattern] != '\'')
return wsOutput;
@@ -173,8 +173,8 @@ CFX_WideString GetLiteralTextReverse(const wchar_t* pStrPattern,
return wsOutput;
}
-bool GetNumericDotIndex(const CFX_WideString& wsNum,
- const CFX_WideString& wsDotSymbol,
+bool GetNumericDotIndex(const WideString& wsNum,
+ const WideString& wsDotSymbol,
int32_t* iDotIndex) {
int32_t ccf = 0;
int32_t iLenf = wsNum.GetLength();
@@ -221,8 +221,8 @@ bool ExtractCountDigitsWithOptional(const wchar_t* str,
return true;
}
-bool ParseLocaleDate(const CFX_WideString& wsDate,
- const CFX_WideString& wsDatePattern,
+bool ParseLocaleDate(const WideString& wsDate,
+ const WideString& wsDatePattern,
IFX_Locale* pLocale,
CFX_DateTime* datetime,
int32_t* cc) {
@@ -234,10 +234,10 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
int32_t len = wsDate.GetLength();
const wchar_t* strf = wsDatePattern.c_str();
int32_t lenf = wsDatePattern.GetLength();
- CFX_WideStringC wsDateSymbols(gs_wsDateSymbols);
+ WideStringView wsDateSymbols(gs_wsDateSymbols);
while (*cc < len && ccf < lenf) {
if (strf[ccf] == '\'') {
- CFX_WideString wsLiteral = GetLiteralText(strf, &ccf, lenf);
+ WideString wsLiteral = GetLiteralText(strf, &ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (*cc + iLiteralLen > len ||
wcsncmp(str + *cc, wsLiteral.c_str(), iLiteralLen)) {
@@ -254,7 +254,7 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
continue;
}
- CFX_WideString symbol;
+ WideString symbol;
symbol.Reserve(4);
symbol += strf[ccf++];
while (ccf < lenf && strf[ccf] == symbol[0])
@@ -273,7 +273,7 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
return false;
} else if (symbol == L"MMM" || symbol == L"MMMM") {
for (uint16_t i = 0; i < 12; i++) {
- CFX_WideString wsMonthName = pLocale->GetMonthName(i, symbol == L"MMM");
+ WideString wsMonthName = pLocale->GetMonthName(i, symbol == L"MMM");
if (wsMonthName.IsEmpty())
continue;
if (!wcsncmp(wsMonthName.c_str(), str + *cc, wsMonthName.GetLength())) {
@@ -284,7 +284,7 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
}
} else if (symbol == L"EEE" || symbol == L"EEEE") {
for (uint16_t i = 0; i < 7; i++) {
- CFX_WideString wsDayName = pLocale->GetDayName(i, symbol == L"EEE");
+ WideString wsDayName = pLocale->GetDayName(i, symbol == L"EEE");
if (wsDayName.IsEmpty())
continue;
if (!wcsncmp(wsDayName.c_str(), str + *cc, wsDayName.GetLength())) {
@@ -338,8 +338,8 @@ void ResolveZone(FX_TIMEZONE tzDiff,
*wMinute = iMinuteDiff % 60;
}
-bool ParseLocaleTime(const CFX_WideString& wsTime,
- const CFX_WideString& wsTimePattern,
+bool ParseLocaleTime(const WideString& wsTime,
+ const WideString& wsTimePattern,
IFX_Locale* pLocale,
CFX_DateTime* datetime,
int32_t* cc) {
@@ -354,10 +354,10 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
int lenf = wsTimePattern.GetLength();
bool bHasA = false;
bool bPM = false;
- CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols);
+ WideStringView wsTimeSymbols(gs_wsTimeSymbols);
while (*cc < len && ccf < lenf) {
if (strf[ccf] == '\'') {
- CFX_WideString wsLiteral = GetLiteralText(strf, &ccf, lenf);
+ WideString wsLiteral = GetLiteralText(strf, &ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (*cc + iLiteralLen > len ||
wcsncmp(str + *cc, wsLiteral.c_str(), iLiteralLen)) {
@@ -375,7 +375,7 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
continue;
}
- CFX_WideString symbol;
+ WideString symbol;
symbol.Reserve(4);
symbol += strf[ccf++];
while (ccf < lenf && strf[ccf] == symbol[0])
@@ -415,16 +415,16 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
if (!ExtractCountDigits(str, len, 3, cc, &millisecond))
return false;
} else if (symbol == L"A") {
- CFX_WideString wsAM = pLocale->GetMeridiemName(true);
- CFX_WideString wsPM = pLocale->GetMeridiemName(false);
+ WideString wsAM = pLocale->GetMeridiemName(true);
+ WideString wsPM = pLocale->GetMeridiemName(false);
if ((*cc + pdfium::base::checked_cast<int32_t>(wsAM.GetLength()) <=
len) &&
- (CFX_WideStringC(str + *cc, wsAM.GetLength()) == wsAM)) {
+ (WideStringView(str + *cc, wsAM.GetLength()) == wsAM)) {
*cc += wsAM.GetLength();
bHasA = true;
} else if ((*cc + pdfium::base::checked_cast<int32_t>(wsPM.GetLength()) <=
len) &&
- (CFX_WideStringC(str + *cc, wsPM.GetLength()) == wsPM)) {
+ (WideStringView(str + *cc, wsPM.GetLength()) == wsPM)) {
*cc += wsPM.GetLength();
bHasA = true;
bPM = true;
@@ -433,7 +433,7 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
if (*cc + 3 > len)
continue;
- CFX_WideString tz(str[(*cc)++]);
+ WideString tz(str[(*cc)++]);
tz += str[(*cc)++];
tz += str[(*cc)++];
if (tz == L"GMT") {
@@ -480,7 +480,7 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
return !!(*cc);
}
-int32_t GetNumTrailingLimit(const CFX_WideString& wsFormat,
+int32_t GetNumTrailingLimit(const WideString& wsFormat,
int iDotPos,
bool* bTrimTailZeros) {
if (iDotPos < 0)
@@ -553,23 +553,23 @@ uint16_t GetWeekOfYear(uint16_t year, uint16_t month, uint16_t day) {
return week_index;
}
-CFX_WideString NumToString(size_t fmt_size, int32_t value) {
- CFX_WideString str;
+WideString NumToString(size_t fmt_size, int32_t value) {
+ WideString str;
str.Format(fmt_size == 1 ? L"%d" : fmt_size == 2 ? L"%02d" : L"%03d", value);
return str;
}
-CFX_WideString DateFormat(const CFX_WideString& wsDatePattern,
- IFX_Locale* pLocale,
- const CFX_DateTime& datetime) {
- CFX_WideString wsResult;
+WideString DateFormat(const WideString& wsDatePattern,
+ IFX_Locale* pLocale,
+ const CFX_DateTime& datetime) {
+ WideString wsResult;
int32_t year = datetime.GetYear();
uint8_t month = datetime.GetMonth();
uint8_t day = datetime.GetDay();
int32_t ccf = 0;
const wchar_t* strf = wsDatePattern.c_str();
int32_t lenf = wsDatePattern.GetLength();
- CFX_WideStringC wsDateSymbols(gs_wsDateSymbols);
+ WideStringView wsDateSymbols(gs_wsDateSymbols);
while (ccf < lenf) {
if (strf[ccf] == '\'') {
wsResult += GetLiteralText(strf, &ccf, lenf);
@@ -581,7 +581,7 @@ CFX_WideString DateFormat(const CFX_WideString& wsDatePattern,
continue;
}
- CFX_WideString symbol;
+ WideString symbol;
symbol.Reserve(4);
symbol += strf[ccf++];
while (ccf < lenf && strf[ccf] == symbol[0])
@@ -621,10 +621,10 @@ CFX_WideString DateFormat(const CFX_WideString& wsDatePattern,
return wsResult;
}
-CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
- IFX_Locale* pLocale,
- const CFX_DateTime& datetime) {
- CFX_WideString wsResult;
+WideString TimeFormat(const WideString& wsTimePattern,
+ IFX_Locale* pLocale,
+ const CFX_DateTime& datetime) {
+ WideString wsResult;
uint8_t hour = datetime.GetHour();
uint8_t minute = datetime.GetMinute();
uint8_t second = datetime.GetSecond();
@@ -639,7 +639,7 @@ CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
bPM = true;
}
- CFX_WideStringC wsTimeSymbols(gs_wsTimeSymbols);
+ WideStringView wsTimeSymbols(gs_wsTimeSymbols);
while (ccf < lenf) {
if (strf[ccf] == '\'') {
wsResult += GetLiteralText(strf, &ccf, lenf);
@@ -651,7 +651,7 @@ CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
continue;
}
- CFX_WideString symbol;
+ WideString symbol;
symbol.Reserve(4);
symbol += strf[ccf++];
while (ccf < lenf && strf[ccf] == symbol[0])
@@ -685,7 +685,7 @@ CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
if (tz.tzHour != 0 || tz.tzMinute != 0) {
wsResult += tz.tzHour < 0 ? L"-" : L"+";
- CFX_WideString wsTimezone;
+ WideString wsTimezone;
wsTimezone.Format(L"%02d:%02d", abs(tz.tzHour), tz.tzMinute);
wsResult += wsTimezone;
}
@@ -694,16 +694,16 @@ CFX_WideString TimeFormat(const CFX_WideString& wsTimePattern,
return wsResult;
}
-CFX_WideString FormatDateTimeInternal(const CFX_DateTime& dt,
- const CFX_WideString& wsDatePattern,
- const CFX_WideString& wsTimePattern,
- bool bDateFirst,
- IFX_Locale* pLocale) {
- CFX_WideString wsDateOut;
+WideString FormatDateTimeInternal(const CFX_DateTime& dt,
+ const WideString& wsDatePattern,
+ const WideString& wsTimePattern,
+ bool bDateFirst,
+ IFX_Locale* pLocale) {
+ WideString wsDateOut;
if (!wsDatePattern.IsEmpty())
wsDateOut = DateFormat(wsDatePattern, pLocale, dt);
- CFX_WideString wsTimeOut;
+ WideString wsTimeOut;
if (!wsTimePattern.IsEmpty())
wsTimeOut = TimeFormat(wsTimePattern, pLocale, dt);
@@ -712,8 +712,7 @@ CFX_WideString FormatDateTimeInternal(const CFX_DateTime& dt,
} // namespace
-bool FX_DateFromCanonical(const CFX_WideString& wsDate,
- CFX_DateTime* datetime) {
+bool FX_DateFromCanonical(const WideString& wsDate, CFX_DateTime* datetime) {
const wchar_t* str = wsDate.c_str();
int len = wsDate.GetLength();
if (len > 10)
@@ -762,7 +761,7 @@ bool FX_DateFromCanonical(const CFX_WideString& wsDate,
return true;
}
-bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime,
+bool FX_TimeFromCanonical(const WideStringView& wsTime,
CFX_DateTime* datetime,
IFX_Locale* pLocale) {
if (wsTime.GetLength() == 0)
@@ -840,8 +839,8 @@ CFGAS_FormatString::CFGAS_FormatString(CXFA_LocaleMgr* pLocaleMgr)
CFGAS_FormatString::~CFGAS_FormatString() {}
void CFGAS_FormatString::SplitFormatString(
- const CFX_WideString& wsFormatString,
- std::vector<CFX_WideString>* wsPatterns) {
+ const WideString& wsFormatString,
+ std::vector<WideString>* wsPatterns) {
int32_t iStrLen = wsFormatString.GetLength();
const wchar_t* pStr = wsFormatString.c_str();
const wchar_t* pToken = pStr;
@@ -849,32 +848,31 @@ void CFGAS_FormatString::SplitFormatString(
bool iQuote = false;
while (true) {
if (pStr >= pEnd) {
- wsPatterns->push_back(CFX_WideString(pToken, pStr - pToken));
+ wsPatterns->push_back(WideString(pToken, pStr - pToken));
return;
}
if (*pStr == '\'') {
iQuote = !iQuote;
} else if (*pStr == L'|' && !iQuote) {
- wsPatterns->push_back(CFX_WideString(pToken, pStr - pToken));
+ wsPatterns->push_back(WideString(pToken, pStr - pToken));
pToken = pStr + 1;
}
pStr++;
}
}
-FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(
- const CFX_WideString& wsPattern) {
+FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(const WideString& wsPattern) {
FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown;
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
const wchar_t* pStr = wsPattern.c_str();
bool bBraceOpen = false;
- CFX_WideStringC wsConstChars(gs_wsConstChars);
+ WideStringView wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
GetLiteralText(pStr, &ccf, iLenf);
} else if (!bBraceOpen && !wsConstChars.Contains(pStr[ccf])) {
- CFX_WideString wsCategory(pStr[ccf]);
+ WideString wsCategory(pStr[ccf]);
ccf++;
while (true) {
if (ccf == iLenf)
@@ -889,7 +887,7 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(
ccf++;
}
- uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringC(), false);
+ uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringView(), false);
if (dwHash == FX_LOCALECATEGORY_DateHash) {
if (eCategory == FX_LOCALECATEGORY_Time)
return FX_LOCALECATEGORY_DateTime;
@@ -917,22 +915,21 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(
return eCategory;
}
-CFX_WideString CFGAS_FormatString::GetTextFormat(
- const CFX_WideString& wsPattern,
- const CFX_WideStringC& wsCategory) {
+WideString CFGAS_FormatString::GetTextFormat(const WideString& wsPattern,
+ const WideStringView& wsCategory) {
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
const wchar_t* pStr = wsPattern.c_str();
bool bBrackOpen = false;
- CFX_WideStringC wsConstChars(gs_wsConstChars);
- CFX_WideString wsPurgePattern;
+ WideStringView wsConstChars(gs_wsConstChars);
+ WideString wsPurgePattern;
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
int32_t iCurChar = ccf;
GetLiteralText(pStr, &ccf, iLenf);
- wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
+ wsPurgePattern += WideStringView(pStr + iCurChar, ccf - iCurChar + 1);
} else if (!bBrackOpen && !wsConstChars.Contains(pStr[ccf])) {
- CFX_WideString wsSearchCategory(pStr[ccf]);
+ WideString wsSearchCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
pStr[ccf] != '(') {
@@ -965,11 +962,10 @@ CFX_WideString CFGAS_FormatString::GetTextFormat(
return wsPurgePattern;
}
-IFX_Locale* CFGAS_FormatString::GetNumericFormat(
- const CFX_WideString& wsPattern,
- int32_t* iDotIndex,
- uint32_t* dwStyle,
- CFX_WideString* wsPurgePattern) {
+IFX_Locale* CFGAS_FormatString::GetNumericFormat(const WideString& wsPattern,
+ int32_t* iDotIndex,
+ uint32_t* dwStyle,
+ WideString* wsPurgePattern) {
*dwStyle = 0;
IFX_Locale* pLocale = nullptr;
int32_t ccf = 0;
@@ -977,14 +973,14 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(
const wchar_t* pStr = wsPattern.c_str();
bool bFindDot = false;
bool bBrackOpen = false;
- CFX_WideStringC wsConstChars(gs_wsConstChars);
+ WideStringView wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
int32_t iCurChar = ccf;
GetLiteralText(pStr, &ccf, iLenf);
- *wsPurgePattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
+ *wsPurgePattern += WideStringView(pStr + iCurChar, ccf - iCurChar + 1);
} else if (!bBrackOpen && !wsConstChars.Contains(pStr[ccf])) {
- CFX_WideString wsCategory(pStr[ccf]);
+ WideString wsCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
pStr[ccf] != '(') {
@@ -999,7 +995,7 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(
while (ccf < iLenf) {
if (pStr[ccf] == '(') {
ccf++;
- CFX_WideString wsLCID;
+ WideString wsLCID;
while (ccf < iLenf && pStr[ccf] != ')')
wsLCID += pStr[ccf++];
@@ -1008,13 +1004,13 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(
bBrackOpen = true;
break;
} else if (pStr[ccf] == '.') {
- CFX_WideString wsSubCategory;
+ WideString wsSubCategory;
ccf++;
while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{')
wsSubCategory += pStr[ccf++];
uint32_t dwSubHash =
- FX_HashCode_GetW(wsSubCategory.AsStringC(), false);
+ FX_HashCode_GetW(wsSubCategory.AsStringView(), false);
FX_LOCALENUMSUBCATEGORY eSubCategory = FX_LOCALENUMPATTERN_Decimal;
for (int32_t i = 0; i < g_iFXLocaleNumSubCatCount; i++) {
if (g_FXLocaleNumSubCatData[i].uHash == dwSubHash) {
@@ -1068,14 +1064,14 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(
return pLocale;
}
-bool CFGAS_FormatString::ParseText(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern,
- CFX_WideString* wsValue) {
+bool CFGAS_FormatString::ParseText(const WideString& wsSrcText,
+ const WideString& wsPattern,
+ WideString* wsValue) {
wsValue->clear();
if (wsSrcText.IsEmpty() || wsPattern.IsEmpty())
return false;
- CFX_WideString wsTextFormat = GetTextFormat(wsPattern, L"text");
+ WideString wsTextFormat = GetTextFormat(wsPattern, L"text");
if (wsTextFormat.IsEmpty())
return false;
@@ -1088,7 +1084,7 @@ bool CFGAS_FormatString::ParseText(const CFX_WideString& wsSrcText,
while (iPattern < iLenPattern && iText < iLenText) {
switch (pStrPattern[iPattern]) {
case '\'': {
- CFX_WideString wsLiteral =
+ WideString wsLiteral =
GetLiteralText(pStrPattern, &iPattern, iLenPattern);
int32_t iLiteralLen = wsLiteral.GetLength();
if (iText + iLiteralLen > iLenText ||
@@ -1141,28 +1137,28 @@ bool CFGAS_FormatString::ParseText(const CFX_WideString& wsSrcText,
return iPattern == iLenPattern && iText == iLenText;
}
-bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- CFX_WideString* wsValue) {
+bool CFGAS_FormatString::ParseNum(const WideString& wsSrcNum,
+ const WideString& wsPattern,
+ WideString* wsValue) {
wsValue->clear();
if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty())
return false;
int32_t dot_index_f = -1;
uint32_t dwFormatStyle = 0;
- CFX_WideString wsNumFormat;
+ WideString wsNumFormat;
IFX_Locale* pLocale =
GetNumericFormat(wsPattern, &dot_index_f, &dwFormatStyle, &wsNumFormat);
if (!pLocale || wsNumFormat.IsEmpty())
return false;
int32_t iExponent = 0;
- CFX_WideString wsDotSymbol =
+ WideString wsDotSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
- CFX_WideString wsGroupSymbol =
+ WideString wsGroupSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping);
int32_t iGroupLen = wsGroupSymbol.GetLength();
- CFX_WideString wsMinus = pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus);
+ WideString wsMinus = pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus);
int32_t iMinusLen = wsMinus.GetLength();
const wchar_t* str = wsSrcNum.c_str();
int len = wsSrcNum.GetLength();
@@ -1192,7 +1188,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
while (ccf >= 0 && cc >= 0) {
switch (strf[ccf]) {
case '\'': {
- CFX_WideString wsLiteral = GetLiteralTextReverse(strf, &ccf);
+ WideString wsLiteral = GetLiteralTextReverse(strf, &ccf);
int32_t iLiteralLen = wsLiteral.GetLength();
cc -= iLiteralLen - 1;
if (cc < 0 || wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen))
@@ -1265,7 +1261,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
break;
}
case '$': {
- CFX_WideString wsSymbol =
+ WideString wsSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
cc -= iSymbolLen - 1;
@@ -1307,7 +1303,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
}
break;
case '%': {
- CFX_WideString wsSymbol =
+ WideString wsSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent);
int32_t iSysmbolLen = wsSymbol.GetLength();
cc -= iSysmbolLen - 1;
@@ -1371,7 +1367,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
while (cc < len && ccf < lenf) {
switch (strf[ccf]) {
case '\'': {
- CFX_WideString wsLiteral = GetLiteralText(strf, &ccf, lenf);
+ WideString wsLiteral = GetLiteralText(strf, &ccf, lenf);
int32_t iLiteralLen = wsLiteral.GetLength();
if (cc + iLiteralLen > len ||
wcsncmp(str + cc, wsLiteral.c_str(), iLiteralLen)) {
@@ -1441,7 +1437,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
break;
}
case '$': {
- CFX_WideString wsSymbol =
+ WideString wsSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_CurrencySymbol);
int32_t iSymbolLen = wsSymbol.GetLength();
if (cc + iSymbolLen > len ||
@@ -1483,7 +1479,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
case 'v':
return false;
case '%': {
- CFX_WideString wsSymbol =
+ WideString wsSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Percent);
int32_t iSysmbolLen = wsSymbol.GetLength();
if (cc + iSysmbolLen <= len &&
@@ -1532,7 +1528,7 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
return false;
}
if (iExponent || bHavePercentSymbol) {
- CFX_Decimal decimal = CFX_Decimal(wsValue->AsStringC());
+ CFX_Decimal decimal = CFX_Decimal(wsValue->AsStringView());
if (iExponent) {
decimal = decimal *
CFX_Decimal(FXSYS_pow(10, static_cast<float>(iExponent)), 3);
@@ -1549,27 +1545,27 @@ bool CFGAS_FormatString::ParseNum(const CFX_WideString& wsSrcNum,
}
FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat(
- const CFX_WideString& wsPattern,
+ const WideString& wsPattern,
IFX_Locale** pLocale,
- CFX_WideString* wsDatePattern,
- CFX_WideString* wsTimePattern) {
+ WideString* wsDatePattern,
+ WideString* wsTimePattern) {
*pLocale = nullptr;
- CFX_WideString wsTempPattern;
+ WideString wsTempPattern;
FX_LOCALECATEGORY eCategory = FX_LOCALECATEGORY_Unknown;
int32_t ccf = 0;
int32_t iLenf = wsPattern.GetLength();
const wchar_t* pStr = wsPattern.c_str();
int32_t iFindCategory = 0;
bool bBraceOpen = false;
- CFX_WideStringC wsConstChars(gs_wsConstChars);
+ WideStringView wsConstChars(gs_wsConstChars);
while (ccf < iLenf) {
if (pStr[ccf] == '\'') {
int32_t iCurChar = ccf;
GetLiteralText(pStr, &ccf, iLenf);
- wsTempPattern += CFX_WideStringC(pStr + iCurChar, ccf - iCurChar + 1);
+ wsTempPattern += WideStringView(pStr + iCurChar, ccf - iCurChar + 1);
} else if (!bBraceOpen && iFindCategory != 3 &&
!wsConstChars.Contains(pStr[ccf])) {
- CFX_WideString wsCategory(pStr[ccf]);
+ WideString wsCategory(pStr[ccf]);
ccf++;
while (ccf < iLenf && pStr[ccf] != '{' && pStr[ccf] != '.' &&
pStr[ccf] != '(') {
@@ -1602,7 +1598,7 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat(
while (ccf < iLenf) {
if (pStr[ccf] == '(') {
ccf++;
- CFX_WideString wsLCID;
+ WideString wsLCID;
while (ccf < iLenf && pStr[ccf] != ')')
wsLCID += pStr[ccf++];
@@ -1611,13 +1607,13 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat(
bBraceOpen = true;
break;
} else if (pStr[ccf] == '.') {
- CFX_WideString wsSubCategory;
+ WideString wsSubCategory;
ccf++;
while (ccf < iLenf && pStr[ccf] != '(' && pStr[ccf] != '{')
wsSubCategory += pStr[ccf++];
uint32_t dwSubHash =
- FX_HashCode_GetW(wsSubCategory.AsStringC(), false);
+ FX_HashCode_GetW(wsSubCategory.AsStringView(), false);
FX_LOCALEDATETIMESUBCATEGORY eSubCategory =
FX_LOCALEDATETIMESUBCATEGORY_Medium;
for (int32_t i = 0; i < g_iFXLocaleDateTimeSubCatCount; i++) {
@@ -1685,16 +1681,16 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat(
return (FX_DATETIMETYPE)iFindCategory;
}
-bool CFGAS_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
+bool CFGAS_FormatString::ParseDateTime(const WideString& wsSrcDateTime,
+ const WideString& wsPattern,
FX_DATETIMETYPE eDateTimeType,
CFX_DateTime* dtValue) {
dtValue->Reset();
if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty())
return false;
- CFX_WideString wsDatePattern;
- CFX_WideString wsTimePattern;
+ WideString wsDatePattern;
+ WideString wsTimePattern;
IFX_Locale* pLocale = nullptr;
FX_DATETIMETYPE eCategory =
GetDateTimeFormat(wsPattern, &pLocale, &wsDatePattern, &wsTimePattern);
@@ -1730,9 +1726,9 @@ bool CFGAS_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime,
return true;
}
-bool CFGAS_FormatString::ParseZero(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern) {
- CFX_WideString wsTextFormat = GetTextFormat(wsPattern, L"zero");
+bool CFGAS_FormatString::ParseZero(const WideString& wsSrcText,
+ const WideString& wsPattern) {
+ WideString wsTextFormat = GetTextFormat(wsPattern, L"zero");
int32_t iText = 0;
int32_t iPattern = 0;
@@ -1742,7 +1738,7 @@ bool CFGAS_FormatString::ParseZero(const CFX_WideString& wsSrcText,
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern && iText < iLenText) {
if (pStrPattern[iPattern] == '\'') {
- CFX_WideString wsLiteral =
+ WideString wsLiteral =
GetLiteralText(pStrPattern, &iPattern, iLenPattern);
int32_t iLiteralLen = wsLiteral.GetLength();
if (iText + iLiteralLen > iLenText ||
@@ -1762,9 +1758,9 @@ bool CFGAS_FormatString::ParseZero(const CFX_WideString& wsSrcText,
return iPattern == iLenPattern && iText == iLenText;
}
-bool CFGAS_FormatString::ParseNull(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern) {
- CFX_WideString wsTextFormat = GetTextFormat(wsPattern, L"null");
+bool CFGAS_FormatString::ParseNull(const WideString& wsSrcText,
+ const WideString& wsPattern) {
+ WideString wsTextFormat = GetTextFormat(wsPattern, L"null");
int32_t iText = 0;
int32_t iPattern = 0;
@@ -1774,7 +1770,7 @@ bool CFGAS_FormatString::ParseNull(const CFX_WideString& wsSrcText,
int32_t iLenPattern = wsTextFormat.GetLength();
while (iPattern < iLenPattern && iText < iLenText) {
if (pStrPattern[iPattern] == '\'') {
- CFX_WideString wsLiteral =
+ WideString wsLiteral =
GetLiteralText(pStrPattern, &iPattern, iLenPattern);
int32_t iLiteralLen = wsLiteral.GetLength();
if (iText + iLiteralLen > iLenText ||
@@ -1794,9 +1790,9 @@ bool CFGAS_FormatString::ParseNull(const CFX_WideString& wsSrcText,
return iPattern == iLenPattern && iText == iLenText;
}
-bool CFGAS_FormatString::FormatText(const CFX_WideString& wsSrcText,
- const CFX_WideString& wsPattern,
- CFX_WideString* wsOutput) {
+bool CFGAS_FormatString::FormatText(const WideString& wsSrcText,
+ const WideString& wsPattern,
+ WideString* wsOutput) {
if (wsPattern.IsEmpty())
return false;
@@ -1804,7 +1800,7 @@ bool CFGAS_FormatString::FormatText(const CFX_WideString& wsSrcText,
if (iLenText == 0)
return false;
- CFX_WideString wsTextFormat = GetTextFormat(wsPattern, L"text");
+ WideString wsTextFormat = GetTextFormat(wsPattern, L"text");
int32_t iText = 0;
int32_t iPattern = 0;
@@ -1856,15 +1852,15 @@ bool CFGAS_FormatString::FormatText(const CFX_WideString& wsSrcText,
return iText == iLenText;
}
-bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
- const CFX_WideString& wsPattern,
- CFX_WideString* wsOutput) {
+bool CFGAS_FormatString::FormatStrNum(const WideStringView& wsInputNum,
+ const WideString& wsPattern,
+ WideString* wsOutput) {
if (wsInputNum.IsEmpty() || wsPattern.IsEmpty())
return false;
int32_t dot_index_f = -1;
uint32_t dwNumStyle = 0;
- CFX_WideString wsNumFormat;
+ WideString wsNumFormat;
IFX_Locale* pLocale =
GetNumericFormat(wsPattern, &dot_index_f, &dwNumStyle, &wsNumFormat);
if (!pLocale || wsNumFormat.IsEmpty())
@@ -1873,12 +1869,12 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
int32_t cc = 0, ccf = 0;
const wchar_t* strf = wsNumFormat.c_str();
int lenf = wsNumFormat.GetLength();
- CFX_WideString wsSrcNum(wsInputNum);
+ WideString wsSrcNum(wsInputNum);
wsSrcNum.TrimLeft('0');
if (wsSrcNum.IsEmpty() || wsSrcNum[0] == '.')
wsSrcNum.InsertAtFront('0');
- CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringC());
+ CFX_Decimal decimal = CFX_Decimal(wsSrcNum.AsStringView());
if (dwNumStyle & FX_NUMSTYLE_Percent) {
decimal = decimal * CFX_Decimal(100);
wsSrcNum = decimal;
@@ -1937,7 +1933,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
wsSrcNum.TrimRight(L".");
}
- CFX_WideString wsGroupSymbol =
+ WideString wsGroupSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Grouping);
bool bNeg = false;
if (wsSrcNum[0] == '-') {
@@ -2010,7 +2006,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
ccf--;
break;
case 'E': {
- CFX_WideString wsExp;
+ WideString wsExp;
wsExp.Format(L"E%+d", exponent);
*wsOutput = wsExp + *wsOutput;
ccf--;
@@ -2114,7 +2110,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
return true;
}
- CFX_WideString wsDotSymbol =
+ WideString wsDotSymbol =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
if (strf[dot_index_f] == 'V') {
*wsOutput += wsDotSymbol;
@@ -2168,7 +2164,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
ccf++;
break;
case 'E': {
- CFX_WideString wsExp;
+ WideString wsExp;
wsExp.Format(L"E%+d", exponent);
*wsOutput += wsExp;
ccf++;
@@ -2247,23 +2243,23 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
return true;
}
-bool CFGAS_FormatString::FormatNum(const CFX_WideString& wsSrcNum,
- const CFX_WideString& wsPattern,
- CFX_WideString* wsOutput) {
+bool CFGAS_FormatString::FormatNum(const WideString& wsSrcNum,
+ const WideString& wsPattern,
+ WideString* wsOutput) {
if (wsSrcNum.IsEmpty() || wsPattern.IsEmpty())
return false;
- return FormatStrNum(wsSrcNum.AsStringC(), wsPattern, wsOutput);
+ return FormatStrNum(wsSrcNum.AsStringView(), wsPattern, wsOutput);
}
-bool CFGAS_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
- const CFX_WideString& wsPattern,
+bool CFGAS_FormatString::FormatDateTime(const WideString& wsSrcDateTime,
+ const WideString& wsPattern,
FX_DATETIMETYPE eDateTimeType,
- CFX_WideString* wsOutput) {
+ WideString* wsOutput) {
if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty())
return false;
- CFX_WideString wsDatePattern;
- CFX_WideString wsTimePattern;
+ WideString wsDatePattern;
+ WideString wsTimePattern;
IFX_Locale* pLocale = nullptr;
FX_DATETIMETYPE eCategory =
GetDateTimeFormat(wsPattern, &pLocale, &wsDatePattern, &wsTimePattern);
@@ -2290,15 +2286,15 @@ bool CFGAS_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
return true;
}
if (eCategory == FX_DATETIMETYPE_Time &&
- FX_TimeFromCanonical(wsSrcDateTime.AsStringC(), &dt, pLocale)) {
+ FX_TimeFromCanonical(wsSrcDateTime.AsStringView(), &dt, pLocale)) {
*wsOutput = FormatDateTimeInternal(dt, wsDatePattern, wsTimePattern, true,
pLocale);
return true;
}
} else {
- CFX_WideString wsSrcDate(wsSrcDateTime.c_str(), iT.value());
- CFX_WideStringC wsSrcTime(wsSrcDateTime.c_str() + iT.value() + 1,
- wsSrcDateTime.GetLength() - iT.value() - 1);
+ WideString wsSrcDate(wsSrcDateTime.c_str(), iT.value());
+ WideStringView wsSrcTime(wsSrcDateTime.c_str() + iT.value() + 1,
+ wsSrcDateTime.GetLength() - iT.value() - 1);
if (wsSrcDate.IsEmpty() || wsSrcTime.IsEmpty())
return false;
if (FX_DateFromCanonical(wsSrcDate, &dt) &&
@@ -2312,12 +2308,12 @@ bool CFGAS_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime,
return false;
}
-bool CFGAS_FormatString::FormatZero(const CFX_WideString& wsPattern,
- CFX_WideString* wsOutput) {
+bool CFGAS_FormatString::FormatZero(const WideString& wsPattern,
+ WideString* wsOutput) {
if (wsPattern.IsEmpty())
return false;
- CFX_WideString wsTextFormat = GetTextFormat(wsPattern, L"zero");
+ WideString wsTextFormat = GetTextFormat(wsPattern, L"zero");
int32_t iPattern = 0;
const wchar_t* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();
@@ -2334,12 +2330,12 @@ bool CFGAS_FormatString::FormatZero(const CFX_WideString& wsPattern,
return true;
}
-bool CFGAS_FormatString::FormatNull(const CFX_WideString& wsPattern,
- CFX_WideString* wsOutput) {
+bool CFGAS_FormatString::FormatNull(const WideString& wsPattern,
+ WideString* wsOutput) {
if (wsPattern.IsEmpty())
return false;
- CFX_WideString wsTextFormat = GetTextFormat(wsPattern, L"null");
+ WideString wsTextFormat = GetTextFormat(wsPattern, L"null");
int32_t iPattern = 0;
const wchar_t* pStrPattern = wsTextFormat.c_str();
int32_t iLenPattern = wsTextFormat.GetLength();