summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-05 12:22:15 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-05 12:22:15 -0700
commitfc58ad18b7ab32e7b0bb3959b07dbe7538a7cebd (patch)
tree8662b886d373b149fbdd6f5db9570c233cb23ce7 /core/fxcrt
parentc7a7349cf316af37d4ad4b71c5742159deccbf33 (diff)
downloadpdfium-fc58ad18b7ab32e7b0bb3959b07dbe7538a7cebd.tar.xz
Make down-conversion explicit from CFX_Widetring to CFX_WideStringC.
Companion to https://codereview.chromium.org/1853233002 BUG= Review URL: https://codereview.chromium.org/1857073002
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_xml_parser.cpp7
-rw-r--r--core/fxcrt/include/fx_string.h30
2 files changed, 20 insertions, 17 deletions
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index b39c32bfbd..d59a6b9780 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -398,7 +398,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);
+ attr_name.AsByteStringC(),
+ attr_value.AsWideStringC());
}
m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
if (m_dwIndex < m_dwBufferSize || IsEOF()) {
@@ -461,7 +462,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
if (!bCDATA && !m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
- InsertContentSegment(bCDATA, dataStr, pElement);
+ InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement);
content.Clear();
decoder.Clear();
bCDATA = FALSE;
@@ -505,7 +506,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
if (!m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
- InsertContentSegment(bCDATA, dataStr, pElement);
+ InsertContentSegment(bCDATA, dataStr.AsWideStringC(), pElement);
content.Clear();
decoder.Clear();
bCDATA = FALSE;
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index d48b26c30f..9373b058ee 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -431,8 +431,6 @@ class CFX_WideStringC {
m_Length = src.m_Length;
}
- CFX_WideStringC(const CFX_WideString& src);
-
CFX_WideStringC& operator=(const FX_WCHAR* src) {
m_Ptr = src;
m_Length = FXSYS_wcslen(src);
@@ -557,13 +555,20 @@ class CFX_WideString {
static FX_STRSIZE WStringLength(const unsigned short* str);
// Explicit conversion to C-style wide string.
+ // Note: |this| must outlive the use of the result.
const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; }
// Implicit conversion to C-style wide string -- deprecated.
+ // Note: |this| must outlive the use of the result.
operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; }
- void Empty();
+ // Explicit conversion to CFX_WideStringC.
+ // Note: |this| must outlive the use of the result.
+ CFX_WideStringC AsWideStringC() const {
+ return CFX_WideStringC(c_str(), GetLength());
+ }
+ void Empty();
bool IsEmpty() const { return !GetLength(); }
FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
@@ -685,10 +690,7 @@ class CFX_WideString {
StringData* m_pData;
friend class fxcrt_WideStringConcatInPlace_Test;
};
-inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) {
- m_Ptr = src.c_str();
- m_Length = src.GetLength();
-}
+
inline CFX_WideStringC& CFX_WideStringC::operator=(const CFX_WideString& src) {
m_Ptr = src.c_str();
m_Length = src.GetLength();
@@ -715,29 +717,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, str2);
+ return CFX_WideString(str1.AsWideStringC(), str2.AsWideStringC());
}
inline CFX_WideString operator+(const CFX_WideString& str1, FX_WCHAR ch) {
- return CFX_WideString(str1, CFX_WideStringC(ch));
+ return CFX_WideString(str1.AsWideStringC(), CFX_WideStringC(ch));
}
inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideString& str2) {
- return CFX_WideString(ch, str2);
+ return CFX_WideString(ch, str2.AsWideStringC());
}
inline CFX_WideString operator+(const CFX_WideString& str1,
const FX_WCHAR* str2) {
- return CFX_WideString(str1, str2);
+ return CFX_WideString(str1.AsWideStringC(), str2);
}
inline CFX_WideString operator+(const FX_WCHAR* str1,
const CFX_WideString& str2) {
- return CFX_WideString(str1, str2);
+ return CFX_WideString(str1, str2.AsWideStringC());
}
inline CFX_WideString operator+(const CFX_WideString& str1,
const CFX_WideStringC& str2) {
- return CFX_WideString(str1, str2);
+ return CFX_WideString(str1.AsWideStringC(), str2);
}
inline CFX_WideString operator+(const CFX_WideStringC& str1,
const CFX_WideString& str2) {
- return CFX_WideString(str1, str2);
+ return CFX_WideString(str1, str2.AsWideStringC());
}
inline bool operator==(const wchar_t* lhs, const CFX_WideString& rhs) {
return rhs == lhs;