| 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 #ifndef CORE_FXCRT_INCLUDE_FX_STRING_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_STRING_H_ |
| 8 #define CORE_FXCRT_INCLUDE_FX_STRING_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_STRING_H_ |
| 9 | 9 |
| 10 #include <stdint.h> // For intptr_t. | 10 #include <stdint.h> // For intptr_t. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // Implicit conversion to C-style string -- deprecated. | 173 // Implicit conversion to C-style string -- deprecated. |
| 174 operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; } | 174 operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; } |
| 175 | 175 |
| 176 // Explicit conversion to uint8_t*. | 176 // Explicit conversion to uint8_t*. |
| 177 // Note: |this| must outlive the use of the result. | 177 // Note: |this| must outlive the use of the result. |
| 178 const uint8_t* raw_str() const { | 178 const uint8_t* raw_str() const { |
| 179 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) | 179 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) |
| 180 : nullptr; | 180 : nullptr; |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Implicit conversion to uint8_t* -- deprecated. | |
| 184 operator const uint8_t*() const { | |
| 185 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) | |
| 186 : nullptr; | |
| 187 } | |
| 188 | |
| 189 // Explicit conversion to CFX_ByteStringC. | 183 // Explicit conversion to CFX_ByteStringC. |
| 190 // Note: |this| must outlive the use of the result. | 184 // Note: |this| must outlive the use of the result. |
| 191 CFX_ByteStringC AsStringC() const { | 185 CFX_ByteStringC AsStringC() const { |
| 192 return CFX_ByteStringC(raw_str(), GetLength()); | 186 return CFX_ByteStringC(raw_str(), GetLength()); |
| 193 } | 187 } |
| 194 | 188 |
| 195 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } | 189 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } |
| 196 bool IsEmpty() const { return !GetLength(); } | 190 bool IsEmpty() const { return !GetLength(); } |
| 197 | 191 |
| 198 int Compare(const CFX_ByteStringC& str) const; | 192 int Compare(const CFX_ByteStringC& str) const; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 FX_STRSIZE nCopyLen, | 281 FX_STRSIZE nCopyLen, |
| 288 FX_STRSIZE nCopyIndex) const; | 282 FX_STRSIZE nCopyIndex) const; |
| 289 void AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen); | 283 void AssignCopy(const FX_CHAR* pSrcData, FX_STRSIZE nSrcLen); |
| 290 void Concat(const FX_CHAR* lpszSrcData, FX_STRSIZE nSrcLen); | 284 void Concat(const FX_CHAR* lpszSrcData, FX_STRSIZE nSrcLen); |
| 291 | 285 |
| 292 CFX_RetainPtr<StringData> m_pData; | 286 CFX_RetainPtr<StringData> m_pData; |
| 293 friend class fxcrt_ByteStringConcat_Test; | 287 friend class fxcrt_ByteStringConcat_Test; |
| 294 }; | 288 }; |
| 295 | 289 |
| 296 inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) { | 290 inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) { |
| 297 m_Ptr = (const uint8_t*)src; | 291 m_Ptr = src.raw_str(); |
| 298 m_Length = src.GetLength(); | 292 m_Length = src.GetLength(); |
| 299 return *this; | 293 return *this; |
| 300 } | 294 } |
| 301 | 295 |
| 302 inline bool operator==(const char* lhs, const CFX_ByteString& rhs) { | 296 inline bool operator==(const char* lhs, const CFX_ByteString& rhs) { |
| 303 return rhs == lhs; | 297 return rhs == lhs; |
| 304 } | 298 } |
| 305 inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { | 299 inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) { |
| 306 return rhs == lhs; | 300 return rhs == lhs; |
| 307 } | 301 } |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 681 } |
| 688 | 682 |
| 689 FX_FLOAT FX_atof(const CFX_ByteStringC& str); | 683 FX_FLOAT FX_atof(const CFX_ByteStringC& str); |
| 690 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { | 684 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { |
| 691 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); | 685 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); |
| 692 } | 686 } |
| 693 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); | 687 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); |
| 694 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); | 688 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
| 695 | 689 |
| 696 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ | 690 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ |
| OLD | NEW |