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_INCLUDE_FXCRT_FX_STRING_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_STRING_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_STRING_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_STRING_H_ |
9 | 9 |
10 #include <stdint.h> // For intptr_t. | 10 #include <stdint.h> // For intptr_t. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 | 162 |
163 CFX_ByteString(const CFX_ByteStringC& bstrc); | 163 CFX_ByteString(const CFX_ByteStringC& bstrc); |
164 CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2); | 164 CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2); |
165 | 165 |
166 ~CFX_ByteString(); | 166 ~CFX_ByteString(); |
167 | 167 |
168 static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1); | 168 static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1); |
169 | 169 |
170 static CFX_ByteString FromUnicode(const CFX_WideString& str); | 170 static CFX_ByteString FromUnicode(const CFX_WideString& str); |
171 | 171 |
172 // Explicit conversion to raw string | 172 // Explicit conversion to C-style string. |
173 const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; } | 173 const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; } |
174 | 174 |
175 // Implicit conversion to C-style string -- deprecated | 175 // Implicit conversion to C-style string -- deprecated |
176 operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; } | 176 operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; } |
177 | 177 |
178 // Explicit conversion to uint8_t*. | |
179 const uint8_t* raw_str() const { | |
180 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) | |
181 : nullptr; | |
182 } | |
183 | |
184 // Implicit conversiont to uint8_t* -- deprectated | |
dsinclair
2016/03/14 17:29:44
nit: deprecated
| |
178 operator const uint8_t*() const { | 185 operator const uint8_t*() const { |
179 return m_pData ? (const uint8_t*)m_pData->m_String : NULL; | 186 return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) |
187 : nullptr; | |
180 } | 188 } |
181 | 189 |
182 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } | 190 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } |
183 | 191 |
184 bool IsEmpty() const { return !GetLength(); } | 192 bool IsEmpty() const { return !GetLength(); } |
185 | 193 |
186 int Compare(const CFX_ByteStringC& str) const; | 194 int Compare(const CFX_ByteStringC& str) const; |
187 | 195 |
188 bool Equal(const char* ptr) const; | 196 bool Equal(const char* ptr) const; |
189 bool Equal(const CFX_ByteStringC& str) const; | 197 bool Equal(const CFX_ByteStringC& str) const; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 | 570 |
563 static CFX_WideString FromCodePage(const CFX_ByteString& str, | 571 static CFX_WideString FromCodePage(const CFX_ByteString& str, |
564 FX_WORD codepage); | 572 FX_WORD codepage); |
565 | 573 |
566 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len); | 574 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len); |
567 | 575 |
568 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len); | 576 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len); |
569 | 577 |
570 static FX_STRSIZE WStringLength(const unsigned short* str); | 578 static FX_STRSIZE WStringLength(const unsigned short* str); |
571 | 579 |
572 // Explicit conversion to raw string | 580 // Explicit conversion to C-style wide string. |
573 const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; } | 581 const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; } |
574 | 582 |
575 // Implicit conversion to C-style wide string -- deprecated | 583 // Implicit conversion to C-style wide string -- deprecated. |
576 operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; } | 584 operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; } |
577 | 585 |
578 void Empty(); | 586 void Empty(); |
579 | 587 |
580 bool IsEmpty() const { return !GetLength(); } | 588 bool IsEmpty() const { return !GetLength(); } |
581 | 589 |
582 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } | 590 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } |
583 | 591 |
584 const CFX_WideString& operator=(const FX_WCHAR* str); | 592 const CFX_WideString& operator=(const FX_WCHAR* str); |
585 | 593 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 } | 810 } |
803 | 811 |
804 FX_FLOAT FX_atof(const CFX_ByteStringC& str); | 812 FX_FLOAT FX_atof(const CFX_ByteStringC& str); |
805 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { | 813 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { |
806 return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength())); | 814 return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength())); |
807 } | 815 } |
808 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); | 816 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); |
809 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); | 817 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
810 | 818 |
811 #endif // CORE_INCLUDE_FXCRT_FX_STRING_H_ | 819 #endif // CORE_INCLUDE_FXCRT_FX_STRING_H_ |
OLD | NEW |