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

Unified Diff: core/fxcrt/fx_basic_bstring.cpp

Issue 2060913003: Make code compile with clang_use_chrome_plugin (part II) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: base Created 4 years, 6 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
Index: core/fxcrt/fx_basic_bstring.cpp
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index 379f1ee882ca2673de6da276548194dbcb7b3a0e..bc59e62ca58467968727a7959d069a2e6843563a 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -94,11 +94,23 @@ CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) {
}
}
+CFX_ByteString::CFX_ByteString() {}
+
+CFX_ByteString::CFX_ByteString(const CFX_ByteString& other)
+ : m_pData(other.m_pData) {}
+
+CFX_ByteString::CFX_ByteString(CFX_ByteString&& other) {
+ m_pData.Swap(other.m_pData);
+}
+
CFX_ByteString::CFX_ByteString(char ch) {
m_pData.Reset(StringData::Create(1));
m_pData->m_String[0] = ch;
}
+CFX_ByteString::CFX_ByteString(const FX_CHAR* ptr)
+ : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
+
CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) {
if (!stringSrc.IsEmpty())
m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength()));
@@ -117,6 +129,10 @@ CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& str1,
CFX_ByteString::~CFX_ByteString() {}
+void CFX_ByteString::clear() {
+ m_pData.Reset();
+}
+
const CFX_ByteString& CFX_ByteString::operator=(const FX_CHAR* pStr) {
if (!pStr || !pStr[0])
clear();
@@ -201,6 +217,32 @@ bool CFX_ByteString::operator==(const CFX_ByteString& other) const {
m_pData->m_nDataLength) == 0;
}
+bool CFX_ByteString::operator!=(const char* ptr) const {
+ return !(*this == ptr);
+}
+
+bool CFX_ByteString::operator!=(const CFX_ByteStringC& str) const {
+ return !(*this == str);
+}
+
+bool CFX_ByteString::operator!=(const CFX_ByteString& other) const {
+ return !(*this == other);
+}
+
+bool CFX_ByteString::operator<(const CFX_ByteString& str) const {
+ int result = FXSYS_memcmp(c_str(), str.c_str(),
+ std::min(GetLength(), str.GetLength()));
+ return result < 0 || (result == 0 && GetLength() < str.GetLength());
+}
+
+uint8_t CFX_ByteString::GetAt(FX_STRSIZE nIndex) const {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+}
+
+uint8_t CFX_ByteString::operator[](FX_STRSIZE nIndex) const {
+ return m_pData ? m_pData->m_String[nIndex] : 0;
+}
+
bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const {
if (!m_pData)
return str.IsEmpty();
@@ -835,6 +877,27 @@ CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) {
return CFX_CharMap::GetByteString(0, str.AsStringC());
}
+const FX_CHAR* CFX_ByteString::c_str() const {
+ return m_pData ? m_pData->m_String : "";
+}
+
+const uint8_t* CFX_ByteString::raw_str() const {
+ return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String)
+ : nullptr;
+}
+
+CFX_ByteStringC CFX_ByteString::AsStringC() const {
+ return CFX_ByteStringC(raw_str(), GetLength());
+}
+
+FX_STRSIZE CFX_ByteString::GetLength() const {
+ return m_pData ? m_pData->m_nDataLength : 0;
+}
+
+bool CFX_ByteString::IsEmpty() const {
+ return !GetLength();
+}
+
int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
if (!m_pData) {
return str.IsEmpty() ? 0 : -1;

Powered by Google App Engine
This is Rietveld 408576698