Index: core/fxcrt/fx_basic_wstring.cpp |
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp |
index ba86823fe23fd8ae7472f4b0aa1dc618fc9b1b6d..4cfb134610872b0348a33a5badc940798b23e862 100644 |
--- a/core/fxcrt/fx_basic_wstring.cpp |
+++ b/core/fxcrt/fx_basic_wstring.cpp |
@@ -71,11 +71,23 @@ CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) { |
m_pData.Reset(StringData::Create(pStr, nLen)); |
} |
+CFX_WideString::CFX_WideString() {} |
+ |
+CFX_WideString::CFX_WideString(const CFX_WideString& other) |
+ : m_pData(other.m_pData) {} |
+ |
+CFX_WideString::CFX_WideString(CFX_WideString&& other) { |
+ m_pData.Swap(other.m_pData); |
+} |
+ |
CFX_WideString::CFX_WideString(FX_WCHAR ch) { |
m_pData.Reset(StringData::Create(1)); |
m_pData->m_String[0] = ch; |
} |
+CFX_WideString::CFX_WideString(const FX_WCHAR* ptr) |
+ : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {} |
+ |
CFX_WideString::CFX_WideString(const CFX_WideStringC& stringSrc) { |
if (!stringSrc.IsEmpty()) { |
m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength())); |
@@ -179,6 +191,32 @@ bool CFX_WideString::operator==(const CFX_WideString& other) const { |
m_pData->m_nDataLength) == 0; |
} |
+bool CFX_WideString::operator!=(const wchar_t* ptr) const { |
+ return !(*this == ptr); |
+} |
+ |
+bool CFX_WideString::operator!=(const CFX_WideStringC& str) const { |
+ return !(*this == str); |
+} |
+ |
+bool CFX_WideString::operator!=(const CFX_WideString& other) const { |
+ return !(*this == other); |
+} |
+ |
+bool CFX_WideString::operator<(const CFX_WideString& str) const { |
+ int result = |
+ wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength())); |
+ return result < 0 || (result == 0 && GetLength() < str.GetLength()); |
+} |
+ |
+FX_WCHAR CFX_WideString::GetAt(FX_STRSIZE nIndex) const { |
+ return m_pData ? m_pData->m_String[nIndex] : 0; |
+} |
+ |
+FX_WCHAR CFX_WideString::operator[](FX_STRSIZE nIndex) const { |
+ return m_pData ? m_pData->m_String[nIndex] : 0; |
+} |
+ |
void CFX_WideString::AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) { |
AllocBeforeWrite(nSrcLen); |
m_pData->CopyContents(pSrcData, nSrcLen); |
@@ -859,6 +897,26 @@ FX_STRSIZE CFX_WideString::WStringLength(const unsigned short* str) { |
return len; |
} |
+const FX_WCHAR* CFX_WideString::c_str() const { |
+ return m_pData ? m_pData->m_String : L""; |
+} |
+ |
+CFX_WideStringC CFX_WideString::AsStringC() const { |
+ return CFX_WideStringC(c_str(), GetLength()); |
+} |
+ |
+void CFX_WideString::clear() { |
+ m_pData.Reset(); |
+} |
+ |
+FX_STRSIZE CFX_WideString::GetLength() const { |
+ return m_pData ? m_pData->m_nDataLength : 0; |
+} |
+ |
+bool CFX_WideString::IsEmpty() const { |
+ return !GetLength(); |
+} |
+ |
void CFX_WideString::TrimRight(const CFX_WideStringC& pTargets) { |
if (IsEmpty() || pTargets.IsEmpty()) |
return; |