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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ~CFX_ByteString(); | 160 ~CFX_ByteString(); |
161 | 161 |
162 // Deprecated -- use clear(). | 162 // Deprecated -- use clear(). |
163 void Empty() { m_pData.Reset(); } | 163 void Empty() { m_pData.Reset(); } |
164 void clear() { m_pData.Reset(); } | 164 void clear() { m_pData.Reset(); } |
165 | 165 |
166 static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1); | 166 static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1); |
167 static CFX_ByteString FromUnicode(const CFX_WideString& str); | 167 static CFX_ByteString FromUnicode(const CFX_WideString& str); |
168 | 168 |
169 // Explicit conversion to C-style string. | 169 // Explicit conversion to C-style string. |
170 // Note: |this| must outlive the use of the result. | 170 // Note: Any subsequent modification of |this| will invalidate the result. |
171 const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; } | 171 const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; } |
172 | 172 |
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: Any subsequent modification of |this| will invalidate 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. | 183 // Implicit conversion to uint8_t* -- deprecated. |
184 operator const uint8_t*() const { | 184 operator const uint8_t*() const { |
185 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) | 185 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) |
186 : nullptr; | 186 : nullptr; |
187 } | 187 } |
188 | 188 |
189 // Explicit conversion to CFX_ByteStringC. | 189 // Explicit conversion to CFX_ByteStringC. |
190 // Note: |this| must outlive the use of the result. | 190 // Note: Any subsequent modification of |this| will invalidate the result. |
191 CFX_ByteStringC AsStringC() const { | 191 CFX_ByteStringC AsStringC() const { |
192 return CFX_ByteStringC(raw_str(), GetLength()); | 192 return CFX_ByteStringC(raw_str(), GetLength()); |
193 } | 193 } |
194 | 194 |
195 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } | 195 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } |
196 bool IsEmpty() const { return !GetLength(); } | 196 bool IsEmpty() const { return !GetLength(); } |
197 | 197 |
198 int Compare(const CFX_ByteStringC& str) const; | 198 int Compare(const CFX_ByteStringC& str) const; |
199 bool EqualNoCase(const CFX_ByteStringC& str) const; | 199 bool EqualNoCase(const CFX_ByteStringC& str) const; |
200 | 200 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 static CFX_WideString FromLocal(const CFX_ByteStringC& str); | 496 static CFX_WideString FromLocal(const CFX_ByteStringC& str); |
497 static CFX_WideString FromCodePage(const CFX_ByteStringC& str, | 497 static CFX_WideString FromCodePage(const CFX_ByteStringC& str, |
498 uint16_t codepage); | 498 uint16_t codepage); |
499 | 499 |
500 static CFX_WideString FromUTF8(const CFX_ByteStringC& str); | 500 static CFX_WideString FromUTF8(const CFX_ByteStringC& str); |
501 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len); | 501 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len); |
502 | 502 |
503 static FX_STRSIZE WStringLength(const unsigned short* str); | 503 static FX_STRSIZE WStringLength(const unsigned short* str); |
504 | 504 |
505 // Explicit conversion to C-style wide string. | 505 // Explicit conversion to C-style wide string. |
506 // Note: |this| must outlive the use of the result. | 506 // Note: Any subsequent modification of |this| will invalidate the result. |
507 const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; } | 507 const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; } |
508 | 508 |
509 // Implicit conversion to C-style wide string -- deprecated. | 509 // Implicit conversion to C-style wide string -- deprecated. |
510 // Note: |this| must outlive the use of the result. | 510 // Note: Any subsequent modification of |this| will invalidate the result. |
511 operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; } | 511 operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; } |
512 | 512 |
513 // Explicit conversion to CFX_WideStringC. | 513 // Explicit conversion to CFX_WideStringC. |
514 // Note: |this| must outlive the use of the result. | 514 // Note: Any subsequent modification of |this| will invalidate the result. |
515 CFX_WideStringC AsStringC() const { | 515 CFX_WideStringC AsStringC() const { |
516 return CFX_WideStringC(c_str(), GetLength()); | 516 return CFX_WideStringC(c_str(), GetLength()); |
517 } | 517 } |
518 | 518 |
519 // Deprecated -- use clear(). | 519 // Deprecated -- use clear(). |
520 void Empty() { m_pData.Reset(); } | 520 void Empty() { m_pData.Reset(); } |
521 void clear() { m_pData.Reset(); } | 521 void clear() { m_pData.Reset(); } |
522 | 522 |
523 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } | 523 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } |
524 bool IsEmpty() const { return !GetLength(); } | 524 bool IsEmpty() const { return !GetLength(); } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 687 } |
688 | 688 |
689 FX_FLOAT FX_atof(const CFX_ByteStringC& str); | 689 FX_FLOAT FX_atof(const CFX_ByteStringC& str); |
690 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { | 690 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { |
691 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); | 691 return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str()); |
692 } | 692 } |
693 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); | 693 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); |
694 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); | 694 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
695 | 695 |
696 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ | 696 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ |
OLD | NEW |