1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
7 #ifndef CORE_INCLUDE_FXCRT_FX_STRING_H_
8 #define CORE_INCLUDE_FXCRT_FX_STRING_H_
10 #include <stdint.h> // For intptr_t.
13 #include "fx_memory.h"
14 #include "fx_system.h"
21 // An immutable string with caller-provided storage which must outlive the
26 typedef FX_CHAR value_type;
34 CFX_ByteStringC(const uint8_t* ptr, FX_STRSIZE size)
40 CFX_ByteStringC(const FX_CHAR* ptr)
42 m_Ptr = (const uint8_t*)ptr;
43 m_Length = ptr ? FXSYS_strlen(ptr) : 0;
46 // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
47 // the use of char rvalues are not caught at compile time. They are
48 // implicitly promoted to CFX_ByteString (see below) and then the
49 // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
50 // constructor below. The CFX_ByteString then typically goes out of scope
51 // and |m_Ptr| may be left pointing to invalid memory. Beware.
52 // TODO(tsepez): Mark single-argument string constructors as explicit.
53 CFX_ByteStringC(FX_CHAR& ch)
55 m_Ptr = (const uint8_t*)&ch;
59 CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len)
61 m_Ptr = (const uint8_t*)ptr;
62 m_Length = (len == -1) ? FXSYS_strlen(ptr) : len;
65 CFX_ByteStringC(const CFX_ByteStringC& src)
68 m_Length = src.m_Length;
71 CFX_ByteStringC(const CFX_ByteString& src);
73 CFX_ByteStringC& operator = (const FX_CHAR* src)
75 m_Ptr = (const uint8_t*)src;
76 m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
80 CFX_ByteStringC& operator = (const CFX_ByteStringC& src)
83 m_Length = src.m_Length;
87 CFX_ByteStringC& operator = (const CFX_ByteString& src);
89 bool operator== (const char* ptr) const {
90 return FXSYS_strlen(ptr) == m_Length &&
91 FXSYS_memcmp32(ptr, m_Ptr, m_Length) == 0;
93 bool operator== (const CFX_ByteStringC& other) const {
94 return other.m_Length == m_Length &&
95 FXSYS_memcmp32(other.m_Ptr, m_Ptr, m_Length) == 0;
97 bool operator!= (const char* ptr) const { return !(*this == ptr); }
98 bool operator!= (const CFX_ByteStringC& other) const {
99 return !(*this == other);
102 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
104 const uint8_t* GetPtr() const
109 const FX_CHAR* GetCStr() const
111 return (const FX_CHAR*)m_Ptr;
114 FX_STRSIZE GetLength() const
121 return m_Length == 0;
124 uint8_t GetAt(FX_STRSIZE index) const
129 CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
134 if (index > m_Length) {
135 return CFX_ByteStringC();
137 if (count < 0 || count > m_Length - index) {
138 count = m_Length - index;
140 return CFX_ByteStringC(m_Ptr + index, count);
143 const uint8_t& operator[] (size_t index) const
148 bool operator< (const CFX_ByteStringC& that) const
150 int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
151 return result < 0 || (result == 0 && m_Length < that.m_Length);
155 const uint8_t* m_Ptr;
159 void* operator new (size_t) throw()
164 inline bool operator== (const char* lhs, const CFX_ByteStringC& rhs) {
167 inline bool operator!= (const char* lhs, const CFX_ByteStringC& rhs) {
170 #define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
171 #define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
173 // A mutable string with shared buffers using copy-on-write semantics that
174 // avoids the cost of std::string's iterator stability guarantees.
178 typedef FX_CHAR value_type;
180 CFX_ByteString() : m_pData(nullptr) { }
183 CFX_ByteString(const CFX_ByteString& str);
186 inline CFX_ByteString(CFX_ByteString&& other) {
187 m_pData = other.m_pData;
188 other.m_pData = nullptr;
191 CFX_ByteString(char ch);
192 CFX_ByteString(const FX_CHAR* ptr)
193 : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) { }
195 CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len);
196 CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
198 CFX_ByteString(const CFX_ByteStringC& bstrc);
199 CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
203 static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1);
205 static CFX_ByteString FromUnicode(const CFX_WideString& str);
207 // Explicit conversion to raw string
208 const FX_CHAR* c_str() const
210 return m_pData ? m_pData->m_String : "";
213 // Implicit conversion to C-style string -- deprecated
214 operator const FX_CHAR*() const
216 return m_pData ? m_pData->m_String : "";
219 operator const uint8_t*() const
221 return m_pData ? (const uint8_t*)m_pData->m_String : NULL;
224 FX_STRSIZE GetLength() const
226 return m_pData ? m_pData->m_nDataLength : 0;
234 int Compare(const CFX_ByteStringC& str) const;
237 bool Equal(const char* ptr) const;
238 bool Equal(const CFX_ByteStringC& str) const;
239 bool Equal(const CFX_ByteString& other) const;
241 bool EqualNoCase(const CFX_ByteStringC& str) const;
243 bool operator== (const char* ptr) const { return Equal(ptr); }
244 bool operator== (const CFX_ByteStringC& str) const { return Equal(str); }
245 bool operator== (const CFX_ByteString& other) const { return Equal(other); }
247 bool operator!= (const char* ptr) const { return !(*this == ptr); }
248 bool operator!= (const CFX_ByteStringC& str) const {
249 return !(*this == str);
251 bool operator!= (const CFX_ByteString& other) const {
252 return !(*this == other);
255 bool operator< (const CFX_ByteString& str) const
257 int result = FXSYS_memcmp32(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
258 return result < 0 || (result == 0 && GetLength() < str.GetLength());
263 const CFX_ByteString& operator = (const FX_CHAR* str);
265 const CFX_ByteString& operator = (const CFX_ByteStringC& bstrc);
267 const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
269 const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
271 void Load(const uint8_t* str, FX_STRSIZE len);
273 const CFX_ByteString& operator += (FX_CHAR ch);
275 const CFX_ByteString& operator += (const FX_CHAR* str);
277 const CFX_ByteString& operator += (const CFX_ByteString& str);
279 const CFX_ByteString& operator += (const CFX_ByteStringC& bstrc);
281 uint8_t GetAt(FX_STRSIZE nIndex) const
283 return m_pData ? m_pData->m_String[nIndex] : 0;
286 uint8_t operator[](FX_STRSIZE nIndex) const
288 return m_pData ? m_pData->m_String[nIndex] : 0;
291 void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
293 FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
295 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
298 void Format(const FX_CHAR* lpszFormat, ... );
300 void FormatV(const FX_CHAR* lpszFormat, va_list argList);
303 void Reserve(FX_STRSIZE len);
305 FX_CHAR* GetBuffer(FX_STRSIZE len);
307 void ReleaseBuffer(FX_STRSIZE len = -1);
309 CFX_ByteString Mid(FX_STRSIZE first) const;
311 CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
313 CFX_ByteString Left(FX_STRSIZE count) const;
315 CFX_ByteString Right(FX_STRSIZE count) const;
317 FX_STRSIZE Find(const CFX_ByteStringC& lpszSub, FX_STRSIZE start = 0) const;
319 FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
321 FX_STRSIZE ReverseFind(FX_CHAR ch) const;
329 void TrimRight(FX_CHAR chTarget);
331 void TrimRight(const CFX_ByteStringC& lpszTargets);
335 void TrimLeft(FX_CHAR chTarget);
337 void TrimLeft(const CFX_ByteStringC& lpszTargets);
339 FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld, const CFX_ByteStringC& lpszNew);
341 FX_STRSIZE Remove(FX_CHAR ch);
343 CFX_WideString UTF8Decode() const;
345 void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
347 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
349 #define FXFORMAT_SIGNED 1
350 #define FXFORMAT_HEX 2
351 #define FXFORMAT_CAPITAL 4
353 static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
354 static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
357 // To ensure ref counts do not overflow, consider the worst possible case:
358 // the entire address space contains nothing but pointers to this object.
359 // Since the count increments with each new pointer, the largest value is
360 // the number of pointers that can fit into the address space. The size of
361 // the address space itself is a good upper bound on it; we need not go
365 static StringData* Create(int nLen);
366 void Retain() { ++m_nRefs; }
367 void Release() { if (--m_nRefs <= 0) FX_Free(this); }
369 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
370 FX_STRSIZE m_nDataLength;
371 FX_STRSIZE m_nAllocLength;
375 StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
376 : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
377 FXSYS_assert(dataLen >= 0);
378 FXSYS_assert(allocLen >= 0);
379 FXSYS_assert(dataLen <= allocLen);
380 m_String[dataLen] = 0;
382 ~StringData() = delete;
385 void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
386 void AssignCopy(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
387 void ConcatCopy(FX_STRSIZE nSrc1Len, const FX_CHAR* lpszSrc1Data, FX_STRSIZE nSrc2Len, const FX_CHAR* lpszSrc2Data);
388 void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
389 void CopyBeforeWrite();
390 void AllocBeforeWrite(FX_STRSIZE nLen);
393 friend class fxcrt_ByteStringConcatInPlace_Test;
395 inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
397 m_Ptr = (const uint8_t*)src;
398 m_Length = src.GetLength();
400 inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
402 m_Ptr = (const uint8_t*)src;
403 m_Length = src.GetLength();
407 inline bool operator== (const char* lhs, const CFX_ByteString& rhs) {
410 inline bool operator== (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
413 inline bool operator!= (const char* lhs, const CFX_ByteString& rhs) {
416 inline bool operator!= (const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
420 inline CFX_ByteString operator + (const CFX_ByteStringC& str1, const CFX_ByteStringC& str2)
422 return CFX_ByteString(str1, str2);
424 inline CFX_ByteString operator + (const CFX_ByteStringC& str1, const FX_CHAR* str2)
426 return CFX_ByteString(str1, str2);
428 inline CFX_ByteString operator + (const FX_CHAR* str1, const CFX_ByteStringC& str2)
430 return CFX_ByteString(str1, str2);
432 inline CFX_ByteString operator + (const CFX_ByteStringC& str1, FX_CHAR ch)
434 return CFX_ByteString(str1, CFX_ByteStringC(ch));
436 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteStringC& str2)
438 return CFX_ByteString(ch, str2);
440 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2)
442 return CFX_ByteString(str1, str2);
444 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch)
446 return CFX_ByteString(str1, CFX_ByteStringC(ch));
448 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2)
450 return CFX_ByteString(ch, str2);
452 inline CFX_ByteString operator + (const CFX_ByteString& str1, const FX_CHAR* str2)
454 return CFX_ByteString(str1, str2);
456 inline CFX_ByteString operator + (const FX_CHAR* str1, const CFX_ByteString& str2)
458 return CFX_ByteString(str1, str2);
460 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteStringC& str2)
462 return CFX_ByteString(str1, str2);
464 inline CFX_ByteString operator + (const CFX_ByteStringC& str1, const CFX_ByteString& str2)
466 return CFX_ByteString(str1, str2);
468 class CFX_WideStringC
471 typedef FX_WCHAR value_type;
479 CFX_WideStringC(const FX_WCHAR* ptr)
482 m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
485 CFX_WideStringC(FX_WCHAR& ch)
491 CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len)
494 m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len;
497 CFX_WideStringC(const CFX_WideStringC& src)
500 m_Length = src.m_Length;
503 CFX_WideStringC(const CFX_WideString& src);
505 CFX_WideStringC& operator = (const FX_WCHAR* src)
508 m_Length = FXSYS_wcslen(src);
512 CFX_WideStringC& operator = (const CFX_WideStringC& src)
515 m_Length = src.m_Length;
519 CFX_WideStringC& operator = (const CFX_WideString& src);
521 bool operator== (const wchar_t* ptr) const {
522 return FXSYS_wcslen(ptr) == m_Length &&
523 wmemcmp(ptr, m_Ptr, m_Length) == 0;
525 bool operator== (const CFX_WideStringC& str) const {
526 return str.m_Length == m_Length &&
527 wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0;
529 bool operator!= (const wchar_t* ptr) const { return !(*this == ptr); }
530 bool operator!= (const CFX_WideStringC& str) const {
531 return !(*this == str);
534 const FX_WCHAR* GetPtr() const
539 FX_STRSIZE GetLength() const
546 return m_Length == 0;
549 FX_WCHAR GetAt(FX_STRSIZE index) const
554 CFX_WideStringC Left(FX_STRSIZE count) const
557 return CFX_WideStringC();
559 if (count > m_Length) {
562 return CFX_WideStringC(m_Ptr, count);
565 CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
570 if (index > m_Length) {
571 return CFX_WideStringC();
573 if (count < 0 || count > m_Length - index) {
574 count = m_Length - index;
576 return CFX_WideStringC(m_Ptr + index, count);
579 CFX_WideStringC Right(FX_STRSIZE count) const
582 return CFX_WideStringC();
584 if (count > m_Length) {
587 return CFX_WideStringC(m_Ptr + m_Length - count, count);
590 const FX_WCHAR& operator[] (size_t index) const
595 bool operator< (const CFX_WideStringC& that) const
597 int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
598 return result < 0 || (result == 0 && m_Length < that.m_Length);
602 const FX_WCHAR* m_Ptr;
606 void* operator new (size_t) throw()
611 inline bool operator== (const wchar_t* lhs, const CFX_WideStringC& rhs) {
614 inline bool operator!= (const wchar_t* lhs, const CFX_WideStringC& rhs) {
617 #define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1)
619 // A mutable string with shared buffers using copy-on-write semantics that
620 // avoids the cost of std::string's iterator stability guarantees.
624 typedef FX_WCHAR value_type;
626 CFX_WideString() : m_pData(nullptr) { }
629 CFX_WideString(const CFX_WideString& str);
632 inline CFX_WideString(CFX_WideString&& other) {
633 m_pData = other.m_pData;
634 other.m_pData = nullptr;
637 CFX_WideString(const FX_WCHAR* ptr)
638 : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) { }
640 CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
642 CFX_WideString(FX_WCHAR ch);
644 CFX_WideString(const CFX_WideStringC& str);
646 CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
650 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
652 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len);
654 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
656 static FX_STRSIZE WStringLength(const unsigned short* str);
658 // Explicit conversion to raw string
659 const FX_WCHAR* c_str() const
661 return m_pData ? m_pData->m_String : L"";
664 // Implicit conversion to C-style wide string -- deprecated
665 operator const FX_WCHAR*() const
667 return m_pData ? m_pData->m_String : L"";
673 FX_BOOL IsEmpty() const
678 FX_STRSIZE GetLength() const
680 return m_pData ? m_pData->m_nDataLength : 0;
683 const CFX_WideString& operator = (const FX_WCHAR* str);
685 const CFX_WideString& operator =(const CFX_WideString& stringSrc);
687 const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
689 const CFX_WideString& operator += (const FX_WCHAR* str);
691 const CFX_WideString& operator += (FX_WCHAR ch);
693 const CFX_WideString& operator += (const CFX_WideString& str);
695 const CFX_WideString& operator += (const CFX_WideStringC& str);
697 bool operator== (const wchar_t* ptr) const { return Equal(ptr); }
698 bool operator== (const CFX_WideStringC& str) const { return Equal(str); }
699 bool operator== (const CFX_WideString& other) const { return Equal(other); }
701 bool operator!= (const wchar_t* ptr) const { return !(*this == ptr); }
702 bool operator!= (const CFX_WideStringC& str) const {
703 return !(*this == str);
705 bool operator!= (const CFX_WideString& other) const {
706 return !(*this == other);
709 bool operator< (const CFX_WideString& str) const {
710 int result = wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
711 return result < 0 || (result == 0 && GetLength() < str.GetLength());
714 FX_WCHAR GetAt(FX_STRSIZE nIndex) const
716 return m_pData ? m_pData->m_String[nIndex] : 0;
719 FX_WCHAR operator[](FX_STRSIZE nIndex) const
721 return m_pData ? m_pData->m_String[nIndex] : 0;
724 void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
726 int Compare(const FX_WCHAR* str) const;
728 int Compare(const CFX_WideString& str) const;
730 int CompareNoCase(const FX_WCHAR* str) const;
732 bool Equal(const wchar_t* ptr) const;
733 bool Equal(const CFX_WideStringC& str) const;
734 bool Equal(const CFX_WideString& other) const;
736 CFX_WideString Mid(FX_STRSIZE first) const;
738 CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
740 CFX_WideString Left(FX_STRSIZE count) const;
742 CFX_WideString Right(FX_STRSIZE count) const;
744 FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
746 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
748 void Format(const FX_WCHAR* lpszFormat, ... );
750 void FormatV(const FX_WCHAR* lpszFormat, va_list argList);
758 void TrimRight(FX_WCHAR chTarget);
760 void TrimRight(const FX_WCHAR* lpszTargets);
764 void TrimLeft(FX_WCHAR chTarget);
766 void TrimLeft(const FX_WCHAR* lpszTargets);
768 void Reserve(FX_STRSIZE len);
770 FX_WCHAR* GetBuffer(FX_STRSIZE len);
772 void ReleaseBuffer(FX_STRSIZE len = -1);
774 int GetInteger() const;
776 FX_FLOAT GetFloat() const;
778 FX_STRSIZE Find(const FX_WCHAR* lpszSub, FX_STRSIZE start = 0) const;
780 FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
782 FX_STRSIZE Replace(const FX_WCHAR* lpszOld, const FX_WCHAR* lpszNew);
784 FX_STRSIZE Remove(FX_WCHAR ch);
786 CFX_ByteString UTF8Encode() const;
788 CFX_ByteString UTF16LE_Encode() const;
790 void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
795 static StringData* Create(int nLen);
796 void Retain() { ++m_nRefs; }
797 void Release() { if (--m_nRefs <= 0) FX_Free(this); }
799 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
800 FX_STRSIZE m_nDataLength;
801 FX_STRSIZE m_nAllocLength;
802 FX_WCHAR m_String[1];
805 StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
806 : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
807 FXSYS_assert(dataLen >= 0);
808 FXSYS_assert(allocLen >= 0);
809 FXSYS_assert(dataLen <= allocLen);
810 m_String[dataLen] = 0;
812 ~StringData() = delete;
815 void CopyBeforeWrite();
816 void AllocBeforeWrite(FX_STRSIZE nLen);
817 void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
818 void ConcatCopy(FX_STRSIZE nSrc1Len, const FX_WCHAR* lpszSrc1Data, FX_STRSIZE nSrc2Len, const FX_WCHAR* lpszSrc2Data);
819 void AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
820 void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex) const;
823 friend class fxcrt_WideStringConcatInPlace_Test;
825 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
828 m_Length = src.GetLength();
830 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
833 m_Length = src.GetLength();
837 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2)
839 return CFX_WideString(str1, str2);
841 inline CFX_WideString operator + (const CFX_WideStringC& str1, const FX_WCHAR* str2)
843 return CFX_WideString(str1, str2);
845 inline CFX_WideString operator + (const FX_WCHAR* str1, const CFX_WideStringC& str2)
847 return CFX_WideString(str1, str2);
849 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch)
851 return CFX_WideString(str1, CFX_WideStringC(ch));
853 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2)
855 return CFX_WideString(ch, str2);
857 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2)
859 return CFX_WideString(str1, str2);
861 inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch)
863 return CFX_WideString(str1, CFX_WideStringC(ch));
865 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2)
867 return CFX_WideString(ch, str2);
869 inline CFX_WideString operator + (const CFX_WideString& str1, const FX_WCHAR* str2)
871 return CFX_WideString(str1, str2);
873 inline CFX_WideString operator + (const FX_WCHAR* str1, const CFX_WideString& str2)
875 return CFX_WideString(str1, str2);
877 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2)
879 return CFX_WideString(str1, str2);
881 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2)
883 return CFX_WideString(str1, str2);
885 inline bool operator== (const wchar_t* lhs, const CFX_WideString& rhs) {
888 inline bool operator== (const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
891 inline bool operator!= (const wchar_t* lhs, const CFX_WideString& rhs) {
894 inline bool operator!= (const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
897 FX_FLOAT FX_atof(const CFX_ByteStringC& str);
898 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
899 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
900 CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len);
901 inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr)
903 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
905 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr)
907 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
910 #endif // CORE_INCLUDE_FXCRT_FX_STRING_H_