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 <algorithm> | 10 #include <algorithm> |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return CFX_ByteString(str1, str2); | 434 return CFX_ByteString(str1, str2); |
435 } | 435 } |
436 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) | 436 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) |
437 { | 437 { |
438 return CFX_ByteString(str1, str2); | 438 return CFX_ByteString(str1, str2); |
439 } | 439 } |
440 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) | 440 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) |
441 { | 441 { |
442 return CFX_ByteString(str1, str2); | 442 return CFX_ByteString(str1, str2); |
443 } | 443 } |
444 class CFX_WideStringC | 444 class CFX_WideStringC |
445 { | 445 { |
446 public: | 446 public: |
447 typedef FX_WCHAR value_type; | 447 typedef FX_WCHAR value_type; |
448 | 448 |
449 CFX_WideStringC() | 449 CFX_WideStringC() |
450 { | 450 { |
451 m_Ptr = NULL; | 451 m_Ptr = NULL; |
452 m_Length = 0; | 452 m_Length = 0; |
453 } | 453 } |
454 | 454 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 CFX_WideStringC Right(FX_STRSIZE count) const | 556 CFX_WideStringC Right(FX_STRSIZE count) const |
557 { | 557 { |
558 if (count < 1) { | 558 if (count < 1) { |
559 return CFX_WideStringC(); | 559 return CFX_WideStringC(); |
560 } | 560 } |
561 if (count > m_Length) { | 561 if (count > m_Length) { |
562 count = m_Length; | 562 count = m_Length; |
563 } | 563 } |
564 return CFX_WideStringC(m_Ptr + m_Length - count, count); | 564 return CFX_WideStringC(m_Ptr + m_Length - count, count); |
565 } | 565 } |
| 566 |
| 567 const FX_WCHAR& operator[] (size_t index) const |
| 568 { |
| 569 return m_Ptr[index]; |
| 570 } |
| 571 |
| 572 bool operator< (const CFX_WideStringC& that) const |
| 573 { |
| 574 int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length
)); |
| 575 return result < 0 || (result == 0 && m_Length < that.m_Length); |
| 576 } |
| 577 |
566 protected: | 578 protected: |
| 579 FX_LPCWSTR m_Ptr; |
| 580 FX_STRSIZE m_Length; |
567 | 581 |
568 FX_LPCWSTR m_Ptr; | |
569 | |
570 FX_STRSIZE m_Length; | |
571 private: | 582 private: |
572 | |
573 void* operator new (size_t) throw() | 583 void* operator new (size_t) throw() |
574 { | 584 { |
575 return NULL; | 585 return NULL; |
576 } | 586 } |
577 }; | 587 }; |
578 typedef const CFX_WideStringC& FX_WSTR; | 588 typedef const CFX_WideStringC& FX_WSTR; |
579 #define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1) | 589 #define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1) |
580 struct CFX_StringDataW { | 590 struct CFX_StringDataW { |
581 | 591 |
582 long m_nRefs; | 592 long m_nRefs; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); | 839 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); |
830 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) | 840 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) |
831 { | 841 { |
832 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); | 842 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); |
833 } | 843 } |
834 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) | 844 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) |
835 { | 845 { |
836 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); | 846 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); |
837 } | 847 } |
838 #endif | 848 #endif |
OLD | NEW |