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. |
11 #include <algorithm> | 11 #include <algorithm> |
12 | 12 |
13 #include "core/fxcrt/cfx_string_data_template.h" | 13 #include "core/fxcrt/cfx_string_data_template.h" |
14 #include "core/fxcrt/include/cfx_retain_ptr.h" | 14 #include "core/fxcrt/include/cfx_retain_ptr.h" |
15 #include "core/fxcrt/include/fx_memory.h" | 15 #include "core/fxcrt/include/fx_memory.h" |
16 #include "core/fxcrt/include/fx_system.h" | 16 #include "core/fxcrt/include/fx_system.h" |
17 | 17 |
18 class CFX_BinaryBuf; | |
19 class CFX_ByteString; | 18 class CFX_ByteString; |
20 class CFX_WideString; | 19 class CFX_WideString; |
21 | 20 |
22 // An immutable string with caller-provided storage which must outlive the | 21 // An immutable string with caller-provided storage which must outlive the |
23 // string itself. | 22 // string itself. |
24 class CFX_ByteStringC { | 23 class CFX_ByteStringC { |
25 public: | 24 public: |
26 typedef FX_CHAR value_type; | 25 typedef FX_CHAR value_type; |
27 | 26 |
28 CFX_ByteStringC() { | 27 CFX_ByteStringC() { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 210 |
212 bool operator<(const CFX_ByteString& str) const { | 211 bool operator<(const CFX_ByteString& str) const { |
213 int result = FXSYS_memcmp(c_str(), str.c_str(), | 212 int result = FXSYS_memcmp(c_str(), str.c_str(), |
214 std::min(GetLength(), str.GetLength())); | 213 std::min(GetLength(), str.GetLength())); |
215 return result < 0 || (result == 0 && GetLength() < str.GetLength()); | 214 return result < 0 || (result == 0 && GetLength() < str.GetLength()); |
216 } | 215 } |
217 | 216 |
218 const CFX_ByteString& operator=(const FX_CHAR* str); | 217 const CFX_ByteString& operator=(const FX_CHAR* str); |
219 const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc); | 218 const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc); |
220 const CFX_ByteString& operator=(const CFX_ByteString& stringSrc); | 219 const CFX_ByteString& operator=(const CFX_ByteString& stringSrc); |
221 const CFX_ByteString& operator=(const CFX_BinaryBuf& buf); | |
222 | |
223 void Load(const uint8_t* str, FX_STRSIZE len); | |
224 | 220 |
225 const CFX_ByteString& operator+=(FX_CHAR ch); | 221 const CFX_ByteString& operator+=(FX_CHAR ch); |
226 const CFX_ByteString& operator+=(const FX_CHAR* str); | 222 const CFX_ByteString& operator+=(const FX_CHAR* str); |
227 const CFX_ByteString& operator+=(const CFX_ByteString& str); | 223 const CFX_ByteString& operator+=(const CFX_ByteString& str); |
228 const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc); | 224 const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc); |
229 | 225 |
230 uint8_t GetAt(FX_STRSIZE nIndex) const { | 226 uint8_t GetAt(FX_STRSIZE nIndex) const { |
231 return m_pData ? m_pData->m_String[nIndex] : 0; | 227 return m_pData ? m_pData->m_String[nIndex] : 0; |
232 } | 228 } |
233 | 229 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 } | 687 } |
692 | 688 |
693 FX_FLOAT FX_atof(const CFX_ByteStringC& str); | 689 FX_FLOAT FX_atof(const CFX_ByteStringC& str); |
694 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { | 690 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { |
695 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()); |
696 } | 692 } |
697 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); |
698 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); | 694 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
699 | 695 |
700 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ | 696 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ |
OLD | NEW |