From 4c3debb3c91f5842784be30a911b52cdabcab7df Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 8 Apr 2016 12:20:38 -0700 Subject: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). The naming is redundant given the base type, and will stand in the way of consolidating Byte and Wide code. BUG= Review URL: https://codereview.chromium.org/1862123003 --- core/fxcrt/fx_basic_bstring.cpp | 2 +- core/fxcrt/fx_basic_buffer.cpp | 2 +- core/fxcrt/fx_xml_parser.cpp | 13 ++++++------- core/fxcrt/fxcrt_posix.cpp | 2 +- core/fxcrt/include/fx_basic.h | 2 +- core/fxcrt/include/fx_string.h | 32 ++++++++++++++++---------------- 6 files changed, 26 insertions(+), 27 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index 34abe1e067..5b9c683c53 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -810,7 +810,7 @@ CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, // static CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) { - return CFX_CharMap::GetByteString(0, str.AsWideStringC()); + return CFX_CharMap::GetByteString(0, str.AsStringC()); } int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index 8553474914..7f85c95d3f 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -248,7 +248,7 @@ CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const FX_WCHAR* wstr) { } CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const CFX_WideString& wstr) { CFX_ByteString encoded = wstr.UTF16LE_Encode(); - return operator<<(encoded.AsByteStringC()); + return operator<<(encoded.AsStringC()); } void CFX_ArchiveSaver::Write(const void* pData, FX_STRSIZE dwSize) { if (m_pStream) { diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index d59a6b9780..b4df4d0532 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -371,7 +371,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, } CXML_Element* pElement = new CXML_Element; pElement->m_pParent = pParent; - pElement->SetTag(tag_space.AsByteStringC(), tag_name.AsByteStringC()); + pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC()); do { CFX_ByteString attr_space, attr_name; while (m_dwIndex < m_dwBufferSize) { @@ -397,9 +397,8 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, } CFX_WideString attr_value; GetAttrValue(attr_value); - pElement->m_AttrMap.SetAt(attr_space.AsByteStringC(), - attr_name.AsByteStringC(), - attr_value.AsWideStringC()); + pElement->m_AttrMap.SetAt(attr_space.AsStringC(), attr_name.AsStringC(), + attr_value.AsStringC()); } m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (m_dwIndex < m_dwBufferSize || IsEOF()) { @@ -462,7 +461,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, if (!bCDATA && !m_bSaveSpaceChars) { dataStr.TrimRight(L" \t\r\n"); } - InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement); + InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); content.Clear(); decoder.Clear(); bCDATA = FALSE; @@ -506,7 +505,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, if (!m_bSaveSpaceChars) { dataStr.TrimRight(L" \t\r\n"); } - InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement); + InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); content.Clear(); decoder.Clear(); bCDATA = FALSE; @@ -602,7 +601,7 @@ CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const { if (bQualified) { return m_QSpaceName; } - return GetNamespaceURI(m_QSpaceName.AsByteStringC()); + return GetNamespaceURI(m_QSpaceName.AsStringC()); } CFX_ByteString CXML_Element::GetNamespaceURI( const CFX_ByteStringC& qName) const { diff --git a/core/fxcrt/fxcrt_posix.cpp b/core/fxcrt/fxcrt_posix.cpp index a18bb69c55..9237acef6b 100644 --- a/core/fxcrt/fxcrt_posix.cpp +++ b/core/fxcrt/fxcrt_posix.cpp @@ -45,7 +45,7 @@ FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName, } FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName, uint32_t dwMode) { - return Open(FX_UTF8Encode(fileName).AsByteStringC(), dwMode); + return Open(FX_UTF8Encode(fileName).AsStringC(), dwMode); } void CFXCRT_FileAccess_Posix::Close() { if (m_nFD < 0) { diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 1cb5174351..1b64a5924f 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -67,7 +67,7 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf { return *this << CFX_ByteStringC(pStr); } CFX_ByteTextBuf& operator<<(const CFX_ByteString& str) { - return *this << str.AsByteStringC(); + return *this << str.AsStringC(); } CFX_ByteTextBuf& operator<<(const CFX_ByteStringC& lpsz); CFX_ByteTextBuf& operator<<(const CFX_ByteTextBuf& buf); diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index 6e2954fcbb..5e3cb45fba 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -188,7 +188,7 @@ class CFX_ByteString { // Explicit conversion to CFX_ByteStringC. // Note: |this| must outlive the use of the result. - CFX_ByteStringC AsByteStringC() const { + CFX_ByteStringC AsStringC() const { return CFX_ByteStringC(raw_str(), GetLength()); } @@ -332,29 +332,29 @@ inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteStringC& str2) { } inline CFX_ByteString operator+(const CFX_ByteString& str1, const CFX_ByteString& str2) { - return CFX_ByteString(str1.AsByteStringC(), str2.AsByteStringC()); + return CFX_ByteString(str1.AsStringC(), str2.AsStringC()); } inline CFX_ByteString operator+(const CFX_ByteString& str1, FX_CHAR ch) { - return CFX_ByteString(str1.AsByteStringC(), CFX_ByteStringC(ch)); + return CFX_ByteString(str1.AsStringC(), CFX_ByteStringC(ch)); } inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteString& str2) { - return CFX_ByteString(ch, str2.AsByteStringC()); + return CFX_ByteString(ch, str2.AsStringC()); } inline CFX_ByteString operator+(const CFX_ByteString& str1, const FX_CHAR* str2) { - return CFX_ByteString(str1.AsByteStringC(), str2); + return CFX_ByteString(str1.AsStringC(), str2); } inline CFX_ByteString operator+(const FX_CHAR* str1, const CFX_ByteString& str2) { - return CFX_ByteString(str1, str2.AsByteStringC()); + return CFX_ByteString(str1, str2.AsStringC()); } inline CFX_ByteString operator+(const CFX_ByteString& str1, const CFX_ByteStringC& str2) { - return CFX_ByteString(str1.AsByteStringC(), str2); + return CFX_ByteString(str1.AsStringC(), str2); } inline CFX_ByteString operator+(const CFX_ByteStringC& str1, const CFX_ByteString& str2) { - return CFX_ByteString(str1, str2.AsByteStringC()); + return CFX_ByteString(str1, str2.AsStringC()); } class CFX_WideStringC { @@ -512,7 +512,7 @@ class CFX_WideString { // Explicit conversion to CFX_WideStringC. // Note: |this| must outlive the use of the result. - CFX_WideStringC AsWideStringC() const { + CFX_WideStringC AsStringC() const { return CFX_WideStringC(c_str(), GetLength()); } @@ -641,29 +641,29 @@ inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideStringC& str2) { } inline CFX_WideString operator+(const CFX_WideString& str1, const CFX_WideString& str2) { - return CFX_WideString(str1.AsWideStringC(), str2.AsWideStringC()); + return CFX_WideString(str1.AsStringC(), str2.AsStringC()); } inline CFX_WideString operator+(const CFX_WideString& str1, FX_WCHAR ch) { - return CFX_WideString(str1.AsWideStringC(), CFX_WideStringC(ch)); + return CFX_WideString(str1.AsStringC(), CFX_WideStringC(ch)); } inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideString& str2) { - return CFX_WideString(ch, str2.AsWideStringC()); + return CFX_WideString(ch, str2.AsStringC()); } inline CFX_WideString operator+(const CFX_WideString& str1, const FX_WCHAR* str2) { - return CFX_WideString(str1.AsWideStringC(), str2); + return CFX_WideString(str1.AsStringC(), str2); } inline CFX_WideString operator+(const FX_WCHAR* str1, const CFX_WideString& str2) { - return CFX_WideString(str1, str2.AsWideStringC()); + return CFX_WideString(str1, str2.AsStringC()); } inline CFX_WideString operator+(const CFX_WideString& str1, const CFX_WideStringC& str2) { - return CFX_WideString(str1.AsWideStringC(), str2); + return CFX_WideString(str1.AsStringC(), str2); } inline CFX_WideString operator+(const CFX_WideStringC& str1, const CFX_WideString& str2) { - return CFX_WideString(str1, str2.AsWideStringC()); + return CFX_WideString(str1, str2.AsStringC()); } inline bool operator==(const wchar_t* lhs, const CFX_WideString& rhs) { return rhs == lhs; -- cgit v1.2.3