| 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 class CFX_ByteStringC; | 9 class CFX_ByteStringC; |
| 10 class CFX_ByteString; | 10 class CFX_ByteString; |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 ~CFX_WideString(); | 633 ~CFX_WideString(); |
| 634 | 634 |
| 635 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1); | 635 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1); |
| 636 | 636 |
| 637 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len); | 637 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len); |
| 638 | 638 |
| 639 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZ
E len); | 639 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZ
E len); |
| 640 | 640 |
| 641 static FX_STRSIZE WStringLength(const unsigned short* str); | 641 static FX_STRSIZE WStringLength(const unsigned short* str); |
| 642 | 642 |
| 643 // Explicit conversion to raw string |
| 644 FX_LPCWSTR c_str() const |
| 645 { |
| 646 return m_pData ? m_pData->m_String : L""; |
| 647 } |
| 648 |
| 649 // Implicit conversion to C-style wide string -- deprecated |
| 643 operator FX_LPCWSTR() const | 650 operator FX_LPCWSTR() const |
| 644 { | 651 { |
| 645 return m_pData ? m_pData->m_String : (FX_WCHAR*)L""; | 652 return m_pData ? m_pData->m_String : L""; |
| 646 } | 653 } |
| 647 | 654 |
| 648 void Empty(); | 655 void Empty(); |
| 649 | 656 |
| 650 | 657 |
| 651 FX_BOOL IsEmpty() const | 658 FX_BOOL IsEmpty() const |
| 652 { | 659 { |
| 653 return !GetLength(); | 660 return !GetLength(); |
| 654 } | 661 } |
| 655 | 662 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 CFX_StringDataW* m_pData; | 762 CFX_StringDataW* m_pData; |
| 756 void CopyBeforeWrite(); | 763 void CopyBeforeWrite(); |
| 757 void AllocBeforeWrite(FX_STRSIZE nLen
); | 764 void AllocBeforeWrite(FX_STRSIZE nLen
); |
| 758 void ConcatInPlace(FX_STRSIZE nSrcLen
, FX_LPCWSTR lpszSrcData); | 765 void ConcatInPlace(FX_STRSIZE nSrcLen
, FX_LPCWSTR lpszSrcData); |
| 759 void ConcatCopy(FX_STRSIZE nSrc1Len,
FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data); | 766 void ConcatCopy(FX_STRSIZE nSrc1Len,
FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data); |
| 760 void AssignCopy(FX_STRSIZE nSrcLen, F
X_LPCWSTR lpszSrcData); | 767 void AssignCopy(FX_STRSIZE nSrcLen, F
X_LPCWSTR lpszSrcData); |
| 761 void AllocCopy(CFX_WideString& dest,
FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const; | 768 void AllocCopy(CFX_WideString& dest,
FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const; |
| 762 }; | 769 }; |
| 763 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) | 770 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) |
| 764 { | 771 { |
| 765 m_Ptr = (FX_LPCWSTR)src; | 772 m_Ptr = src.c_str(); |
| 766 m_Length = src.GetLength(); | 773 m_Length = src.GetLength(); |
| 767 } | 774 } |
| 768 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src) | 775 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src) |
| 769 { | 776 { |
| 770 m_Ptr = (FX_LPCWSTR)src; | 777 m_Ptr = src.c_str(); |
| 771 m_Length = src.GetLength(); | 778 m_Length = src.GetLength(); |
| 772 return *this; | 779 return *this; |
| 773 } | 780 } |
| 774 | 781 |
| 775 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStr
ingC& str2) | 782 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStr
ingC& str2) |
| 776 { | 783 { |
| 777 return CFX_WideString(str1, str2); | 784 return CFX_WideString(str1, str2); |
| 778 } | 785 } |
| 779 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2) | 786 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2) |
| 780 { | 787 { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 FX_FLOAT FX_atof(FX_BSTR str); | 841 FX_FLOAT FX_atof(FX_BSTR str); |
| 835 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData); | 842 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData); |
| 836 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf); | 843 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf); |
| 837 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); | 844 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len); |
| 838 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) | 845 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) |
| 839 { | 846 { |
| 840 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); | 847 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength()); |
| 841 } | 848 } |
| 842 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) | 849 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) |
| 843 { | 850 { |
| 844 return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength()); | 851 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()); |
| 845 } | 852 } |
| 846 #endif | 853 #endif |
| OLD | NEW |