diff options
author | tsepez <tsepez@chromium.org> | 2016-04-14 13:42:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-14 13:42:44 -0700 |
commit | 8e4c505ff6d82263183e9f812fcc7b45c1414f15 (patch) | |
tree | 765e0f3a18f9ad60dde74431846d770fecdcdb37 /core | |
parent | 3bac505132235c009b4b79aa4ac238afad5366e8 (diff) | |
download | pdfium-8e4c505ff6d82263183e9f812fcc7b45c1414f15.tar.xz |
Rename CFX_ByteTextBuf::GetByteString() to AsStringC().
Do the same for CFX_WideTextBuf as well.
The name is confusing because these return CFX_ByteStringC,
not CFX_ByteString. The AsStringC naming gives parallelism with
the string types themselves, and may help to indicate that
the result is only good for the lifetime of the object being
operated upon.
Review URL: https://codereview.chromium.org/1886263003
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 4 | ||||
-rw-r--r-- | core/fpdfdoc/cpvt_generateap.cpp | 16 | ||||
-rw-r--r-- | core/fpdftext/fpdf_text_int.cpp | 21 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_buffer.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/fx_xml_parser.cpp | 10 | ||||
-rw-r--r-- | core/fxcrt/include/fx_basic.h | 8 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_fontmap.cpp | 4 |
9 files changed, 40 insertions, 41 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 940881bacb..cf29aa2684 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -562,7 +562,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() { if (buf.GetLength() > MAX_STRING_LENGTH) { return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH); } - return buf.GetByteString(); + return buf.AsStringC(); } parlevel--; buf.AppendChar(')'); @@ -641,7 +641,7 @@ CFX_ByteString CPDF_StreamParser::ReadString() { if (buf.GetLength() > MAX_STRING_LENGTH) { return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH); } - return buf.GetByteString(); + return buf.AsStringC(); } CFX_ByteString CPDF_StreamParser::ReadHexString() { @@ -675,7 +675,7 @@ CFX_ByteString CPDF_StreamParser::ReadHexString() { if (buf.GetLength() > MAX_STRING_LENGTH) return CFX_ByteString(buf.GetBuffer(), MAX_STRING_LENGTH); - return buf.GetByteString(); + return buf.AsStringC(); } bool CPDF_StreamParser::PositionIsInBounds() const { diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index 5c3398d50a..889b58e928 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -218,7 +218,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() { case 0: if (ch == ')') { if (parlevel == 0) { - return buf.GetByteString(); + return buf.AsStringC(); } parlevel--; buf.AppendChar(')'); @@ -291,7 +291,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadString() { } GetNextChar(ch); - return buf.GetByteString(); + return buf.AsStringC(); } CFX_ByteString CPDF_SyntaxParser::ReadHexString() { @@ -323,7 +323,7 @@ CFX_ByteString CPDF_SyntaxParser::ReadHexString() { if (!bFirst) buf.AppendByte(code); - return buf.GetByteString(); + return buf.AsStringC(); } void CPDF_SyntaxParser::ToNextLine() { diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 5e71002d4d..5f8d425b96 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -530,7 +530,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { result.AppendChar("0123456789ABCDEF"[src[i] % 16]); } result.AppendChar('>'); - return result.GetByteString(); + return result.AsStringC(); } result.AppendChar('('); for (int i = 0; i < srclen; i++) { @@ -547,7 +547,7 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex) { result.AppendChar(ch); } result.AppendChar(')'); - return result.GetByteString(); + return result.AsStringC(); } void FlateEncode(const uint8_t* src_buf, diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 06a64359e9..ec1b9fbf4e 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -418,7 +418,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, << "q\n"; sAppStream << rcBody.left << " " << rcBody.bottom << " " << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n"; - sAppStream << sBody.GetByteString() << "Q\nEMC\n"; + sAppStream << sBody.AsStringC() << "Q\nEMC\n"; } } break; } @@ -523,7 +523,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( if (bContinuous) { if (place.LineCmp(oldplace) != 0) { if (sWords.GetSize() > 0) { - sLineStream << GetWordRenderString(sWords.GetByteString()); + sLineStream << GetWordRenderString(sWords.AsStringC()); sEditStream << sLineStream; sLineStream.Clear(); sWords.Clear(); @@ -548,7 +548,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( if (pIterator->GetWord(word)) { if (word.nFontIndex != nCurFontIndex) { if (sWords.GetSize() > 0) { - sLineStream << GetWordRenderString(sWords.GetByteString()); + sLineStream << GetWordRenderString(sWords.AsStringC()); sWords.Clear(); } sLineStream << GetFontSetString(pFontMap, word.nFontIndex, @@ -580,12 +580,12 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( } } if (sWords.GetSize() > 0) { - sLineStream << GetWordRenderString(sWords.GetByteString()); + sLineStream << GetWordRenderString(sWords.AsStringC()); sEditStream << sLineStream; sWords.Clear(); } } - return sEditStream.GetByteString(); + return sEditStream.AsStringC(); } // Static. @@ -693,7 +693,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( break; } } - return sAppStream.GetByteString(); + return sAppStream.AsStringC(); } // Static. @@ -718,7 +718,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, case CPVT_Color::kTransparent: break; } - return sColorStream.GetByteString(); + return sColorStream.AsStringC(); } // Static. @@ -766,5 +766,5 @@ CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap, if (sFontAlias.GetLength() > 0 && fFontSize > 0) sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; } - return sRet.GetByteString(); + return sRet.AsStringC(); } diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp index 8de65cb07a..8e8686c4a1 100644 --- a/core/fpdftext/fpdf_text_int.cpp +++ b/core/fpdftext/fpdf_text_int.cpp @@ -512,8 +512,7 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const { if (nCount == -1) { nCount = pdfium::CollectionSize<int>(m_CharList) - start; - return m_TextBuf.GetWideString().Mid(start, - m_TextBuf.GetWideString().GetLength()); + return m_TextBuf.AsStringC().Mid(start, m_TextBuf.AsStringC().GetLength()); } if (nCount <= 0 || m_CharList.empty()) { return L""; @@ -550,7 +549,7 @@ CFX_WideString CPDF_TextPage::GetPageText(int start, int nCount) const { if (nCount <= 0) { return L""; } - return m_TextBuf.GetWideString().Mid(startindex, nCount); + return m_TextBuf.AsStringC().Mid(startindex, nCount); } int CPDF_TextPage::CountRects(int start, int nCount) { @@ -987,7 +986,7 @@ void CPDF_TextPage::CloseTempLine() { if (m_TempCharList.empty()) return; - CFX_WideString str = m_TempTextBuf.GetWideString(); + CFX_WideString str = m_TempTextBuf.AsStringC(); FX_BOOL bPrevSpace = FALSE; for (int i = 0; i < str.GetLength(); i++) { if (str.GetAt(i) != ' ') { @@ -1353,8 +1352,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { } } while (m_TempTextBuf.GetSize() > 0 && - m_TempTextBuf.GetWideString().GetAt(m_TempTextBuf.GetLength() - - 1) == 0x20) { + m_TempTextBuf.AsStringC().GetAt(m_TempTextBuf.GetLength() - 1) == + 0x20) { m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); m_TempCharList.pop_back(); } @@ -1395,9 +1394,9 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_OriginY = 0; pTextObj->GetItemInfo(i, &item); if (item.m_CharCode == (uint32_t)-1) { - CFX_WideString str = m_TempTextBuf.GetWideString(); + CFX_WideString str = m_TempTextBuf.AsStringC(); if (str.IsEmpty()) { - str = m_TextBuf.GetWideString(); + str = m_TextBuf.AsStringC(); } if (str.IsEmpty() || str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) { continue; @@ -1531,7 +1530,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { m_TempCharList.push_back(charinfo); } } else if (i == 0) { - CFX_WideString str = m_TempTextBuf.GetWideString(); + CFX_WideString str = m_TempTextBuf.AsStringC(); if (!str.IsEmpty() && str.GetAt(str.GetLength() - 1) == TEXT_BLANK_CHAR) { m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1); @@ -1574,9 +1573,9 @@ int32_t CPDF_TextPage::GetTextObjectWritingMode( return m_TextlineDir; } FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) { - CFX_WideString strCurText = m_TempTextBuf.GetWideString(); + CFX_WideString strCurText = m_TempTextBuf.AsStringC(); if (strCurText.GetLength() == 0) { - strCurText = m_TextBuf.GetWideString(); + strCurText = m_TextBuf.AsStringC(); } FX_STRSIZE nCount = strCurText.GetLength(); int nIndex = nCount - 1; diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index 1e5d0554d1..338edc16c9 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -100,7 +100,7 @@ void CFX_BinaryBuf::InsertBlock(FX_STRSIZE pos, m_DataSize += size; } -CFX_ByteStringC CFX_ByteTextBuf::GetByteString() const { +CFX_ByteStringC CFX_ByteTextBuf::AsStringC() const { return CFX_ByteStringC(m_pBuffer.get(), m_DataSize); } @@ -186,8 +186,8 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideTextBuf& buf) { return *this; } -CFX_WideStringC CFX_WideTextBuf::GetWideString() const { - return CFX_WideStringC((const FX_WCHAR*)m_pBuffer.get(), +CFX_WideStringC CFX_WideTextBuf::AsStringC() const { + return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()), m_DataSize / sizeof(FX_WCHAR)); } diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index b4df4d0532..4b52189142 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -132,7 +132,7 @@ void CXML_Parser::GetName(CFX_ByteString& space, CFX_ByteString& name) { while (m_dwIndex < m_dwBufferSize) { ch = m_pBuffer[m_dwIndex]; if (ch == ':') { - space = buf.GetByteString(); + space = buf.AsStringC(); buf.Clear(); } else if (g_FXCRT_XML_IsNameChar(ch)) { buf.AppendChar(ch); @@ -146,7 +146,7 @@ void CXML_Parser::GetName(CFX_ByteString& space, CFX_ByteString& name) { break; } } while (ReadNextBlock()); - name = buf.GetByteString(); + name = buf.AsStringC(); } void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; @@ -202,7 +202,7 @@ uint32_t CXML_Parser::GetCharRef() { case 1: m_dwIndex++; if (ch == ';') { - CFX_ByteStringC ref = buf.GetByteString(); + CFX_ByteStringC ref = buf.AsStringC(); if (ref == "gt") { code = '>'; } else if (ref == "lt") { @@ -457,7 +457,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, iState = 10; } else { content << decoder.GetResult(); - CFX_WideString dataStr = content.GetWideString(); + CFX_WideString dataStr = content.AsStringC(); if (!bCDATA && !m_bSaveSpaceChars) { dataStr.TrimRight(L" \t\r\n"); } @@ -501,7 +501,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, } } while (ReadNextBlock()); content << decoder.GetResult(); - CFX_WideString dataStr = content.GetWideString(); + CFX_WideString dataStr = content.AsStringC(); if (!m_bSaveSpaceChars) { dataStr.TrimRight(L" \t\r\n"); } diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 1b64a5924f..5a577c2e54 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -58,7 +58,7 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf { public: void AppendChar(int ch) { AppendByte((uint8_t)ch); } FX_STRSIZE GetLength() const { return m_DataSize; } - CFX_ByteStringC GetByteString() const; + CFX_ByteStringC AsStringC() const; CFX_ByteTextBuf& operator<<(int i); CFX_ByteTextBuf& operator<<(uint32_t i); @@ -80,7 +80,7 @@ class CFX_WideTextBuf : public CFX_BinaryBuf { FX_WCHAR* GetBuffer() const { return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get()); } - CFX_WideStringC GetWideString() const; + CFX_WideStringC AsStringC() const; void Delete(int start_index, int count) { CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), @@ -206,7 +206,7 @@ class CFX_UTF8Decoder { void ClearStatus() { m_PendingBytes = 0; } - CFX_WideStringC GetResult() const { return m_Buffer.GetWideString(); } + CFX_WideStringC GetResult() const { return m_Buffer.AsStringC(); } protected: int m_PendingBytes; @@ -222,7 +222,7 @@ class CFX_UTF8Encoder { void Input(FX_WCHAR unicode); void AppendStr(const CFX_ByteStringC& str) { m_Buffer << str; } - CFX_ByteStringC GetResult() const { return m_Buffer.GetByteString(); } + CFX_ByteStringC GetResult() const { return m_Buffer.AsStringC(); } protected: CFX_ByteTextBuf m_Buffer; diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 194f91034d..8524660043 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -317,7 +317,7 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { CFX_ByteTextBuf buf; if (!iLen || iLen <= iIndex) { - return buf.GetByteString(); + return buf.AsStringC(); } while (iIndex < iLen) { if (pStyle[iIndex] == ',') { @@ -326,7 +326,7 @@ CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { buf.AppendChar(pStyle[iIndex]); ++iIndex; } - return buf.GetByteString(); + return buf.AsStringC(); } int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { |