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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 bool operator==(const CFX_ByteStringC& other) const { | 83 bool operator==(const CFX_ByteStringC& other) const { |
84 return other.m_Length == m_Length && | 84 return other.m_Length == m_Length && |
85 FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0; | 85 FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0; |
86 } | 86 } |
87 bool operator!=(const char* ptr) const { return !(*this == ptr); } | 87 bool operator!=(const char* ptr) const { return !(*this == ptr); } |
88 bool operator!=(const CFX_ByteStringC& other) const { | 88 bool operator!=(const CFX_ByteStringC& other) const { |
89 return !(*this == other); | 89 return !(*this == other); |
90 } | 90 } |
91 | 91 |
92 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const; | 92 uint32_t GetID(FX_STRSIZE start_pos = 0) const; |
93 | 93 |
94 const uint8_t* GetPtr() const { return m_Ptr; } | 94 const uint8_t* GetPtr() const { return m_Ptr; } |
95 | 95 |
96 const FX_CHAR* GetCStr() const { return (const FX_CHAR*)m_Ptr; } | 96 const FX_CHAR* GetCStr() const { return (const FX_CHAR*)m_Ptr; } |
97 | 97 |
98 FX_STRSIZE GetLength() const { return m_Length; } | 98 FX_STRSIZE GetLength() const { return m_Length; } |
99 | 99 |
100 bool IsEmpty() const { return m_Length == 0; } | 100 bool IsEmpty() const { return m_Length == 0; } |
101 | 101 |
102 uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; } | 102 uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 289 |
290 void TrimLeft(const CFX_ByteStringC& lpszTargets); | 290 void TrimLeft(const CFX_ByteStringC& lpszTargets); |
291 | 291 |
292 FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld, | 292 FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld, |
293 const CFX_ByteStringC& lpszNew); | 293 const CFX_ByteStringC& lpszNew); |
294 | 294 |
295 FX_STRSIZE Remove(FX_CHAR ch); | 295 FX_STRSIZE Remove(FX_CHAR ch); |
296 | 296 |
297 CFX_WideString UTF8Decode() const; | 297 CFX_WideString UTF8Decode() const; |
298 | 298 |
299 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const; | 299 uint32_t GetID(FX_STRSIZE start_pos = 0) const; |
300 | 300 |
301 #define FXFORMAT_SIGNED 1 | 301 #define FXFORMAT_SIGNED 1 |
302 #define FXFORMAT_HEX 2 | 302 #define FXFORMAT_HEX 2 |
303 #define FXFORMAT_CAPITAL 4 | 303 #define FXFORMAT_CAPITAL 4 |
304 | 304 |
305 static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0); | 305 static CFX_ByteString FormatInteger(int i, uint32_t flags = 0); |
306 static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0); | 306 static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0); |
307 | 307 |
308 protected: | 308 protected: |
309 // To ensure ref counts do not overflow, consider the worst possible case: | 309 // To ensure ref counts do not overflow, consider the worst possible case: |
310 // the entire address space contains nothing but pointers to this object. | 310 // the entire address space contains nothing but pointers to this object. |
311 // Since the count increments with each new pointer, the largest value is | 311 // Since the count increments with each new pointer, the largest value is |
312 // the number of pointers that can fit into the address space. The size of | 312 // the number of pointers that can fit into the address space. The size of |
313 // the address space itself is a good upper bound on it; we need not go | 313 // the address space itself is a good upper bound on it; we need not go |
314 // larger. | 314 // larger. |
315 class StringData { | 315 class StringData { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 } | 810 } |
811 | 811 |
812 FX_FLOAT FX_atof(const CFX_ByteStringC& str); | 812 FX_FLOAT FX_atof(const CFX_ByteStringC& str); |
813 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { | 813 inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { |
814 return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength())); | 814 return FX_atof(FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength())); |
815 } | 815 } |
816 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); |
817 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); | 817 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); |
818 | 818 |
819 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ | 819 #endif // CORE_FXCRT_INCLUDE_FX_STRING_H_ |
OLD | NEW |