OLD | NEW |
---|---|
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 return other.IsEmpty(); | 187 return other.IsEmpty(); |
188 | 188 |
189 if (other.IsEmpty()) | 189 if (other.IsEmpty()) |
190 return false; | 190 return false; |
191 | 191 |
192 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && | 192 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && |
193 wmemcmp(other.m_pData->m_String, m_pData->m_String, | 193 wmemcmp(other.m_pData->m_String, m_pData->m_String, |
194 m_pData->m_nDataLength) == 0; | 194 m_pData->m_nDataLength) == 0; |
195 } | 195 } |
196 | 196 |
197 bool CFX_WideString::operator<(const CFX_WideString& str) const { | |
198 if (m_pData == str.m_pData) | |
199 return true; | |
dsinclair
2016/09/15 17:21:34
false?
Should we create a couple simple unit test
Tom Sepez
2016/09/15 17:25:29
I am a moron. Fixed.
| |
200 | |
201 int result = | |
202 wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength())); | |
203 return result < 0 || (result == 0 && GetLength() < str.GetLength()); | |
204 } | |
205 | |
197 void CFX_WideString::AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) { | 206 void CFX_WideString::AssignCopy(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) { |
198 AllocBeforeWrite(nSrcLen); | 207 AllocBeforeWrite(nSrcLen); |
199 m_pData->CopyContents(pSrcData, nSrcLen); | 208 m_pData->CopyContents(pSrcData, nSrcLen); |
200 m_pData->m_nDataLength = nSrcLen; | 209 m_pData->m_nDataLength = nSrcLen; |
201 } | 210 } |
202 | 211 |
203 void CFX_WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) { | 212 void CFX_WideString::ReallocBeforeWrite(FX_STRSIZE nNewLength) { |
204 if (m_pData && m_pData->CanOperateInPlace(nNewLength)) | 213 if (m_pData && m_pData->CanOperateInPlace(nNewLength)) |
205 return; | 214 return; |
206 | 215 |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1003 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); | 1012 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); |
1004 CFX_WideString wstr; | 1013 CFX_WideString wstr; |
1005 if (dest_len) { | 1014 if (dest_len) { |
1006 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); | 1015 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); |
1007 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, | 1016 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, |
1008 dest_len); | 1017 dest_len); |
1009 wstr.ReleaseBuffer(dest_len); | 1018 wstr.ReleaseBuffer(dest_len); |
1010 } | 1019 } |
1011 return wstr; | 1020 return wstr; |
1012 } | 1021 } |
OLD | NEW |