summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/doc_basic.cpp2
-rw-r--r--core/fxcrt/fx_xml_parser.cpp7
-rw-r--r--core/fxcrt/include/fx_string.h30
3 files changed, 21 insertions, 18 deletions
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index ad21db815c..2555d4839b 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -335,7 +335,7 @@ bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const {
} else {
return false;
}
- *csFileName = DecodeFileName(*csFileName);
+ *csFileName = DecodeFileName(csFileName->AsWideStringC());
return true;
}
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;