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;
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:
58  {
59  m_Ptr = NULL;
60  m_Length = 0;
61  }
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
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  }
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  }
119  {
120  m_Ptr = src.m_Ptr;
121  m_Length = src.m_Length;
122  }
128  CFX_ByteStringC(const CFX_ByteString& src);
129 
138  {
139  m_Ptr = (FX_LPCBYTE)src;
140  m_Length = m_Ptr ? (FX_STRSIZE)FXSYS_strlen(src) : 0;
141  return *this;
142  }
151  {
152  m_Ptr = src.m_Ptr;
153  m_Length = src.m_Length;
154  return *this;
155  }
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 //*****************************************************************************
303 {
305  long m_nRefs;
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);
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 #ifdef _NATIVE_WCHAR_T_DEFINED
387 
395  static CFX_ByteString FromUnicode(const wchar_t* str, FX_STRSIZE len = -1) { return FromUnicode((FX_LPCWSTR)str, len); }
396 #endif
397 //<<<+++OPENSOURCE_MUST_END
398 
402  operator FX_LPCSTR() const { return m_pData ? m_pData->m_String : ""; }
406  operator FX_LPCBYTE() const { return m_pData ? (FX_LPCBYTE)m_pData->m_String : NULL; }
407 
413  FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
414 
420  bool IsEmpty() const { return !GetLength(); }
432  int Compare(FX_BSTR str) const;
433 
444  bool Equal(FX_BSTR str) const;
445 
455  bool EqualNoCase(FX_BSTR str) const;
456 
457 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
458 #ifndef _NO_LPCSTR_SUPPORT_
459 //<<<+++OPENSOURCE_MUST_END
467  bool operator == (FX_LPCSTR str) const { return Equal(str); }
468 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
469 #endif
470 //<<<+++OPENSOURCE_MUST_END
478  bool operator == (FX_BSTR str) const { return Equal(str); }
486  bool operator == (const CFX_ByteString& str) const;
487 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
488 #ifndef _NO_LPCSTR_SUPPORT_
489 //<<<+++OPENSOURCE_MUST_END
497  bool operator != (FX_LPCSTR str) const { return !Equal(str); }
498 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
499 #endif
500 //<<<+++OPENSOURCE_MUST_END
508  bool operator != (FX_BSTR str) const { return !Equal(str); }
516  bool operator != (const CFX_ByteString& str) const { return !operator==(str); }
517 
525  bool operator< (const CFX_ByteString& rhs) const;
526 
532  void Empty();
533 
549  const CFX_ByteString& operator = (FX_BSTR bstrc);
557  const CFX_ByteString& operator = (const CFX_ByteString& stringSrc);
565  const CFX_ByteString& operator = (const CFX_BinaryBuf& buf);
566 
575  void Load(FX_LPCBYTE str, FX_STRSIZE len);
576 
600  const CFX_ByteString& operator += (const CFX_ByteString& str);
608  const CFX_ByteString& operator += (FX_BSTR bstrc);
609 
617  FX_BYTE GetAt(FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
625  FX_BYTE operator[](FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
634  void SetAt(FX_STRSIZE nIndex, FX_CHAR ch);
635 
644  FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch);
645 
654  FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
671  void Format(FX_LPCSTR lpszFormat, ... );
682  void FormatV(FX_LPCSTR lpszFormat, va_list argList);
694  void Reserve(FX_STRSIZE len);
695 
708 
718 
729  void ReleaseBuffer(FX_STRSIZE len = -1);
730 
738  CFX_ByteString Mid(FX_STRSIZE first) const;
747  CFX_ByteString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
755  CFX_ByteString Left(FX_STRSIZE count) const;
763  CFX_ByteString Right(FX_STRSIZE count) const;
772  FX_STRSIZE Find(FX_BSTR lpszSub, FX_STRSIZE start=0) const;
781  FX_STRSIZE Find(FX_CHAR ch, FX_STRSIZE start=0) const;
789  FX_STRSIZE ReverseFind(FX_CHAR ch) const;
790 
796  void MakeLower();
802  void MakeUpper();
803 
809  void TrimRight();
817  void TrimRight(FX_CHAR chTarget);
825  void TrimRight(FX_BSTR lpszTargets);
831  void TrimLeft();
839  void TrimLeft(FX_CHAR chTarget);
847  void TrimLeft(FX_BSTR lpszTargets);
848 
857  FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew);
866 
872  CFX_WideString UTF8Decode() const;
873 
883  void ConvertFrom(const CFX_WideString& str, CFX_CharMap* pCharMap = NULL);
891  FX_DWORD GetID(FX_STRSIZE start_pos = 0) const;
899  static CFX_ByteString LoadFromFile(FX_BSTR file_path);
900 
902 #define FXFORMAT_SIGNED 1
903 
904 #define FXFORMAT_HEX 2
905 
906 #define FXFORMAT_CAPITAL 4
907 
923  static CFX_ByteString FormatInteger(FX_INT32 i, FX_DWORD flags = 0);
934  static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
935 
936  protected:
937  /* Pointer to ref counted byte string data. */
938  struct CFX_StringData* m_pData;
939 
940  void AllocCopy(CFX_ByteString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
941  void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
942  void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCSTR lpszSrc2Data);
943  void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCSTR lpszSrcData);
944  void CopyBeforeWrite();
945  void AllocBeforeWrite(FX_STRSIZE nLen);
946 };
947 
949 {
950  m_Ptr = (FX_LPCBYTE)src;
951  m_Length = src.GetLength();
952 }
953 
955 {
956  m_Ptr = (FX_LPCBYTE)src;
957  m_Length = src.GetLength();
958  return *this;
959 }
960 
973 
982 inline CFX_ByteString operator + (FX_BSTR str1, FX_BSTR str2) { return CFX_ByteString(str1, str2); }
983 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
984 #ifndef _NO_LPCSTR_SUPPORT_
985 //<<<+++OPENSOURCE_MUST_END
994 inline CFX_ByteString operator + (FX_BSTR str1, FX_LPCSTR str2) { return CFX_ByteString(str1, str2); }
1003 inline CFX_ByteString operator + (FX_LPCSTR str1,FX_BSTR str2) { return CFX_ByteString(str1, str2); }
1004 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1005 #endif
1006 //<<<+++OPENSOURCE_MUST_END
1025 
1034 inline CFX_ByteString operator + (const CFX_ByteString& str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1043 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_CHAR ch) { return CFX_ByteString(str1, CFX_ByteStringC(ch)); }
1052 inline CFX_ByteString operator + (FX_CHAR ch, const CFX_ByteString& str2) { return CFX_ByteString(CFX_ByteStringC(ch), str2); }
1053 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1054 #ifndef _NO_LPCSTR_SUPPORT_
1055 //<<<+++OPENSOURCE_MUST_END
1064 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_LPCSTR str2) { return CFX_ByteString(str1, str2); }
1073 inline CFX_ByteString operator + (FX_LPCSTR str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1074 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1075 #endif
1076 //<<<+++OPENSOURCE_MUST_END
1085 inline CFX_ByteString operator + (const CFX_ByteString& str1, FX_BSTR str2) { return CFX_ByteString(str1, str2); }
1094 inline CFX_ByteString operator + (FX_BSTR str1, const CFX_ByteString& str2) { return CFX_ByteString(str1, str2); }
1095 
1104 class CFX_StringBufBase : public CFX_Object
1105 {
1106  public:
1112  explicit CFX_StringBufBase(FX_STRSIZE limit) { m_Size = 0; m_Limit = limit; }
1113 
1119  FX_CHAR* GetPtr() const { return (FX_CHAR*)(this + 1); }
1125  FX_STRSIZE GetSize() const { return m_Size; }
1126 
1132  void Empty() { m_Size = 0; }
1133 
1141  void Copy(FX_BSTR str);
1142 
1150  void Append(FX_BSTR str);
1151 
1162  void Append(int i, FX_DWORD flags = 0);
1163 
1169  CFX_ByteStringC GetStringC() const { return CFX_ByteStringC((FX_CHAR*)(this + 1), m_Size); }
1175  CFX_ByteString GetString() const { return CFX_ByteString((FX_CHAR*)(this + 1), m_Size); }
1176 
1177  protected:
1178  /* The buffer limit. */
1179  FX_STRSIZE m_Limit;
1180  /* The string size. */
1181  FX_STRSIZE m_Size;
1182  // the real buffer follows
1183 };
1184 
1188 template<FX_STRSIZE limit>
1190 {
1191  public:
1196 
1203 };
1204 
1207 
1208 //*****************************************************************************
1209 //* CFX_WideStringC - constant wide string
1210 //*****************************************************************************
1216 class CFX_WideStringC : public CFX_Object
1217 {
1218  public:
1223  {
1224  m_Ptr = NULL;
1225  m_Length = 0;
1226  }
1227 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1228 #ifndef _NO_LPCSTR_SUPPORT_
1229 //<<<+++OPENSOURCE_MUST_END
1236  {
1237  m_Ptr = ptr;
1238  m_Length = ptr ? (FX_STRSIZE)FXSYS_wcslen(ptr) : 0;
1239  }
1240 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1241 #endif
1242 //<<<+++OPENSOURCE_MUST_END
1249  {
1250  m_Ptr = &ch;
1251  m_Length = 1;
1252  }
1260  {
1261  m_Ptr = ptr;
1262  if (len == -1)
1263  m_Length = (FX_STRSIZE)FXSYS_wcslen(ptr);
1264  else
1265  m_Length = len;
1266  }
1273  {
1274  m_Ptr = src.m_Ptr;
1275  m_Length = src.m_Length;
1276  }
1282  CFX_WideStringC(const CFX_WideString& src);
1283 
1292  {
1293  m_Ptr = src;
1294  m_Length = (FX_STRSIZE)FXSYS_wcslen(src);
1295  return *this;
1296  }
1305  {
1306  m_Ptr = src.m_Ptr;
1307  m_Length = src.m_Length;
1308  return *this;
1309  }
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  }
1337  bool operator != (const CFX_WideStringC& str) const
1338  {
1339  return str.m_Length != m_Length || FXSYS_memcmp32(str.m_Ptr, m_Ptr, m_Length*sizeof(FX_WCHAR)) != 0;
1340  }
1341 
1347  FX_LPCWSTR GetPtr() const { return m_Ptr; }
1353  FX_STRSIZE GetLength() const { return m_Length; }
1359  bool IsEmpty() const { return m_Length == 0; }
1360 
1368  FX_WCHAR GetAt(FX_STRSIZE index) const { return m_Ptr[index]; }
1369 
1378  {
1379  if (count < 1) return CFX_WideStringC();
1380  if (count > m_Length) count = m_Length;
1381  return CFX_WideStringC(m_Ptr, count);
1382  }
1383 
1392  CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const
1393  {
1394  if (index < 0) index = 0;
1395  if (index > m_Length) return CFX_WideStringC();
1396  if (count < 0 || count > m_Length - index) count = m_Length - index;
1397  return CFX_WideStringC(m_Ptr + index, count);
1398  }
1399 
1408  {
1409  if (count < 1) return CFX_WideStringC();
1410  if (count > m_Length) count = m_Length;
1411  return CFX_WideStringC(m_Ptr + m_Length - count, count);
1412  }
1413 
1414  protected:
1415  /* The constant byte string pointer. */
1416  FX_LPCWSTR m_Ptr;
1417  /* the length in bytes of the byte string. */
1418  FX_STRSIZE m_Length;
1419 
1420  private:
1421  /*
1422  * new operator forbidden. Cannot allocate a CFX_WideStringC in heap.
1423  */
1424  void* operator new (size_t) throw() { return NULL; }
1425 };
1426 
1428 typedef const CFX_WideStringC& FX_WSTR;
1429 
1439 #define FX_WSTRC(wstr) CFX_WideStringC((FX_LPCWSTR)wstr, sizeof(wstr) / sizeof(FX_WCHAR) - 1)
1440 
1441 //*****************************************************************************
1442 //* CFX_WideString - wide string
1443 //*****************************************************************************
1446 {
1448  long m_nRefs;
1455 };
1456 
1463 class CFX_WideString : public CFX_Object
1464 {
1465  public:
1469  CFX_WideString() { m_pData = NULL; }
1475  CFX_WideString(const CFX_WideString& str);
1482  CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len = -1) { InitStr(ptr, len); }
1483 
1484 #ifdef _NATIVE_WCHAR_T_DEFINED
1485 
1491  CFX_WideString(const wchar_t* ptr, FX_STRSIZE len = -1) { InitStr((FX_LPCWSTR)ptr, len); }
1492 #endif
1493 
1505  CFX_WideString(const CFX_WideStringC& str);
1512  CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
1516  ~CFX_WideString();
1517 
1527  static CFX_WideString FromLocal(const char* str, FX_STRSIZE len = -1);
1536  static CFX_WideString FromUTF8(const char* str, FX_STRSIZE len = -1);
1545  static CFX_WideString FromUTF16LE(const unsigned short* str, FX_STRSIZE len = -1);
1546 
1555  static CFX_WideString FromUTF16BE(const unsigned short* str, FX_STRSIZE len = -1);
1556 
1564  static FX_STRSIZE WStringLength(const unsigned short* str);
1565 
1569  operator FX_LPCWSTR() const { return m_pData ? m_pData->m_String : (FX_WCHAR*)L""; }
1570 
1571 #ifdef _NATIVE_WCHAR_T_DEFINED
1572 
1575  operator const wchar_t*() const { return m_pData ? (const wchar_t*)m_pData->m_String : L""; }
1576 #endif
1577 
1583  void Empty();
1589  FX_BOOL IsEmpty() const { return !GetLength(); }
1590 
1596  FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; }
1597 
1606 
1607 #ifdef _NATIVE_WCHAR_T_DEFINED
1608 
1615  const CFX_WideString& operator = (const wchar_t* str) { return operator = ((FX_LPCWSTR)str); }
1616 #endif
1617 
1625  const CFX_WideString& operator =(const CFX_WideString& stringSrc);
1633  const CFX_WideString& operator =(const CFX_WideStringC& stringSrc);
1634 
1643 
1644 #ifdef _NATIVE_WCHAR_T_DEFINED
1645 
1652  const CFX_WideString& operator += (const wchar_t* str) { return operator += ((FX_LPCWSTR)str); }
1653 #endif
1654 
1670  const CFX_WideString& operator += (const CFX_WideString& str);
1678  const CFX_WideString& operator += (const CFX_WideStringC& str);
1679 
1687  FX_WCHAR GetAt(FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
1695  FX_WCHAR operator[](FX_STRSIZE nIndex) const { return m_pData ? m_pData->m_String[nIndex] : 0; }
1704  void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch);
1705 
1717  int Compare(FX_LPCWSTR str) const;
1729  int Compare(const CFX_WideString& str) const;
1730 
1742  int CompareNoCase(FX_LPCWSTR str) const;
1743 
1744 #ifdef _NATIVE_WCHAR_T_DEFINED
1745 
1756  int CompareNoCase(const wchar_t* str) const { return CompareNoCase((FX_LPCWSTR)str); }
1768  int CompareNoCase(const CFX_WideString& str) const { return CompareNoCase((FX_LPCWSTR)str); }
1769 #endif
1770 
1781  bool Equal(const CFX_WideStringC& str) const;
1782 
1790  CFX_WideString Mid(FX_STRSIZE first) const;
1800  CFX_WideString Mid(FX_STRSIZE first, FX_STRSIZE count) const;
1808  CFX_WideString Left(FX_STRSIZE count) const;
1816  CFX_WideString Right(FX_STRSIZE count) const;
1817 
1826  FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch);
1835  FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count = 1);
1843  void Format(FX_LPCWSTR lpszFormat, ... );
1854  void FormatV(FX_LPCWSTR lpszFormat, va_list argList);
1860  void MakeLower();
1866  void MakeUpper();
1867 
1873  void TrimRight();
1881  void TrimRight(FX_WCHAR chTarget);
1889  void TrimRight(FX_LPCWSTR lpszTargets);
1890 
1891 #ifdef _NATIVE_WCHAR_T_DEFINED
1892 
1899  void TrimRight(const wchar_t* lpszTargets) { TrimRight((FX_LPCWSTR)lpszTargets); }
1900 #endif
1901 
1907  void TrimLeft();
1915  void TrimLeft(FX_WCHAR chTarget);
1923  void TrimLeft(FX_LPCWSTR lpszTargets);
1924 
1925 #ifdef _NATIVE_WCHAR_T_DEFINED
1926 
1933  void TrimLeft(const wchar_t* lpszTargets) { TrimLeft((FX_LPCWSTR)lpszTargets); }
1934 #endif
1935 
1945  void Reserve(FX_STRSIZE len);
1969  void ReleaseBuffer(FX_STRSIZE len = -1);
1970 
1976  int GetInteger() const;
1977 
1983  FX_FLOAT GetFloat() const;
1984 
1985 #ifdef _NATIVE_WCHAR_T_DEFINED
1986 
1994  FX_STRSIZE Find(const wchar_t* lpszSub, FX_STRSIZE start=0) const { return Find((FX_LPCWSTR)lpszSub, start); }
2003  FX_STRSIZE Find(CFX_WideString& lpszSub, FX_STRSIZE start=0) const { return Find((FX_LPCWSTR)lpszSub, start); }
2004 #endif
2005 
2014  FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start=0) const;
2023  FX_STRSIZE Find(FX_WCHAR ch, FX_STRSIZE start=0) const;
2024 
2033  FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew);
2042 
2048  CFX_ByteString UTF8Encode() const;
2056  CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate = TRUE) const;
2057 
2068  void ConvertFrom(const CFX_ByteString& str, CFX_CharMap* pCharMap = NULL);
2069 
2070  protected:
2071  void InitStr(FX_LPCWSTR ptr, int len);
2072 
2073  /* Pointer to ref counted wide string data. */
2074  CFX_StringDataW* m_pData;
2075 
2076  void CopyBeforeWrite();
2077  void AllocBeforeWrite(FX_STRSIZE nLen);
2078 
2079  void ConcatInPlace(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
2080  void ConcatCopy(FX_STRSIZE nSrc1Len, FX_LPCWSTR lpszSrc1Data, FX_STRSIZE nSrc2Len, FX_LPCWSTR lpszSrc2Data);
2081  void AssignCopy(FX_STRSIZE nSrcLen, FX_LPCWSTR lpszSrcData);
2082  void AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STRSIZE nCopyIndex, FX_STRSIZE nExtraLen) const;
2083 };
2084 
2086 {
2087  m_Ptr = (FX_LPCWSTR)src;
2088  m_Length = src.GetLength();
2089 }
2090 
2092 {
2093  m_Ptr = (FX_LPCWSTR)src;
2094  m_Length = src.GetLength();
2095  return *this;
2096 }
2097 
2111 
2120 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2121 #ifndef _NO_LPCSTR_SUPPORT_
2122 
2130 inline CFX_WideString operator + (const CFX_WideStringC& str1, FX_LPCWSTR str2) { return CFX_WideString(str1, str2); }
2139 inline CFX_WideString operator + (FX_LPCWSTR str1,const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2140 #endif
2141 
2158 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideStringC& str2) { return CFX_WideString(ch, str2); }
2159 
2168 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2177 inline CFX_WideString operator + (const CFX_WideString& str1, FX_WCHAR ch) { return CFX_WideString(str1, CFX_WideStringC(ch)); }
2186 inline CFX_WideString operator + (FX_WCHAR ch, const CFX_WideString& str2) { return CFX_WideString(ch, str2); }
2187 #ifndef _NO_LPCSTR_SUPPORT_
2188 
2196 inline CFX_WideString operator + (const CFX_WideString& str1, FX_LPCWSTR str2) { return CFX_WideString(str1, str2); }
2205 inline CFX_WideString operator + (FX_LPCWSTR str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2206 #endif
2207 
2215 inline CFX_WideString operator + (const CFX_WideString& str1, const CFX_WideStringC& str2) { return CFX_WideString(str1, str2); }
2224 inline CFX_WideString operator + (const CFX_WideStringC& str1, const CFX_WideString& str2) { return CFX_WideString(str1, str2); }
2225 
2232 
2241 bool operator==(const CFX_WideString& s1, const CFX_WideString& s2);
2250 bool operator==(const CFX_WideString& s1, const CFX_WideStringC& s2);
2259 bool operator==(const CFX_WideStringC& s1, const CFX_WideString& s2);
2268 bool operator== (const CFX_WideString& s1, FX_LPCWSTR s2);
2277 bool operator==(FX_LPCWSTR s1, const CFX_WideString& s2);
2278 
2287 bool operator!=(const CFX_WideString& s1, const CFX_WideString& s2);
2296 bool operator!=(const CFX_WideString& s1, const CFX_WideStringC& s2);
2305 bool operator!=(const CFX_WideStringC& s1, const CFX_WideString& s2);
2314 bool operator!= (const CFX_WideString& s1, FX_LPCWSTR s2);
2323 bool operator!=(FX_LPCWSTR s1, const CFX_WideString& s2);
2324 
2325 #ifdef _NATIVE_WCHAR_T_DEFINED
2326 
2334 inline bool operator== (const CFX_WideString& s1, const wchar_t* s2) { return operator==(s1, (FX_LPCWSTR)s2); }
2343 inline bool operator==(const wchar_t* s1, const CFX_WideString& s2) { return operator==((FX_LPCWSTR)s1, s2); }
2352 inline bool operator!= (const CFX_WideString& s1, const wchar_t* s2) { return operator!=(s1, (FX_LPCWSTR)s2); }
2361 inline bool operator!=(const wchar_t* s1, const CFX_WideString& s2) { return operator!=((FX_LPCWSTR)s1, s2); }
2362 #endif
2363 
2372 bool operator< (const CFX_WideString& lhs, const CFX_WideString& rhs);
2373 
2384 FX_FLOAT FX_atof(FX_BSTR str);
2395 void FX_atonum(FX_BSTR str, FX_BOOL& bInteger, void* pData, int sizeOfData = 4);
2396 
2406 
2450 #define FXWCHAR_LTR 0
2451 
2452 #define FXWCHAR_RTL 1
2453 
2454 #define FXWCHAR_UNKNOWN 2
2455 
2463 int FXWCHAR_GetDirection(FX_WCHAR wchar);
2465 //<<<+++OPENSOURCE_END
2466 
2471 
2488 inline CFX_ByteString FX_UTF8Encode(FX_WSTR wsStr) {return FX_UTF8Encode(wsStr.GetPtr(), wsStr.GetLength());}
2496 inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr) {return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength());}
2497 
2498 // The following two functions only make sense if the the system
2499 // uses UTF-16 for wide string encoding. All supported systems
2500 // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
2501 
2502 // Determines if the arguments constitute UTF-16 surrogate pair
2503 // and thus should be combined into a single Unicode code point
2504 // using CreateCodePointFromUtf16SurrogatePair.
2505 inline FX_BOOL FX_IsUtf16SurrogatePair(FX_WCHAR first, FX_WCHAR second)
2506 {
2507  return ((first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00);
2508 }
2509 
2510 // Creates a Unicode code point from UTF16 surrogate pair.
2511 inline FX_DWORD FX_CreateCodePointFromUtf16SurrogatePair(FX_WCHAR first,
2512  FX_WCHAR second)
2513 {
2514  const FX_DWORD mask = (1 << 10) - 1;
2515  return (((first & mask) << 10) | (second & mask)) + 0x10000;
2516  // This function should not be called when the condition is
2517  // false, but we provide a sensible default in case it is.
2518 }
2519 
2522 //*****************************************************************************
2523 //* CFX_ByteStringL - long term byte string
2524 //*****************************************************************************
2525 class CFX_ByteStringL : public CFX_ByteStringC
2526 {
2527  public:
2528  CFX_ByteStringL() : CFX_ByteStringC() {}
2529  ~CFX_ByteStringL() {}
2530 
2531  void Empty(IFX_Allocator* pAllocator);
2532 
2533  FX_LPSTR AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocator);
2534 
2535  void Set(FX_BSTR src, IFX_Allocator* pAllocator);
2536 };
2537 
2538 //*****************************************************************************
2539 //* CFX_WideStringL - long term wide string
2540 //*****************************************************************************
2541 class CFX_WideStringL : public CFX_WideStringC
2542 {
2543  public:
2544  CFX_WideStringL() : CFX_WideStringC() {}
2545  ~CFX_WideStringL() {}
2546 
2547  void Empty(IFX_Allocator* pAllocator);
2548 
2549  void Set(FX_WSTR src, IFX_Allocator* pAllocator);
2550 
2551  int GetInteger() const;
2552  FX_FLOAT GetFloat() const;
2553 
2554  void TrimRight(FX_LPCWSTR lpszTargets);
2555 };
2556 
2557 void FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len, CFX_ByteStringL &utf8Str, IFX_Allocator* pAllocator = NULL);
2558 //<<<+++OPENSOURCE_END
2559 
2560 //<<<+++OPENSOURCE_MUST_BEGIN
2561 #endif // _FX_STRING_H_
2562 //<<<+++OPENSOURCE_MUST_END
2563 
2566 //<<<+++OPENSOURCE_END
bool operator<(const CFX_WideString &lhs, const CFX_WideString &rhs)
Comparison(<) operator overload. Case-sensitive.
FX_BYTE GetAt(FX_STRSIZE nIndex) const
Get a single byte specified by an index number.
Definition: fx_string.h:617
CFX_ByteStringC(FX_LPCBYTE ptr, FX_STRSIZE size)
Constructs from a byte string.
Definition: fx_string.h:68
Definition: fx_basic.h:52
int CompareNoCase(FX_LPCWSTR str) const
Compare the the string with a wide character string. No case-insensitive.
CFX_ByteStringC GetStringC() const
Get a non-buffered byte string.
Definition: fx_string.h:1169
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:1452
FX_WCHAR GetAt(FX_STRSIZE nIndex) const
Retrieves a single wide character specified by an index number.
Definition: fx_string.h:1687
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more characters starting from specific position.
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:708
CFX_WideStringC()
Constructs a null constant string.
Definition: fx_string.h:1222
FX_STRSIZE Insert(FX_STRSIZE index, FX_WCHAR ch)
Insert a wide character before specific position.
const CFX_ByteStringC & FX_BSTR
A reference to a constant CFX_ByteStringC object.
Definition: fx_string.h:285
FX_FLOAT GetFloat() const
Convert to other data type.
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...
void TrimRight()
Trim white spaces from the right side of the byte string.
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_WideString::GetBuffer or CFX_WideString::LockBuffer, and set the length of modified string.
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:698
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:1407
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1216
bool IsEmpty() const
Determines whether current string object is empty.
Definition: fx_string.h:1359
FX_CHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:311
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:1377
long m_nRefs
Reference count.
Definition: fx_string.h:305
FX_STRSIZE Find(FX_LPCWSTR lpszSub, FX_STRSIZE start=0) const
Find a sub-string, from specific position. Only first occurrence is found.
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:1353
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:227
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:1392
bool operator!=(const CFX_WideStringC &str) const
Comparison(!=) operator overload. Case-sensitive.
Definition: fx_string.h:1337
CFX_ByteStringC(FX_LPCSTR ptr)
Construct from a character string.
Definition: fx_string.h:81
FX_FLOAT FX_atof(FX_BSTR str)
Convert a non-buffered byte string to a floating-point number.
CFX_ByteStringC(FX_LPCSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:105
bool Equal(const CFX_WideStringC &str) const
Check if current string is equal to another.
bool operator==(const CFX_ByteStringC &str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:172
FX_LPSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer.
void Empty()
Set this string to be empty.
Definition: fx_string.h:1132
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:712
bool operator!=(const CFX_ByteStringC &str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:183
void TrimLeft()
Trim white spaces from the left side of the byte string.
FX_STRSIZE Delete(FX_STRSIZE index, FX_STRSIZE count=1)
Delete one or more wide characters starting from specific position.
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:625
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:854
FX_LPWSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of characters allocated.
FX_STRSIZE GetSize() const
Gets the length of the string.
Definition: fx_string.h:1125
CFX_WideString(FX_LPCWSTR ptr, FX_STRSIZE len=-1)
Construct from a wide character string.
Definition: fx_string.h:1482
void Empty()
Set this string to be empty.
FX_INT32 FXSYS_memcmp32(const void *buf1, const void *buf2, size_t size)
Compare data in two buffers.
char * FX_LPSTR
Pointer to 8-bit Windows (ANSI) characters.
Definition: fx_system.h:677
CFX_StringBufTemplate< 256 > CFX_StringBuf256
A fixed 256-byte string buffer.
Definition: fx_string.h:1206
FX_LPSTR GetBuffer(FX_STRSIZE len)
Get a buffer with specific number of bytes allocated.
void Load(FX_LPCBYTE str, FX_STRSIZE len)
Load from a byte string.
FX_STRSIZE Remove(FX_WCHAR ch)
Remove all occurrence of a particular character.
CFX_ByteStringC(const CFX_ByteStringC &src)
Copy constructor.
Definition: fx_string.h:118
CFX_WideStringC & operator=(FX_LPCWSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:1291
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...
WIDE STRING CLASS.
Definition: fx_string.h:1463
void Empty()
Set this string to be empty.
void TrimLeft()
Trim white spaces from the left side of the wide string.
CFX_WideStringC(const CFX_WideStringC &src)
Copy constructor.
Definition: fx_string.h:1272
void MakeUpper()
Change case of English letters to upper.
static FX_STRSIZE WStringLength(const unsigned short *str)
Length of string.
FX_LPCBYTE GetPtr() const
Get a constant byte string pointer to the byte string.
Definition: fx_string.h:215
FX_BOOL FXWCHAR_IsWordBreak(FX_WCHAR wchar)
Check if the unicode can break a word.
FX_STRSIZE Replace(FX_LPCWSTR lpszOld, FX_LPCWSTR lpszNew)
Replace all patterns in the string with a new sub-string.
static CFX_WideString FromUTF8(const char *str, FX_STRSIZE len=-1)
Create a wide string from UTF-8 string (ASCII string compatible).
void TrimRight()
Trim white spaces from the right side of the wide string.
This class represents the data of a wide string object.
Definition: fx_string.h:1445
FX_WCHAR FXWCHAR_GetUpper(FX_WCHAR wchar)
Convert to upper-case letter.
FX_WCHAR FXWCHAR_GetLower(FX_WCHAR wchar)
Convert to lower-case letter.
FX_WCHAR m_String[1]
Real data (actually a variable-sized array).
Definition: fx_string.h:1454
FX_STRSIZE GetLength() const
Get number of characters, not bytes. Trailing zero not counted.
Definition: fx_string.h:1596
FX_STRSIZE Remove(FX_CHAR ch)
Remove all occurrence of a particular character.
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of bytes.
FX_BOOL FXWCHAR_IsSpace(FX_WCHAR wchar)
Check if the unicode is space.
CFX_WideString()
Construct a null wide string.
Definition: fx_string.h:1469
A fixed string buffer holding up to certain number of characters.
Definition: fx_string.h:1104
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:662
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
A fixed string buffer template.
Definition: fx_string.h:1189
bool EqualNoCase(FX_BSTR str) const
Check if current string is equal to another one, not considering case.
FX_STRSIZE m_nAllocLength
Length of allocation.
Definition: fx_string.h:309
const CFX_ByteString & operator+=(FX_CHAR ch)
Concatenation(+=) operator overload. Concatenate a single character.
FX_WCHAR GetAt(FX_STRSIZE index) const
Retrieves a single byte specified by an index number.
Definition: fx_string.h:1368
int Compare(FX_LPCWSTR str) const
Compare current string with a wide character string. Case-sensitive.
CFX_ByteStringC()
Constructs a null constant string.
Definition: fx_string.h:57
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:666
int Compare(FX_BSTR str) const
Compare the the string with another. Case-sensitive.
CFX_WideStringC(FX_WCHAR &ch)
Construct from a single character.
Definition: fx_string.h:1248
void Format(FX_LPCSTR lpszFormat,...)
Format a number of parameters into this byte string.
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:679
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1003
const CFX_WideString & operator+=(FX_LPCWSTR str)
Concatenation(+=) operator overload. Concatenate a wide character string.
bool operator!=(FX_LPCSTR str) const
Comparison(!=) operator overload. case-sensitive.
Definition: fx_string.h:497
static CFX_WideString FromLocal(const char *str, FX_STRSIZE len=-1)
Create a wide string from system multi-byte charset.
CFX_ByteString Left(FX_STRSIZE count) const
Extracts the first (leftmost) count bytes from this CFX_ByteString object as a sub-string.
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string. See function CFX_ByteStringC::GetID for details.
CFX_ByteString GetString() const
Get a buffered byte string.
Definition: fx_string.h:1175
void SetAt(FX_STRSIZE nIndex, FX_CHAR ch)
Overwrites a single byte specified by an index number.
FX_STRSIZE GetLength() const
Get number of bytes in the byte string (not counting any possible terminator).
Definition: fx_string.h:413
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:307
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:1695
This class represents the data of a byte string object.
Definition: fx_string.h:302
~CFX_WideString()
The Destructor.
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:420
FX_CHAR m_Buffer[limit]
The fixed string buffer.
Definition: fx_string.h:1202
CFX_ByteString UTF8Encode() const
Do UTF8 encoding.
void MakeLower()
Change case of English letters to lower.
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, starting at position index (zero-based).
Definition: fx_string.h:263
static CFX_ByteString FormatFloat(FX_FLOAT f, int precision=0)
Convert from floating-point number.
FX_STRSIZE m_nDataLength
Length of data (excluding terminator).
Definition: fx_string.h:1450
CFX_ByteString Mid(FX_STRSIZE first) const
Extracts a substring from this CFX_ByteString object, starting at position nFirst (zero-based) to las...
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:982
Foxit allocator interface.
Definition: fx_memory.h:960
Definition: fx_basic.h:905
void ConvertFrom(const CFX_ByteString &str, CFX_CharMap *pCharMap=NULL)
Load MBCS data into this wide string, using specified character mapper.
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:675
void FX_atonum(FX_BSTR str, FX_BOOL &bInteger, void *pData, int sizeOfData=4)
Convert a non-buffered byte string to a number.
FX_LPCSTR GetCStr() const
Get a constant character string pointer to the byte string.
Definition: fx_string.h:221
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:664
CFX_StringBufBase(FX_STRSIZE limit)
A Constructor.
Definition: fx_string.h:1112
bool IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:233
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_LPSTR buf)
Convert float to byte string.
FX_STRSIZE ReverseFind(FX_CHAR ch) const
Find a character from end of the string.
bool operator<(const CFX_ByteString &rhs) const
Comparison(<) operator overload. case-sensitive.
void FormatV(FX_LPCSTR lpszFormat, va_list argList)
Format a number of parameters into this byte string, using va_list.
CFX_ByteString FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len)
Encode a wide string into a UTF-8 string.
void SetAt(FX_STRSIZE nIndex, FX_WCHAR ch)
Overwrites a single wide character specified by an index number.
#define TRUE
Keyword which value is 1.
Definition: fx_system.h:757
void Append(FX_BSTR str)
Append a non-buffered byte string.
CFX_ByteStringC & operator=(FX_LPCSTR src)
Assignment(=) operator overload. From a character string.
Definition: fx_string.h:137
CFX_ByteString UTF16LE_Encode(FX_BOOL bTerminate=TRUE) const
Do UTF16LE encoding.
FX_BYTE GetAt(FX_STRSIZE index) const
This method retrieves a single byte specified by an index number.
Definition: fx_string.h:252
static CFX_ByteString LoadFromFile(FX_BSTR file_path)
Load the whole content of a file.
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
CFX_ByteString()
Construct a null byte string.
Definition: fx_string.h:323
const CFX_WideStringC & FX_WSTR
Type definition for a reference to a constant CFX_WideStringC object.
Definition: fx_string.h:1428
bool operator!=(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(!=) operator overload. Case-sensitive.
FX_STRSIZE Replace(FX_BSTR lpszOld, FX_BSTR lpszNew)
Replace all patterns in the string with a new sub-string.
void Reserve(FX_STRSIZE len)
Reserve a buffer that can hold specific number of characters.
static CFX_ByteString FormatInteger(FX_INT32 i, FX_DWORD flags=0)
Convert from Integer.
CFX_WideStringC(FX_LPCWSTR ptr)
Construct from a character string.
Definition: fx_string.h:1235
bool operator==(const CFX_WideStringC &str) const
Comparison(==) operator overload. Case-sensitive.
Definition: fx_string.h:1326
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(FX_STRSIZE count) const
Extracts the last (rightmost) count bytes from this CFX_ByteString object as a sub-string.
long m_nRefs
Reference count.
Definition: fx_string.h:1448
CFX_WideString UTF8Decode() const
Decode a UTF-8 unicode string (assume this byte string is UTF-8 encoded).
static CFX_WideString FromUTF16BE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16BE encoded string.
void MakeUpper()
Change case of English letters to upper.
BYTE STRING CLASS.
Definition: fx_string.h:317
int GetInteger() const
Convert to other data type.
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:648
FX_CHAR * GetPtr() const
Get a C-style string pointer to the string buffer.
Definition: fx_string.h:1119
FX_LPWSTR LockBuffer()
Lock and get the current string buffer, so the caller can modify the returned buffer. Caller can modified the returned buffer, and should call CFX_WideString::ReleaseBuffer after modification done.
static CFX_WideString FromUTF16LE(const unsigned short *str, FX_STRSIZE len=-1)
Create a wide string from UTF16LE encoded string.
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:710
CFX_WideString Right(FX_STRSIZE count) const
Extracts the last (rightmost) count wide characters from this CFX_WideString object as a sub-string...
void MakeLower()
Change case of English letters to lower.
#define NULL
The null-pointer value.
Definition: fx_system.h:767
FX_BOOL IsEmpty() const
Check whether current string object is empty.
Definition: fx_string.h:1589
bool Equal(FX_BSTR str) const
Check if current string is equal to another one. Case-sensitive.
CFX_WideString Left(FX_STRSIZE count) const
Extracts the first (leftmost) count wide characters from this CFX_WideString object as a sub-string...
void Copy(FX_BSTR str)
Copy from a non-buffered byte string.
bool operator==(const CFX_WideString &s1, const CFX_WideString &s2)
Comparison(==) operator overload. Case-sensitive.
void ReleaseBuffer(FX_STRSIZE len=-1)
Release the buffer fetched by function CFX_ByteString::GetBuffer or CFX_ByteString::LockBuffer, and set the length of modified string.
const CFX_WideString & operator=(FX_LPCWSTR str)
Assignment(=) operator overload. From a wide character string.
void FormatV(FX_LPCWSTR lpszFormat, va_list argList)
Format a number of parameters into this wide string. using va_list.
FX_LPCWSTR GetPtr() const
Get a constant wide string pointer to the wide string.
Definition: fx_string.h:1347
int FXWCHAR_GetDirection(FX_WCHAR wchar)
Get text direction.
CFX_StringBufTemplate()
A constructor.
Definition: fx_string.h:1195
CFX_WideStringC(FX_LPCWSTR ptr, FX_STRSIZE len)
Construct from a character string.
Definition: fx_string.h:1259
CFX_ByteStringC(const FX_CHAR &ch)
Construct from a single character.
Definition: fx_string.h:94
FX_STRSIZE Insert(FX_STRSIZE index, FX_CHAR ch)
Insert a character before specific position.
const CFX_ByteString & operator=(FX_LPCSTR str)
Assignment(=) operator overload. From a character string.
CFX_WideString Mid(FX_STRSIZE first) const
Extracts a substring from this CFX_WideString object, starting at position nFirst (zero-based) to las...
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:644
FX_DWORD GetID(FX_STRSIZE start_pos=0) const
Get a DWORD identifier of the string, from a particular position.
bool operator==(FX_LPCSTR str) const
Comparison(==) operator overload. case-sensitive.
Definition: fx_string.h:467
void Format(FX_LPCWSTR lpszFormat,...)
Format a number of parameters into this wide string.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.