| 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 _FX_STRING_H_ | 7 #ifndef _FX_STRING_H_ |
| 8 #define _FX_STRING_H_ | 8 #define _FX_STRING_H_ |
| 9 | 9 |
| 10 #include <stdint.h> // For intptr_t. | 10 #include <stdint.h> // For intptr_t. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Since the count increments with each new pointer, the largest value is | 175 // Since the count increments with each new pointer, the largest value is |
| 176 // the number of pointers that can fit into the address space. The size of | 176 // the number of pointers that can fit into the address space. The size of |
| 177 // the address space itself is a good upper bound on it; we need not go | 177 // the address space itself is a good upper bound on it; we need not go |
| 178 // larger. | 178 // larger. |
| 179 struct CFX_StringData { | 179 struct CFX_StringData { |
| 180 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support. | 180 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support. |
| 181 FX_STRSIZE m_nDataLength; | 181 FX_STRSIZE m_nDataLength; |
| 182 FX_STRSIZE m_nAllocLength; | 182 FX_STRSIZE m_nAllocLength; |
| 183 FX_CHAR m_String[1]; | 183 FX_CHAR m_String[1]; |
| 184 }; | 184 }; |
| 185 class CFX_ByteString | 185 |
| 186 // A mutable string with shared buffers using copy-on-write semantics that |
| 187 // avoids the cost of std::string's iterator stability guarantees. |
| 188 class CFX_ByteString |
| 186 { | 189 { |
| 187 public: | 190 public: |
| 188 typedef FX_CHAR value_type; | 191 typedef FX_CHAR value_type; |
| 189 | 192 |
| 190 CFX_ByteString() | 193 CFX_ByteString() |
| 191 { | 194 { |
| 192 m_pData = NULL; | 195 m_pData = NULL; |
| 193 } | 196 } |
| 194 | 197 |
| 195 CFX_ByteString(const CFX_ByteString& str); | 198 CFX_ByteString(const CFX_ByteString& str); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 591 } |
| 589 }; | 592 }; |
| 590 typedef const CFX_WideStringC& FX_WSTR; | 593 typedef const CFX_WideStringC& FX_WSTR; |
| 591 #define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1) | 594 #define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1) |
| 592 struct CFX_StringDataW { | 595 struct CFX_StringDataW { |
| 593 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support. | 596 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support. |
| 594 FX_STRSIZE m_nDataLength; | 597 FX_STRSIZE m_nDataLength; |
| 595 FX_STRSIZE m_nAllocLength; | 598 FX_STRSIZE m_nAllocLength; |
| 596 FX_WCHAR m_String[1]; | 599 FX_WCHAR m_String[1]; |
| 597 }; | 600 }; |
| 598 class CFX_WideString | 601 |
| 602 // A mutable string with shared buffers using copy-on-write semantics that |
| 603 // avoids the cost of std::string's iterator stability guarantees. |
| 604 class CFX_WideString |
| 599 { | 605 { |
| 600 public: | 606 public: |
| 601 typedef FX_WCHAR value_type; | 607 typedef FX_WCHAR value_type; |
| 602 | 608 |
| 603 CFX_WideString() | 609 CFX_WideString() |
| 604 { | 610 { |
| 605 m_pData = NULL; | 611 m_pData = NULL; |
| 606 } | 612 } |
| 607 | 613 |
| 608 CFX_WideString(const CFX_WideString& str); | 614 CFX_WideString(const CFX_WideString& str); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); | 841 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); |
| 836 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) | 842 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) |
| 837 { | 843 { |
| 838 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); | 844 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); |
| 839 } | 845 } |
| 840 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) | 846 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) |
| 841 { | 847 { |
| 842 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); | 848 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); |
| 843 } | 849 } |
| 844 #endif | 850 #endif |
| OLD | NEW |