From 8a1758bf11c2d741e0cddc761b1dd2cdf564db93 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 15 Aug 2017 10:37:59 -0400 Subject: Remove GetAt from string classes This method duplicates the behaviour of the const [] operator and doesn't offer any additional safety. Folding them into one implementation. SetAt is retained, since implementing the non-const [] operator to replace SetAt has potential performance concerns. Specifically many non-obvious cases of reading an element using [] will cause a realloc & copy. BUG=pdfium:860 Change-Id: I3ef5e5e5a15376f040256b646eb0d90636e24b67 Reviewed-on: https://pdfium-review.googlesource.com/10870 Commit-Queue: Ryan Harrison Reviewed-by: Tom Sepez --- core/fpdfapi/font/cpdf_cidfont.cpp | 6 +- core/fpdfapi/font/cpdf_cmapparser.cpp | 25 ++++---- core/fpdfapi/font/cpdf_font.cpp | 2 +- core/fpdfapi/font/cpdf_tounicodemap.cpp | 4 +- core/fpdfapi/render/cpdf_charposlist.cpp | 2 +- core/fpdfdoc/cpdf_filespec.cpp | 18 +++--- core/fpdfdoc/cpdf_variabletext.cpp | 12 ++-- core/fpdfdoc/cpvt_generateap.cpp | 2 +- core/fpdftext/cpdf_linkextract.cpp | 6 +- core/fpdftext/cpdf_textpage.cpp | 30 +++++----- core/fpdftext/cpdf_textpagefind.cpp | 26 ++++----- core/fxcrt/cfx_bytestring.cpp | 16 +++--- core/fxcrt/cfx_bytestring.h | 5 +- core/fxcrt/cfx_bytestring_unittest.cpp | 79 +++++++++----------------- core/fxcrt/cfx_chariter.cpp | 2 +- core/fxcrt/cfx_string_c_template.h | 6 +- core/fxcrt/cfx_widestring.cpp | 12 ++-- core/fxcrt/cfx_widestring.h | 4 +- core/fxcrt/cfx_widestring_unittest.cpp | 77 +++++++++---------------- core/fxcrt/xml/cxml_parser.cpp | 2 +- fpdfsdk/javascript/Document.cpp | 2 +- fpdfsdk/javascript/PublicMethods.cpp | 38 ++++++------- fxbarcode/datamatrix/BC_ASCIIEncoder.cpp | 4 +- fxbarcode/datamatrix/BC_Base256Encoder.cpp | 14 ++--- fxbarcode/datamatrix/BC_C40Encoder.cpp | 6 +- fxbarcode/datamatrix/BC_DefaultPlacement.cpp | 2 +- fxbarcode/datamatrix/BC_EdifactEncoder.cpp | 8 +-- fxbarcode/datamatrix/BC_EncoderContext.cpp | 8 +-- fxbarcode/datamatrix/BC_ErrorCorrection.cpp | 6 +- fxbarcode/datamatrix/BC_HighLevelEncoder.cpp | 8 +-- fxbarcode/oned/BC_OnedCodaBarWriter.cpp | 4 +- fxbarcode/oned/BC_OnedCode39Writer.cpp | 6 +- fxbarcode/oned/BC_OnedEAN13Writer.cpp | 2 +- fxbarcode/oned/BC_OnedEAN8Writer.cpp | 2 +- fxbarcode/oned/BC_OnedUPCAWriter.cpp | 4 +- fxbarcode/pdf417/BC_PDF417.cpp | 2 +- fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp | 2 +- fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp | 32 +++++------ fxbarcode/qrcode/BC_QRCoderEncoder.cpp | 14 +++-- xfa/fxfa/cxfa_ffpasswordedit.cpp | 2 +- xfa/fxfa/cxfa_pdffontmgr.cpp | 2 +- xfa/fxfa/cxfa_textlayout.cpp | 4 +- xfa/fxfa/cxfa_textparser.cpp | 2 +- xfa/fxfa/cxfa_widgetacc.cpp | 2 +- xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp | 22 +++---- xfa/fxfa/fm2js/cxfa_fmexpression.cpp | 18 +++--- xfa/fxfa/parser/cxfa_dataexporter.cpp | 6 +- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 2 +- xfa/fxfa/parser/cxfa_localemgr.cpp | 7 +-- xfa/fxfa/parser/cxfa_measurement.cpp | 2 +- xfa/fxfa/parser/cxfa_node.cpp | 10 ++-- xfa/fxfa/parser/cxfa_nodehelper.cpp | 6 +- xfa/fxfa/parser/cxfa_resolveprocessor.cpp | 4 +- xfa/fxfa/parser/cxfa_scriptcontext.cpp | 2 +- xfa/fxfa/parser/cxfa_widgetdata.cpp | 4 +- 55 files changed, 271 insertions(+), 324 deletions(-) diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 8cb59de739..9a2261caa9 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -627,7 +627,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { if (uni_str.IsEmpty()) return cid; - unicode = uni_str.GetAt(0); + unicode = uni_str[0]; #endif } else { if (cid && m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded()) @@ -637,7 +637,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { if (unicode == 0) { CFX_WideString unicode_str = UnicodeFromCharCode(charcode); if (!unicode_str.IsEmpty()) - unicode = unicode_str.GetAt(0); + unicode = unicode_str[0]; } } FXFT_Face face = m_Font.GetFace(); @@ -735,7 +735,7 @@ int CPDF_CIDFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) { if (unicode_str.IsEmpty()) return -1; - charcode = unicode_str.GetAt(0); + charcode = unicode_str[0]; } return GetGlyphIndex(charcode, pVertGlyph); } diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp index cbf693966e..272f8deb34 100644 --- a/core/fpdfapi/font/cpdf_cmapparser.cpp +++ b/core/fpdfapi/font/cpdf_cmapparser.cpp @@ -121,7 +121,7 @@ void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { } m_Status = 0; } else { - if (word.GetLength() == 0 || word.GetAt(0) != '<') { + if (word.GetLength() == 0 || word[0] != '<') { return; } if (m_CodeSeq % 2) { @@ -140,18 +140,17 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { if (word.IsEmpty()) return 0; pdfium::base::CheckedNumeric num = 0; - if (word.GetAt(0) == '<') { - for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) { - num = num * 16 + FXSYS_HexCharToInt(word.GetAt(i)); + if (word[0] == '<') { + for (int i = 1; i < word.GetLength() && std::isxdigit(word[i]); ++i) { + num = num * 16 + FXSYS_HexCharToInt(word[i]); if (!num.IsValid()) return 0; } return num.ValueOrDie(); } - for (int i = 0; i < word.GetLength() && std::isdigit(word.GetAt(i)); ++i) { - num = - num * 10 + FXSYS_DecimalCharToInt(static_cast(word.GetAt(i))); + for (int i = 0; i < word.GetLength() && std::isdigit(word[i]); ++i) { + num = num * 10 + FXSYS_DecimalCharToInt(static_cast(word[i])); if (!num.IsValid()) return 0; } @@ -162,12 +161,12 @@ uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range, const CFX_ByteStringC& first, const CFX_ByteStringC& second) { - if (first.GetLength() == 0 || first.GetAt(0) != '<') + if (first.GetLength() == 0 || first[0] != '<') return false; int i; for (i = 1; i < first.GetLength(); ++i) { - if (first.GetAt(i) == '>') { + if (first[i] == '>') { break; } } @@ -176,8 +175,8 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range, return false; for (i = 0; i < range.m_CharSize; ++i) { - uint8_t digit1 = first.GetAt(i * 2 + 1); - uint8_t digit2 = first.GetAt(i * 2 + 2); + uint8_t digit1 = first[i * 2 + 1]; + uint8_t digit2 = first[i * 2 + 2]; range.m_Lower[i] = FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2); } @@ -185,10 +184,10 @@ bool CPDF_CMapParser::CMap_GetCodeRange(CPDF_CMap::CodeRange& range, uint32_t size = second.GetLength(); for (i = 0; i < range.m_CharSize; ++i) { uint8_t digit1 = ((uint32_t)i * 2 + 1 < size) - ? second.GetAt((FX_STRSIZE)i * 2 + 1) + ? second[static_cast(i * 2 + 1)] : '0'; uint8_t digit2 = ((uint32_t)i * 2 + 2 < size) - ? second.GetAt((FX_STRSIZE)i * 2 + 2) + ? second[static_cast(i * 2 + 2)] : '0'; range.m_Upper[i] = FXSYS_HexCharToInt(digit1) * 16 + FXSYS_HexCharToInt(digit2); diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index 82f9be3361..0fd8b45326 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -467,7 +467,7 @@ int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) { return -1; CFX_WideString str = UnicodeFromCharCode(charcode); - uint32_t unicode = !str.IsEmpty() ? str.GetAt(0) : charcode; + uint32_t unicode = !str.IsEmpty() ? str[0] : charcode; int glyph = FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), unicode); if (glyph == 0) diff --git a/core/fpdfapi/font/cpdf_tounicodemap.cpp b/core/fpdfapi/font/cpdf_tounicodemap.cpp index 30bf0317ee..9076f4a737 100644 --- a/core/fpdfapi/font/cpdf_tounicodemap.cpp +++ b/core/fpdfapi/font/cpdf_tounicodemap.cpp @@ -147,7 +147,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { continue; } if (len == 1) { - m_Map[srccode] = destcode.GetAt(0); + m_Map[srccode] = destcode[0]; } else { m_Map[srccode] = GetUnicode(); m_MultiCharBuf.AppendChar(destcode.GetLength()); @@ -178,7 +178,7 @@ void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) { continue; } if (len == 1) { - m_Map[code] = destcode.GetAt(0); + m_Map[code] = destcode[0]; } else { m_Map[code] = GetUnicode(); m_MultiCharBuf.AppendChar(destcode.GetLength()); diff --git a/core/fpdfapi/render/cpdf_charposlist.cpp b/core/fpdfapi/render/cpdf_charposlist.cpp index a87fc3334e..f5882d9944 100644 --- a/core/fpdfapi/render/cpdf_charposlist.cpp +++ b/core/fpdfapi/render/cpdf_charposlist.cpp @@ -38,7 +38,7 @@ void CPDF_CharPosList::Load(const std::vector& charCodes, if (pCIDFont) charpos.m_bFontStyle = true; CFX_WideString unicode = pFont->UnicodeFromCharCode(CharCode); - charpos.m_Unicode = !unicode.IsEmpty() ? unicode.GetAt(0) : CharCode; + charpos.m_Unicode = !unicode.IsEmpty() ? unicode[0] : CharCode; charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); uint32_t GlyphID = charpos.m_GlyphIndex; #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp index 5ef6f466c5..e34f54e4e1 100644 --- a/core/fpdfdoc/cpdf_filespec.cpp +++ b/core/fpdfdoc/cpdf_filespec.cpp @@ -69,13 +69,13 @@ CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideString& filepath) { return ChangeSlashToPlatform(filepath.c_str()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - if (filepath.GetAt(0) != L'/') + if (filepath[0] != L'/') return ChangeSlashToPlatform(filepath.c_str()); - if (filepath.GetAt(1) == L'/') + if (filepath[1] == L'/') return ChangeSlashToPlatform(filepath.c_str() + 1); - if (filepath.GetAt(2) == L'/') { + if (filepath[2] == L'/') { CFX_WideString result; - result += filepath.GetAt(1); + result += filepath[1]; result += L':'; result += ChangeSlashToPlatform(filepath.c_str() + 2); return result; @@ -158,19 +158,19 @@ CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideString& filepath) { return CFX_WideString(); #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - if (filepath.GetAt(1) == L':') { + if (filepath[1] == L':') { CFX_WideString result(L'/'); - result += filepath.GetAt(0); - if (filepath.GetAt(2) != L'\\') + result += filepath[0]; + if (filepath[2] != L'\\') result += L'/'; result += ChangeSlashToPDF(filepath.c_str() + 2); return result; } - if (filepath.GetAt(0) == L'\\' && filepath.GetAt(1) == L'\\') + if (filepath[0] == L'\\' && filepath[1] == L'\\') return ChangeSlashToPDF(filepath.c_str() + 1); - if (filepath.GetAt(0) == L'\\') + if (filepath[0] == L'\\') return L'/' + ChangeSlashToPDF(filepath.c_str()); return ChangeSlashToPDF(filepath.c_str()); #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 74a5e3adfc..877f8ca01e 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -358,11 +358,11 @@ CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, CPVT_WordPlace wp = place; for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { CPVT_WordPlace oldwp = wp; - uint16_t word = swText.GetAt(i); + uint16_t word = swText[i]; switch (word) { case 0x0D: if (m_bMultiLine) { - if (swText.GetAt(i + 1) == 0x0A) + if (swText[i + 1] == 0x0A) i += 1; wp = InsertSection(wp, nullptr, nullptr); @@ -370,7 +370,7 @@ CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, break; case 0x0A: if (m_bMultiLine) { - if (swText.GetAt(i + 1) == 0x0D) + if (swText[i + 1] == 0x0D) i += 1; wp = InsertSection(wp, nullptr, nullptr); @@ -426,11 +426,11 @@ void CPDF_VariableText::SetText(const CFX_WideString& swText) { if (m_nCharArray > 0 && nCharCount >= m_nCharArray) break; - uint16_t word = swText.GetAt(i); + uint16_t word = swText[i]; switch (word) { case 0x0D: if (m_bMultiLine) { - if (i + 1 < sz && swText.GetAt(i + 1) == 0x0A) + if (i + 1 < sz && swText[i + 1] == 0x0A) i++; wp.AdvanceSection(); AddSection(wp, secinfo); @@ -438,7 +438,7 @@ void CPDF_VariableText::SetText(const CFX_WideString& swText) { break; case 0x0A: if (m_bMultiLine) { - if (i + 1 < sz && swText.GetAt(i + 1) == 0x0D) + if (i + 1 < sz && swText[i + 1] == 0x0D) i++; wp.AdvanceSection(); AddSection(wp, secinfo); diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index d1abde681d..9b5a82a055 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -123,7 +123,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, dsBorder = CPVT_Dash(pArray->GetIntegerAt(0), pArray->GetIntegerAt(1), pArray->GetIntegerAt(2)); } - switch (pBSDict->GetStringFor("S").GetAt(0)) { + switch (pBSDict->GetStringFor("S")[0]) { case 'S': nBorderStyle = BorderStyle::SOLID; break; diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp index d795e71639..fb228ec832 100644 --- a/core/fpdftext/cpdf_linkextract.cpp +++ b/core/fpdftext/cpdf_linkextract.cpp @@ -152,7 +152,7 @@ void CPDF_LinkExtract::ParseLink() { if (strBeCheck.GetLength() > 5) { while (strBeCheck.GetLength() > 0) { - wchar_t ch = strBeCheck.GetAt(strBeCheck.GetLength() - 1); + wchar_t ch = strBeCheck[strBeCheck.GetLength() - 1]; if (ch == L')' || ch == L',' || ch == L'>' || ch == L'.') { strBeCheck = strBeCheck.Left(strBeCheck.GetLength() - 1); nCount--; @@ -242,7 +242,7 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) { // Check the local part. int pPos = aPos; // Used to track the position of '@' or '.'. for (int i = aPos - 1; i >= 0; i--) { - wchar_t ch = str->GetAt(i); + wchar_t ch = (*str)[i]; if (ch == L'_' || ch == L'-' || FXSYS_iswalnum(ch)) continue; @@ -278,7 +278,7 @@ bool CPDF_LinkExtract::CheckMailLink(CFX_WideString* str) { int nLen = str->GetLength(); pPos = 0; // Used to track the position of '.'. for (int i = aPos + 1; i < nLen; i++) { - wchar_t wch = str->GetAt(i); + wchar_t wch = (*str)[i]; if (wch == L'-' || FXSYS_iswalnum(wch)) continue; diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 1470ad700d..a4c8b8fba0 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -701,7 +701,7 @@ void CPDF_TextPage::CloseTempLine() { CFX_WideString str = m_TempTextBuf.MakeString(); bool bPrevSpace = false; for (int i = 0; i < str.GetLength(); i++) { - if (str.GetAt(i) != ' ') { + if (str[i] != ' ') { bPrevSpace = false; continue; } @@ -841,8 +841,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { CPDF_Font* pFont = pTextObj->GetFont(); bExist = false; for (FX_STRSIZE i = 0; i < nItems; i++) { - if (pFont->CharCodeFromUnicode(actText.GetAt(i)) != - CPDF_Font::kInvalidCharCode) { + if (pFont->CharCodeFromUnicode(actText[i]) != CPDF_Font::kInvalidCharCode) { bExist = true; break; } @@ -852,7 +851,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { bExist = false; for (FX_STRSIZE i = 0; i < nItems; i++) { - wchar_t wChar = actText.GetAt(i); + wchar_t wChar = actText[i]; if ((wChar > 0x80 && wChar < 0xFFFD) || (wChar <= 0x80 && isprint(wChar))) { bExist = true; break; @@ -889,7 +888,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { matrix.Concat(Obj.m_formMatrix); for (FX_STRSIZE k = 0; k < nItems; k++) { - wchar_t wChar = actText.GetAt(k); + wchar_t wChar = actText[k]; if (wChar <= 0x80 && !isprint(wChar)) wChar = 0x20; if (wChar >= 0xFFFD) @@ -1005,12 +1004,12 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { pTextObj->GetFont()->UnicodeFromCharCode(item.m_CharCode); if (wstrItem.IsEmpty()) wstrItem += (wchar_t)item.m_CharCode; - wchar_t curChar = wstrItem.GetAt(0); + wchar_t curChar = wstrItem[0]; if (curChar == 0x2D || curChar == 0xAD) return; } while (m_TempTextBuf.GetSize() > 0 && - m_TempTextBuf.AsStringC().GetAt(m_TempTextBuf.GetLength() - 1) == + m_TempTextBuf.AsStringC()[m_TempTextBuf.GetLength() - 1] == 0x20) { m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); m_TempCharList.pop_back(); @@ -1053,7 +1052,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { CFX_WideString str = m_TempTextBuf.MakeString(); if (str.IsEmpty()) str = m_TextBuf.AsStringC(); - if (str.IsEmpty() || str.GetAt(str.GetLength() - 1) == TEXT_SPACE_CHAR) + if (str.IsEmpty() || str[str.GetLength() - 1] == TEXT_SPACE_CHAR) continue; float fontsize_h = pTextObj->m_TextState.GetFontSizeH(); @@ -1164,7 +1163,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { } if (!bDel) { for (int nIndex = 0; nIndex < nTotal; nIndex++) { - charinfo.m_Unicode = wstrItem.GetAt(nIndex); + charinfo.m_Unicode = wstrItem[nIndex]; if (charinfo.m_Unicode) { charinfo.m_Index = m_TextBuf.GetLength(); m_TempTextBuf.AppendChar(charinfo.m_Unicode); @@ -1175,8 +1174,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { } } else if (i == 0) { CFX_WideString str = m_TempTextBuf.MakeString(); - if (!str.IsEmpty() && - str.GetAt(str.GetLength() - 1) == TEXT_SPACE_CHAR) { + if (!str.IsEmpty() && str[str.GetLength() - 1] == TEXT_SPACE_CHAR) { m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); m_TempCharList.pop_back(); } @@ -1225,12 +1223,12 @@ bool CPDF_TextPage::IsHyphen(wchar_t curChar) { if (nCount < 1) return false; int nIndex = nCount - 1; - wchar_t wcTmp = strCurText.GetAt(nIndex); + wchar_t wcTmp = strCurText[nIndex]; while (wcTmp == 0x20 && nIndex > 0 && nIndex <= nCount - 1) - wcTmp = strCurText.GetAt(--nIndex); + wcTmp = strCurText[--nIndex]; if (0x2D == wcTmp || 0xAD == wcTmp) { if (--nIndex > 0) { - wchar_t preChar = strCurText.GetAt((nIndex)); + wchar_t preChar = strCurText[nIndex]; if (FXSYS_iswalpha(preChar) && FXSYS_iswalpha(curChar)) return true; } @@ -1268,7 +1266,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode); if (wstrItem.IsEmpty()) wstrItem += static_cast(item.m_CharCode); - wchar_t curChar = wstrItem.GetAt(0); + wchar_t curChar = wstrItem[0]; if (WritingMode == TextOrientation::Horizontal) { if (this_rect.Height() > 4.5 && prev_rect.Height() > 4.5) { float top = this_rect.top < prev_rect.top ? this_rect.top : prev_rect.top; @@ -1357,7 +1355,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode); if (PrevStr.IsEmpty()) return GenerateCharacter::None; - wchar_t preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); + wchar_t preChar = PrevStr[PrevStr.GetLength() - 1]; CFX_Matrix matrix = pObj->GetTextMatrix(); matrix.Concat(formMatrix); diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp index 3c8e532a7f..55f940cad7 100644 --- a/core/fpdftext/cpdf_textpagefind.cpp +++ b/core/fpdftext/cpdf_textpagefind.cpp @@ -110,7 +110,7 @@ bool CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat, m_csFindWhatArray.clear(); int i = 0; while (i < len) { - if (findwhatStr.GetAt(i) != ' ') + if (findwhatStr[i] != ' ') break; i++; } @@ -150,7 +150,7 @@ bool CPDF_TextPageFind::FindNext() { CFX_WideString csWord = m_csFindWhatArray[iWord]; if (csWord.IsEmpty()) { if (iWord == nCount - 1) { - wchar_t strInsert = m_strText.GetAt(nStartPos); + wchar_t strInsert = m_strText[nStartPos]; if (strInsert == TEXT_LINEFEED_CHAR || strInsert == TEXT_SPACE_CHAR || strInsert == TEXT_RETURN_CHAR || strInsert == 160) { nResultPos = nStartPos + 1; @@ -174,16 +174,16 @@ bool CPDF_TextPageFind::FindNext() { bool bMatch = true; if (iWord != 0 && !bSpaceStart) { int PreResEndPos = nStartPos; - int curChar = csWord.GetAt(0); + int curChar = csWord[0]; CFX_WideString lastWord = m_csFindWhatArray[iWord - 1]; - int lastChar = lastWord.GetAt(lastWord.GetLength() - 1); + int lastChar = lastWord[lastWord.GetLength() - 1]; if (nStartPos == nResultPos && !(IsIgnoreSpaceCharacter(lastChar) || IsIgnoreSpaceCharacter(curChar))) { bMatch = false; } for (int d = PreResEndPos; d < nResultPos; d++) { - wchar_t strInsert = m_strText.GetAt(d); + wchar_t strInsert = m_strText[d]; if (strInsert != TEXT_LINEFEED_CHAR && strInsert != TEXT_SPACE_CHAR && strInsert != TEXT_RETURN_CHAR && strInsert != 160) { bMatch = false; @@ -192,7 +192,7 @@ bool CPDF_TextPageFind::FindNext() { } } else if (bSpaceStart) { if (nResultPos > 0) { - wchar_t strInsert = m_strText.GetAt(nResultPos - 1); + wchar_t strInsert = m_strText[nResultPos - 1]; if (strInsert != TEXT_LINEFEED_CHAR && strInsert != TEXT_SPACE_CHAR && strInsert != TEXT_RETURN_CHAR && strInsert != 160) { bMatch = false; @@ -293,7 +293,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) { int pos = 0; while (pos < csWord.GetLength()) { CFX_WideString curStr = csWord.Mid(pos, 1); - wchar_t curChar = csWord.GetAt(pos); + wchar_t curChar = csWord[pos]; if (IsIgnoreSpaceCharacter(curChar)) { if (pos > 0 && curChar == 0x2019) { pos++; @@ -326,12 +326,12 @@ bool CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, int char_count = endPos - startPos + 1; if (char_count < 1) return false; - if (char_count == 1 && csPageText.GetAt(startPos) > 255) + if (char_count == 1 && csPageText[startPos] > 255) return true; if (startPos - 1 >= 0) - char_left = csPageText.GetAt(startPos - 1); + char_left = csPageText[startPos - 1]; if (startPos + char_count < csPageText.GetLength()) - char_right = csPageText.GetAt(startPos + char_count); + char_right = csPageText[startPos + char_count]; if ((char_left > 'A' && char_left < 'a') || (char_left > 'a' && char_left < 'z') || (char_left > 0xfb00 && char_left < 0xfb06) || std::iswdigit(char_left) || @@ -348,9 +348,9 @@ bool CPDF_TextPageFind::IsMatchWholeWord(const CFX_WideString& csPageText, return false; } if (char_count > 0) { - if (std::iswdigit(char_left) && std::iswdigit(csPageText.GetAt(startPos))) + if (std::iswdigit(char_left) && std::iswdigit(csPageText[startPos])) return false; - if (std::iswdigit(char_right) && std::iswdigit(csPageText.GetAt(endPos))) + if (std::iswdigit(char_right) && std::iswdigit(csPageText[endPos])) return false; } return true; @@ -386,7 +386,7 @@ CFX_WideString CPDF_TextPageFind::MakeReverse(const CFX_WideString& str) { str2.clear(); int nlen = str.GetLength(); for (int i = nlen - 1; i >= 0; i--) - str2 += str.GetAt(i); + str2 += str[i]; return str2; } diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp index 0aba3be12a..cd049dcc5d 100644 --- a/core/fxcrt/cfx_bytestring.cpp +++ b/core/fxcrt/cfx_bytestring.cpp @@ -518,6 +518,12 @@ void CFX_ByteString::Format(const char* pFormat, ...) { va_end(argList); } +void CFX_ByteString::SetAt(FX_STRSIZE index, char c) { + ASSERT(index >= 0 && index < GetLength()); + ReallocBeforeWrite(m_pData->m_nDataLength); + m_pData->m_String[index] = c; +} + FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE index, char ch) { const FX_STRSIZE cur_length = m_pData ? m_pData->m_nDataLength : 0; if (index != pdfium::clamp(index, 0, cur_length)) @@ -694,12 +700,6 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, return nCount; } -void CFX_ByteString::SetAt(FX_STRSIZE index, char c) { - ASSERT(index >= 0 && index < GetLength()); - ReallocBeforeWrite(m_pData->m_nDataLength); - m_pData->m_String[index] = c; -} - CFX_WideString CFX_ByteString::UTF8Decode() const { CFX_UTF8Decoder decoder; for (FX_STRSIZE i = 0; i < GetLength(); i++) { @@ -721,10 +721,10 @@ int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { int that_len = str.GetLength(); int min_len = this_len < that_len ? this_len : that_len; for (int i = 0; i < min_len; i++) { - if ((uint8_t)m_pData->m_String[i] < str.GetAt(i)) { + if ((uint8_t)m_pData->m_String[i] < str[i]) { return -1; } - if ((uint8_t)m_pData->m_String[i] > str.GetAt(i)) { + if ((uint8_t)m_pData->m_String[i] > str[i]) { return 1; } } diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h index df31751273..3e8b6619c2 100644 --- a/core/fxcrt/cfx_bytestring.h +++ b/core/fxcrt/cfx_bytestring.h @@ -107,14 +107,13 @@ class CFX_ByteString { const CFX_ByteString& operator+=(const CFX_ByteString& str); const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc); - uint8_t GetAt(FX_STRSIZE index) const { + const CharType& operator[](const FX_STRSIZE index) const { ASSERT(index >= 0 && index < GetLength()); return m_pData->m_String[index]; } - uint8_t operator[](FX_STRSIZE index) const { return GetAt(index); } - void SetAt(FX_STRSIZE index, char c); + FX_STRSIZE Insert(FX_STRSIZE index, char ch); FX_STRSIZE InsertAtFront(char ch) { return Insert(0, ch); } FX_STRSIZE InsertAtBack(char ch) { return Insert(GetLength(), ch); } diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp index 680a37e342..35f407f6ec 100644 --- a/core/fxcrt/cfx_bytestring_unittest.cpp +++ b/core/fxcrt/cfx_bytestring_unittest.cpp @@ -11,26 +11,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/base/stl_util.h" -TEST(fxcrt, ByteStringGetAt) { - CFX_ByteString short_string("a"); - CFX_ByteString longer_string("abc"); - CFX_ByteString embedded_nul_string("ab\0c", 4); - -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(-1); }, ".*"); -#endif - EXPECT_EQ('a', short_string.GetAt(0)); -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(1); }, ".*"); -#endif - EXPECT_EQ('c', longer_string.GetAt(2)); - EXPECT_EQ('b', embedded_nul_string.GetAt(1)); - EXPECT_EQ('\0', embedded_nul_string.GetAt(2)); - EXPECT_EQ('c', embedded_nul_string.GetAt(3)); -} - -TEST(fxcrt, ByteStringOperatorSubscript) { - CFX_ByteString abc("abc"); +TEST(fxcrt, ByteStringElementAccess) { + const CFX_ByteString abc("abc"); #ifndef NDEBUG EXPECT_DEATH({ abc[-1]; }, ".*"); #endif @@ -40,22 +22,35 @@ TEST(fxcrt, ByteStringOperatorSubscript) { #ifndef NDEBUG EXPECT_DEATH({ abc[3]; }, ".*"); #endif -} -TEST(fxcrt, ByteStringSetAt) { - // CFX_ByteString includes the NUL terminator for non-empty strings. - CFX_ByteString abc("abc"); + CFX_ByteString mutable_abc = abc; + EXPECT_EQ(abc.c_str(), mutable_abc.c_str()); + EXPECT_EQ('a', mutable_abc[0]); + EXPECT_EQ('b', mutable_abc[1]); + EXPECT_EQ('c', mutable_abc[2]); + EXPECT_EQ(abc.c_str(), mutable_abc.c_str()); + #ifndef NDEBUG - EXPECT_DEATH({ abc.SetAt(-1, 'd'); }, ".*"); + EXPECT_DEATH({ mutable_abc.SetAt(-1, 'd'); }, ".*"); + EXPECT_EQ("abc", abc); #endif - abc.SetAt(0, 'd'); - EXPECT_EQ("dbc", abc); - abc.SetAt(1, 'e'); - EXPECT_EQ("dec", abc); - abc.SetAt(2, 'f'); - EXPECT_EQ("def", abc); + const char* c_str = abc.c_str(); + mutable_abc.SetAt(0, 'd'); + EXPECT_EQ(c_str, abc.c_str()); + EXPECT_NE(c_str, mutable_abc.c_str()); + EXPECT_EQ("abc", abc); + EXPECT_EQ("dbc", mutable_abc); + + mutable_abc.SetAt(1, 'e'); + EXPECT_EQ("abc", abc); + EXPECT_EQ("dec", mutable_abc); + + mutable_abc.SetAt(2, 'f'); + EXPECT_EQ("abc", abc); + EXPECT_EQ("def", mutable_abc); #ifndef NDEBUG - EXPECT_DEATH({ abc.SetAt(3, 'g'); }, ".*"); + EXPECT_DEATH({ mutable_abc.SetAt(3, 'g'); }, ".*"); + EXPECT_EQ("abc", abc); #endif } @@ -943,25 +938,7 @@ TEST(fxcrt, ByteStringCMid) { EXPECT_EQ(trailing_substring, longer_string.Mid(4, 3)); } -TEST(fxcrt, ByteStringCGetAt) { - CFX_ByteStringC short_string("a"); - CFX_ByteStringC longer_string("abc"); - CFX_ByteStringC embedded_nul_string("ab\0c", 4); - -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(-1); }, ".*"); -#endif - EXPECT_EQ('a', static_cast(short_string.GetAt(0))); -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(1); }, ".*"); -#endif - EXPECT_EQ('c', static_cast(longer_string.GetAt(2))); - EXPECT_EQ('b', static_cast(embedded_nul_string.GetAt(1))); - EXPECT_EQ('\0', static_cast(embedded_nul_string.GetAt(2))); - EXPECT_EQ('c', static_cast(embedded_nul_string.GetAt(3))); -} - -TEST(fxcrt, ByteStringCOperatorSubscript) { +TEST(fxcrt, ByteStringCElementAccess) { // CFX_ByteStringC includes the NUL terminator for non-empty strings. CFX_ByteStringC abc("abc"); #ifndef NDEBUG diff --git a/core/fxcrt/cfx_chariter.cpp b/core/fxcrt/cfx_chariter.cpp index b726a7e484..d26dd2df8f 100644 --- a/core/fxcrt/cfx_chariter.cpp +++ b/core/fxcrt/cfx_chariter.cpp @@ -29,7 +29,7 @@ bool CFX_CharIter::Next(bool bPrev) { } wchar_t CFX_CharIter::GetChar() { - return m_wsText.GetAt(m_nIndex); + return m_wsText[m_nIndex]; } void CFX_CharIter::SetAt(int32_t nIndex) { diff --git a/core/fxcrt/cfx_string_c_template.h b/core/fxcrt/cfx_string_c_template.h index bc0fe1e0a0..99948e90a0 100644 --- a/core/fxcrt/cfx_string_c_template.h +++ b/core/fxcrt/cfx_string_c_template.h @@ -119,12 +119,12 @@ class CFX_StringCTemplate { FX_STRSIZE GetLength() const { return m_Length; } bool IsEmpty() const { return m_Length == 0; } - UnsignedType GetAt(FX_STRSIZE index) const { + const UnsignedType& operator[](const FX_STRSIZE index) const { ASSERT(index >= 0 && index < GetLength()); return m_Ptr.Get()[index]; } - CharType CharAt(FX_STRSIZE index) const { + const CharType CharAt(const FX_STRSIZE index) const { ASSERT(index >= 0 && index < GetLength()); return static_cast(m_Ptr.Get()[index]); } @@ -164,8 +164,6 @@ class CFX_StringCTemplate { return CFX_StringCTemplate(m_Ptr.Get() + m_Length - count, count); } - UnsignedType operator[](FX_STRSIZE index) const { return GetAt(index); } - bool operator<(const CFX_StringCTemplate& that) const { int result = FXSYS_cmp(reinterpret_cast(m_Ptr.Get()), reinterpret_cast(that.m_Ptr.Get()), diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp index c2e1e4877d..01fc8c764e 100644 --- a/core/fxcrt/cfx_widestring.cpp +++ b/core/fxcrt/cfx_widestring.cpp @@ -841,12 +841,6 @@ FX_STRSIZE CFX_WideString::Replace(const CFX_WideStringC& pOld, return nCount; } -void CFX_WideString::SetAt(FX_STRSIZE index, wchar_t c) { - ASSERT(index >= 0 && index < GetLength()); - ReallocBeforeWrite(m_pData->m_nDataLength); - m_pData->m_String[index] = c; -} - // static CFX_WideString CFX_WideString::FromLocal(const CFX_ByteStringC& str) { return FromCodePage(str, 0); @@ -886,6 +880,12 @@ CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, return result; } +void CFX_WideString::SetAt(FX_STRSIZE index, wchar_t c) { + ASSERT(index >= 0 && index < GetLength()); + ReallocBeforeWrite(m_pData->m_nDataLength); + m_pData->m_String[index] = c; +} + int CFX_WideString::Compare(const wchar_t* lpsz) const { if (m_pData) return wcscmp(m_pData->m_String, lpsz); diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h index b49e898f32..d57e47c62f 100644 --- a/core/fxcrt/cfx_widestring.h +++ b/core/fxcrt/cfx_widestring.h @@ -101,13 +101,11 @@ class CFX_WideString { bool operator<(const CFX_WideString& str) const; - wchar_t GetAt(FX_STRSIZE index) const { + const CharType& operator[](const FX_STRSIZE index) const { ASSERT(index >= 0 && index < GetLength()); return m_pData->m_String[index]; } - wchar_t operator[](FX_STRSIZE index) const { return GetAt(index); } - void SetAt(FX_STRSIZE index, wchar_t c); int Compare(const wchar_t* str) const; diff --git a/core/fxcrt/cfx_widestring_unittest.cpp b/core/fxcrt/cfx_widestring_unittest.cpp index a23763218d..e7206dde06 100644 --- a/core/fxcrt/cfx_widestring_unittest.cpp +++ b/core/fxcrt/cfx_widestring_unittest.cpp @@ -10,26 +10,8 @@ #include "testing/gtest/include/gtest/gtest.h" -TEST(fxcrt, WideStringGetAt) { - CFX_WideString short_string(L"a"); - CFX_WideString longer_string(L"abc"); - CFX_WideString embedded_nul_string(L"ab\0c", 4); - -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(-1); }, ".*"); -#endif - EXPECT_EQ(L'a', short_string.GetAt(0)); -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(1); }, ".*"); -#endif - EXPECT_EQ(L'c', longer_string.GetAt(2)); - EXPECT_EQ(L'b', embedded_nul_string.GetAt(1)); - EXPECT_EQ(L'\0', embedded_nul_string.GetAt(2)); - EXPECT_EQ(L'c', embedded_nul_string.GetAt(3)); -} - -TEST(fxcrt, WideStringOperatorSubscript) { - CFX_WideString abc(L"abc"); +TEST(fxcrt, WideStringElementAccess) { + const CFX_WideString abc(L"abc"); #ifndef NDEBUG EXPECT_DEATH({ abc[-1]; }, ".*"); #endif @@ -39,21 +21,34 @@ TEST(fxcrt, WideStringOperatorSubscript) { #ifndef NDEBUG EXPECT_DEATH({ abc[4]; }, ".*"); #endif -} -TEST(fxcrt, WideStringSetAt) { - CFX_WideString abc(L"abc"); + CFX_WideString mutable_abc = abc; + EXPECT_EQ(abc.c_str(), mutable_abc.c_str()); + EXPECT_EQ(L'a', mutable_abc[0]); + EXPECT_EQ(L'b', mutable_abc[1]); + EXPECT_EQ(L'c', mutable_abc[2]); + EXPECT_EQ(abc.c_str(), mutable_abc.c_str()); #ifndef NDEBUG - EXPECT_DEATH({ abc.SetAt(-1, L'd'); }, ".*"); + EXPECT_DEATH({ mutable_abc.SetAt(-1, L'd'); }, ".*"); + EXPECT_EQ(L"abc", abc); #endif - abc.SetAt(0, L'd'); - EXPECT_EQ(L"dbc", abc); - abc.SetAt(1, L'e'); - EXPECT_EQ(L"dec", abc); - abc.SetAt(2, L'f'); - EXPECT_EQ(L"def", abc); + const wchar_t* c_str = abc.c_str(); + mutable_abc.SetAt(0, L'd'); + EXPECT_EQ(c_str, abc.c_str()); + EXPECT_NE(c_str, mutable_abc.c_str()); + EXPECT_EQ(L"abc", abc); + EXPECT_EQ(L"dbc", mutable_abc); + + mutable_abc.SetAt(1, L'e'); + EXPECT_EQ(L"abc", abc); + EXPECT_EQ(L"dec", mutable_abc); + + mutable_abc.SetAt(2, L'f'); + EXPECT_EQ(L"abc", abc); + EXPECT_EQ(L"def", mutable_abc); #ifndef NDEBUG - EXPECT_DEATH({ abc.SetAt(3, L'g'); }, ".*"); + EXPECT_DEATH({ mutable_abc.SetAt(3, L'g'); }, ".*"); + EXPECT_EQ(L"abc", abc); #endif } @@ -780,25 +775,7 @@ TEST(fxcrt, WideStringCFromVector) { EXPECT_EQ(nullptr, cleared_string.raw_str()); } -TEST(fxcrt, WideStringCGetAt) { - CFX_WideStringC short_string(L"a"); - CFX_WideStringC longer_string(L"abc"); - CFX_WideStringC embedded_nul_string(L"ab\0c", 4); - -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(-1); }, ".*"); -#endif - EXPECT_EQ(L'a', static_cast(short_string.GetAt(0))); -#ifndef NDEBUG - EXPECT_DEATH({ short_string.GetAt(1); }, ".*"); -#endif - EXPECT_EQ(L'c', static_cast(longer_string.GetAt(2))); - EXPECT_EQ(L'b', static_cast(embedded_nul_string.GetAt(1))); - EXPECT_EQ(L'\0', static_cast(embedded_nul_string.GetAt(2))); - EXPECT_EQ(L'c', static_cast(embedded_nul_string.GetAt(3))); -} - -TEST(fxcrt, WideStringCOperatorSubscript) { +TEST(fxcrt, WideStringCElementAccess) { CFX_WideStringC abc(L"abc"); #ifndef NDEBUG EXPECT_DEATH({ abc[-1]; }, ".*"); diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp index 4d9e3dc469..ebd5873b33 100644 --- a/core/fxcrt/xml/cxml_parser.cpp +++ b/core/fxcrt/xml/cxml_parser.cpp @@ -171,7 +171,7 @@ void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) { int32_t i = 0, iLen = str.GetLength(); do { while (m_dwIndex < m_dwBufferSize) { - if (str.GetAt(i) != m_pBuffer[m_dwIndex++]) { + if (str[i] != m_pBuffer[m_dwIndex++]) { i = 0; continue; } diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 77878a53ed..9b821471c2 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -1018,7 +1018,7 @@ bool Document::documentFileName(CJS_Runtime* pRuntime, CFX_WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath(); int32_t i = wsFilePath.GetLength() - 1; for (; i >= 0; i--) { - if (wsFilePath.GetAt(i) == L'\\' || wsFilePath.GetAt(i) == L'/') + if (wsFilePath[i] == L'\\' || wsFilePath[i] == L'/') break; } if (i >= 0 && i < wsFilePath.GetLength() - 1) { diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index bf35a67edc..2996316d79 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -235,7 +235,7 @@ int CJS_PublicMethods::ParseStringInteger(const CFX_WideString& str, if (i - nStart > 10) break; - wchar_t c = str.GetAt(i); + wchar_t c = str[i]; if (!std::iswdigit(c)) break; @@ -254,7 +254,7 @@ CFX_WideString CJS_PublicMethods::ParseStringString(const CFX_WideString& str, CFX_WideString swRet; nSkip = 0; for (int i = nStart, sz = str.GetLength(); i < sz; i++) { - wchar_t c = str.GetAt(i); + wchar_t c = str[i]; if (!std::iswdigit(c)) break; @@ -286,7 +286,7 @@ double CJS_PublicMethods::ParseNormalDate(const CFX_WideString& value, if (nIndex > 2) break; - wchar_t c = value.GetAt(i); + wchar_t c = value[i]; if (std::iswdigit(c)) { number[nIndex++] = ParseStringInteger(value, i, nSkip, 4); i += nSkip; @@ -373,7 +373,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, if (bExit) break; - wchar_t c = format.GetAt(i); + wchar_t c = format[i]; switch (c) { case ':': case '.': @@ -396,7 +396,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, int nSkip = 0; int remaining = format.GetLength() - i - 1; - if (remaining == 0 || format.GetAt(i + 1) != c) { + if (remaining == 0 || format[i + 1] != c) { switch (c) { case 'y': i++; @@ -433,12 +433,12 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, j += nSkip; break; case 't': - bPm = (j < value.GetLength() && value.GetAt(j) == 'p'); + bPm = (j < value.GetLength() && value[j] == 'p'); i++; j++; break; } - } else if (remaining == 1 || format.GetAt(i + 2) != c) { + } else if (remaining == 1 || format[i + 2] != c) { switch (c) { case 'y': nYear = ParseStringInteger(value, j, nSkip, 4); @@ -476,13 +476,13 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, j += nSkip; break; case 't': - bPm = (j + 1 < value.GetLength() && value.GetAt(j) == 'p' && - value.GetAt(j + 1) == 'm'); + bPm = (j + 1 < value.GetLength() && value[j] == 'p' && + value[j + 1] == 'm'); i += 2; j += 2; break; } - } else if (remaining == 2 || format.GetAt(i + 3) != c) { + } else if (remaining == 2 || format[i + 3] != c) { switch (c) { case 'm': { CFX_WideString sMonth = ParseStringString(value, j, nSkip); @@ -510,7 +510,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, j += 3; break; } - } else if (remaining == 3 || format.GetAt(i + 4) != c) { + } else if (remaining == 3 || format[i + 4] != c) { switch (c) { case 'y': nYear = ParseStringInteger(value, j, nSkip, 4); @@ -548,7 +548,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, break; } } else { - if (j >= value.GetLength() || format.GetAt(i) != value.GetAt(j)) { + if (j >= value.GetLength() || format[i] != value[j]) { bBadFormat = true; bExit = true; } @@ -566,7 +566,7 @@ double CJS_PublicMethods::MakeRegularDate(const CFX_WideString& value, default: if (value.GetLength() <= j) { bExit = true; - } else if (format.GetAt(i) != value.GetAt(j)) { + } else if (format[i] != value[j]) { bBadFormat = true; bExit = true; } @@ -630,7 +630,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, int i = 0; while (i < format.GetLength()) { - wchar_t c = format.GetAt(i); + wchar_t c = format[i]; int remaining = format.GetLength() - i - 1; sPart = L""; switch (c) { @@ -642,7 +642,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, case 'M': case 's': case 't': - if (remaining == 0 || format.GetAt(i + 1) != c) { + if (remaining == 0 || format[i + 1] != c) { switch (c) { case 'y': sPart += c; @@ -670,7 +670,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, break; } i++; - } else if (remaining == 1 || format.GetAt(i + 2) != c) { + } else if (remaining == 1 || format[i + 2] != c) { switch (c) { case 'y': sPart.Format(L"%02d", nYear - (nYear / 100) * 100); @@ -698,7 +698,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, break; } i += 2; - } else if (remaining == 2 || format.GetAt(i + 3) != c) { + } else if (remaining == 2 || format[i + 3] != c) { switch (c) { case 'm': i += 3; @@ -712,7 +712,7 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, sPart += c; break; } - } else if (remaining == 3 || format.GetAt(i + 4) != c) { + } else if (remaining == 3 || format[i + 4] != c) { switch (c) { case 'y': sPart.Format(L"%04d", nYear); @@ -1762,7 +1762,7 @@ bool CJS_PublicMethods::AFExtractNums(CJS_Runtime* pRuntime, } CFX_WideString str = params[0].ToCFXWideString(pRuntime); - if (str.GetAt(0) == L'.' || str.GetAt(0) == L',') + if (str[0] == L'.' || str[0] == L',') str = L"0" + str; CFX_WideString sPart; diff --git a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp index de57d81b71..e6b7a2b35b 100644 --- a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp +++ b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp @@ -37,8 +37,8 @@ void CBC_ASCIIEncoder::Encode(CBC_EncoderContext& context, int32_t& e) { int32_t n = CBC_HighLevelEncoder::determineConsecutiveDigitCount( context.m_msg, context.m_pos); if (n >= 2) { - wchar_t code = encodeASCIIDigits(context.m_msg.GetAt(context.m_pos), - context.m_msg.GetAt(context.m_pos + 1), e); + wchar_t code = encodeASCIIDigits(context.m_msg[context.m_pos], + context.m_msg[context.m_pos + 1], e); if (e != BCExceptionNO) { return; } diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp index edcd411114..0cbd3fdb10 100644 --- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp +++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp @@ -35,7 +35,7 @@ int32_t CBC_Base256Encoder::getEncodingMode() { } void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { CFX_WideString buffer; - buffer += (wchar_t)'\0'; + buffer += L'\0'; while (context.hasMoreCharacters()) { wchar_t c = context.getCurrentChar(); buffer += c; @@ -50,7 +50,7 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { int32_t dataCount = buffer.GetLength() - 1; char buf[128]; FXSYS_itoa(dataCount, buf, 10); - buffer.SetAt(0, wchar_t(*buf) - '0'); + buffer.SetAt(0, static_cast(*buf) - '0'); int32_t lengthFieldSize = 1; int32_t currentSize = context.getCodewordCount() + dataCount + lengthFieldSize; @@ -61,10 +61,10 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { bool mustPad = (context.m_symbolInfo->dataCapacity() - currentSize) > 0; if (context.hasMoreCharacters() || mustPad) { if (dataCount <= 249) { - buffer.SetAt(0, (wchar_t)dataCount); + buffer.SetAt(0, static_cast(dataCount)); } else if (dataCount > 249 && dataCount <= 1555) { - buffer.SetAt(0, (wchar_t)((dataCount / 250) + 249)); - buffer.Insert(1, (wchar_t)(dataCount % 250)); + buffer.SetAt(0, static_cast((dataCount / 250) + 249)); + buffer.Insert(1, static_cast(dataCount % 250)); } else { e = BCExceptionIllegalStateMessageLengthInvalid; return; @@ -79,8 +79,8 @@ wchar_t CBC_Base256Encoder::randomize255State(wchar_t ch, int32_t pseudoRandom = ((149 * codewordPosition) % 255) + 1; int32_t tempVariable = ch + pseudoRandom; if (tempVariable <= 255) { - return (wchar_t)tempVariable; + return static_cast(tempVariable); } else { - return (wchar_t)(tempVariable - 256); + return static_cast(tempVariable - 256); } } diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp index 8edd9eccfe..8a55c922ed 100644 --- a/fxbarcode/datamatrix/BC_C40Encoder.cpp +++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp @@ -32,9 +32,9 @@ namespace { CFX_WideString EncodeToCodewords(const CFX_WideString& sb, int32_t startPos) { - wchar_t c1 = sb.GetAt(startPos); - wchar_t c2 = sb.GetAt(startPos + 1); - wchar_t c3 = sb.GetAt(startPos + 2); + wchar_t c1 = sb[startPos]; + wchar_t c2 = sb[startPos + 1]; + wchar_t c3 = sb[startPos + 2]; int32_t v = (1600 * c1) + (40 * c2) + c3 + 1; wchar_t cw[2]; cw[0] = static_cast(v / 256); diff --git a/fxbarcode/datamatrix/BC_DefaultPlacement.cpp b/fxbarcode/datamatrix/BC_DefaultPlacement.cpp index 405b4f72a1..934d79503c 100644 --- a/fxbarcode/datamatrix/BC_DefaultPlacement.cpp +++ b/fxbarcode/datamatrix/BC_DefaultPlacement.cpp @@ -107,7 +107,7 @@ void CBC_DefaultPlacement::module(int32_t row, col += m_numcols; row += 4 - ((m_numcols + 4) % 8); } - int32_t v = m_codewords.GetAt(pos); + int32_t v = m_codewords[pos]; v &= 1 << (8 - bit); setBit(col, row, v != 0); } diff --git a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp index c7d6b317c1..7407efb47e 100644 --- a/fxbarcode/datamatrix/BC_EdifactEncoder.cpp +++ b/fxbarcode/datamatrix/BC_EdifactEncoder.cpp @@ -38,10 +38,10 @@ CFX_WideString EncodeToCodewords(const CFX_WideString& sb, int32_t startPos) { if (len == 0) return CFX_WideString(); - wchar_t c1 = sb.GetAt(startPos); - wchar_t c2 = len >= 2 ? sb.GetAt(startPos + 1) : 0; - wchar_t c3 = len >= 3 ? sb.GetAt(startPos + 2) : 0; - wchar_t c4 = len >= 4 ? sb.GetAt(startPos + 3) : 0; + wchar_t c1 = sb[startPos]; + wchar_t c2 = len >= 2 ? sb[startPos + 1] : 0; + wchar_t c3 = len >= 3 ? sb[startPos + 2] : 0; + wchar_t c4 = len >= 4 ? sb[startPos + 3] : 0; int32_t v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4; constexpr int32_t kBuflen = 3; wchar_t cw[kBuflen]; diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp index 404c07d980..eaf3768f49 100644 --- a/fxbarcode/datamatrix/BC_EncoderContext.cpp +++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp @@ -36,8 +36,8 @@ CBC_EncoderContext::CBC_EncoderContext(const CFX_WideString& msg, CFX_WideString sb; FX_STRSIZE c = dststr.GetLength(); for (FX_STRSIZE i = 0; i < c; i++) { - wchar_t ch = static_cast(dststr.GetAt(i) & 0xff); - if (ch == '?' && dststr.GetAt(i) != '?') { + wchar_t ch = static_cast(dststr[i] & 0xff); + if (ch == '?' && dststr[i] != '?') { e = BCExceptionCharactersOutsideISO88591Encoding; } sb += ch; @@ -60,10 +60,10 @@ void CBC_EncoderContext::setSkipAtEnd(int32_t count) { m_skipAtEnd = count; } wchar_t CBC_EncoderContext::getCurrentChar() { - return m_msg.GetAt(m_pos); + return m_msg[m_pos]; } wchar_t CBC_EncoderContext::getCurrent() { - return m_msg.GetAt(m_pos); + return m_msg[m_pos]; } void CBC_EncoderContext::writeCodewords(const CFX_WideString& codewords) { diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp index 4071602303..2e84df5c59 100644 --- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp +++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp @@ -150,7 +150,7 @@ CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, for (int32_t block = 0; block < blockCount; block++) { CFX_WideString temp; for (int32_t d = block; d < symbolInfo->dataCapacity(); d += blockCount) { - temp += (wchar_t)codewords.GetAt(d); + temp += (wchar_t)codewords[d]; } CFX_WideString ecc = createECCBlock(temp, errorSizes[block], e); if (e != BCExceptionNO) @@ -158,7 +158,7 @@ CFX_WideString CBC_ErrorCorrection::encodeECC200(CFX_WideString codewords, int32_t pos = 0; for (int32_t l = block; l < errorSizes[block] * blockCount; l += blockCount) { - sb.SetAt(symbolInfo->dataCapacity() + l, ecc.GetAt(pos++)); + sb.SetAt(symbolInfo->dataCapacity() + l, ecc[pos++]); } } } @@ -186,7 +186,7 @@ CFX_WideString CBC_ErrorCorrection::createECCBlock(CFX_WideString codewords, uint16_t* ecc = FX_Alloc(uint16_t, numECWords); memset(ecc, 0, numECWords * sizeof(uint16_t)); for (int32_t l = start; l < start + len; l++) { - uint16_t m = ecc[numECWords - 1] ^ codewords.GetAt(l); + uint16_t m = ecc[numECWords - 1] ^ codewords[l]; for (int32_t k = numECWords - 1; k > 0; k--) { if (m != 0 && FACTORS[table][k] != 0) { ecc[k] = (uint16_t)(ecc[k - 1] ^ diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp index 6034173ee4..8b8b413c9b 100644 --- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp +++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp @@ -174,7 +174,7 @@ int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg, } return C40_ENCODATION; } - wchar_t c = msg.GetAt(startpos + charsProcessed); + wchar_t c = msg[startpos + charsProcessed]; charsProcessed++; if (isDigit(c)) { charCounts[ASCII_ENCODATION] += 0.5; @@ -253,7 +253,7 @@ int32_t CBC_HighLevelEncoder::lookAheadTest(CFX_WideString msg, if (intCharCounts[C40_ENCODATION] == intCharCounts[X12_ENCODATION]) { int32_t p = startpos + charsProcessed + 1; while (p < msg.GetLength()) { - wchar_t tc = msg.GetAt(p); + wchar_t tc = msg[p]; if (isX12TermSep(tc)) { return X12_ENCODATION; } @@ -280,12 +280,12 @@ int32_t CBC_HighLevelEncoder::determineConsecutiveDigitCount(CFX_WideString msg, int32_t len = msg.GetLength(); int32_t idx = startpos; if (idx < len) { - wchar_t ch = msg.GetAt(idx); + wchar_t ch = msg[idx]; while (isDigit(ch) && idx < len) { count++; idx++; if (idx < len) { - ch = msg.GetAt(idx); + ch = msg[idx]; } } } diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index 14ffcdfc35..ecaeb8d656 100644 --- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp @@ -106,7 +106,7 @@ CFX_WideString CBC_OnedCodaBarWriter::FilterContents( CFX_WideString filtercontents; wchar_t ch; for (int32_t index = 0; index < contents.GetLength(); index++) { - ch = contents.GetAt(index); + ch = contents[index]; if (ch > 175) { index++; continue; @@ -137,7 +137,7 @@ uint8_t* CBC_OnedCodaBarWriter::EncodeImpl(const CFX_ByteString& contents, char ch; int32_t position = 0; for (int32_t index = 0; index < data.GetLength(); index++) { - ch = data.GetAt(index); + ch = data[index]; if (((ch >= 'a') && (ch <= 'z'))) { ch = ch - 32; } diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp index b9d594a028..cd87231fdf 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp @@ -50,7 +50,7 @@ CBC_OnedCode39Writer::~CBC_OnedCode39Writer() {} bool CBC_OnedCode39Writer::CheckContentValidity( const CFX_WideStringC& contents) { for (int32_t i = 0; i < contents.GetLength(); i++) { - wchar_t ch = contents.GetAt(i); + wchar_t ch = contents[i]; if ((ch >= (wchar_t)'0' && ch <= (wchar_t)'9') || (ch >= (wchar_t)'A' && ch <= (wchar_t)'Z') || ch == (wchar_t)'-' || ch == (wchar_t)'.' || ch == (wchar_t)' ' || ch == (wchar_t)'*' || @@ -67,7 +67,7 @@ CFX_WideString CBC_OnedCode39Writer::FilterContents( const CFX_WideStringC& contents) { CFX_WideString filtercontents; for (int32_t i = 0; i < contents.GetLength(); i++) { - wchar_t ch = contents.GetAt(i); + wchar_t ch = contents[i]; if (ch == (wchar_t)'*' && (i == 0 || i == contents.GetLength() - 1)) { continue; } @@ -92,7 +92,7 @@ CFX_WideString CBC_OnedCode39Writer::RenderTextContents( const CFX_WideStringC& contents) { CFX_WideString renderContents; for (int32_t i = 0; i < contents.GetLength(); i++) { - wchar_t ch = contents.GetAt(i); + wchar_t ch = contents[i]; if (ch == (wchar_t)'*' && (i == 0 || i == contents.GetLength() - 1)) { continue; } diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 6f1d957a01..85f545c602 100644 --- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -64,7 +64,7 @@ CFX_WideString CBC_OnedEAN13Writer::FilterContents( CFX_WideString filtercontents; wchar_t ch; for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); + ch = contents[i]; if (ch > 175) { i++; continue; diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp index 9a85f814a7..ae10fe52ef 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -70,7 +70,7 @@ CFX_WideString CBC_OnedEAN8Writer::FilterContents( CFX_WideString filtercontents; wchar_t ch; for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); + ch = contents[i]; if (ch > 175) { i++; continue; diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 13514eb53f..fff4184221 100644 --- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -43,7 +43,7 @@ CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {} bool CBC_OnedUPCAWriter::CheckContentValidity(const CFX_WideStringC& contents) { for (FX_STRSIZE i = 0; i < contents.GetLength(); ++i) { - if (contents.GetAt(i) < '0' || contents.GetAt(i) > '9') + if (contents[i] < '0' || contents[i] > '9') return false; } return true; @@ -54,7 +54,7 @@ CFX_WideString CBC_OnedUPCAWriter::FilterContents( CFX_WideString filtercontents; wchar_t ch; for (int32_t i = 0; i < contents.GetLength(); i++) { - ch = contents.GetAt(i); + ch = contents[i]; if (ch > 175) { i++; continue; diff --git a/fxbarcode/pdf417/BC_PDF417.cpp b/fxbarcode/pdf417/BC_PDF417.cpp index 9844798b24..3f492f9c10 100644 --- a/fxbarcode/pdf417/BC_PDF417.cpp +++ b/fxbarcode/pdf417/BC_PDF417.cpp @@ -523,7 +523,7 @@ void CBC_PDF417::encodeLowLevel(CFX_WideString fullCodewords, int32_t pattern = CODEWORD_TABLE[cluster][left]; encodeChar(pattern, 17, logic->getCurrentRow()); for (int32_t x = 0; x < c; x++) { - pattern = CODEWORD_TABLE[cluster][fullCodewords.GetAt(idx)]; + pattern = CODEWORD_TABLE[cluster][fullCodewords[idx]]; encodeChar(pattern, 17, logic->getCurrentRow()); idx++; } diff --git a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp index 6f1d7946eb..1d8258e720 100644 --- a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp +++ b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp @@ -145,7 +145,7 @@ bool CBC_PDF417ErrorCorrection::generateErrorCorrection( std::vector ech(k); int32_t sld = dataCodewords.GetLength(); for (int32_t i = 0; i < sld; i++) { - int32_t t1 = (dataCodewords.GetAt(i) + ech[k - 1]) % 929; + int32_t t1 = (dataCodewords[i] + ech[k - 1]) % 929; int32_t t2; int32_t t3; for (int32_t j = k - 1; j >= 1; j--) { diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp index f65cfe46ae..c531716e4f 100644 --- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp +++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp @@ -64,8 +64,8 @@ CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel( CFX_WideString msg; int32_t len = bytes.GetLength(); for (int32_t i = 0; i < len; i++) { - wchar_t ch = (wchar_t)(bytes.GetAt(i) & 0xff); - if (ch == '?' && bytes.GetAt(i) != '?') { + wchar_t ch = (wchar_t)(bytes[i] & 0xff); + if (ch == '?' && bytes[i] != '?') { e = BCExceptionCharactersOutsideISO88591Encoding; return CFX_WideString(); } @@ -154,7 +154,7 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, int32_t submode = initialSubmode; int32_t idx = 0; while (true) { - wchar_t ch = msg.GetAt(startpos + idx); + wchar_t ch = msg[startpos + idx]; switch (submode) { case SUBMODE_ALPHA: if (isAlphaUpper(ch)) { @@ -216,7 +216,7 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, continue; } else { if (startpos + idx + 1 < count) { - wchar_t next = msg.GetAt(startpos + idx + 1); + wchar_t next = msg[startpos + idx + 1]; if (isPunctuation(next)) { submode = SUBMODE_PUNCTUATION; tmp += (wchar_t)25; @@ -247,10 +247,10 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg, for (int32_t i = 0; i < len; i++) { bool odd = (i % 2) != 0; if (odd) { - h = (wchar_t)((h * 30) + tmp.GetAt(i)); + h = (wchar_t)((h * 30) + tmp[i]); sb += h; } else { - h = tmp.GetAt(i); + h = tmp[i]; } } if ((len % 2) != 0) { @@ -313,7 +313,7 @@ void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg, bigint = bigint / num900; } while (!bigint.isZero()); for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) { - sb += tmp.GetAt(i); + sb += tmp[i]; } idx += len; } @@ -343,12 +343,12 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount( int32_t len = msg.GetLength(); int32_t idx = startpos; if (idx < len) { - wchar_t ch = msg.GetAt(idx); + wchar_t ch = msg[idx]; while (isDigit(ch) && idx < len) { count++; idx++; if (idx < len) { - ch = msg.GetAt(idx); + ch = msg[idx]; } } } @@ -360,13 +360,13 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount( int32_t len = msg.GetLength(); int32_t idx = startpos; while (idx < len) { - wchar_t ch = msg.GetAt(idx); + wchar_t ch = msg[idx]; int32_t numericCount = 0; while (numericCount < 13 && isDigit(ch) && idx < len) { numericCount++; idx++; if (idx < len) { - ch = msg.GetAt(idx); + ch = msg[idx]; } } if (numericCount >= 13) { @@ -375,7 +375,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount( if (numericCount > 0) { continue; } - ch = msg.GetAt(idx); + ch = msg[idx]; if (!isText(ch)) { break; } @@ -391,7 +391,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( int32_t len = msg.GetLength(); int32_t idx = startpos; while (idx < len) { - wchar_t ch = msg.GetAt(idx); + wchar_t ch = msg[idx]; int32_t numericCount = 0; while (numericCount < 13 && isDigit(ch)) { numericCount++; @@ -399,7 +399,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( if (i >= len) { break; } - ch = msg.GetAt(i); + ch = msg[i]; } if (numericCount >= 13) { return idx - startpos; @@ -411,12 +411,12 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount( if (i >= len) { break; } - ch = msg.GetAt(i); + ch = msg[i]; } if (textCount >= 5) { return idx - startpos; } - ch = msg.GetAt(idx); + ch = msg[idx]; if ((*bytes)[idx] == 63 && ch != '?') { e = BCExceptionNonEncodableCharacterDetected; return -1; diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index cad70b81c5..f779ed4b95 100644 --- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -426,9 +426,10 @@ void MergeString(std::vector* result, void SplitString(const CFX_ByteString& content, std::vector* result) { int32_t index = 0; - while (index < content.GetLength() && - ((content[index] >= 0xA1 && content[index] <= 0xAA) || - (content[index] >= 0xB0 && content[index] <= 0xFA))) { + while (index < content.GetLength()) { + uint8_t c = static_cast(content[index]); + if (!((c >= 0xA1 && c <= 0xAA) || (c >= 0xB0 && c <= 0xFA))) + break; index += 2; } if (index) @@ -438,9 +439,10 @@ void SplitString(const CFX_ByteString& content, int32_t flag = index; while (GetAlphaNumericCode(content[index]) == -1 && - index < content.GetLength() && - !((content[index] >= 0xA1 && content[index] <= 0xAA) || - (content[index] >= 0xB0 && content[index] <= 0xFA))) { + index < content.GetLength()) { + uint8_t c = static_cast(content[index]); + if (((c >= 0xA1 && c <= 0xAA) || (c >= 0xB0 && c <= 0xFA))) + break; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ bool high = !!IsDBCSLeadByte(content[index]); #else diff --git a/xfa/fxfa/cxfa_ffpasswordedit.cpp b/xfa/fxfa/cxfa_ffpasswordedit.cpp index e0d9f33428..df2ea99cde 100644 --- a/xfa/fxfa/cxfa_ffpasswordedit.cpp +++ b/xfa/fxfa/cxfa_ffpasswordedit.cpp @@ -52,7 +52,7 @@ void CXFA_FFPasswordEdit::UpdateWidgetProperty() { CFX_WideString wsPassWord; m_pDataAcc->GetPasswordChar(wsPassWord); if (!wsPassWord.IsEmpty()) - pWidget->SetAliasChar(wsPassWord.GetAt(0)); + pWidget->SetAliasChar(wsPassWord[0]); if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || diff --git a/xfa/fxfa/cxfa_pdffontmgr.cpp b/xfa/fxfa/cxfa_pdffontmgr.cpp index 6e7a2ede4b..af94ee8c82 100644 --- a/xfa/fxfa/cxfa_pdffontmgr.cpp +++ b/xfa/fxfa/cxfa_pdffontmgr.cpp @@ -162,7 +162,7 @@ bool CXFA_PDFFontMgr::PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, return false; bool bMatch = false; - switch (bsPsName.GetAt(iPsLen - 1)) { + switch (bsPsName[iPsLen - 1]) { case 'L': { if (bsDRName.Right(5) == "Light") { bMatch = true; diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index 25bbe45e1b..9c4e36739d 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -796,7 +796,7 @@ bool CXFA_TextLayout::LoadRichText( (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; } else if (wsText.GetLength() > 0 && - (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { + (0x20 == wsText[wsText.GetLength() - 1])) { m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; } else if (wsText.GetLength() != 0) { m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; @@ -885,7 +885,7 @@ bool CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, int32_t iLength = wsText.GetLength(); for (int32_t i = iChar; i < iLength; i++) { - wchar_t wch = wsText.GetAt(i); + wchar_t wch = wsText[i]; if (wch == 0xA0) wch = 0x20; diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index 7e16202b16..659ec9cc6d 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -498,7 +498,7 @@ bool CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, CFX_WideString wsAttr = pElement->GetString(L"xfa:embed"); if (wsAttr.IsEmpty()) return false; - if (wsAttr.GetAt(0) == L'#') + if (wsAttr[0] == L'#') wsAttr.Delete(0); CFX_WideString ws = pElement->GetString(L"xfa:embedType"); diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 92d00e5ba9..30b1eca3e7 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -828,7 +828,7 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { } wchar_t wcEnter = '\n'; - wchar_t wsLast = wsText.GetAt(wsText.GetLength() - 1); + wchar_t wsLast = wsText[wsText.GetLength() - 1]; if (wsLast == wcEnter) wsText = wsText + wcEnter; diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp index 9028642b76..5912d26a99 100644 --- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp @@ -3488,17 +3488,17 @@ CFX_WideString CXFA_FM2JSContext::EncodeURL(const CFX_ByteString& szURLString) { int32_t iIndex = 0; if (iLen % 2 != 0) { strEncode[1] = '0'; - strEncode[2] = strTmp.GetAt(iLen - 1); + strEncode[2] = strTmp[iLen - 1]; iIndex = iLen - 2; } else { - strEncode[1] = strTmp.GetAt(iLen - 1); - strEncode[2] = strTmp.GetAt(iLen - 2); + strEncode[1] = strTmp[iLen - 1]; + strEncode[2] = strTmp[iLen - 2]; iIndex = iLen - 3; } wsResultBuf << strEncode; while (iIndex > 0) { - strEncode[1] = strTmp.GetAt(iIndex); - strEncode[2] = strTmp.GetAt(iIndex - 1); + strEncode[1] = strTmp[iIndex]; + strEncode[2] = strTmp[iIndex - 1]; iIndex -= 2; wsResultBuf << strEncode; } @@ -3994,8 +3994,8 @@ void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, std::ostringstream resultString; int32_t iFindIndex = 0; for (int32_t u = 0; u < oneString.GetLength(); ++u) { - char ch = static_cast(oneString.GetAt(u)); - if (ch != static_cast(twoString.GetAt(iFindIndex))) { + char ch = static_cast(oneString[u]); + if (ch != static_cast(twoString[iFindIndex])) { resultString << ch; continue; } @@ -4003,8 +4003,8 @@ void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, int32_t iTemp = u + 1; ++iFindIndex; while (iFindIndex < iFindLen) { - uint8_t chTemp = oneString.GetAt(iTemp); - if (chTemp != twoString.GetAt(iFindIndex)) { + uint8_t chTemp = oneString[iTemp]; + if (chTemp != twoString[iFindIndex]) { iFindIndex = 0; break; } @@ -4246,13 +4246,13 @@ void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, std::ostringstream resultString; int32_t i = 0; while (i < iStart) { - resultString << static_cast(sourceString.GetAt(i)); + resultString << static_cast(sourceString[i]); ++i; } resultString << insertString.AsStringC(); i = iStart + iDelete; while (i < iLength) { - resultString << static_cast(sourceString.GetAt(i)); + resultString << static_cast(sourceString[i]); ++i; } resultString << '\0'; diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp index c6b5814d6d..e323a330dc 100644 --- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp @@ -72,7 +72,7 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { for (const auto& identifier : m_pArguments) { if (bNeedComma) javascript << L", "; - if (identifier.GetAt(0) == L'!') { + if (identifier[0] == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + identifier.Right(identifier.GetLength() - 1); @@ -128,7 +128,7 @@ CXFA_FMVarExpression::~CXFA_FMVarExpression() {} bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"var "; CFX_WideString tempName(m_wsName); - if (m_wsName.GetAt(0) == L'!') { + if (m_wsName[0] == L'!') { tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1); } @@ -152,7 +152,7 @@ bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { bool CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L"var "; CFX_WideString tempName(m_wsName); - if (m_wsName.GetAt(0) == L'!') { + if (m_wsName[0] == L'!') { tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Right(m_wsName.GetLength() - 1); } @@ -459,7 +459,7 @@ CXFA_FMForExpression::~CXFA_FMForExpression() {} bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"{\nvar "; CFX_WideString tempVariant; - if (m_wsVariant.GetAt(0) == L'!') { + if (m_wsVariant[0] == L'!') { tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Right(m_wsVariant.GetLength() - 1); javascript << tempVariant; @@ -514,7 +514,7 @@ bool CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L" = 0;\n"; javascript << L"{\nvar "; CFX_WideString tempVariant; - if (m_wsVariant.GetAt(0) == L'!') { + if (m_wsVariant[0] == L'!') { tempVariant = EXCLAMATION_IN_IDENTIFIER + m_wsVariant.Right(m_wsVariant.GetLength() - 1); javascript << tempVariant; @@ -580,7 +580,7 @@ CXFA_FMForeachExpression::~CXFA_FMForeachExpression() {} bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L"{\n"; javascript << L"var "; - if (m_wsIdentifier.GetAt(0) == L'!') { + if (m_wsIdentifier[0] == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1); @@ -612,7 +612,7 @@ bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << L" < "; javascript << RUNTIMEBLOCKTEMPARRAY; javascript << L".length)\n{\n"; - if (m_wsIdentifier.GetAt(0) == L'!') { + if (m_wsIdentifier[0] == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1); @@ -637,7 +637,7 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L" = 0;\n"; javascript << L"{\n"; javascript << L"var "; - if (m_wsIdentifier.GetAt(0) == L'!') { + if (m_wsIdentifier[0] == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1); @@ -668,7 +668,7 @@ bool CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << L" < "; javascript << RUNTIMEBLOCKTEMPARRAY; javascript << L".length)\n{\n"; - if (m_wsIdentifier.GetAt(0) == L'!') { + if (m_wsIdentifier[0] == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1); diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index ff9e981e9f..b502bbdfa7 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -58,7 +58,7 @@ CFX_WideString ExportEncodeContent(const CFX_WideStringC& str) { CFX_WideTextBuf textBuf; int32_t iLen = str.GetLength(); for (int32_t i = 0; i < iLen; i++) { - wchar_t ch = str.GetAt(i); + wchar_t ch = str[i]; if (!IsXMLValidChar(ch)) continue; @@ -73,13 +73,13 @@ CFX_WideString ExportEncodeContent(const CFX_WideStringC& str) { } else if (ch == '\"') { textBuf << L"""; } else if (ch == ' ') { - if (i && str.GetAt(i - 1) != ' ') { + if (i && str[i - 1] != ' ') { textBuf.AppendChar(' '); } else { textBuf << L" "; } } else { - textBuf.AppendChar(str.GetAt(i)); + textBuf.AppendChar(str[i]); } } return textBuf.MakeString(); diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 55851bb34a..e643bc502f 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -160,7 +160,7 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, return nullptr; bTargetAllFind = false; - if (wsExpr.GetAt(0) == '#') { + if (wsExpr[0] == '#') { CXFA_Node* pNode = pDocument->GetNodeByID( ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), wsExpr.Right(wsExpr.GetLength() - 1).AsStringC()); diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp index 633f4b41fd..833f72c33f 100644 --- a/xfa/fxfa/parser/cxfa_localemgr.cpp +++ b/xfa/fxfa/parser/cxfa_localemgr.cpp @@ -1083,10 +1083,9 @@ static uint16_t XFA_GetLanguage(CFX_WideString wsLanguage) { return FX_LANG_en_US; wsLanguage.MakeLower(); - uint32_t dwIDFirst = wsLanguage.GetAt(0) << 8 | wsLanguage.GetAt(1); - uint32_t dwIDSecond = wsLanguage.GetLength() >= 5 - ? wsLanguage.GetAt(3) << 8 | wsLanguage.GetAt(4) - : 0; + uint32_t dwIDFirst = wsLanguage[0] << 8 | wsLanguage[1]; + uint32_t dwIDSecond = + wsLanguage.GetLength() >= 5 ? wsLanguage[3] << 8 | wsLanguage[4] : 0; switch (dwIDFirst) { case FXBSTR_ID(0, 0, 'z', 'h'): if (dwIDSecond == FXBSTR_ID(0, 0, 'c', 'n')) diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp index 66b715ec38..1c427209f9 100644 --- a/xfa/fxfa/parser/cxfa_measurement.cpp +++ b/xfa/fxfa/parser/cxfa_measurement.cpp @@ -37,7 +37,7 @@ void CXFA_Measurement::SetString(const CFX_WideStringC& wsMeasure) { return; } int32_t iUsedLen = 0; - int32_t iOffset = (wsMeasure.GetAt(0) == L'=') ? 1 : 0; + int32_t iOffset = (wsMeasure[0] == L'=') ? 1 : 0; float fValue = FXSYS_wcstof(wsMeasure.unterminated_c_str() + iOffset, wsMeasure.GetLength() - iOffset, &iUsedLen); XFA_UNIT eUnit = GetUnitFromString( diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 8497e60a74..2b4bdd22c0 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -76,7 +76,7 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) { if (iCount == 0) { CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || + if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' || wsInstName.Right(wsInstName.GetLength() - 1) != wsName) { return iCount; } @@ -197,7 +197,7 @@ CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) { if (iCount == 0) { CFX_WideStringC wsName = pNode->GetCData(XFA_ATTRIBUTE_Name); CFX_WideStringC wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstName.GetLength() < 1 || wsInstName.GetAt(0) != '_' || + if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' || wsInstName.Right(wsInstName.GetLength() - 1) != wsName) { return nullptr; } @@ -406,7 +406,7 @@ void StrToRGB(const CFX_WideString& strRGB, int32_t iIndex = 0; int32_t iLen = strRGB.GetLength(); for (int32_t i = 0; i < iLen; ++i) { - wchar_t ch = strRGB.GetAt(i); + wchar_t ch = strRGB[i]; if (ch == L',') ++iIndex; if (iIndex > 2) @@ -2736,7 +2736,7 @@ void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { if (pNode->GetElementType() == XFA_Element::InstanceManager) { CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && + if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName[0] == '_' && wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) { pInstanceMgr = pNode; } @@ -4664,7 +4664,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { if (eType == XFA_Element::InstanceManager) { CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); CFX_WideStringC wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name); - if (wsInstName.GetLength() > 0 && wsInstName.GetAt(0) == '_' && + if (wsInstName.GetLength() > 0 && wsInstName[0] == '_' && wsInstName.Right(wsInstName.GetLength() - 1) == wsName) { pInstanceMgr = pNode; } diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp index 547831caca..4f1ed04fe3 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.cpp +++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp @@ -283,7 +283,7 @@ bool CXFA_NodeHelper::CreateNode_ForCondition(CFX_WideString& wsCondition) { m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; return false; } - if (wsCondition.GetAt(0) == '[') { + if (wsCondition[0] == '[') { int32_t i = 1; for (; i < iLen; ++i) { wchar_t ch = wsCondition[i]; @@ -323,12 +323,12 @@ bool CXFA_NodeHelper::ResolveNodes_CreateNode( } bool bIsClassName = false; bool bResult = false; - if (wsName.GetAt(0) == '!') { + if (wsName[0] == '!') { wsName = wsName.Right(wsName.GetLength() - 1); m_pCreateParent = ToNode( pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); } - if (wsName.GetAt(0) == '#') { + if (wsName[0] == '#') { bIsClassName = true; wsName = wsName.Right(wsName.GetLength() - 1); } diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp index 93b2d86061..9edb3bce81 100644 --- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp @@ -41,7 +41,7 @@ int32_t CXFA_ResolveProcessor::Resolve(CXFA_ResolveNodesData& rnd) { if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) { return ResolveAnyChild(rnd); } - wchar_t wch = rnd.m_wsName.GetAt(0); + wchar_t wch = rnd.m_wsName[0]; switch (wch) { case '$': return ResolveDollar(rnd); @@ -89,7 +89,7 @@ int32_t CXFA_ResolveProcessor::ResolveAnyChild(CXFA_ResolveNodesData& rnd) { CFX_WideString wsCondition = rnd.m_wsCondition; CXFA_Node* findNode = nullptr; bool bClassName = false; - if (wsName.GetAt(0) == '#') { + if (wsName[0] == '#') { bClassName = true; wsName = wsName.Right(wsName.GetLength() - 1); } diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp index 115cd5651e..57caa9981b 100644 --- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp +++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp @@ -340,7 +340,7 @@ void CXFA_ScriptContext::NormalPropertySetter(CFXJSE_Value* pOriginalValue, pReturnValue, true, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); } else { if (pObject->IsNode()) { - if (wsPropName.GetAt(0) == '#') { + if (wsPropName[0] == '#') { wsPropName = wsPropName.Right(wsPropName.GetLength() - 1); } CXFA_Node* pNode = ToNode(pObject); diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index d68a907e18..5b9f62c93f 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -1215,7 +1215,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(char* val) { CFX_WideStringC wsStartEndChar; if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) { if (wsStartEndChar.GetLength()) { - *val = static_cast(wsStartEndChar.GetAt(0)); + *val = static_cast(wsStartEndChar[0]); return true; } } @@ -1227,7 +1227,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_EndChar(char* val) { CFX_WideStringC wsStartEndChar; if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) { if (wsStartEndChar.GetLength()) { - *val = static_cast(wsStartEndChar.GetAt(0)); + *val = static_cast(wsStartEndChar[0]); return true; } } -- cgit v1.2.3