Foxit PDF Conversion 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);
923 static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
924
925 protected:
926 /* Pointer to ref counted byte string data. */
927 struct CFX_StringData* m_pData;
928
929 void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
930 void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
931 void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data);
932 void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
933 void CopyBeforeWrite();
934 void AllocBeforeWrite(FX_STRSIZE nLen);
935 };
936
937 inline CFX_ByteStringC::CFX_ByteStringC(const CFX_ByteString& src)
938 {
939 m_Ptr = (FX_LPCBYTE)src;
940 m_Length = src.GetLength();
941 }
942
943 inline CFX_ByteStringC& CFX_ByteStringC::operator = (const CFX_ByteString& src)
944 {
945 m_Ptr = (FX_LPCBYTE)src;
946 m_Length = src.GetLength();
947 return *this;
948 }
949
962
971 inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2) { return CFX_ByteString(str1, str2); }
972 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
973 #ifndef _NO_LPCSTR_SUPPORT_
974 //<<<+++OPENSOURCE_MUST_END
983 inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2) { return CFX_ByteString(str1, str2); }
992 inline CFX_ByteString operator + (FX_LPCSTR str1,FX_BSTR str2) { return CFX_ByteString(str1, str2); }
993 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
994 #endif
995 //<<<+++OPENSOURCE_MUST_END
1004 inline CFX_ByteString operator + (FX_BSTR str1, FX_CHAR ch) { return CFX_ByteString(str1, CFX_ByteStringC(ch)); }
1013 inline CFX_ByteString operator + (FX_CHAR ch, FX_BSTR str2) { return CFX_ByteString(CFX_ByteStringC(ch), str2); }
1014
1023 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1032 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch) { return CFX_ByteString(str1, CFX_ByteStringC(ch)); }
1041 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2) { return CFX_ByteString(CFX_ByteStringC(ch), str2); }
1042 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1043 #ifndef _NO_LPCSTR_SUPPORT_
1044 //<<<+++OPENSOURCE_MUST_END
1053 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2) { return CFX_ByteString(str1, str2); }
1062 inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1063 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1064 #endif
1065 //<<<+++OPENSOURCE_MUST_END
1074 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) { return CFX_ByteString(str1, str2); }
1083 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1084
1093 class CFX_StringBufBase : public CFX_Object
1094 {
1095 public:
1101 explicit CFX_StringBufBase(FX_STRSIZE limit) { m_Size = 0; m_Limit = limit; }
1102
1108 FX_CHAR* GetPtr() const { return (FX_CHAR*)(this + 1); }
1114 FX_STRSIZE GetSize() const { return m_Size; }
1115
1121 void Empty() { m_Size = 0; }
1122
1130 void Copy(FX_BSTR str);
1131
1139 void Append(FX_BSTR str);
1140
1151 void Append(int i, FX_DWORD flags = 0);
1152
1158 CFX_ByteStringC GetStringC() const { return CFX_ByteStringC((FX_CHAR*)(this + 1), m_Size); }
1164 CFX_ByteString GetString() const { return CFX_ByteString((FX_CHAR*)(this + 1), m_Size); }
1165
1166 protected:
1167 /* The buffer limit. */
1168 FX_STRSIZE m_Limit;
1169 /* The string size. */
1170 FX_STRSIZE m_Size;
1171 // the real buffer follows
1172 };
1173
1177 template<FX_STRSIZE limit>
1178 class CFX_StringBufTemplate : public CFX_StringBufBase
1179 {
1180 public:
1184 CFX_StringBufTemplate() : CFX_StringBufBase(limit) {FXSYS_memset32(m_Buffer, 0, limit * sizeof(FX_CHAR));}
1185
1191 FX_CHAR m_Buffer[limit];
1192 };
1193
1195 typedef CFX_StringBufTemplate<256> CFX_StringBuf256;
1196
1197 //*****************************************************************************
1198 //* CFX_WideStringC - constant wide string
1199 //*****************************************************************************
1205 class CFX_WideStringC : public CFX_Object
1206 {
1207 public:
1211 CFX_WideStringC()
1212 {
1213 m_Ptr = NULL;
1214 m_Length = 0;
1215 }
1216 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1217 #ifndef _NO_LPCSTR_SUPPORT_
1218 //<<<+++OPENSOURCE_MUST_END
1224 CFX_WideStringC(FX_LPCWSTR ptr)
1225 {
1226 m_Ptr = ptr;
1227 m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
1228 }
1229 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1230 #endif
1231 //<<<+++OPENSOURCE_MUST_END
1237 CFX_WideStringC(FX_WCHAR& ch)
1238 {
1239 m_Ptr = &ch;
1240 m_Length = 1;
1241 }
1248 CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
1249 {
1250 m_Ptr = ptr;
1251 if (len == -1)
1252 m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
1253 else
1254 m_Length = len;
1255 }
1261 CFX_WideStringC(const CFX_WideStringC& src)
1262 {
1263 m_Ptr = src.m_Ptr;
1264 m_Length = src.m_Length;
1265 }
1271 CFX_WideStringC(const CFX_WideString& src);
1272
1280 CFX_WideStringC& operator = (FX_LPCWSTR src)
1281 {
1282 m_Ptr = src;
1283 m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
1284 return *this;
1285 }
1293 CFX_WideStringC& operator = (const CFX_WideStringC& src)
1294 {
1295 m_Ptr = src.m_Ptr;
1296 m_Length = src.m_Length;
1297 return *this;
1298 }
1306 CFX_WideStringC& operator = (const CFX_WideString& src);
1307
1315 bool operator == (const CFX_WideStringC& str) const
1316 {
1317 return str.m_Length == m_Length && FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length*sizeof(FX_WCHAR)) == 0;
1318 }
1326 bool operator != (const CFX_WideStringC& str) const
1327 {
1328 return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length*sizeof(FX_WCHAR)) != 0;
1329 }
1330
1336 FX_LPCWSTR GetPtr() const { return m_Ptr; }
1342 FX_STRSIZE GetLength() const { return m_Length; }
1348 bool IsEmpty() const { return m_Length == 0; }
1349
1357 FX_WCHAR GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
1358
1366 CFX_WideStringC Left(FX_STRSIZE count) const
1367 {
1368 if (count < 1) return CFX_WideStringC();
1369 if (count > m_Length) count = m_Length;
1370 return CFX_WideStringC(m_Ptr, count);
1371 }
1372
1381 CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
1382 {
1383 if (index < 0) index = 0;
1384 if (index > m_Length) return CFX_WideStringC();
1385 if (count < 0 || count > m_Length - index) count = m_Length - index;
1386 return CFX_WideStringC(m_Ptr + index, count);
1387 }
1388
1396 CFX_WideStringC Right(FX_STRSIZE count) const
1397 {
1398 if (count < 1) return CFX_WideStringC();
1399 if (count > m_Length) count = m_Length;
1400 return CFX_WideStringC(m_Ptr + m_Length - count, count);
1401 }
1402
1403 protected:
1404 /* The constant byte string pointer. */
1405 FX_LPCWSTR m_Ptr;
1406 /* the length in bytes of the byte string. */
1407 FX_STRSIZE m_Length;
1408
1409 private:
1410 /*
1411 * new operator forbidden. Cannot allocate a CFX_WideStringC in heap.
1412 */
1413 void* operator new (size_t) throw() { return NULL; }
1414 };
1415
1417 typedef const CFX_WideStringC& FX_WSTR;
1418
1428 #define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
1429
1430 //*****************************************************************************
1431 //* CFX_WideString - wide string
1432 //*****************************************************************************
1434 struct CFX_StringDataW
1435 {
1437 long m_nRefs;
1439 FX_STRSIZE m_nDataLength;
1441 FX_STRSIZE m_nAllocLength;
1443 FX_WCHAR m_String[1];
1444 };
1445
1452 class CFX_WideString : public CFX_Object
1453 {
1454 public:
1458 CFX_WideString() { m_pData = NULL; }
1464 CFX_WideString(const CFX_WideString& str);
1471 CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1) { InitStr(ptr, len); }
1472
1478 CFX_WideString(FX_WCHAR ch);
1484 CFX_WideString(const CFX_WideStringC& str);
1491 CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
1495 ~CFX_WideString();
1496
1506 static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
1515 static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len = -1);
1524 static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len = -1);
1525
1534 static CFX_WideString FromUTF16BE(const unsigned short* str, FX_STRSIZE len = -1);
1535
1543 static FX_STRSIZE WStringLength(const unsigned short* str);
1544
1548 operator FX_LPCWSTR() const { return m_pData ? m_pData->m_String : (FX_WCHAR*)L""; }
1549
1555 void Empty();
1561 FX_BOOL IsEmpty() const { return !GetLength(); }
1562
1568 FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
1569
1577 const CFX_WideString& operator = (FX_LPCWSTR str);
1578
1586 const CFX_WideString& operator =(const CFX_WideString& stringSrc);
1594 const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
1595
1603 const CFX_WideString& operator += (FX_LPCWSTR str);
1604
1612 const CFX_WideString& operator += (FX_WCHAR ch);
1620 const CFX_WideString& operator += (const CFX_WideString& str);
1628 const CFX_WideString& operator += (const CFX_WideStringC& str);
1629
1637 FX_WCHAR GetAt(FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
1645 FX_WCHAR operator[](FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
1654 void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
1655
1667 int Compare(FX_LPCWSTR str) const;
1679 int Compare(const CFX_WideString& str) const;
1680
1692 int CompareNoCase(FX_LPCWSTR str) const;
1693
1704 bool Equal(const CFX_WideStringC& str) const;
1705
1713 CFX_WideString Mid(FX_STRSIZE first) const;
1723 CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
1731 CFX_WideString Left(FX_STRSIZE count) const;
1739 CFX_WideString Right(FX_STRSIZE count) const;
1740
1749 FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
1758 FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
1766 void Format(FX_LPCWSTR lpszFormat, ... );
1777 void FormatV(FX_LPCWSTR lpszFormat, va_list argList);
1783 void MakeLower();
1789 void MakeUpper();
1790
1796 void TrimRight();
1804 void TrimRight(FX_WCHAR chTarget);
1812 void TrimRight(FX_LPCWSTR lpszTargets);
1813
1819 void TrimLeft();
1827 void TrimLeft(FX_WCHAR chTarget);
1835 void TrimLeft(FX_LPCWSTR lpszTargets);
1836
1846 void Reserve(FX_STRSIZE len);
1854 FX_LPWSTR GetBuffer(FX_STRSIZE len);
1861 FX_LPWSTR LockBuffer();
1870 void ReleaseBuffer(FX_STRSIZE len = -1);
1871
1877 int GetInteger() const;
1878
1884 FX_FLOAT GetFloat() const;
1885
1894 FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start=0) const;
1903 FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start=0) const;
1904
1913 FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew);
1921 FX_STRSIZE Remove(FX_WCHAR ch);
1922
1928 CFX_ByteString UTF8Encode() const;
1936 CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate = true) const;
1937
1948 void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
1949
1950 protected:
1951 void InitStr(FX_LPCWSTR ptr, int len);
1952
1953 /* Pointer to ref counted wide string data. */
1954 CFX_StringDataW* m_pData;
1955
1956 void CopyBeforeWrite();
1957 void AllocBeforeWrite(FX_STRSIZE nLen);
1958
1959 void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
1960 void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
1961 void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
1962 void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
1963 };
1964
1965 inline CFX_WideStringC::CFX_WideStringC(const CFX_WideString& src)
1966 {
1967 m_Ptr = (FX_LPCWSTR)src;
1968 m_Length = src.GetLength();
1969 }
1970
1971 inline CFX_WideStringC& CFX_WideStringC::operator = (const CFX_WideString& src)
1972 {
1973 m_Ptr = (FX_LPCWSTR)src;
1974 m_Length = src.GetLength();
1975 return *this;
1976 }
1977
1991
2000 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2001 #ifndef _NO_LPCSTR_SUPPORT_
2002
2010 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2) { return CFX_WideString(str1, str2); }
2019 inline CFX_WideString operator + (FX_LPCWSTR str1,const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2020 #endif
2021
2029 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_WCHAR ch) { return CFX_WideString(str1, CFX_WideStringC(ch)); }
2038 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2) { return CFX_WideString(ch, str2); }
2039
2048 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2057 inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch) { return CFX_WideString(str1, CFX_WideStringC(ch)); }
2066 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2) { return CFX_WideString(ch, str2); }
2067 #ifndef _NO_LPCSTR_SUPPORT_
2068
2076 inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2) { return CFX_WideString(str1, str2); }
2085 inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2086 #endif
2087
2095 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2104 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2105
2112
2121 bool operator==(const CFX_WideString& s1, const CFX_WideString& s2);
2130 bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2);
2139 bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2);
2148 bool operator== (const CFX_WideString& s1, FX_LPCWSTR s2);
2157 bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2);
2158
2167 bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2);
2176 bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2);
2185 bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2);
2194 bool operator!= (const CFX_WideString& s1, FX_LPCWSTR s2);
2203 bool operator!=(FX_LPCWSTR s1, const CFX_WideString& s2);
2204
2213 bool operator< (const CFX_WideString& lhs, const CFX_WideString& rhs);
2214
2225 FX_FLOAT FX_atof(FX_BSTR str);
2236 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData, int sizeOfData = 4);
2237
2247 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf, int precision = 0);
2248
2260 FX_WCHAR FXWCHAR_GetUpper(FX_WCHAR wchar);
2268 FX_WCHAR FXWCHAR_GetLower(FX_WCHAR wchar);
2277 FX_BOOL FXWCHAR_IsWordBreak(FX_WCHAR wchar);
2286 FX_BOOL FXWCHAR_IsSpace(FX_WCHAR wchar);
2292 #define FXWCHAR_LTR 0
2293
2294 #define FXWCHAR_RTL 1
2295
2296 #define FXWCHAR_UNKNOWN 2
2297
2306 int FXWCHAR_GetDirection(FX_WCHAR wchar);
2308 //<<<+++OPENSOURCE_END
2309
2314
2323 CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len);
2331 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) {return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());}
2339 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) {return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength());}
2340
2353 inline FX_BOOL FX_IsUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
2354 {
2355 return ((first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00);
2356 }
2357
2369 inline FX_DWORD FX_CreateCodePointFromUtf16SurrogatePair(FX_WCHAR first,
2370 FX_WCHAR second)
2371 {
2372 const FX_DWORD mask = (1 << 10) - 1;
2373 return (((first & mask) << 10) | (second & mask)) + 0x10000;
2374 // This function should not be called when the condition is
2375 // false, but we provide a sensible default in case it is.
2376 }
2377
2391 inline FX_BOOL FX_CreateUtf16SurrogatePairFromCodePoint(FX_DWORD unicode,
2392 FX_WCHAR& first,
2393 FX_WCHAR& second)
2394 {
2395 // 0x10000 = 0xFFFF+1
2396 if (unicode < 0x10000 || unicode > 0x10FFFF)
2397 return false;
2398
2399 /* high surrogate = top 10 bits added to D800 */
2400 first = (FX_WCHAR)(0xD800 - (0x10000 >> 10) + ((unicode) >> 10));
2401 /* low surrogate = bottom 10 bits added to DC00 */
2402 second = (FX_WCHAR)(0xDC00 + ((unicode)&0x3FF));
2403 return true;
2404 }
2405
2408 //*****************************************************************************
2409 //* CFX_ByteStringL - long term byte string
2410 //*****************************************************************************
2411 class CFX_ByteStringL : public CFX_ByteStringC
2412 {
2413 public:
2414 CFX_ByteStringL() : CFX_ByteStringC() {}
2415 ~CFX_ByteStringL() {}
2416
2417 void Empty(IFX_Allocator* pAllocator);
2418
2419 FX_LPSTR AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocator);
2420
2421 void Set(FX_BSTR src, IFX_Allocator* pAllocator);
2422 };
2423
2424 //*****************************************************************************
2425 //* CFX_WideStringL - long term wide string
2426 //*****************************************************************************
2427 class CFX_WideStringL : public CFX_WideStringC
2428 {
2429 public:
2430 CFX_WideStringL() : CFX_WideStringC() {}
2431 ~CFX_WideStringL() {}
2432
2433 void Empty(IFX_Allocator* pAllocator);
2434
2435 void Set(FX_WSTR src, IFX_Allocator* pAllocator);
2436
2437 int GetInteger() const;
2438 FX_FLOAT GetFloat() const;
2439
2440 void TrimRight(FX_LPCWSTR lpszTargets);
2441 };
2442
2443 void FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len, CFX_ByteStringL &utf8Str, IFX_Allocator* pAllocator = NULL);
2444 //<<<+++OPENSOURCE_END
2445
2446 //<<<+++OPENSOURCE_MUST_BEGIN
2447 #endif // _FX_STRING_H_
2448 //<<<+++OPENSOURCE_MUST_END
2449
2452 //<<<+++OPENSOURCE_END
operator<
bool operator<(const CFX_WideString &lhs, const CFX_WideString &rhs)
Comparison(<) operator overload. Case-sensitive.
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_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
Constructs from a byte string.
Definition: fx_string.h:68
CFX_BinaryBuf
Dynamic binary buffers designed for more efficient appending.
Definition: fx_basic.h:52
CFX_WideString::CompareNoCase
int CompareNoCase(FX_LPCWSTR str) const
Compare the the string with a wide character string. No case-insensitive.
CFX_StringBufBase::GetStringC
CFX_ByteStringC GetStringC() const
Get a non-buffered byte string.
Definition: fx_string.h:1158
CFX_StringDataW::m_nAllocLength
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:1441
CFX_WideString::GetAt
FX_WCHAR GetAt(FX_STRSIZE nIndex) const
Retrieves a single wide character specified by an index number.
Definition: fx_string.h:1637
CFX_ByteString::Delete
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more characters starting from specific position.
FX_WCHAR
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:726
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC()
Constructs a null constant string.
Definition: fx_string.h:1211
CFX_WideString::Insert
FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch)
Insert a wide character before specific position.
FX_BSTR
const CFX_ByteStringC & FX_BSTR
A reference to a constant CFX_ByteStringC object.
Definition: fx_string.h:285
CFX_WideString::GetFloat
FX_FLOAT GetFloat() const
Convert to other data type.
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_ByteString::TrimRight
void TrimRight()
Trim white spaces from the right side of the byte string.
CFX_WideString::ReleaseBuffer
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_WideString::GetBuffer or CFX_WideString::LockBuffer,...
FX_DWORD
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:720
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:1396
CFX_WideStringC
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1205
CFX_WideStringC::IsEmpty
bool IsEmpty() const
Determines whether current string object is empty.
Definition: fx_string.h:1348
CFX_StringData::m_String
FX_CHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:311
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:1366
CFX_StringData::m_nRefs
long m_nRefs
Reference count.
Definition: fx_string.h:305
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::GetLength
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:1342
CFX_ByteStringC::GetLength
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:227
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:1381
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(FX_LPCSTR ptr)
Construct from a character string.
Definition: fx_string.h:81
FX_atof
FX_FLOAT FX_atof(FX_BSTR str)
Convert a non-buffered byte string to a floating-point number.
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:105
CFX_WideString::Equal
bool Equal(const CFX_WideStringC &str) const
Check if current string is equal to another.
CFX_ByteStringC::operator==
bool operator==(const CFX_ByteStringC &str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:172
CFX_ByteString::LockBuffer
FX_LPSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer.
CFX_StringBufBase::Empty
void Empty()
Set this string to be empty.
Definition: fx_string.h:1121
FX_LPCWSTR
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:730
CFX_ByteString::TrimLeft
void TrimLeft()
Trim white spaces from the left side of the byte string.
CFX_WideString::Delete
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more wide characters starting from specific position.
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
FXSYS_strlen
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:872
CFX_WideString::GetBuffer
FX_LPWSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of characters allocated.
CFX_StringBufBase::GetSize
FX_STRSIZE GetSize() const
Gets the length of the string.
Definition: fx_string.h:1114
CFX_WideString::CFX_WideString
CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len=-1)
Construct from a wide character string.
Definition: fx_string.h:1471
CFX_WideString::Empty
void Empty()
Set this string to be empty.
FXSYS_memcmp32
FX_INT32 FXSYS_memcmp32(const void *buf1, const void *buf2, size_t size)
Compare data in two buffers.
FX_LPSTR
char * FX_LPSTR
Pointer to 8-bit Windows (ANSI) characters.
Definition: fx_system.h:699
CFX_StringBuf256
CFX_StringBufTemplate< 256 > CFX_StringBuf256
A fixed 256-byte string buffer.
Definition: fx_string.h:1195
CFX_ByteString::GetBuffer
FX_LPSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of bytes allocated.
CFX_ByteString::Load
void Load(FX_LPCBYTE str, FX_STRSIZE len)
Load from a byte string.
CFX_WideString::Remove
FX_STRSIZE Remove(FX_WCHAR ch)
Remove all occurrence of a particular character.
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(const CFX_ByteStringC &src)
Copy constructor.
Definition: fx_string.h:118
CFX_WideStringC::operator=
CFX_WideStringC & operator=(FX_LPCWSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:1280
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_WideStringC::operator !=
bool operator !=(const CFX_WideStringC &str) const
Comparison(!=) operator overload. Case-sensitive.
Definition: fx_string.h:1326
CFX_WideString
WIDE STRING CLASS.
Definition: fx_string.h:1452
CFX_ByteString::Empty
void Empty()
Set this string to be empty.
CFX_WideString::TrimLeft
void TrimLeft()
Trim white spaces from the left side of the wide string.
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(const CFX_WideStringC &src)
Copy constructor.
Definition: fx_string.h:1261
CFX_WideString::MakeUpper
void MakeUpper()
Change case of English letters to upper.
CFX_WideString::WStringLength
static FX_STRSIZE WStringLength(const unsigned short *str)
Length of string.
CFX_ByteStringC::GetPtr
FX_LPCBYTE GetPtr() const
Get a constant byte string pointer to the byte string.
Definition: fx_string.h:215
FXWCHAR_IsWordBreak
FX_BOOL FXWCHAR_IsWordBreak(FX_WCHAR wchar)
Check if the unicode can break a word.
CFX_WideString::Replace
FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew)
Replace all patterns in the string with a new sub-string.
FX_ftoa
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf, int precision=0)
Convert float to byte string.
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::TrimRight
void TrimRight()
Trim white spaces from the right side of the wide string.
CFX_StringDataW
This class represents the data of a wide string object.
Definition: fx_string.h:1434
FXWCHAR_GetUpper
FX_WCHAR FXWCHAR_GetUpper(FX_WCHAR wchar)
Convert to upper-case letter.
FXWCHAR_GetLower
FX_WCHAR FXWCHAR_GetLower(FX_WCHAR wchar)
Convert to lower-case letter.
CFX_StringDataW::m_String
FX_WCHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:1443
CFX_WideString::GetLength
FX_STRSIZE GetLength() const
Get number of characters, not bytes. Trailing zero not counted.
Definition: fx_string.h:1568
CFX_ByteString::Remove
FX_STRSIZE Remove(FX_CHAR ch)
Remove all occurrence of a particular character.
CFX_ByteString::Reserve
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of bytes.
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:1458
CFX_StringBufBase
A fixed string buffer holding up to certain number of characters.
Definition: fx_string.h:1093
FX_INT32
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:679
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_StringBufTemplate
A fixed string buffer template.
Definition: fx_string.h:1178
CFX_ByteString::EqualNoCase
bool EqualNoCase(FX_BSTR str) const
Check if current string is equal to another one, not considering case.
CFX_StringData::m_nAllocLength
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:309
CFX_ByteString::operator+=
const CFX_ByteString & operator+=(FX_CHAR ch)
Concatenation(+=) operator overload. Concatenate a single character.
CFX_WideStringC::GetAt
FX_WCHAR GetAt(FX_STRSIZE index) const
Retrieves a single byte specified by an index number.
Definition: fx_string.h:1357
CFX_WideString::Compare
int Compare(FX_LPCWSTR str) const
Compare current string with a wide character string. Case-sensitive.
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC()
Constructs a null constant string.
Definition: fx_string.h:57
FX_BOOL
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:687
CFX_ByteString::Compare
int Compare(FX_BSTR str) const
Compare the the string with another. Case-sensitive.
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(FX_WCHAR &ch)
Construct from a single character.
Definition: fx_string.h:1237
CFX_ByteString::Format
void Format(FX_LPCSTR lpszFormat,...)
Format a number of parameters into this byte string.
FX_LPCSTR
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:701
FXSYS_wcslen
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1021
CFX_WideString::operator+=
const CFX_WideString & operator+=(FX_LPCWSTR str)
Concatenation(+=) operator overload. Concatenate a wide character string.
CFX_WideString::UTF16LE_Encode
CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate=true) const
Do UTF16LE encoding.
CFX_WideString::FromLocal
static CFX_WideString FromLocal(const char *str, FX_STRSIZE len=-1)
Create a wide string from system multi-byte charset.
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::GetID
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string. See function CFX_ByteStringC::GetID for details.
CFX_StringBufBase::GetString
CFX_ByteString GetString() const
Get a buffered byte string.
Definition: fx_string.h:1164
CFX_ByteString::SetAt
void SetAt(FX_STRSIZE nIndex, FX_CHAR ch)
Overwrites a single byte specified by an index number.
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_StringData::m_nDataLength
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:307
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:1645
CFX_StringData
This class represents the data of a byte string object.
Definition: fx_string.h:302
CFX_WideString::~CFX_WideString
~CFX_WideString()
The Destructor.
CFX_ByteString::IsEmpty
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:409
CFX_StringBufTemplate::m_Buffer
FX_CHAR m_Buffer[limit]
The fixed string buffer.
Definition: fx_string.h:1191
CFX_WideString::UTF8Encode
CFX_ByteString UTF8Encode() const
Do UTF8 encoding.
CFX_WideString::MakeLower
void MakeLower()
Change case of English letters to lower.
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_ByteString::FormatFloat
static CFX_ByteString FormatFloat(FX_FLOAT f, int precision=0)
Convert from floating-point number.
CFX_StringDataW::m_nDataLength
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:1439
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...
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:971
IFX_Allocator
Foxit allocator interface.
Definition: fx_memory.h:997
CFX_CharMap
Definition: fx_basic.h:956
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_CHAR
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:697
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_ByteStringC::GetCStr
FX_LPCSTR GetCStr() const
Get a constant character string pointer to the byte string.
Definition: fx_string.h:221
FX_FLOAT
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:681
CFX_StringBufBase::CFX_StringBufBase
CFX_StringBufBase(FX_STRSIZE limit)
A Constructor.
Definition: fx_string.h:1101
CFX_ByteStringC::IsEmpty
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:233
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:2391
CFX_ByteString::ReverseFind
FX_STRSIZE ReverseFind(FX_CHAR ch) const
Find a character from end of the string.
CFX_ByteString::operator<
bool operator<(const CFX_ByteString &rhs) const
Comparison(<) operator overload. case-sensitive.
CFX_ByteString::FormatV
void FormatV(FX_LPCSTR lpszFormat, va_list argList)
Format a number of parameters into this byte string, using va_list.
FX_UTF8Encode
CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len)
Encode a wide string into a UTF-8 string.
CFX_WideString::SetAt
void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch)
Overwrites a single wide character specified by an index number.
CFX_StringBufBase::Append
void Append(FX_BSTR str)
Append a non-buffered byte string.
CFX_ByteString::operator !=
bool operator !=(FX_LPCSTR str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:486
CFX_ByteStringC::operator=
CFX_ByteStringC & operator=(FX_LPCSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:137
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_ByteString::LoadFromFile
static CFX_ByteString LoadFromFile(FX_BSTR file_path)
Load the whole content of a file.
CFX_ByteStringC
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
CFX_ByteString::CFX_ByteString
CFX_ByteString()
Construct a null byte string.
Definition: fx_string.h:323
FX_WSTR
const CFX_WideStringC & FX_WSTR
Type definition for a reference to a constant CFX_WideStringC object.
Definition: fx_string.h:1417
operator!=
bool operator!=(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(!=) operator overload. Case-sensitive.
CFX_ByteString::Replace
FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew)
Replace all patterns in the string with a new sub-string.
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_WideStringC::CFX_WideStringC
CFX_WideStringC(FX_LPCWSTR ptr)
Construct from a character string.
Definition: fx_string.h:1224
CFX_WideStringC::operator==
bool operator==(const CFX_WideStringC &str) const
Comparison(==) operator overload. Case-sensitive.
Definition: fx_string.h:1315
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_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_StringDataW::m_nRefs
long m_nRefs
Reference count.
Definition: fx_string.h:1437
CFX_ByteString::UTF8Decode
CFX_WideString UTF8Decode() const
Decode a UTF-8 unicode string (assume this byte string is UTF-8 encoded).
CFX_WideString::FromUTF16BE
static CFX_WideString FromUTF16BE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16BE encoded string.
CFX_ByteString::MakeUpper
void MakeUpper()
Change case of English letters to upper.
CFX_ByteString
BYTE STRING CLASS.
Definition: fx_string.h:317
CFX_WideString::GetInteger
int GetInteger() const
Convert to other data type.
FX_LPCBYTE
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:665
CFX_ByteStringC::operator !=
bool operator !=(const CFX_ByteStringC &str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:183
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:2369
CFX_StringBufBase::GetPtr
FX_CHAR * GetPtr() const
Get a C-style string pointer to the string buffer.
Definition: fx_string.h:1108
CFX_WideString::LockBuffer
FX_LPWSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer....
CFX_WideString::FromUTF16LE
static CFX_WideString FromUTF16LE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16LE encoded string.
FX_LPWSTR
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:728
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::MakeLower
void MakeLower()
Change case of English letters to lower.
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:785
CFX_WideString::IsEmpty
FX_BOOL IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:1561
CFX_ByteString::Equal
bool Equal(FX_BSTR str) const
Check if current string is equal to another one. Case-sensitive.
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_StringBufBase::Copy
void Copy(FX_BSTR str)
Copy from a non-buffered byte string.
operator==
bool operator==(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(==) operator overload. Case-sensitive.
CFX_ByteString::ReleaseBuffer
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_ByteString::GetBuffer or CFX_ByteString::LockBuffer,...
CFX_WideString::operator=
const CFX_WideString & operator=(FX_LPCWSTR str)
Assignment(=) operator overload. From a wide character string.
CFX_WideString::FormatV
void FormatV(FX_LPCWSTR lpszFormat, va_list argList)
Format a number of parameters into this wide string. using va_list.
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:2353
CFX_WideStringC::GetPtr
FX_LPCWSTR GetPtr() const
Get a constant wide string pointer to the wide string.
Definition: fx_string.h:1336
FXWCHAR_GetDirection
int FXWCHAR_GetDirection(FX_WCHAR wchar)
Get text direction.
CFX_StringBufTemplate::CFX_StringBufTemplate
CFX_StringBufTemplate()
A constructor.
Definition: fx_string.h:1184
CFX_ByteString::~CFX_ByteString
~CFX_ByteString()
CFX_WideStringC::CFX_WideStringC
CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:1248
CFX_ByteStringC::CFX_ByteStringC
CFX_ByteStringC(const FX_CHAR &ch)
Construct from a single character.
Definition: fx_string.h:94
CFX_ByteString::Insert
FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch)
Insert a character before specific position.
CFX_ByteString::operator=
const CFX_ByteString & operator=(FX_LPCSTR str)
Assignment(=) operator overload. From a character string.
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...
FX_BYTE
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:661
CFX_ByteStringC::GetID
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string, from a particular position.
CFX_ByteString::operator==
bool operator==(FX_LPCSTR str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:456
CFX_WideString::Format
void Format(FX_LPCWSTR lpszFormat,...)
Format a number of parameters into this wide string.