Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1208)

Unified Diff: core/fxcrt/include/fx_string.h

Issue 1857073002: Make down-conversion explicit from CFX_Widetring to CFX_WideStringC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: String argument type Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxcrt/fx_xml_parser.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/include/fx_string.h
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index d48b26c30ff8594674aa59721bbf4a48f798f473..9373b058eeea1eec36efbc5be809b72b4a2f3859 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;
« no previous file with comments | « core/fxcrt/fx_xml_parser.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698