Foxit PDF SDK

fx_string.h
Go to the documentation of this file.
1
16 //<<<+++OPENSOURCE
17 //<<<+++OPENSOURCE_LICENSE
18 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT||LIC==GOOGLE
19
25 //<<<+++OPENSOURCE_MUST_BEGIN
26 #ifndef _FX_STRING_H_
27 #define _FX_STRING_H_
28 //<<<+++OPENSOURCE_MUST_END
29
30 class CFX_ByteStringC;
31 class CFX_ByteString;
32 class CFX_WideStringC;
33 class CFX_WideString;
34 struct CFX_CharMap;
35 class CFX_BinaryBuf;
36
38 typedef int FX_STRSIZE;
39
40 class CFX_ByteStringL;
41 class CFX_WideStringL;
42
43 //*****************************************************************************
44 //* CFX_ByteStringC - constant byte string
45 //*****************************************************************************
51 class CFX_ByteStringC : public CFX_Object
52 {
53 public:
57 CFX_ByteStringC()
58 {
59 m_Ptr = NULL;
60 m_Length = 0;
61 }
68 CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
69 {
70 m_Ptr = ptr;
71 m_Length = size;
72 }
73 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
74 #ifndef _NO_LPCSTR_SUPPORT_
75 //<<<+++OPENSOURCE_MUST_END
81 CFX_ByteStringC(FX_LPCSTR ptr)
82 {
83 m_Ptr = (FX_LPCBYTE)ptr;
84 m_Length = ptr ? (FX_STRSIZE)FXSYS_strlen(ptr) : 0;
85 }
86 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
87 #endif
88 //<<<+++OPENSOURCE_MUST_END
94 explicit CFX_ByteStringC(const FX_CHAR& ch)
95 {
96 m_Ptr = (FX_LPCBYTE)&ch;
97 m_Length = 1;
98 }
105 CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
106 {
107 m_Ptr = (FX_LPCBYTE)ptr;
108 if (len == -1)
109 m_Length = (FX_STRSIZE)FXSYS_strlen(ptr);
110 else
111 m_Length = len;
112 }
118 CFX_ByteStringC(const CFX_ByteStringC& src)
119 {
120 m_Ptr = src.m_Ptr;
121 m_Length = src.m_Length;
122 }
128 CFX_ByteStringC(const CFX_ByteString& src);
129
137 CFX_ByteStringC& operator = (FX_LPCSTR src)
138 {
139 m_Ptr = (FX_LPCBYTE)src;
140 m_Length = m_Ptr ? (FX_STRSIZE)FXSYS_strlen(src) : 0;
141 return *this;
142 }
150 CFX_ByteStringC& operator = (const CFX_ByteStringC& src)
151 {
152 m_Ptr = src.m_Ptr;
153 m_Length = src.m_Length;
154 return *this;
155 }
163 CFX_ByteStringC& operator = (const CFX_ByteString& src);
164
172 bool operator == (const CFX_ByteStringC& str) const
173 {
174 return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) == 0;
175 }
183 bool operator != (const CFX_ByteStringC& str) const
184 {
185 return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length) != 0;
186 }
187
189 #define FXBSTR_ID(c1, c2, c3, c4) ((c1 << 24) | (c2 << 16) | (c3 << 8) | (c4))
190
208 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
209
215 FX_LPCBYTE GetPtr() const { return m_Ptr; }
221 FX_LPCSTR GetCStr() const { return (FX_LPCSTR)m_Ptr; }
227 FX_STRSIZE GetLength() const { return m_Length; }
233 bool IsEmpty() const { return m_Length == 0; }
234
243 operator FX_LPCBYTE() const { return m_Ptr; }
244
252 FX_BYTE GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
253
263 CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
264 {
265 if (index < 0) index = 0;
266 if (index > m_Length) return CFX_ByteStringC();
267 if (count < 0 || count > m_Length - index) count = m_Length - index;
268 return CFX_ByteStringC(m_Ptr + index, count);
269 }
270
271 protected:
272 /* The constant byte string pointer. */
273 FX_LPCBYTE m_Ptr;
274 /* The length in bytes of the byte string. */
275 FX_STRSIZE m_Length;
276
277 private:
278 /*
279 * "new" operator forbidden. Cannot allocate a CFX_ByteStringC in heap.
280 */
281 void* operator new (size_t) throw() { return NULL; }
282 };
283
285 typedef const CFX_ByteStringC& FX_BSTR;
286
296 #define FX_BSTRC(str) CFX_ByteStringC(str, sizeof str-1)
297
298 //*****************************************************************************
299 //* CFX_ByteString - byte string
300 //*****************************************************************************
302 struct CFX_StringData
303 {
305 long m_nRefs;
307 FX_STRSIZE m_nDataLength;
309 FX_STRSIZE m_nAllocLength;
311 FX_CHAR m_String[1];
312 };
313
317 class CFX_ByteString : public CFX_Object
318 {
319 public:
323 CFX_ByteString() { m_pData = NULL; }
329 CFX_ByteString(const CFX_ByteString& str);
335 explicit CFX_ByteString(char ch);
342 CFX_ByteString(FX_LPCSTR ptr, FX_STRSIZE len=-1);
349 CFX_ByteString(FX_LPCBYTE ptr, FX_STRSIZE len);
355 CFX_ByteString(FX_BSTR bstrc);
362 CFX_ByteString(FX_BSTR bstrc1, FX_BSTR bstrc2);
366 ~CFX_ByteString();
367
376 static CFX_ByteString FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len = -1);
384 static CFX_ByteString FromUnicode(const CFX_WideString& str);
385
386 //<<<+++OPENSOURCE_MUST_END
387
391 operator FX_LPCSTR() const { return m_pData ? m_pData->m_String : ""; }
395 operator FX_LPCBYTE() const { return m_pData ? (FX_LPCBYTE)m_pData->m_String : NULL; }
396
402 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
403
409 bool IsEmpty() const { return !GetLength(); }
421 int Compare(FX_BSTR str) const;
422
433 bool Equal(FX_BSTR str) const;
434
444 bool EqualNoCase(FX_BSTR str) const;
445
446 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
447 #ifndef _NO_LPCSTR_SUPPORT_
448 //<<<+++OPENSOURCE_MUST_END
456 bool operator == (FX_LPCSTR str) const { return Equal(str); }
457 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
458 #endif
459 //<<<+++OPENSOURCE_MUST_END
467 bool operator == (FX_BSTR str) const { return Equal(str); }
475 bool operator == (const CFX_ByteString& str) const;
476 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
477 #ifndef _NO_LPCSTR_SUPPORT_
478 //<<<+++OPENSOURCE_MUST_END
486 bool operator != (FX_LPCSTR str) const { return !Equal(str); }
487 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
488 #endif
489 //<<<+++OPENSOURCE_MUST_END
497 bool operator != (FX_BSTR str) const { return !Equal(str); }
505 bool operator != (const CFX_ByteString& str) const { return !operator==(str); }
506
514 bool operator< (const CFX_ByteString& rhs) const;
515
521 void Empty();
522
530 const CFX_ByteString& operator = (FX_LPCSTR str);
538 const CFX_ByteString& operator = (FX_BSTR bstrc);
546 const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
554 const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
555
564 void Load(FX_LPCBYTE str, FX_STRSIZE len);
565
573 const CFX_ByteString& operator += (FX_CHAR ch);
581 const CFX_ByteString& operator += (FX_LPCSTR str);
589 const CFX_ByteString& operator += (const CFX_ByteString& str);
597 const CFX_ByteString& operator += (FX_BSTR bstrc);
598
606 FX_BYTE GetAt(FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
614 FX_BYTE operator[](FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
623 void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
624
633 FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
634
643 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
660 void Format(FX_LPCSTR lpszFormat, ... );
671 void FormatV(FX_LPCSTR lpszFormat, va_list argList);
683 void Reserve(FX_STRSIZE len);
684
696 FX_LPSTR GetBuffer(FX_STRSIZE len);
697
706 FX_LPSTR LockBuffer();
707
718 void ReleaseBuffer(FX_STRSIZE len = -1);
719
727 CFX_ByteString Mid(FX_STRSIZE first) const;
736 CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
744 CFX_ByteString Left(FX_STRSIZE count) const;
752 CFX_ByteString Right(FX_STRSIZE count) const;
761 FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start=0) const;
770 FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start=0) const;
778 FX_STRSIZE ReverseFind(FX_CHAR ch) const;
779
785 void MakeLower();
791 void MakeUpper();
792
798 void TrimRight();
806 void TrimRight(FX_CHAR chTarget);
814 void TrimRight(FX_BSTR lpszTargets);
820 void TrimLeft();
828 void TrimLeft(FX_CHAR chTarget);
836 void TrimLeft(FX_BSTR lpszTargets);
837
846 FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew);
854 FX_STRSIZE Remove(FX_CHAR ch);
855
861 CFX_WideString UTF8Decode() const;
862
872 void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
880 FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
888 static CFX_ByteString LoadFromFile(FX_BSTR file_path);
889
891 #define FXFORMAT_SIGNED 1
892
893 #define FXFORMAT_HEX 2
894
895 #define FXFORMAT_CAPITAL 4
896
912 static CFX_ByteString FormatInteger(FX_INT32 i, FX_DWORD flags = 0);
920 static CFX_ByteString FormatInteger64(FX_INT64 i);
921
932 static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
933
934 protected:
935 /* Pointer to ref counted byte string data. */
936 struct CFX_StringData* m_pData;
937
938 void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
939 void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
940 void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data);
941 void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
942 void CopyBeforeWrite();
943 void AllocBeforeWrite(FX_STRSIZE nLen);
944 };
945
946 inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
947 {
948 m_Ptr = (FX_LPCBYTE)src;
949 m_Length = src.GetLength();
950 }
951
952 inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
953 {
954 m_Ptr = (FX_LPCBYTE)src;
955 m_Length = src.GetLength();
956 return *this;
957 }
958
971
980 inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2) { return CFX_ByteString(str1, str2); }
981 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
982 #ifndef _NO_LPCSTR_SUPPORT_
983 //<<<+++OPENSOURCE_MUST_END
992 inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2) { return CFX_ByteString(str1, str2); }
1001 inline CFX_ByteString operator + (FX_LPCSTR str1,FX_BSTR str2) { return CFX_ByteString(str1, str2); }
1002 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1003 #endif
1004 //<<<+++OPENSOURCE_MUST_END
1013 inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch) { return CFX_ByteString(str1, CFX_ByteStringC(ch)); }
1022 inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2) { return CFX_ByteString(CFX_ByteStringC(ch), str2); }
1023
1032 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1041 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch) { return CFX_ByteString(str1, CFX_ByteStringC(ch)); }
1050 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2) { return CFX_ByteString(CFX_ByteStringC(ch), str2); }
1051 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1052 #ifndef _NO_LPCSTR_SUPPORT_
1053 //<<<+++OPENSOURCE_MUST_END
1062 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2) { return CFX_ByteString(str1, str2); }
1071 inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1072 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1073 #endif
1074 //<<<+++OPENSOURCE_MUST_END
1083 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) { return CFX_ByteString(str1, str2); }
1092 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1093
1102 class CFX_StringBufBase : public CFX_Object
1103 {
1104 public:
1110 explicit CFX_StringBufBase(FX_STRSIZE limit) { m_Size = 0; m_Limit = limit; }
1111
1117 FX_CHAR* GetPtr() const { return (FX_CHAR*)(this + 1); }
1123 FX_STRSIZE GetSize() const { return m_Size; }
1124
1130 void Empty() { m_Size = 0; }
1131
1139 void Copy(FX_BSTR str);
1140
1148 void Append(FX_BSTR str);
1149
1160 void Append(int i, FX_DWORD flags = 0);
1161
1167 CFX_ByteStringC GetStringC() const { return CFX_ByteStringC((FX_CHAR*)(this + 1), m_Size); }
1173 CFX_ByteString GetString() const { return CFX_ByteString((FX_CHAR*)(this + 1), m_Size); }
1174
1175 protected:
1176 /* The buffer limit. */
1177 FX_STRSIZE m_Limit;
1178 /* The string size. */
1179 FX_STRSIZE m_Size;
1180 // the real buffer follows
1181 };
1182
1186 template<FX_STRSIZE limit>
1187 class CFX_StringBufTemplate : public CFX_StringBufBase
1188 {
1189 public:
1193 CFX_StringBufTemplate() : CFX_StringBufBase(limit) {FXSYS_memset32(m_Buffer, 0, limit * sizeof(FX_CHAR));}
1194
1200 FX_CHAR m_Buffer[limit];
1201 };
1202
1204 typedef CFX_StringBufTemplate<256> CFX_StringBuf256;
1205
1206 //*****************************************************************************
1207 //* CFX_WideStringC - constant wide string
1208 //*****************************************************************************
1214 class CFX_WideStringC : public CFX_Object
1215 {
1216 public:
1220 CFX_WideStringC()
1221 {
1222 m_Ptr = NULL;
1223 m_Length = 0;
1224 }
1225 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1226 #ifndef _NO_LPCSTR_SUPPORT_
1227 //<<<+++OPENSOURCE_MUST_END
1233 CFX_WideStringC(FX_LPCWSTR ptr)
1234 {
1235 m_Ptr = ptr;
1236 m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
1237 }
1238 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1239 #endif
1240 //<<<+++OPENSOURCE_MUST_END
1246 CFX_WideStringC(FX_WCHAR& ch)
1247 {
1248 m_Ptr = &ch;
1249 m_Length = 1;
1250 }
1257 CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
1258 {
1259 m_Ptr = ptr;
1260 if (len == -1)
1261 m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
1262 else
1263 m_Length = len;
1264 }
1270 CFX_WideStringC(const CFX_WideStringC& src)
1271 {
1272 m_Ptr = src.m_Ptr;
1273 m_Length = src.m_Length;
1274 }
1280 CFX_WideStringC(const CFX_WideString& src);
1281
1289 CFX_WideStringC& operator = (FX_LPCWSTR src)
1290 {
1291 m_Ptr = src;
1292 m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
1293 return *this;
1294 }
1302 CFX_WideStringC& operator = (const CFX_WideStringC& src)
1303 {
1304 m_Ptr = src.m_Ptr;
1305 m_Length = src.m_Length;
1306 return *this;
1307 }
1315 CFX_WideStringC& operator = (const CFX_WideString& src);
1316
1324 bool operator == (const CFX_WideStringC& str) const
1325 {
1326 return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length*sizeof(FX_WCHAR)) == 0;
1327 }
1335 bool operator != (const CFX_WideStringC& str) const
1336 {
1337 return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length*sizeof(FX_WCHAR)) != 0;
1338 }
1339
1345 FX_LPCWSTR GetPtr() const { return m_Ptr; }
1351 FX_STRSIZE GetLength() const { return m_Length; }
1357 bool IsEmpty() const { return m_Length == 0; }
1358
1366 FX_WCHAR GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
1367
1375 CFX_WideStringC Left(FX_STRSIZE count) const
1376 {
1377 if (count < 1) return CFX_WideStringC();
1378 if (count > m_Length) count = m_Length;
1379 return CFX_WideStringC(m_Ptr, count);
1380 }
1381
1390 CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
1391 {
1392 if (index < 0) index = 0;
1393 if (index > m_Length) return CFX_WideStringC();
1394 if (count < 0 || count > m_Length - index) count = m_Length - index;
1395 return CFX_WideStringC(m_Ptr + index, count);
1396 }
1397
1405 CFX_WideStringC Right(FX_STRSIZE count) const
1406 {
1407 if (count < 1) return CFX_WideStringC();
1408 if (count > m_Length) count = m_Length;
1409 return CFX_WideStringC(m_Ptr + m_Length - count, count);
1410 }
1411
1412 protected:
1413 /* The constant byte string pointer. */
1414 FX_LPCWSTR m_Ptr;
1415 /* the length in bytes of the byte string. */
1416 FX_STRSIZE m_Length;
1417
1418 private:
1419 /*
1420 * new operator forbidden. Cannot allocate a CFX_WideStringC in heap.
1421 */
1422 void* operator new (size_t) throw() { return NULL; }
1423 };
1424
1426 typedef const CFX_WideStringC& FX_WSTR;
1427
1437 #define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
1438
1439 //*****************************************************************************
1440 //* CFX_WideString - wide string
1441 //*****************************************************************************
1443 struct CFX_StringDataW
1444 {
1446 long m_nRefs;
1448 FX_STRSIZE m_nDataLength;
1450 FX_STRSIZE m_nAllocLength;
1452 FX_WCHAR m_String[1];
1453 };
1454
1461 class CFX_WideString : public CFX_Object
1462 {
1463 public:
1467 CFX_WideString() { m_pData = NULL; }
1473 CFX_WideString(const CFX_WideString& str);
1480 CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1) { InitStr(ptr, len); }
1481
1487 CFX_WideString(FX_WCHAR ch);
1493 CFX_WideString(const CFX_WideStringC& str);
1500 CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
1504 ~CFX_WideString();
1505
1515 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
1524 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len = -1);
1533 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len = -1);
1534
1543 static CFX_WideString FromUTF16BE(const unsigned short* str, FX_STRSIZE len = -1);
1544
1552 static FX_STRSIZE WStringLength(const unsigned short* str);
1553
1557 operator FX_LPCWSTR() const { return m_pData ? m_pData->m_String : (FX_WCHAR*)L""; }
1558
1564 void Empty();
1570 FX_BOOL IsEmpty() const { return !GetLength(); }
1571
1577 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
1578
1586 const CFX_WideString& operator = (FX_LPCWSTR str);
1587
1595 const CFX_WideString& operator =(const CFX_WideString& stringSrc);
1603 const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
1604
1612 const CFX_WideString& operator += (FX_LPCWSTR str);
1613
1621 const CFX_WideString& operator += (FX_WCHAR ch);
1629 const CFX_WideString& operator += (const CFX_WideString& str);
1637 const CFX_WideString& operator += (const CFX_WideStringC& str);
1638
1646 FX_WCHAR GetAt(FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
1654 FX_WCHAR operator[](FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
1663 void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
1664
1676 int Compare(FX_LPCWSTR str) const;
1688 int Compare(const CFX_WideString& str) const;
1689
1701 int CompareNoCase(FX_LPCWSTR str) const;
1702
1713 bool Equal(const CFX_WideStringC& str) const;
1714
1722 CFX_WideString Mid(FX_STRSIZE first) const;
1732 CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
1740 CFX_WideString Left(FX_STRSIZE count) const;
1748 CFX_WideString Right(FX_STRSIZE count) const;
1749
1758 FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
1767 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
1775 void Format(FX_LPCWSTR lpszFormat, ... );
1786 void FormatV(FX_LPCWSTR lpszFormat, va_list argList);
1792 void MakeLower();
1798 void MakeUpper();
1799
1805 void TrimRight();
1813 void TrimRight(FX_WCHAR chTarget);
1821 void TrimRight(FX_LPCWSTR lpszTargets);
1822
1828 void TrimLeft();
1836 void TrimLeft(FX_WCHAR chTarget);
1844 void TrimLeft(FX_LPCWSTR lpszTargets);
1845
1855 void Reserve(FX_STRSIZE len);
1863 FX_LPWSTR GetBuffer(FX_STRSIZE len);
1870 FX_LPWSTR LockBuffer();
1879 void ReleaseBuffer(FX_STRSIZE len = -1);
1880
1886 int GetInteger() const;
1887
1893 FX_FLOAT GetFloat() const;
1894
1903 FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start=0) const;
1912 FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start=0) const;
1913
1922 FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew);
1930 FX_STRSIZE Remove(FX_WCHAR ch);
1931
1937 CFX_ByteString UTF8Encode() const;
1945 CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate = true) const;
1946
1957 void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
1958
1959 protected:
1960 void InitStr(FX_LPCWSTR ptr, int len);
1961
1962 /* Pointer to ref counted wide string data. */
1963 CFX_StringDataW* m_pData;
1964
1965 void CopyBeforeWrite();
1966 void AllocBeforeWrite(FX_STRSIZE nLen);
1967
1968 void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
1969 void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
1970 void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
1971 void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
1972 };
1973
1974 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
1975 {
1976 m_Ptr = (FX_LPCWSTR)src;
1977 m_Length = src.GetLength();
1978 }
1979
1980 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
1981 {
1982 m_Ptr = (FX_LPCWSTR)src;
1983 m_Length = src.GetLength();
1984 return *this;
1985 }
1986
2000
2009 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2010 #ifndef _NO_LPCSTR_SUPPORT_
2011
2019 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2) { return CFX_WideString(str1, str2); }
2028 inline CFX_WideString operator + (FX_LPCWSTR str1,const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2029 #endif
2030
2038 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch) { return CFX_WideString(str1, CFX_WideStringC(ch)); }
2047 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2) { return CFX_WideString(ch, str2); }
2048
2057 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2066 inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch) { return CFX_WideString(str1, CFX_WideStringC(ch)); }
2075 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2) { return CFX_WideString(ch, str2); }
2076 #ifndef _NO_LPCSTR_SUPPORT_
2077
2085 inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2) { return CFX_WideString(str1, str2); }
2094 inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2095 #endif
2096
2104 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2113 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2114
2121
2130 bool operator==(const CFX_WideString& s1, const CFX_WideString& s2);
2139 bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2);
2148 bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2);
2157 bool operator== (const CFX_WideString& s1, FX_LPCWSTR s2);
2166 bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2);
2167
2176 bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2);
2185 bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2);
2194 bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2);
2203 bool operator!= (const CFX_WideString& s1, FX_LPCWSTR s2);
2212 bool operator!=(FX_LPCWSTR s1, const CFX_WideString& s2);
2213
2222 bool operator< (const CFX_WideString& lhs, const CFX_WideString& rhs);
2223
2234 FX_FLOAT FX_atof(FX_BSTR str);
2245 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData, int sizeOfData = 4);
2246
2256 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf, int precision = 0);
2257
2269 FX_WCHAR FXWCHAR_GetUpper(FX_WCHAR wchar);
2277 FX_WCHAR FXWCHAR_GetLower(FX_WCHAR wchar);
2286 FX_BOOL FXWCHAR_IsWordBreak(FX_WCHAR wchar);
2295 FX_BOOL FXWCHAR_IsSpace(FX_WCHAR wchar);
2301 #define FXWCHAR_LTR 0
2302
2303 #define FXWCHAR_RTL 1
2304
2305 #define FXWCHAR_UNKNOWN 2
2306
2315 int FXWCHAR_GetDirection(FX_WCHAR wchar);
2317 //<<<+++OPENSOURCE_END
2318
2323
2332 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len);
2340 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr)
2341 {
2342 return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());
2343 }
2351 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr)
2352 {
2353 return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength());
2354 }
2355
2368 inline FX_BOOL FX_IsUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
2369 {
2370 return ((first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00);
2371 }
2372
2384 inline FX_DWORD FX_CreateCodePointFromUtf16SurrogatePair(FX_WCHAR first,
2385 FX_WCHAR second)
2386 {
2387 const FX_DWORD mask = (1 << 10) - 1;
2388 return (((first & mask) << 10) | (second & mask)) + 0x10000;
2389 // This function should not be called when the condition is
2390 // false, but we provide a sensible default in case it is.
2391 }
2392
2406 inline FX_BOOL FX_CreateUtf16SurrogatePairFromCodePoint(FX_DWORD unicode,
2407 FX_WCHAR& first,
2408 FX_WCHAR& second)
2409 {
2410 // 0x10000 = 0xFFFF+1
2411 if (unicode < 0x10000 || unicode > 0x10FFFF)
2412 return false;
2413
2414 /* high surrogate = top 10 bits added to D800 */
2415 first = (FX_WCHAR)(0xD800 - (0x10000 >> 10) + ((unicode) >> 10));
2416 /* low surrogate = bottom 10 bits added to DC00 */
2417 second = (FX_WCHAR)(0xDC00 + ((unicode)&0x3FF));
2418 return true;
2419 }
2420
2423 //*****************************************************************************
2424 //* CFX_ByteStringL - long term byte string
2425 //*****************************************************************************
2426 class CFX_ByteStringL : public CFX_ByteStringC
2427 {
2428 public:
2429 CFX_ByteStringL() : CFX_ByteStringC() {}
2430 ~CFX_ByteStringL() {}
2431
2432 void Empty(IFX_Allocator* pAllocator);
2433
2434 FX_LPSTR AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocator);
2435
2436 void Set(FX_BSTR src, IFX_Allocator* pAllocator);
2437 };
2438
2439 //*****************************************************************************
2440 //* CFX_WideStringL - long term wide string
2441 //*****************************************************************************
2442 class CFX_WideStringL : public CFX_WideStringC
2443 {
2444 public:
2445 CFX_WideStringL() : CFX_WideStringC() {}
2446 ~CFX_WideStringL() {}
2447
2448 void Empty(IFX_Allocator* pAllocator);
2449
2450 void Set(FX_WSTR src, IFX_Allocator* pAllocator);
2451
2452 int GetInteger() const;
2453 FX_FLOAT GetFloat() const;
2454
2455 void TrimRight(FX_LPCWSTR lpszTargets);
2456 };
2457
2458 void FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len, CFX_ByteStringL &utf8Str, IFX_Allocator* pAllocator = NULL);
2459 //<<<+++OPENSOURCE_END
2460
2461 //<<<+++OPENSOURCE_MUST_BEGIN
2462 #endif // _FX_STRING_H_
2463 //<<<+++OPENSOURCE_MUST_END
2464
2467 //<<<+++OPENSOURCE_END
CFX_WideString::Equal
bool Equal(const CFX_WideStringC &str) const
Check if current string is equal to another.
FX_BYTE
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:665
CFX_ByteString::GetAt
FX_BYTE GetAt(FX_STRSIZE nIndex) const
Get a single byte specified by an index number.
Definition: fx_string.h:606
CFX_ByteString::GetBuffer
FX_LPSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of bytes allocated.
CFX_WideString::GetBuffer
FX_LPWSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of characters allocated.
CFX_ByteString::GetLength
FX_STRSIZE GetLength() const
Get number of bytes in the byte string (not counting any possible terminator).
Definition: fx_string.h:402
CFX_ByteStringC::GetCStr
FX_LPCSTR GetCStr() const
Get a constant character string pointer to the byte string.
Definition: fx_string.h:221
CFX_ByteString::MakeUpper
void MakeUpper()
Change case of English letters to upper.
CFX_WideString::ConvertFrom
void ConvertFrom(const CFX_ByteString &str, CFX_CharMap *pCharMap=NULL)
Load MBCS data into this wide string, using specified character mapper.
FX_DWORD
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:726
CFX_StringDataW::m_nAllocLength
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:1450
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
Constructs from a byte string.
Definition: fx_string.h:68
CFX_ByteString::operator<
bool operator<(const CFX_ByteString &rhs) const
Comparison(<) operator overload. case-sensitive.
CFX_WideStringC::Right
CFX_WideStringC Right(FX_STRSIZE count) const
Extracts the last (rightmost) count wide characters from this CFX_WideStringC object as a sub-string.
Definition: fx_string.h:1405
FXSYS_memcmp32
FX_INT32 FXSYS_memcmp32(const void *buf1, const void *buf2, size_t size)
Compare data in two buffers.
CFX_ByteString::Find
FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start=0) const
Find a sub-string, from specific position. Only first occurrence is found.
CFX_StringData::m_nAllocLength
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:309
CFX_ByteStringC::IsEmpty
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:233
CFX_WideString::MakeUpper
void MakeUpper()
Change case of English letters to upper.
CFX_ByteStringC::Mid
CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count=-1) const
This method extracts a substring of length count bytes from this CFX_ByteStringC object,...
Definition: fx_string.h:263
CFX_WideStringC::operator!=
bool operator!=(const CFX_WideStringC &str) const
Comparison(!=) operator overload. Case-sensitive.
Definition: fx_string.h:1335
CFX_WideString::FormatV
void FormatV(FX_LPCWSTR lpszFormat, va_list argList)
Format a number of parameters into this wide string. using va_list.
CFX_StringDataW::m_nDataLength
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:1448
FX_WCHAR
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:732
CFX_ByteStringC::operator!=
bool operator!=(const CFX_ByteStringC &str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:183
CFX_ByteString::operator==
bool operator==(FX_LPCSTR str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:456
CFX_WideString::Remove
FX_STRSIZE Remove(FX_WCHAR ch)
Remove all occurrence of a particular character.
CFX_StringBufBase::GetStringC
CFX_ByteStringC GetStringC() const
Get a non-buffered byte string.
Definition: fx_string.h:1167
CFX_StringBufBase::Copy
void Copy(FX_BSTR str)
Copy from a non-buffered byte string.
CFX_ByteString::operator=
const CFX_ByteString & operator=(FX_LPCSTR str)
Assignment(=) operator overload. From a character string.
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(FX_WCHAR &ch)
Construct from a single character.
Definition: fx_string.h:1246
CFX_StringBufBase::GetSize
FX_STRSIZE GetSize() const
Gets the length of the string.
Definition: fx_string.h:1123
CFX_ByteStringC::operator==
bool operator==(const CFX_ByteStringC &str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:172
FXWCHAR_GetUpper
FX_WCHAR FXWCHAR_GetUpper(FX_WCHAR wchar)
Convert to upper-case letter.
CFX_WideStringC::Mid
CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count=-1) const
Extracts a substring of length count bytes from this CFX_WideStringC object, starting at position ind...
Definition: fx_string.h:1390
CFX_WideString::Compare
int Compare(FX_LPCWSTR str) const
Compare current string with a wide character string. Case-sensitive.
CFX_StringBufTemplate::CFX_StringBufTemplate
CFX_StringBufTemplate()
A constructor.
Definition: fx_string.h:1193
CFX_StringBufBase::Empty
void Empty()
Set this string to be empty.
Definition: fx_string.h:1130
CFX_ByteString::Left
CFX_ByteString Left(FX_STRSIZE count) const
Extracts the first (leftmost) count bytes from this CFX_ByteString object as a sub-string.
CFX_ByteString::Compare
int Compare(FX_BSTR str) const
Compare the the string with another. Case-sensitive.
CFX_ByteString::FormatFloat
static CFX_ByteString FormatFloat(FX_FLOAT f, int precision=0)
Convert from floating-point number.
FXSYS_strlen
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:879
CFX_ByteString::Reserve
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of bytes.
CFX_WideString::LockBuffer
FX_LPWSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer....
CFX_ByteString::Format
void Format(FX_LPCSTR lpszFormat,...)
Format a number of parameters into this byte string.
FXSYS_memset32
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
FX_STRSIZE
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
CFX_WideString::IsEmpty
FX_BOOL IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:1570
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(const FX_CHAR &ch)
Construct from a single character.
Definition: fx_string.h:94
FXWCHAR_IsWordBreak
FX_BOOL FXWCHAR_IsWordBreak(FX_WCHAR wchar)
Check if the unicode can break a word.
CFX_WideString::~CFX_WideString
~CFX_WideString()
The Destructor.
CFX_WideString::FromLocal
static CFX_WideString FromLocal(const char *str, FX_STRSIZE len=-1)
Create a wide string from system multi-byte charset.
CFX_WideString::SetAt
void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch)
Overwrites a single wide character specified by an index number.
CFX_WideStringC
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1214
FX_ftoa
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf, int precision=0)
Convert float to byte string.
CFX_ByteString::Remove
FX_STRSIZE Remove(FX_CHAR ch)
Remove all occurrence of a particular character.
FX_CHAR
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:701
FX_atonum
void FX_atonum(FX_BSTR str, FX_BOOL &bInteger, void *pData, int sizeOfData=4)
Convert a non-buffered byte string to a number.
CFX_WideString::Delete
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more wide characters starting from specific position.
FX_IsUtf16SurrogatePair
FX_BOOL FX_IsUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
Determines if the arguments constitute UTF-16 surrogate pair.
Definition: fx_string.h:2368
CFX_ByteString::CFX_ByteString
CFX_ByteString()
Construct a null byte string.
Definition: fx_string.h:323
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC()
Constructs a null constant string.
Definition: fx_string.h:57
CFX_ByteString::ConvertFrom
void ConvertFrom(const CFX_WideString &str, CFX_CharMap *pCharMap=NULL)
Load unicode data into this byte string, using specified character mapper. If no character mapper spe...
CFX_ByteString::TrimRight
void TrimRight()
Trim white spaces from the right side of the byte string.
CFX_ByteString::Equal
bool Equal(FX_BSTR str) const
Check if current string is equal to another one. Case-sensitive.
CFX_WideString::GetInteger
int GetInteger() const
Convert to other data type.
CFX_StringDataW::m_nRefs
long m_nRefs
Reference count.
Definition: fx_string.h:1446
FX_LPWSTR
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:734
CFX_WideString::operator=
const CFX_WideString & operator=(FX_LPCWSTR str)
Assignment(=) operator overload. From a wide character string.
CFX_WideString::GetAt
FX_WCHAR GetAt(FX_STRSIZE nIndex) const
Retrieves a single wide character specified by an index number.
Definition: fx_string.h:1646
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(const CFX_WideStringC &src)
Copy constructor.
Definition: fx_string.h:1270
CFX_StringData
This class represents the data of a byte string object.
Definition: fx_string.h:302
FX_LPSTR
char * FX_LPSTR
Pointer to 8-bit Windows (ANSI) characters.
Definition: fx_system.h:703
CFX_WideString::TrimRight
void TrimRight()
Trim white spaces from the right side of the wide string.
CFX_ByteString::operator+=
const CFX_ByteString & operator+=(FX_CHAR ch)
Concatenation(+=) operator overload. Concatenate a single character.
CFX_WideString::Empty
void Empty()
Set this string to be empty.
CFX_ByteString::Empty
void Empty()
Set this string to be empty.
CFX_ByteString::ReverseFind
FX_STRSIZE ReverseFind(FX_CHAR ch) const
Find a character from end of the string.
FXSYS_wcslen
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1028
FX_INT32
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:683
CFX_StringDataW
This class represents the data of a wide string object.
Definition: fx_string.h:1443
operator==
bool operator==(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(==) operator overload. Case-sensitive.
CFX_WideString::CompareNoCase
int CompareNoCase(FX_LPCWSTR str) const
Compare the the string with a wide character string. No case-insensitive.
CFX_ByteString::EqualNoCase
bool EqualNoCase(FX_BSTR str) const
Check if current string is equal to another one, not considering case.
CFX_ByteString
BYTE STRING CLASS.
Definition: fx_string.h:317
FX_CreateCodePointFromUtf16SurrogatePair
FX_DWORD FX_CreateCodePointFromUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
Creates a Unicode code point from UTF16 surrogate pair.
Definition: fx_string.h:2384
CFX_ByteStringC::GetAt
FX_BYTE GetAt(FX_STRSIZE index) const
This method retrieves a single byte specified by an index number.
Definition: fx_string.h:252
CFX_WideString::operator[]
FX_WCHAR operator[](FX_STRSIZE nIndex) const
Subscript([]) operator overload. It retrieves a wide character specified by the zero-based index in n...
Definition: fx_string.h:1654
IFX_Allocator
Foxit allocator interface.
Definition: fx_memory.h:997
FX_UTF8Encode
CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len)
Encode a wide string into a UTF-8 string.
CFX_StringBufBase::CFX_StringBufBase
CFX_StringBufBase(FX_STRSIZE limit)
A Constructor.
Definition: fx_string.h:1110
CFX_ByteString::GetID
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string. See function CFX_ByteStringC::GetID for details.
FX_CreateUtf16SurrogatePairFromCodePoint
FX_BOOL FX_CreateUtf16SurrogatePairFromCodePoint(FX_DWORD unicode, FX_WCHAR &first, FX_WCHAR &second)
Creates UTF16 surrogate pair from a Unicode code point.
Definition: fx_string.h:2406
FX_LPCWSTR
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:736
CFX_ByteString::IsEmpty
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:409
CFX_WideString::UTF8Encode
CFX_ByteString UTF8Encode() const
Do UTF8 encoding.
FXWCHAR_IsSpace
FX_BOOL FXWCHAR_IsSpace(FX_WCHAR wchar)
Check if the unicode is space.
CFX_WideString::CFX_WideString
CFX_WideString()
Construct a null wide string.
Definition: fx_string.h:1467
operator<
bool operator<(const CFX_WideString &lhs, const CFX_WideString &rhs)
Comparison(<) operator overload. Case-sensitive.
CFX_WideStringC::operator=
CFX_WideStringC & operator=(FX_LPCWSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:1289
CFX_WideString::GetFloat
FX_FLOAT GetFloat() const
Convert to other data type.
CFX_ByteStringC::GetID
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string, from a particular position.
CFX_StringBufBase
A fixed string buffer holding up to certain number of characters.
Definition: fx_string.h:1102
CFX_ByteStringC::GetPtr
FX_LPCBYTE GetPtr() const
Get a constant byte string pointer to the byte string.
Definition: fx_string.h:215
CFX_WideStringC::Left
CFX_WideStringC Left(FX_STRSIZE count) const
Extracts the first (leftmost) count wide characters from this CFX_WideStringC object as a sub-string.
Definition: fx_string.h:1375
operator+
CFX_ByteString operator+(FX_BSTR str1, FX_BSTR str2)
Concatenate a non-buffered byte string and a non-buffered byte string.
Definition: fx_string.h:980
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(FX_LPCSTR ptr)
Construct from a character string.
Definition: fx_string.h:81
CFX_WideString::UTF16LE_Encode
CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate=true) const
Do UTF16LE encoding.
CFX_CharMap
Definition: fx_basic.h:956
FX_LPCSTR
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:705
CFX_WideStringC::GetLength
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:1351
FX_LPCBYTE
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:669
FXWCHAR_GetLower
FX_WCHAR FXWCHAR_GetLower(FX_WCHAR wchar)
Convert to lower-case letter.
CFX_WideString::Reserve
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of characters.
CFX_ByteString::FormatInteger
static CFX_ByteString FormatInteger(FX_INT32 i, FX_DWORD flags=0)
Convert from Integer.
CFX_BinaryBuf
Dynamic binary buffers designed for more efficient appending.
Definition: fx_basic.h:52
CFX_StringData::m_nRefs
long m_nRefs
Reference count.
Definition: fx_string.h:305
FX_FLOAT
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:685
CFX_ByteString::MakeLower
void MakeLower()
Change case of English letters to lower.
CFX_StringBufTemplate::m_Buffer
FX_CHAR m_Buffer[limit]
The fixed string buffer.
Definition: fx_string.h:1200
CFX_WideString::CFX_WideString
CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len=-1)
Construct from a wide character string.
Definition: fx_string.h:1480
FX_BSTR
const typedef CFX_ByteStringC & FX_BSTR
A reference to a constant CFX_ByteStringC object.
Definition: fx_string.h:285
CFX_ByteStringC::GetLength
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:227
FXWCHAR_GetDirection
int FXWCHAR_GetDirection(FX_WCHAR wchar)
Get text direction.
CFX_WideString::MakeLower
void MakeLower()
Change case of English letters to lower.
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC()
Constructs a null constant string.
Definition: fx_string.h:1220
CFX_StringData::m_String
FX_CHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:311
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:792
CFX_ByteString::FormatInteger64
static CFX_ByteString FormatInteger64(FX_INT64 i)
Convert from Integer64.
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:1257
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:105
FX_BOOL
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:691
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(const CFX_ByteStringC &src)
Copy constructor.
Definition: fx_string.h:118
CFX_WideString::operator+=
const CFX_WideString & operator+=(FX_LPCWSTR str)
Concatenation(+=) operator overload. Concatenate a wide character string.
CFX_ByteString::Delete
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more characters starting from specific position.
FX_WSTR
const typedef CFX_WideStringC & FX_WSTR
Type definition for a reference to a constant CFX_WideStringC object.
Definition: fx_string.h:1426
CFX_ByteString::operator!=
bool operator!=(FX_LPCSTR str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:486
CFX_ByteString::operator[]
FX_BYTE operator[](FX_STRSIZE nIndex) const
Subscript([]) operator overload. It retrieves a single byte specified by the zero-based index in nInd...
Definition: fx_string.h:614
CFX_WideString::Find
FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start=0) const
Find a sub-string, from specific position. Only first occurrence is found.
CFX_WideStringC::IsEmpty
bool IsEmpty() const
Determines whether current string object is empty.
Definition: fx_string.h:1357
CFX_WideStringC::GetAt
FX_WCHAR GetAt(FX_STRSIZE index) const
Retrieves a single byte specified by an index number.
Definition: fx_string.h:1366
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(FX_LPCWSTR ptr)
Construct from a character string.
Definition: fx_string.h:1233
CFX_WideString::ReleaseBuffer
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_WideString::GetBuffer or CFX_WideString::LockBuffer,...
CFX_WideStringC::GetPtr
FX_LPCWSTR GetPtr() const
Get a constant wide string pointer to the wide string.
Definition: fx_string.h:1345
CFX_ByteString::SetAt
void SetAt(FX_STRSIZE nIndex, FX_CHAR ch)
Overwrites a single byte specified by an index number.
operator!=
bool operator!=(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(!=) operator overload. Case-sensitive.
CFX_ByteString::TrimLeft
void TrimLeft()
Trim white spaces from the left side of the byte string.
CFX_ByteString::FormatV
void FormatV(FX_LPCSTR lpszFormat, va_list argList)
Format a number of parameters into this byte string, using va_list.
CFX_WideString::GetLength
FX_STRSIZE GetLength() const
Get number of characters, not bytes. Trailing zero not counted.
Definition: fx_string.h:1577
CFX_WideStringC::operator==
bool operator==(const CFX_WideStringC &str) const
Comparison(==) operator overload. Case-sensitive.
Definition: fx_string.h:1324
CFX_WideString::Insert
FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch)
Insert a wide character before specific position.
CFX_StringBufBase::GetPtr
FX_CHAR * GetPtr() const
Get a C-style string pointer to the string buffer.
Definition: fx_string.h:1117
CFX_WideString::FromUTF16LE
static CFX_WideString FromUTF16LE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16LE encoded string.
CFX_ByteString::ReleaseBuffer
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_ByteString::GetBuffer or CFX_ByteString::LockBuffer,...
FX_atof
FX_FLOAT FX_atof(FX_BSTR str)
Convert a non-buffered byte string to a floating-point number.
CFX_ByteString::Insert
FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch)
Insert a character before specific position.
CFX_StringBufBase::GetString
CFX_ByteString GetString() const
Get a buffered byte string.
Definition: fx_string.h:1173
CFX_WideString::Left
CFX_WideString Left(FX_STRSIZE count) const
Extracts the first (leftmost) count wide characters from this CFX_WideString object as a sub-string.
CFX_ByteString::FromUnicode
static CFX_ByteString FromUnicode(FX_LPCWSTR ptr, FX_STRSIZE len=-1)
Create a CFX_ByteString object from a Unicode string. Convert from Unicode to system multi-byte chars...
CFX_WideString::Mid
CFX_WideString Mid(FX_STRSIZE first) const
Extracts a substring from this CFX_WideString object, starting at position nFirst (zero-based) to las...
CFX_StringDataW::m_String
FX_WCHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:1452
CFX_WideString::FromUTF8
static CFX_WideString FromUTF8(const char *str, FX_STRSIZE len=-1)
Create a wide string from UTF-8 string (ASCII string compatible).
CFX_WideString::Format
void Format(FX_LPCWSTR lpszFormat,...)
Format a number of parameters into this wide string.
CFX_ByteStringC::operator=
CFX_ByteStringC & operator=(FX_LPCSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:137
CFX_ByteString::~CFX_ByteString
~CFX_ByteString()
CFX_WideString
WIDE STRING CLASS.
Definition: fx_string.h:1461
CFX_WideString::TrimLeft
void TrimLeft()
Trim white spaces from the left side of the wide string.
CFX_StringBufTemplate
A fixed string buffer template.
Definition: fx_string.h:1187
CFX_ByteString::Right
CFX_ByteString Right(FX_STRSIZE count) const
Extracts the last (rightmost) count bytes from this CFX_ByteString object as a sub-string.
CFX_WideString::Right
CFX_WideString Right(FX_STRSIZE count) const
Extracts the last (rightmost) count wide characters from this CFX_WideString object as a sub-string.
CFX_ByteString::UTF8Decode
CFX_WideString UTF8Decode() const
Decode a UTF-8 unicode string (assume this byte string is UTF-8 encoded).
CFX_ByteString::LoadFromFile
static CFX_ByteString LoadFromFile(FX_BSTR file_path)
Load the whole content of a file.
CFX_ByteString::LockBuffer
FX_LPSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer.
CFX_ByteString::Load
void Load(FX_LPCBYTE str, FX_STRSIZE len)
Load from a byte string.
CFX_ByteStringC
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
CFX_WideString::FromUTF16BE
static CFX_WideString FromUTF16BE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16BE encoded string.
CFX_WideString::WStringLength
static FX_STRSIZE WStringLength(const unsigned short *str)
Length of string.
CFX_ByteString::Mid
CFX_ByteString Mid(FX_STRSIZE first) const
Extracts a substring from this CFX_ByteString object, starting at position nFirst (zero-based) to las...
CFX_StringBuf256
CFX_StringBufTemplate< 256 > CFX_StringBuf256
A fixed 256-byte string buffer.
Definition: fx_string.h:1204
CFX_WideString::Replace
FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew)
Replace all patterns in the string with a new sub-string.
CFX_StringData::m_nDataLength
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:307
CFX_ByteString::Replace
FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew)
Replace all patterns in the string with a new sub-string.
CFX_StringBufBase::Append
void Append(FX_BSTR str)
Append a non-buffered byte string.