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

Side by Side Diff: core/fxcrt/fx_basic_wstring.cpp

Issue 1857713003: Rename GetCStr and GetPtr to match CFX_ByteString (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master 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 unified diff | Download patch
« no previous file with comments | « core/fxcrt/fx_basic_util.cpp ('k') | core/fxcrt/fx_xml_composer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 m_pData->m_String[0] = ch; 96 m_pData->m_String[0] = ch;
97 } 97 }
98 } 98 }
99 CFX_WideString::CFX_WideString(const CFX_WideStringC& str) { 99 CFX_WideString::CFX_WideString(const CFX_WideStringC& str) {
100 if (str.IsEmpty()) { 100 if (str.IsEmpty()) {
101 m_pData = NULL; 101 m_pData = NULL;
102 return; 102 return;
103 } 103 }
104 m_pData = StringData::Create(str.GetLength()); 104 m_pData = StringData::Create(str.GetLength());
105 if (m_pData) { 105 if (m_pData) {
106 FXSYS_memcpy(m_pData->m_String, str.GetPtr(), 106 FXSYS_memcpy(m_pData->m_String, str.raw_str(),
107 str.GetLength() * sizeof(FX_WCHAR)); 107 str.GetLength() * sizeof(FX_WCHAR));
108 } 108 }
109 } 109 }
110 CFX_WideString::CFX_WideString(const CFX_WideStringC& str1, 110 CFX_WideString::CFX_WideString(const CFX_WideStringC& str1,
111 const CFX_WideStringC& str2) { 111 const CFX_WideStringC& str2) {
112 m_pData = NULL; 112 m_pData = NULL;
113 int nNewLen = str1.GetLength() + str2.GetLength(); 113 int nNewLen = str1.GetLength() + str2.GetLength();
114 if (nNewLen == 0) { 114 if (nNewLen == 0) {
115 return; 115 return;
116 } 116 }
117 m_pData = StringData::Create(nNewLen); 117 m_pData = StringData::Create(nNewLen);
118 if (m_pData) { 118 if (m_pData) {
119 FXSYS_memcpy(m_pData->m_String, str1.GetPtr(), 119 FXSYS_memcpy(m_pData->m_String, str1.raw_str(),
120 str1.GetLength() * sizeof(FX_WCHAR)); 120 str1.GetLength() * sizeof(FX_WCHAR));
121 FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.GetPtr(), 121 FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.raw_str(),
122 str2.GetLength() * sizeof(FX_WCHAR)); 122 str2.GetLength() * sizeof(FX_WCHAR));
123 } 123 }
124 } 124 }
125 void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) { 125 void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
126 if (!m_pData) { 126 if (!m_pData) {
127 return; 127 return;
128 } 128 }
129 CopyBeforeWrite(); 129 CopyBeforeWrite();
130 if (nNewLength == -1) { 130 if (nNewLength == -1) {
131 nNewLength = m_pData ? FXSYS_wcslen(m_pData->m_String) : 0; 131 nNewLength = m_pData ? FXSYS_wcslen(m_pData->m_String) : 0;
(...skipping 12 matching lines...) Expand all
144 } else { 144 } else {
145 AssignCopy(FXSYS_wcslen(lpsz), lpsz); 145 AssignCopy(FXSYS_wcslen(lpsz), lpsz);
146 } 146 }
147 return *this; 147 return *this;
148 } 148 }
149 const CFX_WideString& CFX_WideString::operator=( 149 const CFX_WideString& CFX_WideString::operator=(
150 const CFX_WideStringC& stringSrc) { 150 const CFX_WideStringC& stringSrc) {
151 if (stringSrc.IsEmpty()) { 151 if (stringSrc.IsEmpty()) {
152 Empty(); 152 Empty();
153 } else { 153 } else {
154 AssignCopy(stringSrc.GetLength(), stringSrc.GetPtr()); 154 AssignCopy(stringSrc.GetLength(), stringSrc.raw_str());
155 } 155 }
156 return *this; 156 return *this;
157 } 157 }
158 const CFX_WideString& CFX_WideString::operator=( 158 const CFX_WideString& CFX_WideString::operator=(
159 const CFX_WideString& stringSrc) { 159 const CFX_WideString& stringSrc) {
160 if (m_pData == stringSrc.m_pData) { 160 if (m_pData == stringSrc.m_pData) {
161 return *this; 161 return *this;
162 } 162 }
163 if (stringSrc.IsEmpty()) { 163 if (stringSrc.IsEmpty()) {
164 Empty(); 164 Empty();
(...skipping 23 matching lines...) Expand all
188 if (!str.m_pData) { 188 if (!str.m_pData) {
189 return *this; 189 return *this;
190 } 190 }
191 ConcatInPlace(str.m_pData->m_nDataLength, str.m_pData->m_String); 191 ConcatInPlace(str.m_pData->m_nDataLength, str.m_pData->m_String);
192 return *this; 192 return *this;
193 } 193 }
194 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) { 194 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideStringC& str) {
195 if (str.IsEmpty()) { 195 if (str.IsEmpty()) {
196 return *this; 196 return *this;
197 } 197 }
198 ConcatInPlace(str.GetLength(), str.GetPtr()); 198 ConcatInPlace(str.GetLength(), str.raw_str());
199 return *this; 199 return *this;
200 } 200 }
201 bool CFX_WideString::operator==(const wchar_t* ptr) const { 201 bool CFX_WideString::operator==(const wchar_t* ptr) const {
202 if (!m_pData) 202 if (!m_pData)
203 return !ptr || !ptr[0]; 203 return !ptr || !ptr[0];
204 204
205 if (!ptr) 205 if (!ptr)
206 return m_pData->m_nDataLength == 0; 206 return m_pData->m_nDataLength == 0;
207 207
208 return wcslen(ptr) == static_cast<size_t>(m_pData->m_nDataLength) && 208 return wcslen(ptr) == static_cast<size_t>(m_pData->m_nDataLength) &&
209 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; 209 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
210 } 210 }
211 bool CFX_WideString::operator==(const CFX_WideStringC& str) const { 211 bool CFX_WideString::operator==(const CFX_WideStringC& str) const {
212 if (!m_pData) 212 if (!m_pData)
213 return str.IsEmpty(); 213 return str.IsEmpty();
214 214
215 return str.GetLength() == m_pData->m_nDataLength && 215 return str.GetLength() == m_pData->m_nDataLength &&
216 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; 216 wmemcmp(str.raw_str(), m_pData->m_String, m_pData->m_nDataLength) == 0;
217 } 217 }
218 bool CFX_WideString::operator==(const CFX_WideString& other) const { 218 bool CFX_WideString::operator==(const CFX_WideString& other) const {
219 if (IsEmpty()) 219 if (IsEmpty())
220 return other.IsEmpty(); 220 return other.IsEmpty();
221 221
222 if (other.IsEmpty()) 222 if (other.IsEmpty())
223 return false; 223 return false;
224 224
225 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && 225 return other.m_pData->m_nDataLength == m_pData->m_nDataLength &&
226 wmemcmp(other.m_pData->m_String, m_pData->m_String, 226 wmemcmp(other.m_pData->m_String, m_pData->m_String,
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 int dest_len = 1034 int dest_len =
1035 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0); 1035 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0);
1036 CFX_WideString wstr; 1036 CFX_WideString wstr;
1037 if (dest_len) { 1037 if (dest_len) {
1038 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); 1038 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len);
1039 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len); 1039 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len);
1040 wstr.ReleaseBuffer(dest_len); 1040 wstr.ReleaseBuffer(dest_len);
1041 } 1041 }
1042 return wstr; 1042 return wstr;
1043 } 1043 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_util.cpp ('k') | core/fxcrt/fx_xml_composer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698