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
23 class CFX_ByteStringC {
25 typedef FX_CHAR value_type;
32 CFX_ByteStringC(const uint8_t* ptr, FX_STRSIZE size) {
37 CFX_ByteStringC(const FX_CHAR* ptr) {
38 m_Ptr = (const uint8_t*)ptr;
39 m_Length = ptr ? FXSYS_strlen(ptr) : 0;
42 // |ch| must be an lvalue that outlives the the CFX_ByteStringC. However,
43 // the use of char rvalues are not caught at compile time. They are
44 // implicitly promoted to CFX_ByteString (see below) and then the
45 // CFX_ByteStringC is constructed from the CFX_ByteString via the alternate
46 // constructor below. The CFX_ByteString then typically goes out of scope
47 // and |m_Ptr| may be left pointing to invalid memory. Beware.
48 // TODO(tsepez): Mark single-argument string constructors as explicit.
49 CFX_ByteStringC(FX_CHAR& ch) {
50 m_Ptr = (const uint8_t*)&ch;
54 CFX_ByteStringC(const FX_CHAR* ptr, FX_STRSIZE len) {
55 m_Ptr = (const uint8_t*)ptr;
56 m_Length = (len == -1) ? FXSYS_strlen(ptr) : len;
59 CFX_ByteStringC(const CFX_ByteStringC& src) {
61 m_Length = src.m_Length;
64 CFX_ByteStringC(const CFX_ByteString& src);
66 CFX_ByteStringC& operator=(const FX_CHAR* src) {
67 m_Ptr = (const uint8_t*)src;
68 m_Length = m_Ptr ? FXSYS_strlen(src) : 0;
72 CFX_ByteStringC& operator=(const CFX_ByteStringC& src) {
74 m_Length = src.m_Length;
78 CFX_ByteStringC& operator=(const CFX_ByteString& src);
80 bool operator==(const char* ptr) const {
81 return FXSYS_strlen(ptr) == m_Length &&
82 FXSYS_memcmp(ptr, m_Ptr, m_Length) == 0;
84 bool operator==(const CFX_ByteStringC& other) const {
85 return other.m_Length == m_Length &&
86 FXSYS_memcmp(other.m_Ptr, m_Ptr, m_Length) == 0;
88 bool operator!=(const char* ptr) const { return !(*this == ptr); }
89 bool operator!=(const CFX_ByteStringC& other) const {
90 return !(*this == other);
93 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
95 const uint8_t* GetPtr() const { return m_Ptr; }
97 const FX_CHAR* GetCStr() const { return (const FX_CHAR*)m_Ptr; }
99 FX_STRSIZE GetLength() const { return m_Length; }
101 bool IsEmpty() const { return m_Length == 0; }
103 uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
105 CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
109 if (index > m_Length) {
110 return CFX_ByteStringC();
112 if (count < 0 || count > m_Length - index) {
113 count = m_Length - index;
115 return CFX_ByteStringC(m_Ptr + index, count);
118 const uint8_t& operator[](size_t index) const { return m_Ptr[index]; }
120 bool operator<(const CFX_ByteStringC& that) const {
121 int result = memcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
122 return result < 0 || (result == 0 && m_Length < that.m_Length);
126 const uint8_t* m_Ptr;
130 void* operator new(size_t) throw() { return NULL; }
132 inline bool operator==(const char* lhs, const CFX_ByteStringC& rhs) {
135 inline bool operator!=(const char* lhs, const CFX_ByteStringC& rhs) {
138 #define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str - 1)
139 #define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
141 // A mutable string with shared buffers using copy-on-write semantics that
142 // avoids the cost of std::string's iterator stability guarantees.
143 class CFX_ByteString {
145 typedef FX_CHAR value_type;
147 CFX_ByteString() : m_pData(nullptr) {}
150 CFX_ByteString(const CFX_ByteString& str);
153 inline CFX_ByteString(CFX_ByteString&& other) {
154 m_pData = other.m_pData;
155 other.m_pData = nullptr;
158 CFX_ByteString(char ch);
159 CFX_ByteString(const FX_CHAR* ptr)
160 : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
162 CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len);
163 CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
165 CFX_ByteString(const CFX_ByteStringC& bstrc);
166 CFX_ByteString(const CFX_ByteStringC& bstrc1, const CFX_ByteStringC& bstrc2);
170 static CFX_ByteString FromUnicode(const FX_WCHAR* ptr, FX_STRSIZE len = -1);
172 static CFX_ByteString FromUnicode(const CFX_WideString& str);
174 // Explicit conversion to raw string
175 const FX_CHAR* c_str() const { return m_pData ? m_pData->m_String : ""; }
177 // Implicit conversion to C-style string -- deprecated
178 operator const FX_CHAR*() const { return m_pData ? m_pData->m_String : ""; }
180 operator const uint8_t*() const {
181 return m_pData ? (const uint8_t*)m_pData->m_String : NULL;
184 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
186 bool IsEmpty() const { return !GetLength(); }
188 int Compare(const CFX_ByteStringC& str) const;
190 bool Equal(const char* ptr) const;
191 bool Equal(const CFX_ByteStringC& str) const;
192 bool Equal(const CFX_ByteString& other) const;
194 bool EqualNoCase(const CFX_ByteStringC& str) const;
196 bool operator==(const char* ptr) const { return Equal(ptr); }
197 bool operator==(const CFX_ByteStringC& str) const { return Equal(str); }
198 bool operator==(const CFX_ByteString& other) const { return Equal(other); }
200 bool operator!=(const char* ptr) const { return !(*this == ptr); }
201 bool operator!=(const CFX_ByteStringC& str) const { return !(*this == str); }
202 bool operator!=(const CFX_ByteString& other) const {
203 return !(*this == other);
206 bool operator<(const CFX_ByteString& str) const {
207 int result = FXSYS_memcmp(c_str(), str.c_str(),
208 std::min(GetLength(), str.GetLength()));
209 return result < 0 || (result == 0 && GetLength() < str.GetLength());
214 const CFX_ByteString& operator=(const FX_CHAR* str);
216 const CFX_ByteString& operator=(const CFX_ByteStringC& bstrc);
218 const CFX_ByteString& operator=(const CFX_ByteString& stringSrc);
220 const CFX_ByteString& operator=(const CFX_BinaryBuf& buf);
222 void Load(const uint8_t* str, FX_STRSIZE len);
224 const CFX_ByteString& operator+=(FX_CHAR ch);
226 const CFX_ByteString& operator+=(const FX_CHAR* str);
228 const CFX_ByteString& operator+=(const CFX_ByteString& str);
230 const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc);
232 uint8_t GetAt(FX_STRSIZE nIndex) const {
233 return m_pData ? m_pData->m_String[nIndex] : 0;
236 uint8_t operator[](FX_STRSIZE nIndex) const {
237 return m_pData ? m_pData->m_String[nIndex] : 0;
240 void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
242 FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
244 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
246 void Format(const FX_CHAR* lpszFormat, ...);
248 void FormatV(const FX_CHAR* lpszFormat, va_list argList);
250 void Reserve(FX_STRSIZE len);
252 FX_CHAR* GetBuffer(FX_STRSIZE len);
254 void ReleaseBuffer(FX_STRSIZE len = -1);
256 CFX_ByteString Mid(FX_STRSIZE first) const;
258 CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
260 CFX_ByteString Left(FX_STRSIZE count) const;
262 CFX_ByteString Right(FX_STRSIZE count) const;
264 FX_STRSIZE Find(const CFX_ByteStringC& lpszSub, FX_STRSIZE start = 0) const;
266 FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start = 0) const;
268 FX_STRSIZE ReverseFind(FX_CHAR ch) const;
276 void TrimRight(FX_CHAR chTarget);
278 void TrimRight(const CFX_ByteStringC& lpszTargets);
282 void TrimLeft(FX_CHAR chTarget);
284 void TrimLeft(const CFX_ByteStringC& lpszTargets);
286 FX_STRSIZE Replace(const CFX_ByteStringC& lpszOld,
287 const CFX_ByteStringC& lpszNew);
289 FX_STRSIZE Remove(FX_CHAR ch);
291 CFX_WideString UTF8Decode() const;
293 void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
295 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
297 #define FXFORMAT_SIGNED 1
298 #define FXFORMAT_HEX 2
299 #define FXFORMAT_CAPITAL 4
301 static CFX_ByteString FormatInteger(int i, FX_DWORD flags = 0);
302 static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
305 // To ensure ref counts do not overflow, consider the worst possible case:
306 // the entire address space contains nothing but pointers to this object.
307 // Since the count increments with each new pointer, the largest value is
308 // the number of pointers that can fit into the address space. The size of
309 // the address space itself is a good upper bound on it; we need not go
313 static StringData* Create(int nLen);
314 void Retain() { ++m_nRefs; }
320 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
321 FX_STRSIZE m_nDataLength;
322 FX_STRSIZE m_nAllocLength;
326 StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
327 : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
328 FXSYS_assert(dataLen >= 0);
329 FXSYS_assert(allocLen >= 0);
330 FXSYS_assert(dataLen <= allocLen);
331 m_String[dataLen] = 0;
333 ~StringData() = delete;
336 void AllocCopy(CFX_ByteString& dest,
338 FX_STRSIZE nCopyIndex) const;
339 void AssignCopy(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
340 void ConcatCopy(FX_STRSIZE nSrc1Len,
341 const FX_CHAR* lpszSrc1Data,
343 const FX_CHAR* lpszSrc2Data);
344 void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_CHAR* lpszSrcData);
345 void CopyBeforeWrite();
346 void AllocBeforeWrite(FX_STRSIZE nLen);
349 friend class fxcrt_ByteStringConcatInPlace_Test;
351 inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src) {
352 m_Ptr = (const uint8_t*)src;
353 m_Length = src.GetLength();
355 inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) {
356 m_Ptr = (const uint8_t*)src;
357 m_Length = src.GetLength();
361 inline bool operator==(const char* lhs, const CFX_ByteString& rhs) {
364 inline bool operator==(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
367 inline bool operator!=(const char* lhs, const CFX_ByteString& rhs) {
370 inline bool operator!=(const CFX_ByteStringC& lhs, const CFX_ByteString& rhs) {
374 inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
375 const CFX_ByteStringC& str2) {
376 return CFX_ByteString(str1, str2);
378 inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
379 const FX_CHAR* str2) {
380 return CFX_ByteString(str1, str2);
382 inline CFX_ByteString operator+(const FX_CHAR* str1,
383 const CFX_ByteStringC& str2) {
384 return CFX_ByteString(str1, str2);
386 inline CFX_ByteString operator+(const CFX_ByteStringC& str1, FX_CHAR ch) {
387 return CFX_ByteString(str1, CFX_ByteStringC(ch));
389 inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteStringC& str2) {
390 return CFX_ByteString(ch, str2);
392 inline CFX_ByteString operator+(const CFX_ByteString& str1,
393 const CFX_ByteString& str2) {
394 return CFX_ByteString(str1, str2);
396 inline CFX_ByteString operator+(const CFX_ByteString& str1, FX_CHAR ch) {
397 return CFX_ByteString(str1, CFX_ByteStringC(ch));
399 inline CFX_ByteString operator+(FX_CHAR ch, const CFX_ByteString& str2) {
400 return CFX_ByteString(ch, str2);
402 inline CFX_ByteString operator+(const CFX_ByteString& str1,
403 const FX_CHAR* str2) {
404 return CFX_ByteString(str1, str2);
406 inline CFX_ByteString operator+(const FX_CHAR* str1,
407 const CFX_ByteString& str2) {
408 return CFX_ByteString(str1, str2);
410 inline CFX_ByteString operator+(const CFX_ByteString& str1,
411 const CFX_ByteStringC& str2) {
412 return CFX_ByteString(str1, str2);
414 inline CFX_ByteString operator+(const CFX_ByteStringC& str1,
415 const CFX_ByteString& str2) {
416 return CFX_ByteString(str1, str2);
418 class CFX_WideStringC {
420 typedef FX_WCHAR value_type;
427 CFX_WideStringC(const FX_WCHAR* ptr) {
429 m_Length = ptr ? FXSYS_wcslen(ptr) : 0;
432 CFX_WideStringC(FX_WCHAR& ch) {
437 CFX_WideStringC(const FX_WCHAR* ptr, FX_STRSIZE len) {
439 m_Length = (len == -1) ? FXSYS_wcslen(ptr) : len;
442 CFX_WideStringC(const CFX_WideStringC& src) {
444 m_Length = src.m_Length;
447 CFX_WideStringC(const CFX_WideString& src);
449 CFX_WideStringC& operator=(const FX_WCHAR* src) {
451 m_Length = FXSYS_wcslen(src);
455 CFX_WideStringC& operator=(const CFX_WideStringC& src) {
457 m_Length = src.m_Length;
461 CFX_WideStringC& operator=(const CFX_WideString& src);
463 bool operator==(const wchar_t* ptr) const {
464 return FXSYS_wcslen(ptr) == m_Length && wmemcmp(ptr, m_Ptr, m_Length) == 0;
466 bool operator==(const CFX_WideStringC& str) const {
467 return str.m_Length == m_Length && wmemcmp(str.m_Ptr, m_Ptr, m_Length) == 0;
469 bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
470 bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
472 const FX_WCHAR* GetPtr() const { return m_Ptr; }
474 FX_STRSIZE GetLength() const { return m_Length; }
476 bool IsEmpty() const { return m_Length == 0; }
478 FX_WCHAR GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
480 CFX_WideStringC Left(FX_STRSIZE count) const {
482 return CFX_WideStringC();
484 if (count > m_Length) {
487 return CFX_WideStringC(m_Ptr, count);
490 CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const {
494 if (index > m_Length) {
495 return CFX_WideStringC();
497 if (count < 0 || count > m_Length - index) {
498 count = m_Length - index;
500 return CFX_WideStringC(m_Ptr + index, count);
503 CFX_WideStringC Right(FX_STRSIZE count) const {
505 return CFX_WideStringC();
507 if (count > m_Length) {
510 return CFX_WideStringC(m_Ptr + m_Length - count, count);
513 const FX_WCHAR& operator[](size_t index) const { return m_Ptr[index]; }
515 bool operator<(const CFX_WideStringC& that) const {
516 int result = wmemcmp(m_Ptr, that.m_Ptr, std::min(m_Length, that.m_Length));
517 return result < 0 || (result == 0 && m_Length < that.m_Length);
521 const FX_WCHAR* m_Ptr;
525 void* operator new(size_t) throw() { return NULL; }
527 inline bool operator==(const wchar_t* lhs, const CFX_WideStringC& rhs) {
530 inline bool operator!=(const wchar_t* lhs, const CFX_WideStringC& rhs) {
533 #define FX_WSTRC(wstr) CFX_WideStringC(wstr, FX_ArraySize(wstr) - 1)
535 // A mutable string with shared buffers using copy-on-write semantics that
536 // avoids the cost of std::string's iterator stability guarantees.
537 class CFX_WideString {
539 typedef FX_WCHAR value_type;
541 CFX_WideString() : m_pData(nullptr) {}
544 CFX_WideString(const CFX_WideString& str);
547 inline CFX_WideString(CFX_WideString&& other) {
548 m_pData = other.m_pData;
549 other.m_pData = nullptr;
552 CFX_WideString(const FX_WCHAR* ptr)
553 : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
555 CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
557 CFX_WideString(FX_WCHAR ch);
559 CFX_WideString(const CFX_WideStringC& str);
561 CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
565 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
567 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len);
569 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len);
571 static FX_STRSIZE WStringLength(const unsigned short* str);
573 // Explicit conversion to raw string
574 const FX_WCHAR* c_str() const { return m_pData ? m_pData->m_String : L""; }
576 // Implicit conversion to C-style wide string -- deprecated
577 operator const FX_WCHAR*() const { return m_pData ? m_pData->m_String : L""; }
581 FX_BOOL IsEmpty() const { return !GetLength(); }
583 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
585 const CFX_WideString& operator=(const FX_WCHAR* str);
587 const CFX_WideString& operator=(const CFX_WideString& stringSrc);
589 const CFX_WideString& operator=(const CFX_WideStringC& stringSrc);
591 const CFX_WideString& operator+=(const FX_WCHAR* str);
593 const CFX_WideString& operator+=(FX_WCHAR ch);
595 const CFX_WideString& operator+=(const CFX_WideString& str);
597 const CFX_WideString& operator+=(const CFX_WideStringC& str);
599 bool operator==(const wchar_t* ptr) const { return Equal(ptr); }
600 bool operator==(const CFX_WideStringC& str) const { return Equal(str); }
601 bool operator==(const CFX_WideString& other) const { return Equal(other); }
603 bool operator!=(const wchar_t* ptr) const { return !(*this == ptr); }
604 bool operator!=(const CFX_WideStringC& str) const { return !(*this == str); }
605 bool operator!=(const CFX_WideString& other) const {
606 return !(*this == other);
609 bool operator<(const CFX_WideString& str) const {
611 wmemcmp(c_str(), str.c_str(), std::min(GetLength(), str.GetLength()));
612 return result < 0 || (result == 0 && GetLength() < str.GetLength());
615 FX_WCHAR GetAt(FX_STRSIZE nIndex) const {
616 return m_pData ? m_pData->m_String[nIndex] : 0;
619 FX_WCHAR operator[](FX_STRSIZE nIndex) const {
620 return m_pData ? m_pData->m_String[nIndex] : 0;
623 void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
625 int Compare(const FX_WCHAR* str) const;
627 int Compare(const CFX_WideString& str) const;
629 int CompareNoCase(const FX_WCHAR* str) const;
631 bool Equal(const wchar_t* ptr) const;
632 bool Equal(const CFX_WideStringC& str) const;
633 bool Equal(const CFX_WideString& other) const;
635 CFX_WideString Mid(FX_STRSIZE first) const;
637 CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
639 CFX_WideString Left(FX_STRSIZE count) const;
641 CFX_WideString Right(FX_STRSIZE count) const;
643 FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
645 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
647 void Format(const FX_WCHAR* lpszFormat, ...);
649 void FormatV(const FX_WCHAR* lpszFormat, va_list argList);
657 void TrimRight(FX_WCHAR chTarget);
659 void TrimRight(const FX_WCHAR* lpszTargets);
663 void TrimLeft(FX_WCHAR chTarget);
665 void TrimLeft(const FX_WCHAR* lpszTargets);
667 void Reserve(FX_STRSIZE len);
669 FX_WCHAR* GetBuffer(FX_STRSIZE len);
671 void ReleaseBuffer(FX_STRSIZE len = -1);
673 int GetInteger() const;
675 FX_FLOAT GetFloat() const;
677 FX_STRSIZE Find(const FX_WCHAR* lpszSub, FX_STRSIZE start = 0) const;
679 FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start = 0) const;
681 FX_STRSIZE Replace(const FX_WCHAR* lpszOld, const FX_WCHAR* lpszNew);
683 FX_STRSIZE Remove(FX_WCHAR ch);
685 CFX_ByteString UTF8Encode() const;
687 CFX_ByteString UTF16LE_Encode() const;
689 void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
694 static StringData* Create(int nLen);
695 void Retain() { ++m_nRefs; }
701 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support.
702 FX_STRSIZE m_nDataLength;
703 FX_STRSIZE m_nAllocLength;
704 FX_WCHAR m_String[1];
707 StringData(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
708 : m_nRefs(1), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
709 FXSYS_assert(dataLen >= 0);
710 FXSYS_assert(allocLen >= 0);
711 FXSYS_assert(dataLen <= allocLen);
712 m_String[dataLen] = 0;
714 ~StringData() = delete;
717 void CopyBeforeWrite();
718 void AllocBeforeWrite(FX_STRSIZE nLen);
719 void ConcatInPlace(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
720 void ConcatCopy(FX_STRSIZE nSrc1Len,
721 const FX_WCHAR* lpszSrc1Data,
723 const FX_WCHAR* lpszSrc2Data);
724 void AssignCopy(FX_STRSIZE nSrcLen, const FX_WCHAR* lpszSrcData);
725 void AllocCopy(CFX_WideString& dest,
727 FX_STRSIZE nCopyIndex) const;
730 friend class fxcrt_WideStringConcatInPlace_Test;
732 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src) {
734 m_Length = src.GetLength();
736 inline CFX_WideStringC& CFX_WideStringC::operator=(const CFX_WideString& src) {
738 m_Length = src.GetLength();
742 inline CFX_WideString operator+(const CFX_WideStringC& str1,
743 const CFX_WideStringC& str2) {
744 return CFX_WideString(str1, str2);
746 inline CFX_WideString operator+(const CFX_WideStringC& str1,
747 const FX_WCHAR* str2) {
748 return CFX_WideString(str1, str2);
750 inline CFX_WideString operator+(const FX_WCHAR* str1,
751 const CFX_WideStringC& str2) {
752 return CFX_WideString(str1, str2);
754 inline CFX_WideString operator+(const CFX_WideStringC& str1, FX_WCHAR ch) {
755 return CFX_WideString(str1, CFX_WideStringC(ch));
757 inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideStringC& str2) {
758 return CFX_WideString(ch, str2);
760 inline CFX_WideString operator+(const CFX_WideString& str1,
761 const CFX_WideString& str2) {
762 return CFX_WideString(str1, str2);
764 inline CFX_WideString operator+(const CFX_WideString& str1, FX_WCHAR ch) {
765 return CFX_WideString(str1, CFX_WideStringC(ch));
767 inline CFX_WideString operator+(FX_WCHAR ch, const CFX_WideString& str2) {
768 return CFX_WideString(ch, str2);
770 inline CFX_WideString operator+(const CFX_WideString& str1,
771 const FX_WCHAR* str2) {
772 return CFX_WideString(str1, str2);
774 inline CFX_WideString operator+(const FX_WCHAR* str1,
775 const CFX_WideString& str2) {
776 return CFX_WideString(str1, str2);
778 inline CFX_WideString operator+(const CFX_WideString& str1,
779 const CFX_WideStringC& str2) {
780 return CFX_WideString(str1, str2);
782 inline CFX_WideString operator+(const CFX_WideStringC& str1,
783 const CFX_WideString& str2) {
784 return CFX_WideString(str1, str2);
786 inline bool operator==(const wchar_t* lhs, const CFX_WideString& rhs) {
789 inline bool operator==(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
792 inline bool operator!=(const wchar_t* lhs, const CFX_WideString& rhs) {
795 inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
798 FX_FLOAT FX_atof(const CFX_ByteStringC& str);
799 void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData);
800 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
801 CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len);
802 inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
803 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
805 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) {
806 return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
809 #endif // CORE_INCLUDE_FXCRT_FX_STRING_H_