Foxit PDF SDK
fx_basic.h
Go to the documentation of this file.
1 
15 //<<<+++OPENSOURCE
16 //<<<+++OPENSOURCE_LICENSE
17 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT||LIC==GOOGLE
18 
23 //<<<+++OPENSOURCE_MUST_BEGIN
24 #ifndef _FX_BASIC_H_
25 #define _FX_BASIC_H_
26 
27 /* System dependant definitions */
28 #ifndef _FX_SYSTEM_H_
29  #include "fx_system.h"
30 #endif
31 #ifndef _FX_MEMORY_H_
32  #include "fx_memory.h"
33 #endif
34 #ifndef _FX_STRING_H_
35  #include "fx_string.h"
36 #endif
37 #ifndef _FX_STREAM_H_
38  #include "fx_stream.h"
39 #endif
40 //<<<+++OPENSOURCE_MUST_END
41 
42 #ifndef _FX_EXCEPTION_H_
43  #include "fx_exception.h"
44 #endif
45 
46 //*****************************************************************************
47 //* Buffer
48 //*****************************************************************************
52 class CFX_BinaryBuf : public CFX_Object
53 {
54  public:
60  CFX_BinaryBuf(IFX_Allocator* pAllocator = NULL);
61 
68  CFX_BinaryBuf(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
69  //<<<+++OPENSOURCE_END
70 
73 
79  void Clear();
80 
90  FX_BOOL EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step = 0);
91 
100  FX_BOOL AppendBlock(const void* pBuf, FX_STRSIZE size);
101 
110  FX_BOOL AppendFill(FX_BYTE byte, FX_STRSIZE count);
111 
119  void AppendString(FX_BSTR str) { AppendBlock(str.GetPtr(), str.GetLength()); }
120 
129  {
130  if (m_AllocSize <= m_DataSize)
131  {
132  if (!ExpandBuf(100))
133  return false;
134  }
135  m_pBuffer[m_DataSize++] = byte;
136  return true;
137  }
138 
148  FX_BOOL InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
149 
158  void AttachData(void* pBuf, FX_STRSIZE size);
159 
168  FX_BOOL CopyData(const void* pBuf, FX_STRSIZE size);
179  void TakeOver(CFX_BinaryBuf& other);
180 
189  void Delete(int start_index, int count);
190 
196  FX_LPBYTE GetBuffer() const { return m_pBuffer; }
197 
203  FX_STRSIZE GetSize() const { return m_DataSize; }
204 
211 
219  void GetByteStringL(CFX_ByteStringL &str) const;
220 
226  void DetachBuffer();
227 
230 
231  protected:
232  /* Allocation step. */
233  FX_STRSIZE m_AllocStep;
234  /* The buffer pointer. */
235  FX_LPBYTE m_pBuffer;
236  /* The length in bytes of the buffer. */
237  FX_STRSIZE m_DataSize;
238  /* Allocation size in bytes of the buffer. */
239  FX_STRSIZE m_AllocSize;
240  /*
241  * Increase allocated buffer, not data size.
242  *
243  * @param[in] size The size in bytes to increase.
244  */
245  FX_BOOL ExpandBuf(FX_STRSIZE size);
246 };
247 
252 {
253  public:
260  CFX_ByteTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
261 
269  void operator = (FX_BSTR str);
270 
278  void AppendChar(int ch) { AppendByte((FX_BYTE)ch); }
279 
288 
297 
306 
314  CFX_ByteTextBuf& operator << (double f);
315 
324 
333 
339  FX_STRSIZE GetLength() const { return m_DataSize; }
340 };
341 
346 {
347  public:
354  CFX_WideTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
355 
363  void operator = (FX_LPCWSTR lpsz);
364 
372  void operator = (FX_WSTR str);
373 
382 
391 
399  CFX_WideTextBuf& operator << (double f);
400 
409 
418 
427 
436 
442  FX_STRSIZE GetLength() const { return m_DataSize/sizeof(FX_WCHAR); }
443 
449  FX_LPWSTR GetBuffer() const { return (FX_LPWSTR)m_pBuffer; }
450 
459  void Delete(int start_index, int count)
460  {
461  CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_WCHAR));
462  }
463 
470 
471  void GetWideStringL(CFX_WideStringL& wideText) const;
472 
473 };
474 
475 //*****************************************************************************
476 //* Archive
477 //*****************************************************************************
485 class CFX_ArchiveSaver : public CFX_Object
486 {
487  public:
494  CFX_ArchiveSaver(IFX_Allocator* pAllocator = NULL) : m_SavingBuf(pAllocator), m_pStream(NULL) {}
495 
504 
513 
522 
531 
540 
549 
557  CFX_ArchiveSaver& operator << (double i);
558 
567 
576 
585 
596 
607 
616  void Write(const void* pData, FX_STRSIZE dwSize);
617 
623  FX_INTPTR GetLength() const { return m_SavingBuf.GetSize(); }
624 
630  FX_LPCBYTE GetBuffer() const { return m_SavingBuf.GetBuffer(); }
631 
639  void SetStream(IFX_FileStream* pStream) { m_pStream = pStream; }
640 
641  protected:
642  /* Saving data. */
643  CFX_BinaryBuf m_SavingBuf;
644  /* Stream data. */
645  IFX_FileStream* m_pStream;
646 };
647 
651 class CFX_ArchiveLoader : public CFX_Object
652 {
653  public:
662  CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize);
663 
672 
681 
690 
699 
708 
717 
725  CFX_ArchiveLoader& operator >> (double& i);
726 
735 
744 
750  FX_BOOL IsEOF();
751 
760  FX_BOOL Read(void* pBuf, FX_DWORD dwSize);
761 
762  protected:
763  /* Current loading position. */
764  FX_DWORD m_LoadingPos;
765  /* Loading buffer. */
766  FX_LPCBYTE m_pLoadingBuf;
767  /* The size in bytes of the loading buffer. */
768  FX_DWORD m_LoadingSize;
769 };
770 
775 {
776  public:
784  IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
785  //<<<+++OPENSOURCE_END
786 
790  virtual ~IFX_BufferArchive() {}
791 
797  virtual void Clear();
798 
804  FX_BOOL Flush();
805 
814  FX_INT32 AppendBlock(const void* pBuf, size_t size);
815 
824 
833 
842 
851 
852  protected:
853  /*
854  * @brief Do work, it will be called when the text buffer is full.
855  *
856  * @param[in] pBuf A pointer to a binary buffer block.
857  * @param[in] size The size in bytes of the buffer block.
858  *
859  * @return <b>true</b> means success, while <b>false</b> means failure.
860  */
861  virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
862 
863  /* Special allocator pointer. NULL to use default allocator. */
864  IFX_Allocator* m_pAllocator;
865 
866  /* The buffer size*/
867  FX_STRSIZE m_BufSize;
868  /* Buffer. */
869  FX_LPBYTE m_pBuffer;
870  /* Current buffer length. */
871  FX_STRSIZE m_Length;
872 };
873 
877 class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object
878 {
879  public:
886  CFX_FileBufferArchive(FX_STRSIZE size = 32768, IFX_Allocator* pAllocator = NULL);
887 
892 
898  virtual void Clear();
899 
905  FX_BOOL Flush();
906 
915  FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = false);
916 
924  FX_BOOL AttachFile(FX_LPCWSTR filename);
925 
933  FX_BOOL AttachFile(FX_LPCSTR filename);
934 
935  private:
936  /*
937  * Do work, it will be called when the text buffer is full.
938  *
939  * @param[in] pBuf A pointer to a binary buffer block.
940  * @param[in] size The size in bytes of the buffer block.
941  *
942  * @return <b>true</b> means success, while <b>false</b> means failure.
943  */
944  virtual FX_BOOL DoWork(const void* pBuf, size_t size);
945 
946  /* The file stream. */
947  IFX_StreamWrite *m_pFile;
948  /* whether take over the file. */
949  FX_BOOL m_bTakeover;
950 };
951 
957 {
968  static CFX_CharMap* GetDefaultMapper(FX_INT32 codepage = 0);
969 
983 
996 
1003 };
1004 
1005 //*****************************************************************************
1006 //* UTF-8
1007 //*****************************************************************************
1012 {
1013  public:
1021  CFX_UTF8Decoder(IFX_Allocator* pAllocator = NULL) : m_PendingBytes(0),m_PendingChar(0),m_Buffer(pAllocator) { }
1022 
1028  void Clear();
1029 
1037  void Input(FX_BYTE byte);
1038 
1046  void AppendChar(FX_DWORD ch);
1047 
1053  void ClearStatus() { m_PendingBytes = 0; }
1054 
1060  CFX_WideStringC GetResult() const { return m_Buffer.GetWideString(); }
1061 
1069  void GetResult(CFX_WideStringL &result) const {m_Buffer.GetWideStringL(result);}
1070 
1071  protected:
1072  /* The decoding status. */
1073  int m_PendingBytes;
1074  /* Cached value. */
1075  FX_DWORD m_PendingChar;
1076  /* The output wide text buffer. */
1077  CFX_WideTextBuf m_Buffer;
1078 };
1079 
1084 {
1085  public:
1091  CFX_UTF8Encoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) { m_UTF16First = 0; }
1092 
1100  void Input(FX_WCHAR unicode);
1101 
1109  void AppendStr(FX_BSTR str) { m_UTF16First = 0; m_Buffer << str; }
1110 
1116  CFX_ByteStringC GetResult() const { return m_Buffer.GetByteString(); }
1117 
1125  void GetResult(CFX_ByteStringL &result) const {m_Buffer.GetByteStringL(result);}
1126 
1127  protected:
1128  /* The output byte text buffer. */
1129  CFX_ByteTextBuf m_Buffer;
1130  /* The encoding status. */
1131  FX_DWORD m_UTF16First;
1132 };
1133 
1142 
1151 
1160 
1169 
1170 //*****************************************************************************
1171 //* Array
1172 //*****************************************************************************
1176 class CFX_BasicArray : public CFX_Object
1177 {
1178  public:
1181 
1182  protected:
1183  /*
1184  * @brief Construct with specified unit size.
1185  *
1186  * @param[in] unit_size The specified unit size. Must be greater than 0 and less than 2^28.
1187  * @param[in] pAllocator Allocator used in this class. <b>NULL</b> means to use default allocator.
1188  * Default value: <b>NULL</b>.
1189  */
1190  CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL);
1191  //<<<+++OPENSOURCE_END
1192 
1193  /*
1194  * @brief The destructor.
1195  */
1196  ~CFX_BasicArray();
1197 
1198  /*
1199  * @brief The copy constructor.
1200  *
1201  * @param[in] other The other CFX_BasicArray object.
1202  * @param[in] pAllocator An allocator.
1203  */
1204  CFX_BasicArray(const CFX_BasicArray& other, IFX_Allocator* pAllocator = NULL);
1205 
1206  /*
1207  * @brief The assignment operator.
1208  *
1209  * @param[in] other The other CFX_BasicArray object.
1210  *
1211  * @return Reference to current object itself.
1212  */
1213  CFX_BasicArray& operator=(const CFX_BasicArray& other);
1214 
1215  /*
1216  * @brief Change the allocated size and the grow amount.
1217  *
1218  * @param[in] nNewSize The new size in elements expected.
1219  * @param[in] nGrowBy The grow amount in elements expected, nGrowBy can be -1 for the grow amount unchanged.
1220  *
1221  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter or memory error).
1222  */
1223  FX_BOOL SetSize(int nNewSize, int nGrowBy);
1224 
1225  /*
1226  * @brief Append a basic array.
1227  *
1228  * @param[in] src The input basic array. It must have the save unit size as the current array.
1229  *
1230  * @return <b>true</b> means success, while <b>false</b> means failure (such as memory error).
1231  */
1232  FX_BOOL Append(const CFX_BasicArray& src);
1233 
1234  /*
1235  * @brief Copy from a basic array.
1236  *
1237  * @param[in] src The input basic array. It must have the save unit size as the current array.
1238  *
1239  * @return <b>true</b> means success, while <b>false</b> means failure (such as memory error).
1240  */
1241  FX_BOOL Copy(const CFX_BasicArray& src);
1242 
1243  /*
1244  * @brief Insert spaces at specified position.
1245  *
1246  * @param[in] nIndex Specifies the zero-based index of element in the basic array.
1247  * @param[in] nCount Specifies the count of element to insert.
1248  *
1249  * @return A byte pointer to the inserted space. <b>NULL</b> means error.
1250  */
1251  FX_LPBYTE InsertSpaceAt(int nIndex, int nCount);
1252 
1253  /*
1254  * @brief Remove a number of elements.
1255  *
1256  * @param[in] nIndex Specifies the zero-based index of start element in the basic array to be removed.
1257  * @param[in] nCount Specifies the count of element to remove.
1258  *
1259  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter error).
1260  */
1261  FX_BOOL RemoveAt(int nIndex, int nCount);
1262 
1263  /*
1264  * @brief Insert a basic array at specified position.
1265  *
1266  * @param[in] nStartIndex Specifies the zero-based index of start element to insert at.
1267  * @param[in] pNewArray The input basic array. It must have the save unit size as the current array.
1268  *
1269  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter or memory error).
1270  */
1271  FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
1272 
1273  /*
1274  * @brief Get a typeless pointer to an element data.
1275  *
1276  * @param[in] index Specifies the zero-based index of element.
1277  *
1278  * @return A typeless pointer to the element data. <b>NULL</b> means error.
1279  */
1280  const void* GetDataPtr(int index) const;
1281 
1282  protected:
1283  /* The actual array of data */
1284  FX_LPBYTE m_pData;
1285  /* # of elements (upperBound - 1) */
1286  int m_nSize;
1287  /* Max allocated */
1288  int m_nMaxSize;
1289  /* Grow amount. */
1290  int m_nGrowBy;
1291  /* Number of bytes in one unit. */
1292  int m_nUnitSize;
1293 };
1294 
1296 template<class TYPE>
1298 {
1299  public:
1308 
1311 
1314  };
1315 
1321  CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(TYPE), pAllocator) {}
1322  //<<<+++OPENSOURCE_END
1323 
1330  CFX_ArrayTemplate(const CFX_ArrayTemplate& other, IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(other, pAllocator) {}
1331 
1341  void FX_Error(ErrorType error,FX_INT32 badIndex=0) const
1342  {
1343  const char *errorMsg[] = {
1344  "Invalid array size",
1345  "Memory allocation error",
1346  "Invalid index:"
1347  };
1348 
1349  fprintf(stderr, "%s\n", errorMsg[error]);
1350  if(error == indexOutOfRange)
1351  fprintf(stderr, "%i\n", badIndex);
1352  abort();
1353  }
1354 
1360  int GetSize() const { return m_nSize; }
1361 
1367  int GetUpperBound() const { return m_nSize-1; }
1368 
1377  FX_BOOL SetSize(int nNewSize, int nGrowBy = -1)
1378  {
1379  return CFX_BasicArray::SetSize(nNewSize, nGrowBy);
1380  }
1381 
1387  void RemoveAll() { SetSize(0, -1); }
1388 
1396  const TYPE GetAt(int nIndex) const {
1397  if (nIndex < 0 || nIndex >= m_nSize)
1398  //return (const TYPE&)(*(volatile const TYPE*)NULL);
1399  //In order to avoid crash, we input the index.(For reasons unknown)
1400  FX_Error(indexOutOfRange, nIndex);
1401  return ((const TYPE*)m_pData)[nIndex];
1402  }
1403 
1412  FX_BOOL SetAt(int nIndex, TYPE newElement) {
1413  if (nIndex < 0 || nIndex >= m_nSize) return false;
1414  ((TYPE*)m_pData)[nIndex] = newElement;
1415  return true;
1416  }
1417 
1425  TYPE& ElementAt(int nIndex)
1426  {
1427  if (nIndex < 0 || nIndex >= m_nSize)
1428  //return *(TYPE*)NULL;
1429  //In order to avoid crash, we input the index.(For reasons unknown)
1430  FX_Error(indexOutOfRange, nIndex);
1431  return ((TYPE*)m_pData)[nIndex];
1432  }
1433 
1439  const TYPE* GetData() const { return (const TYPE*)m_pData; }
1440 
1446  TYPE* GetData() { return (TYPE*)m_pData; }
1447 
1456  FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
1457  {
1458  if (nIndex < 0) return false;
1459  if (nIndex >= m_nSize)
1460  if (!SetSize(nIndex+1, -1)) return false;
1461  ((TYPE*)m_pData)[nIndex] = newElement;
1462  return true;
1463  }
1464 
1472  FX_BOOL Add(TYPE newElement)
1473  {
1474  if (m_nSize < m_nMaxSize)
1475  m_nSize ++;
1476  else
1477  if (!SetSize(m_nSize+1, -1)) return false;
1478  ((TYPE*)m_pData)[m_nSize-1] = newElement;
1479  return true;
1480  }
1481 
1489  FX_BOOL Append(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Append(src); }
1490 
1498  FX_BOOL Copy(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Copy(src); }
1499 
1507  TYPE* GetDataPtr(int index) { return (TYPE*)CFX_BasicArray::GetDataPtr(index); }
1508 
1514  TYPE* AddSpace() { return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1); }
1515 
1524  TYPE* InsertSpaceAt(int nIndex, int nCount) { return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount); }
1525 
1533  CFX_ArrayTemplate& operator=(const CFX_ArrayTemplate& src) { CFX_BasicArray::operator=(src); return *this; }
1534 
1542  const TYPE operator[](int nIndex) const
1543  {
1544  if (nIndex < 0 || nIndex >= m_nSize)
1545  //Merge from google trunk r2049, author: Johnson, date:2012.12.07
1546  *(volatile char*)0 = '\0';
1547  return ((const TYPE*)m_pData)[nIndex];
1548  }
1549 
1558  TYPE& operator[](int nIndex)
1559  {
1560  if (nIndex < 0 || nIndex >= m_nSize)
1561  //Merge from google trunk r2049, author: Johnson, date:2012.12.07
1562  *(volatile char*)0 = '\0';
1563  return ((TYPE*)m_pData)[nIndex];
1564  }
1565 
1575  FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1)
1576  {
1577  if (!InsertSpaceAt(nIndex, nCount)) return false;
1578  while (nCount--)
1579  ((TYPE*)m_pData)[nIndex++] = newElement;
1580  return true;
1581  }
1582 
1591  FX_BOOL RemoveAt(int nIndex, int nCount = 1) { return CFX_BasicArray::RemoveAt(nIndex, nCount); }
1592 
1601  FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) { return CFX_BasicArray::InsertAt(nStartIndex, pNewArray); }
1610  int Find(const TYPE& data, int iStart = 0) const
1611  {
1612  if (iStart < 0) return -1;
1613  for (; iStart < (int)m_nSize; iStart ++)
1614  if (((TYPE*)m_pData)[iStart] == data) return iStart;
1615  return -1;
1616  }
1617 };
1618 
1635 
1644 template <class ObjectClass>
1646 {
1647  public:
1653  CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(ObjectClass), pAllocator) {}
1654 
1659 
1666  CFX_ObjectArray(const CFX_ObjectArray& other, IFX_Allocator* pAllocator = NULL)
1667  : CFX_BasicArray(sizeof(ObjectClass), pAllocator)
1668  {
1669  Copy(other);
1670  }
1671 
1680  {
1681  Copy(other);
1682  return *this;
1683  }
1684 
1694  void Add(const ObjectClass& data)
1695  {
1696  #ifndef _FX_NOPLACEMENTNEW_
1697  new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
1698  #else
1699  ::new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
1700  #endif
1701 
1702  }
1703 
1711  ObjectClass& Add()
1712  {
1713  #ifndef _FX_NOPLACEMENTNEW_
1714  return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
1715  #else
1716  return *(ObjectClass*) ::new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
1717  #endif
1718  }
1719 
1727  void* AddSpace()
1728  {
1729  return InsertSpaceAt(m_nSize, 1);
1730  }
1731 
1742  FX_INT32 Append(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
1743  {
1744  if (nCount == 0) return 0;
1745  FX_INT32 nSize = src.GetSize();
1746  if (!nSize) return 0;
1747  FXSYS_assert(nStart > -1 && nStart < nSize);
1748  if (nCount < 0) nCount = nSize;
1749  if (nStart + nCount > nSize) nCount = nSize - nStart;
1750  if (nCount < 1) return 0;
1751  nSize = m_nSize;
1752  InsertSpaceAt(m_nSize, nCount);
1753  ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
1754  nSize = nStart + nCount;
1755  for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++)
1756  {
1757  #ifndef _FX_NOPLACEMENTNEW_
1758  new ((void*)pStartObj) ObjectClass(src[i]);
1759  #else
1760  ::new ((void*)pStartObj) ObjectClass(src[i]);
1761  #endif
1762 
1763  }
1764  return nCount;
1765  }
1766 
1777  FX_INT32 Copy(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
1778  {
1779  if (this == &src) return 0;
1780  RemoveAll();
1781  if (nCount == 0) return 0;
1782  FX_INT32 nSize = src.GetSize();
1783  if (!nSize) return 0;
1784  FXSYS_assert(nStart > -1 && nStart < nSize);
1785  if (nCount < 0) nCount = nSize;
1786  if (nStart + nCount > nSize) nCount = nSize - nStart;
1787  if (nCount < 1) return 0;
1788  nSize = nStart + nCount;
1789  SetSize(nCount, -1);
1790  ObjectClass* pStartObj = (ObjectClass*)m_pData;
1791  for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++)
1792  {
1793  #ifndef _FX_NOPLACEMENTNEW_
1794  new ((void*)pStartObj) ObjectClass(src[i]);
1795  #else
1796  ::new ((void*)pStartObj) ObjectClass(src[i]);
1797  #endif
1798 
1799  }
1800  return nCount;
1801  }
1802 
1808  int GetSize() const {return m_nSize;}
1809 
1818  ObjectClass& operator[] (int index) const
1819  {
1820  FXSYS_assert(index < m_nSize);
1821  return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
1822  }
1823 
1831  ObjectClass* GetDataPtr(int index) const {return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);}
1832 
1840  void RemoveAt(int index)
1841  {
1842  FXSYS_assert(index < m_nSize);
1843  ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
1844  CFX_BasicArray::RemoveAt(index, 1);
1845  }
1846 
1852  void RemoveAll()
1853  {
1854  for (int i = 0; i < m_nSize; i ++)
1855  ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
1856  CFX_BasicArray::SetSize(0, -1);
1857  }
1858 };
1859 
1864 
1868 template <class TYPE>
1869 class CFX_Stack : CFX_Object
1870 {
1871  public:
1874 
1880  FX_BOOL Empty() const
1881  {
1882  return m_Container.GetSize() == 0;
1883  }
1884 
1890  int Size() const
1891  {
1892  return m_Container.GetSize();
1893  }
1894 
1900  TYPE& Top()
1901  {
1902  return m_Container[Size() - 1];
1903  }
1904 
1910  void Pop()
1911  {
1912  m_Container.RemoveAt(Size() - 1);
1913  }
1914 
1922  void Push(const TYPE& val)
1923  {
1924  m_Container.Add(val);
1925  }
1926 
1932  void Clear()
1933  {
1934  m_Container.RemoveAll();
1935  }
1936  private:
1937  CFX_ArrayTemplate<TYPE> m_Container;
1938 };
1939 
1943 template <class TYPE>
1944 class CFX_ObjectStack : CFX_Object
1945 {
1946  public:
1949 
1955  FX_BOOL Empty() const
1956  {
1957  return m_Container.GetSize() == 0;
1958  }
1959 
1965  int Size() const
1966  {
1967  return m_Container.GetSize();
1968  }
1969 
1975  TYPE& Top()
1976  {
1977  return m_Container[Size() - 1];
1978  }
1979 
1985  void Pop()
1986  {
1987  m_Container.RemoveAt(Size() - 1);
1988  }
1989 
1997  void Push(const TYPE& val)
1998  {
1999  m_Container.Add(val);
2000  }
2001 
2002  private:
2003  CFX_ObjectArray<TYPE> m_Container;
2004 };
2005 
2009 template <>
2010 class CFX_Stack<CFX_ByteString> : CFX_Object
2011 {
2012  public:
2015 
2021  FX_BOOL Empty() const
2022  {
2023  return m_Container.GetSize() == 0;
2024  }
2025 
2031  int Size() const
2032  {
2033  return m_Container.GetSize();
2034  }
2035 
2042  {
2043  return m_Container[Size() - 1];
2044  }
2045 
2051  void Pop()
2052  {
2053  m_Container.RemoveAt(Size() - 1);
2054  }
2055 
2063  void Push(const CFX_ByteString& val)
2064  {
2065  m_Container.Add(val);
2066  }
2067 
2068  private:
2069  CFX_ObjectArray<CFX_ByteString> m_Container;
2070 };
2071 
2075 class CFX_BaseSegmentedArray : public CFX_Object
2076 {
2077  public:
2086  CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8, IFX_Allocator* pAllocator = NULL);
2087 
2092 
2102  void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
2103 
2109  void* Add();
2110 
2118  void* GetAt(int index) const;
2119 
2125  void RemoveAll();
2126 
2135  void Delete(int index, int count = 1);
2136 
2142  int GetSize() const { return m_DataSize; }
2143 
2149  int GetSegmentSize() const { return m_SegmentSize; }
2150 
2156  int GetUnitSize() const { return m_UnitSize; }
2157 
2166  void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const;
2167 
2170  private:
2171  /* Unit size */
2172  int m_UnitSize;
2173  /* Count of units in each segment. */
2174  short m_SegmentSize;
2175  /* Number of index level in the array. */
2176  FX_BYTE m_IndexSize;
2177  /* The current level in the index tree. */
2178  FX_BYTE m_IndexDepth;
2179  /* The current number of units in the array. */
2180  int m_DataSize;
2181  /* index to segments or indices, or directly pointing to the segment if only one segment. */
2182  void* m_pIndex;
2183 
2184  void** GetIndex(int seg_index) const;
2185  void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
2186  void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
2187 };
2188 
2192 template <class ElementType>
2194 {
2195  public:
2203  CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAllocator = NULL)
2204  : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size, pAllocator)
2205  {}
2206  //<<<+++OPENSOURCE_END
2207 
2215  void Add(ElementType data)
2216  {
2217  *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
2218  }
2219 
2227  ElementType& operator [] (int index)
2228  {
2229  return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
2230  }
2231 };
2232 
2236 template <class DataType, int FixedSize>
2237 class CFX_FixedBufGrow : public CFX_Object
2238 {
2239  public:
2247  : m_pAllocator(pAllocator)
2248  , m_pData(NULL)
2249  {
2250  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2251  }
2252 
2260  CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL)
2261  : m_pAllocator(pAllocator)
2262  , m_pData(NULL)
2263  {
2264  if (data_size > FixedSize)
2265  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
2266  else
2267  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2268  }
2269  //<<<+++OPENSOURCE_END
2270 
2278  void SetDataSize(int data_size) {
2279  if (m_pData)
2280  FX_Allocator_Free(m_pAllocator, m_pData);
2281  m_pData = NULL;
2282  if (data_size > FixedSize)
2283  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
2284  else {
2285  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2286  }
2287  }
2288 
2292  ~CFX_FixedBufGrow() { if (m_pData) FX_Allocator_Free(m_pAllocator, m_pData); }
2293 
2294  operator DataType*() { return m_pData ? m_pData : m_Data; }
2295 
2296  private:
2297  IFX_Allocator* m_pAllocator;
2298 
2299  DataType m_Data[FixedSize];
2300  DataType* m_pData;
2301 };
2302 
2306 template <class DataType>
2308 {
2309  public:
2317  CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllocator)
2318  {
2319  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size);
2320  }
2321 
2326  {
2327  if (m_pData) FX_Allocator_Free(m_pAllocator, m_pData);
2328  }
2329  //<<<+++OPENSOURCE_END
2330 
2331  DataType& operator[](int i) { FXSYS_assert(m_pData != NULL); return m_pData[i]; }
2332  operator DataType*() const { return m_pData; }
2333 
2334  private:
2335  IFX_Allocator* m_pAllocator;
2336 
2337  DataType* m_pData;
2338 };
2339 
2340 //*****************************************************************************
2341 //* Map
2342 //*****************************************************************************
2343 
2347 class CFX_MapPtrToPtr : public CFX_Object
2348 {
2349  protected:
2353  struct CAssoc
2354  {
2358  void* key;
2360  void* value;
2361  };
2362 
2363  public:
2371  CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
2372  //<<<+++OPENSOURCE_END
2373 
2377  ~CFX_MapPtrToPtr();
2378 
2384  int GetCount() const { return m_nCount; }
2385 
2391  FX_BOOL IsEmpty() const { return m_nCount == 0; }
2392 
2401  FX_BOOL Lookup(void* key, void*& rValue) const;
2402 
2410  void* GetValueAt(void* key) const;
2411 
2419  void*& operator[](void* key);
2420 
2429  void SetAt(void* key, void* newValue) { (*this)[key] = newValue; }
2430 
2438  FX_BOOL RemoveKey(void* key);
2439 
2445  void RemoveAll();
2446 
2452  FX_POSITION GetStartPosition() const { return (m_nCount == 0) ? NULL : (FX_POSITION)-1; }
2453 
2466  void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const;
2467 
2473  FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
2474 
2484  void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = true);
2485 
2486  protected:
2487  /* Special allocator pointer. NULL to use default allocator. */
2488  IFX_Allocator* m_pAllocator;
2489 
2490  /* The hash table. */
2491  CAssoc** m_pHashTable;
2492  /* The size of hash table. */
2493  FX_DWORD m_nHashTableSize;
2494  /* The number of key-value pair in the map. */
2495  int m_nCount;
2496  /* The freed association list internal. */
2497  CAssoc* m_pFreeList;
2498  /* The block list internal. */
2499  struct CFX_Plex* m_pBlocks;
2500  /* The size in associations of each block. */
2501  int m_nBlockSize;
2502 
2503  /*
2504  * Routine used to user-provided hash keys.
2505  *
2506  * @note Overwrite-able: special non-virtual (see map implementation for details).
2507  *
2508  * @param[in] key The key used to produce hash key.
2509  * @return A hash value.
2510  */
2511  FX_DWORD HashKey(void* key) const;
2512 
2513  /*
2514  * Allocate a new association.
2515  *
2516  * @return The pointer to the new allocated association.
2517  */
2518  CAssoc* NewAssoc();
2519  /*
2520  * Free an association.
2521  *
2522  * @param[in] pAssoc A pointer to an association.
2523  */
2524  void FreeAssoc(CAssoc* pAssoc);
2525  /*
2526  * @brief Retrieve an association by a key.
2527  *
2528  * @param[in] key The input key.
2529  * @param[out] hash The hash value computed.
2530  *
2531  * @return Current association object.
2532  */
2533  CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
2534  /*
2535  * @brief Retrieve current association by position.
2536  *
2537  * @param[in, out] rNextPosition Input a position, and receive the next association position.
2538  *
2539  * @return Current association object.
2540  */
2541  CAssoc* GetCurrentAssoc(FX_POSITION& rNextPosition) const;
2542  /*
2543  * @brief Expand 2 times HashTable Size than before.
2544  *
2545  * @details The MaxHashTableSize is 10000.
2546  *
2547  * @return <b>true</b> means success, while <b>false</b> means failure.
2548  */
2549  FX_BOOL ExpandHashTable();
2550  private:
2551  CFX_MapPtrToPtr(const CFX_MapPtrToPtr &) FX_EQDELETE;
2552  CFX_MapPtrToPtr &operator=(const CFX_MapPtrToPtr &) FX_EQDELETE;
2553 };
2554 
2558 template <class KeyType, class ValueType>
2560 {
2561  public:
2567  CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, pAllocator) {}
2568 
2577  FX_BOOL Lookup(KeyType key, ValueType& rValue) const
2578  {
2579  FX_LPVOID pValue = NULL;
2580  if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue))
2581  return false;
2582  rValue = (ValueType)(FX_UINTPTR)pValue;
2583  return true;
2584  }
2585 
2593  ValueType& operator[](KeyType key) { return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(FX_UINTPTR)key); }
2594 
2603  void SetAt(KeyType key, ValueType newValue) { CFX_MapPtrToPtr::SetAt((void*)(FX_UINTPTR)key, (void*)(FX_UINTPTR)newValue); }
2604 
2612  FX_BOOL RemoveKey(KeyType key) { return CFX_MapPtrToPtr::RemoveKey((void*)(FX_UINTPTR)key); }
2613 
2623  void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const
2624  {
2625  void* pKey = NULL; void* pValue = NULL;
2626  CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
2627  rKey = (KeyType)(FX_UINTPTR)pKey; rValue = (ValueType)(FX_UINTPTR)pValue;
2628  }
2629  private:
2630  CFX_MapPtrTemplate(const CFX_MapPtrTemplate &) FX_EQDELETE;
2631  CFX_MapPtrTemplate &operator=(const CFX_MapPtrTemplate &) FX_EQDELETE;
2632 };
2633 
2638 class CFX_CMapDWordToDWord : public CFX_Object
2639 {
2640  public:
2646  CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) {}
2647 
2656  FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
2657 
2666  void SetAt(FX_DWORD key, FX_DWORD value);
2667 
2676  void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
2677 
2683  FX_POSITION GetStartPosition() const;
2684 
2694  void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
2695 
2701  void RemoveAll() { m_Buffer.Clear(); }
2702 
2703  protected:
2706  private:
2707  CFX_CMapDWordToDWord(const CFX_CMapDWordToDWord &) FX_EQDELETE;
2708  CFX_CMapDWordToDWord &operator=(const CFX_CMapDWordToDWord &) FX_EQDELETE;
2709 };
2710 
2712 class CFX_MapByteStringToPtr : public CFX_Object
2713 {
2714  protected:
2718  struct CAssoc
2719  {
2722 
2728  void* value;
2729  };
2730 
2731  public:
2739  CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
2740 
2746  int GetCount() const { return m_nCount; }
2747 
2753  FX_BOOL IsEmpty() const { return m_nCount == 0; }
2754 
2763  FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
2764 
2772  void*& operator[](FX_BSTR key);
2773 
2782  void SetAt(FX_BSTR key, void* newValue) { (*this)[key] = newValue; }
2783 
2791  FX_BOOL RemoveKey(FX_BSTR key);
2792 
2798  void RemoveAll();
2799 
2805  FX_POSITION GetStartPosition() const { return (m_nCount == 0) ? NULL : (FX_POSITION)-1; }
2806 
2816  void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
2817 
2825  FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
2826 
2832  FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
2833 
2843  void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = true);
2844 
2854  FX_DWORD HashKey(FX_BSTR key) const;
2855 
2856  protected:
2857  /* Special allocator pointer. NULL to use default allocator. */
2858  IFX_Allocator* m_pAllocator;
2859 
2860  /* The hash table. */
2861  CAssoc** m_pHashTable;
2862  /* The size of hash table. */
2863  FX_DWORD m_nHashTableSize;
2864  /* The number of key-value pair in the map. */
2865  int m_nCount;
2866  /* The freed association list internal. */
2867  CAssoc* m_pFreeList;
2868  /* The block list internal. */
2869  struct CFX_Plex* m_pBlocks;
2870  /* The size in associations of each block. */
2871  int m_nBlockSize;
2872 
2873  /*
2874  * @brief Allocate a new association.
2875  *
2876  * @return The pointer to the new allocated association.
2877  */
2878  CAssoc* NewAssoc();
2879  /*
2880  * @brief Free an association.
2881  *
2882  * @param[in] pAssoc A pointer to an association.
2883  *
2884  * @return None.
2885  */
2886  void FreeAssoc(CAssoc* pAssoc);
2887  /*
2888  * @brief Retrieve an association by a key.
2889  *
2890  * @param[in] key The input key.
2891  * @param[out] hash The hash value computed.
2892  *
2893  * @return An association object.
2894  */
2895  CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const;
2896  /*
2897  * @brief Retrieve current association by position.
2898  *
2899  * @param[in] rNextPosition The current position.
2900  *
2901  * @return An association object.
2902  */
2903  CAssoc* GetCurrentAssoc(FX_POSITION& rNextPosition) const;
2904  /*
2905  * @brief Expand 2 times HashTable Size than before.
2906  *
2907  * @details The MaxHashTableSize is 10000.
2908  *
2909  * @return <b>true</b> means success, while <b>false</b> means failure.
2910  */
2911  FX_BOOL ExpendHashTable();
2912 
2913  public:
2916 };
2917 
2926 class CFX_CMapByteStringToPtr : public CFX_Object
2927 {
2928  public:
2935  //<<<+++OPENSOURCE_END
2936 
2939 
2945  void RemoveAll();
2946 
2952  FX_POSITION GetStartPosition() const;
2953 
2963  void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
2964 
2972  FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
2973 
2982  FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
2983 
2992  void SetAt(FX_BSTR key, void* value);
2993 
3001  void RemoveKey(FX_BSTR key);
3002 
3008  int GetCount() const;
3009 
3021  void AddValue(FX_BSTR key, void* pValue);
3022 
3023  protected:
3024  /* A chained buffer storing keys and values. */
3025  CFX_BaseSegmentedArray m_Buffer;
3026 };
3027 
3029 // Lists
3031 
3033 class CFX_PtrList : public CFX_Object
3034 {
3035  protected:
3037  struct CNode
3038  {
3044  void* data;
3045  };
3046 
3047  public:
3054  CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
3055  //<<<+++OPENSOURCE_END
3056 
3062  FX_POSITION GetHeadPosition() const { return (FX_POSITION)m_pNodeHead; }
3063 
3069  FX_POSITION GetTailPosition() const { return (FX_POSITION)m_pNodeTail; }
3070 
3078  void* GetNext(FX_POSITION& rPosition) const
3079  {
3080  CNode* pNode = (CNode*)rPosition; rPosition = (FX_POSITION)pNode->pNext; return pNode->data;
3081  }
3082 
3090  void* GetPrev(FX_POSITION& rPosition) const
3091  {
3092  CNode* pNode = (CNode*)rPosition; rPosition = (FX_POSITION)pNode->pPrev; return pNode->data;
3093  }
3094 
3102  FX_POSITION GetNextPosition(FX_POSITION pos) const { return ((CNode*)pos)->pNext; }
3103 
3111  FX_POSITION GetPrevPosition(FX_POSITION pos) const { return ((CNode*)pos)->pPrev; }
3112 
3120  void* GetAt(FX_POSITION rPosition) const
3121  {
3122  CNode* pNode = (CNode*)rPosition; return pNode ? pNode->data : NULL;
3123  }
3124 
3130  int GetCount() const { return m_nCount; }
3131 
3139  FX_POSITION AddTail(void* newElement);
3140 
3148  FX_POSITION AddHead(void* newElement);
3149 
3158  void SetAt(FX_POSITION pos, void* newElement)
3159  {
3160  CNode* pNode = (CNode*)pos; pNode->data = newElement;
3161  }
3162 
3171  FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
3172 
3181  FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const;
3182 
3190  FX_POSITION FindIndex(int index) const;
3191 
3199  void RemoveAt(FX_POSITION pos);
3200 
3206  void RemoveAll();
3207 
3208  protected:
3209  /* Special allocator pointer. <b>NULL</b> means to use default allocator. */
3210  IFX_Allocator* m_pAllocator;
3211 
3212  /* Pointer to the head. */
3213  CNode* m_pNodeHead;
3214  /* Pointer to the tail. */
3215  CNode* m_pNodeTail;
3216  /* The count of nodes in the list. */
3217  int m_nCount;
3218  /* The freed node list internal. */
3219  CNode* m_pNodeFree;
3220  /* The block list internal. */
3221  struct CFX_Plex* m_pBlocks;
3222  /* The size in nodes of each block. */
3223  int m_nBlockSize;
3224 
3225  /*
3226  * Allocate a new node.
3227  *
3228  * @param[in] pPrev The pointer to the previous node.
3229  * @param[in] pNext The pointer to the next node.
3230  *
3231  * @return The pointer to the new node.
3232  */
3233  CNode* NewNode(CNode* pPrev, CNode* pNext);
3234  /*
3235  * Free a node.
3236  *
3237  * @param[in] pNode The node pointer.
3238  */
3239  void FreeNode(CNode* pNode);
3240 
3241  public:
3243  ~CFX_PtrList();
3244 };
3245 
3246 //*****************************************************************************
3247 //* Utilities
3248 //*****************************************************************************
3249 
3253 typedef void (*PD_CALLBACK_FREEDATA)(FX_LPVOID pData);
3254 
3259 {
3265  void FreeData();
3266 
3269 
3272 
3275 
3281 };
3282 
3287 {
3288  public:
3294  CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {}
3295 
3297  ~CFX_PrivateData();
3298 
3304  void ClearAll();
3305 
3322  void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
3323 
3336  void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject* pObj);
3337 
3348  FX_LPVOID GetPrivateData(FX_LPVOID module_id);
3349 
3359  {
3360  if (!module_id) return false;
3361  FX_DWORD nCount = m_DataList.GetSize();
3362  for (FX_DWORD n = 0; n < nCount; n++) {
3363  if (m_DataList[n].m_pModuleId == module_id) {
3364  pData = m_DataList[n].m_pData;
3365  return true;
3366  }
3367  }
3368  return false;
3369  }
3370 
3380  FX_BOOL RemovePrivateData(FX_LPVOID module_id);
3381 
3382  protected:
3383  /* Private data array. */
3385  /*
3386  * Add a private data. Add if not exist, otherwise modify.
3387  *
3388  * @param[in] module_id The module id.
3389  * @param[in] pData The private data.
3390  * @param[in] callback The callback function for deallocating provided private data.
3391  * @param[in] bSelfDestruct Whether the private data is a CFX_DestructObject derived object actually.
3392  *
3393  * @return None.
3394  */
3395  void AddData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct);
3396 };
3397 
3402 class CFX_BitStream : public CFX_Object
3403 {
3404  public:
3413  void Init(FX_LPCBYTE pData, FX_DWORD dwSize);
3414 
3422  FX_DWORD GetBits(FX_DWORD nBits);
3423 
3429  void ByteAlign();
3430 
3436  FX_BOOL IsEOF() const { return m_BitPos >= m_BitSize; }
3437 
3445  void SkipBits(FX_DWORD nBits) { m_BitPos += nBits; }
3446 
3452  void Rewind() { m_BitPos = 0; }
3453 
3454  protected:
3455  /* Bit position (zero-based). */
3456  FX_DWORD m_BitPos;
3457  /* Total bit counts in the memory block. */
3458  FX_DWORD m_BitSize;
3459  /* bit-stream stream buffer. */
3460  FX_LPCBYTE m_pData;
3461 };
3462 
3466 class CFX_BitWriter : public CFX_Object
3467 {
3468  public:
3474  CFX_BitWriter(CFX_BinaryBuf* pBinBuf) :m_pBinBuf(pBinBuf), m_BitPos(0), m_BytePos(0) {}
3475 
3484  void WriteBits(FX_INT64 value, FX_INT32 nBits);
3485 
3491  void ByteAlign();
3492 
3498  int GetCurBytePos() { return m_BytePos; }
3499 
3500  protected:
3501  /* Dynamic binary buffer. */
3502  CFX_BinaryBuf * m_pBinBuf;
3503  /* Bit position (zero-based). */
3504  int m_BitPos;
3505  /* Byte position (zero-based). */
3506  int m_BytePos;
3507 };
3508 
3513 template <class ObjClass> class CFX_CountRef : public CFX_Object
3514 {
3515  public:
3518 
3522  class CountedObj : public ObjClass
3523  {
3524  public:
3527 
3533  CountedObj(const CountedObj& src) : ObjClass(src) ,m_RefCount(0){}
3534 
3537  };
3538 
3543  {
3544  m_pObject = NULL;
3545  }
3546 
3552  CFX_CountRef(const Ref& ref)
3553  {
3554  m_pObject = ref.m_pObject;
3555  if (m_pObject) m_pObject->m_RefCount ++;
3556  }
3557 
3562  {
3563  if (!m_pObject) return;
3564  m_pObject->m_RefCount --;
3565  if (m_pObject->m_RefCount <= 0) {
3566  delete m_pObject;
3567  m_pObject = NULL;
3568  }
3569  }
3570 
3577  ObjClass* New()
3578  {
3579  if (m_pObject) {
3580  m_pObject->m_RefCount --;
3581  if (m_pObject->m_RefCount <= 0)
3582  delete m_pObject;
3583  m_pObject = NULL;
3584  }
3585  m_pObject = FX_NEW CountedObj;
3586  if (!m_pObject) return NULL;
3587  m_pObject->m_RefCount = 1;
3588  return m_pObject;
3589  }
3590 
3598  void operator = (const Ref& ref)
3599  {
3600  if (ref.m_pObject)
3601  ref.m_pObject->m_RefCount ++;
3602  if (m_pObject) {
3603  m_pObject->m_RefCount --;
3604  if (m_pObject->m_RefCount <= 0)
3605  delete m_pObject;
3606  }
3607  m_pObject = ref.m_pObject;
3608  }
3609 
3617  void operator = (void* p)
3618  {
3619  FXSYS_assert(p == 0);
3620  if (m_pObject == NULL) return;
3621  m_pObject->m_RefCount --;
3622  if (m_pObject->m_RefCount <= 0)
3623  delete m_pObject;
3624  m_pObject = NULL;
3625  }
3626 
3627 #if defined(_FX_MANAGED_CODE_) && defined(GetObject)
3628  #undef GetObject
3629 #endif
3630 
3635  const ObjClass* GetObject() const
3636  {
3637  return m_pObject;
3638  }
3644  operator const ObjClass*() const
3645  {
3646  return m_pObject;
3647  }
3648 
3654  FX_BOOL IsNull() const
3655  {
3656  return m_pObject == NULL;
3657  }
3664  {
3665  return m_pObject != NULL;
3666  }
3667 
3676  ObjClass* GetModify()
3677  {
3678  if (m_pObject == NULL) {
3679  m_pObject = FX_NEW CountedObj;
3680  if (m_pObject)
3681  m_pObject->m_RefCount = 1;
3682  } else if (m_pObject->m_RefCount > 1) {
3683  m_pObject->m_RefCount --;
3684  CountedObj* pOldObject = m_pObject;
3685  m_pObject = NULL;
3686  m_pObject = FX_NEW CountedObj(*pOldObject);
3687  if (m_pObject)
3688  m_pObject->m_RefCount = 1;
3689  }
3690  return m_pObject;
3691  }
3692 
3698  void SetNull()
3699  {
3700  if (m_pObject == NULL) return;
3701  m_pObject->m_RefCount --;
3702  if (m_pObject->m_RefCount <= 0)
3703  delete m_pObject;
3704  m_pObject = NULL;
3705  }
3706 
3714  FX_BOOL operator == (const Ref& ref) const
3715  {
3716  return m_pObject == ref.m_pObject;
3717  }
3718 
3724  int RefCount() const
3725  {
3726  return m_pObject ? m_pObject->m_RefCount : 0;
3727  }
3728 
3734  void Incref()
3735  {
3736  if (m_pObject == NULL) return;
3737  m_pObject->m_RefCount++;
3738  }
3739 
3745  void Decref()
3746  {
3747  if (m_pObject == NULL) return;
3748  m_pObject->m_RefCount--;
3749  if (m_pObject->m_RefCount <= 0) {
3750  delete m_pObject;
3751  m_pObject = NULL;
3752  }
3753  }
3754 
3755  protected:
3756  /* Reference counted object internal. */
3757  CountedObj* m_pObject;
3758 };
3759 
3762 {
3763  public:
3765  virtual ~IFX_Pause() {}
3766 
3772  virtual FX_BOOL NeedToPauseNow() = 0;
3773 };
3774 
3776 class CFX_DataFilter : public CFX_Object
3777 {
3778  public:
3782  virtual ~CFX_DataFilter();
3783 
3791  void SetDestFilter(CFX_DataFilter* pFilter);
3792 
3798  FX_BOOL IsEOF() const { return m_bEOF; }
3799 
3805  FX_FILESIZE GetSrcPos() const { return m_SrcPos; }
3806 
3816  void FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf& dest_buf);
3817 
3826  void FilterFinish(CFX_BinaryBuf& dest_buf);
3827 
3833  FX_BOOL IsExhaustBuffer() const { return m_bExhaustBuffer; }
3834 
3840  FX_BOOL NeedNewSrc();
3841 
3847  FX_BOOL Abort() const { return m_bAbort; }
3848 
3854  FX_BOOL AbortAll();
3855 
3861  void ResetStatistics();
3862 
3863  protected:
3864  /* The constructor. */
3865  CFX_DataFilter();
3866 
3867  virtual void v_FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf& dest_buf) = 0;
3868  virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
3869  virtual void v_ResetStatistics() {};
3870  void ReportEOF(FX_FILESIZE left_input);
3871 
3872  /* Current position in the source stream. */
3873  FX_FILESIZE m_SrcPos;
3874 
3875  /* Store the output data of the FilterIn function.*/
3876  CFX_BinaryBuf m_FilterInBuffer;
3877 
3878  /* Indicate whether this filter aborts the filter process. For instance, RunLenFilter meets bad input data */
3879  FX_BOOL m_bAbort;
3880  /* Indicate whether we met the EOF. */
3881  FX_BOOL m_bEOF;
3882  /* Indicate whether this filter exhausts the input buffer. */
3883  FX_BOOL m_bExhaustBuffer;
3884  /* Filter chain. */
3885  CFX_DataFilter* m_pDestFilter;
3886 };
3887 
3889 template<typename T>
3891  public:
3897  explicit CFX_AutoRestorer(T* location) {
3898  m_Location = location;
3899  m_OldValue = *location;
3900  }
3901 
3903  ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
3904  private:
3905  T* m_Location;
3906  T m_OldValue;
3907 };
3908 
3910 template <class T>
3912 {
3913  public:
3919  CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
3920 
3922  ~CFX_SmartPointer() {m_pObj->Release();}
3923 
3929  T* Get(void) {return m_pObj;}
3930 
3936  T& operator *(void) {return *m_pObj;}
3937 
3943  T* operator ->(void) {return m_pObj;}
3944 
3945  protected:
3946  T *m_pObj;
3947 };
3948 
3949 #define FX_DATALIST_LENGTH 1024
3950 
3952 template<size_t unit>
3953 class CFX_SortListArray : public CFX_Object
3954 {
3955  protected:
3957  struct DataList {
3962  FX_LPBYTE data;
3963  DataList()
3964  {
3965  start = count = 0;
3966  data = NULL;
3967  }
3968  };
3969 
3970  public:
3976  CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLists(pAllocator) {}
3977 
3980  {
3981  Clear();
3982  }
3983 
3989  void Clear()
3990  {
3991  IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
3992 
3993  for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--){
3994  DataList list = m_DataLists.ElementAt(i);
3995  if (list.data) FX_Allocator_Free(pAllocator, list.data);
3996  }
3997  m_DataLists.RemoveAll();
3998  m_CurList = 0;
3999  }
4000 
4009  void Append(FX_INT32 nStart, FX_INT32 nCount)
4010  {
4011  if (nStart < 0) return;
4012 
4013  IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
4014 
4015  while (nCount > 0){
4016  FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
4017  DataList list;
4018 
4019  list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * unit);
4020  if (!list.data) break;
4021  FXSYS_memset32(list.data, 0, temp_count * unit);
4022  list.start = nStart;
4023  list.count = temp_count;
4024 
4025  FX_BOOL ret = Append(list);
4026  if(ret)
4027  {
4028  nCount -= temp_count;
4029  nStart += temp_count;
4030  }
4031  else
4032  {
4033  if (list.data) FX_Allocator_Free(pAllocator, list.data);
4034  return;
4035  }
4036  }
4037  }
4038 
4047  {
4048  if (nIndex < 0) return NULL;
4049  if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) return NULL;
4050  DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
4051  if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count){
4052  pCurList = NULL;
4053  FX_INT32 iStart = 0;
4054  FX_INT32 iEnd = m_DataLists.GetUpperBound();
4055  while (iStart <= iEnd){
4056  FX_INT32 iMid = (iStart + iEnd) / 2;
4057  DataList* list = m_DataLists.GetDataPtr(iMid);
4058  if (nIndex < list->start)
4059  iEnd = iMid - 1;
4060  else if (nIndex >= list->start + list->count)
4061  iStart = iMid + 1;
4062  else {
4063  pCurList = list;
4064  m_CurList = iMid;
4065  break;
4066  }
4067  }
4068  }
4069  return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
4070  }
4071 
4072  protected:
4073  FX_BOOL Append(const DataList& list)
4074  {
4075  FX_INT32 iStart = 0;
4076  FX_INT32 iEnd = m_DataLists.GetUpperBound();
4077  FX_INT32 iFind = 0;
4078  while (iStart <= iEnd) {
4079  FX_INT32 iMid = (iStart + iEnd) / 2;
4080  DataList* cur_list = m_DataLists.GetDataPtr(iMid);
4081  if (list.start == cur_list->start){
4082  return false; // lists overlap, no op
4083  } else if (list.start < cur_list->start + cur_list->count)
4084  iEnd = iMid - 1;
4085  else{
4086  if (iMid == iEnd){
4087  iFind = iMid + 1;
4088  break;
4089  }
4090  DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
4091  if (list.start == next_list->start){
4092  return false; // lists overlap, no op
4093  } else if (list.start < next_list->start){
4094  iFind = iMid + 1;
4095  break;
4096  } else {
4097  iStart = iMid + 1;
4098  }
4099  }
4100  }
4101  m_DataLists.InsertAt(iFind, list);
4102  return true;
4103  }
4104 
4105  FX_INT32 m_CurList;
4106  CFX_ArrayTemplate<DataList> m_DataLists;
4107 };
4108 
4110 template<typename T1, typename T2>
4111 class CFX_ListArrayTemplate : public CFX_Object
4112 {
4113  public:
4119  void Clear()
4120  {
4121  m_Data.Clear();
4122  }
4123 
4132  void Add(FX_INT32 nStart, FX_INT32 nCount)
4133  {
4134  m_Data.Append(nStart, nCount);
4135  }
4136 
4145  {
4146  FX_LPBYTE data = m_Data.GetAt(nIndex);
4147  FXSYS_assert(data != NULL);
4148 
4149  return (T2&)(*(volatile T2*)data);
4150  }
4151 
4159  T2* GetPtrAt(FX_INT32 nIndex)
4160  {
4161  return (T2*)m_Data.GetAt(nIndex);
4162  }
4163  protected:
4164  T1 m_Data;
4165 };
4166 
4171 
4177 typedef enum {
4191 
4192 #define ProgressiveStatus FX_ProgressiveStatus
4193 
4194 #ifdef _FX_NO_NAMESPACE_
4195 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT
4196 #define FX_NAMESPACE_DECLARE(namespace, type) type
4197 //<<<+++OPENSOURCE_END
4198 #else
4199 //<<<+++OPENSOURCE_BEGIN LIC==GOOGLE
4200 #define FX_NAMESPACE_DECLARE(namespace, type) namespace::type
4201 //<<<+++OPENSOURCE_END
4202 #endif
4203 
4206 {
4207  public:
4213  virtual FX_DWORD Release() = 0;
4214 
4220  virtual FX_DWORD AddRef() = 0;
4221 
4222  protected:
4223  virtual ~IFX_Unknown() {}
4224 };
4225 
4227 #define FX_IsOdd(a) ((a) & 1)
4228 
4229 //<<<+++OPENSOURCE_MUST_END
4230 
4231 //<<<+++OPENSOURCE_MUST_BEGIN
4232 #endif // _FX_BASIC_H_
4233 //<<<+++OPENSOURCE_MUST_END
4234 
4237 //<<<+++OPENSOURCE_END
Definition: fx_basic.h:3776
void GetNextAssoc(FX_POSITION &rNextPosition, CFX_ByteString &rKey, void *&rValue) const
Get the current association and set the position to next association.
void SetAt(FX_BSTR key, void *newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2782
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:3286
CFX_WideTextBuf & operator<<(int i)
Left shifts(<<) operator overload. Output a integer to the wide text buffer.
CNode * pNext
Pointer to next node.
Definition: fx_basic.h:3040
CFX_WideStringC GetResult() const
Get the result.
Definition: fx_basic.h:1060
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:645
void RemoveAll()
Remove all the (key, value) pairs in the map.
Dynamic binary buffers designed for more efficient appending.
Definition: fx_basic.h:52
Definition: fx_basic.h:2075
Definition: fx_basic.h:4205
Ready.
Definition: fx_basic.h:4179
~CFX_MapByteStringToPtr()
The destructor.
T2 & operator [](FX_INT32 nIndex)
Subscript([]) operator overload.
Definition: fx_basic.h:4144
void Add(const ObjectClass &data)
Add a copy of an existing object to the array.
Definition: fx_basic.h:1694
Header file for Streams related definitions and classes.
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:721
Bidirectional node in CFX_PtrList.
Definition: fx_basic.h:3037
FX_LPVOID m_pModuleId
Module ID.
Definition: fx_basic.h:3268
CFX_ByteStringC GetResult() const
Get the result.
Definition: fx_basic.h:1116
TYPE & operator[](int nIndex)
Subscript([]) operator overload. This function returns a reference to the specified element specified...
Definition: fx_basic.h:1558
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:715
Definition: fx_basic.h:1083
FX_BOOL RemovePrivateData(FX_LPVOID module_id)
Remove previously stored private data. FPDFAPI assumes the module has deallocated the data,...
FX_BOOL AppendChar(FX_WCHAR wch)
Append a single wide character.
int Size() const
Get size of the container.
Definition: fx_basic.h:2031
FX_BOOL IsEmpty() const
Verify whether the map is empty.
Definition: fx_basic.h:2391
FX_POSITION InsertAfter(FX_POSITION pos, void *newElement)
Insert a value after specified position.
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1205
Not Found.
Definition: fx_basic.h:4185
Association in CFX_MapByteStringToPtr.
Definition: fx_basic.h:2718
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL to use default allocator.
Definition: fx_basic.h:1180
void Incref()
Increase the reference.
Definition: fx_basic.h:3734
void Delete(int index, int count=1)
Delete a number of elements.
Definition: fx_basic.h:1869
~CFX_ObjectArray()
The destructor.
Definition: fx_basic.h:1658
void GetNextAssoc(FX_POSITION &rNextPosition, void *&rKey, void *&rValue) const
Get the current association and set the position to next association.
#define FX_Allocator_Alloc(fxAllocator, type, size)
Release-mode allocation on an allocator.
Definition: fx_memory.h:1087
FX_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:227
CFX_ArrayTemplate< FX_DWORD > CFX_DWordArray
Type definition for a double-word array type.
Definition: fx_basic.h:1624
TYPE & ElementAt(int nIndex)
This method retrieves a ref to an element specified by an index number.
Definition: fx_basic.h:1425
CFX_ObjectArray(const CFX_ObjectArray &other, IFX_Allocator *pAllocator=0)
The copy constructor.
Definition: fx_basic.h:1666
void AddValue(FX_BSTR key, void *pValue)
Add a key-value pair to the dictionary, assuming there is no duplicated key existing.
T2 * GetPtrAt(FX_INT32 nIndex)
Get a point to data.
Definition: fx_basic.h:4159
void Push(const CFX_ByteString &val)
Push the byte string to stack.
Definition: fx_basic.h:2063
CFX_ArrayTemplate< FX_WORD > CFX_WordArray
Type definition for a word array type.
Definition: fx_basic.h:1622
void RemoveAll()
Remove all nodes in the list.
int GetCount() const
Get the number of key-value pairs.
CFX_ByteTextBuf & operator<<(int i)
Left shifts(<<) operator overload. Output an integer to the byte text buffer.
FX_BOOL IsNull() const
Check if the pointer of the object is NULL.
Definition: fx_basic.h:3654
ElementType & operator [](int index)
Subscript([]) operator overload. This function returns a ref to the specified element specified by th...
Definition: fx_basic.h:2227
CFX_FixedBufGrow(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2246
void * data
Node data.
Definition: fx_basic.h:3044
void SetAt(FX_DWORD key, FX_DWORD value)
Add a new (key, value) pair. Add if not exist, otherwise modify.
static CFX_CharMap * GetDefaultMapper(FX_INT32 codepage=0)
Get a character mapper according to Windows code page or other encoding system. This char maps are ma...
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:1955
void Init(FX_LPCBYTE pData, FX_DWORD dwSize)
Initialize the bit-stream with a memory block. Must call Init() first.
CFX_ByteString key
Key data.
Definition: fx_basic.h:2726
void SetAt(KeyType key, ValueType newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2603
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:2805
FX_INT32(* m_GetCodePage)()
A pointer type to GetCodePage function. The function return a code page of the platform.
Definition: fx_basic.h:1002
void GetByteStringL(CFX_ByteStringL &str) const
Get a byte string from current buffer object.
CFX_BinaryBuf(IFX_Allocator *pAllocator=0)
A default constructor creating an empty buffer.
void SetAt(void *key, void *newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2429
void(* PD_CALLBACK_FREEDATA)(FX_LPVOID pData)
Definition: fx_basic.h:3253
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:725
CFX_ObjectArray & operator=(const CFX_ObjectArray &other)
The assignment operator.
Definition: fx_basic.h:1679
FX_BOOL m_bSelfDestruct
A boolean value to decide whether it is using self destruct for private data. If this is true,...
Definition: fx_basic.h:3280
void * Add()
Add an element.
#define GetObject
Get object information. GetObjectW defined for unicode-mode, GetObjectA for ansi-mode.
Definition: fx_system.h:546
FX_LPVOID m_pData
Private data.
Definition: fx_basic.h:3271
CFX_WideTextBuf(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:354
FX_BOOL Flush()
Flush internal buffer of the file.
void FilterFinish(CFX_BinaryBuf &dest_buf)
Indicate the input finished. For some filters, there might be some last output generated.
FX_INT32 start
The start index.
Definition: fx_basic.h:3959
CFX_Stack()
Construct.
Definition: fx_basic.h:2014
~CFX_CountRef()
Destruct a reference and release the object it refers to.
Definition: fx_basic.h:3561
void RemoveAt(int index)
Remove an object at specified position.
Definition: fx_basic.h:1840
int GetSize() const
Get number of elements in the array.
Definition: fx_basic.h:2142
int GetCurBytePos()
Get current byte position.
Definition: fx_basic.h:3498
CFX_PtrList(int nBlockSize=10, IFX_Allocator *pAllocator=0)
Construct with block size and allocator.
void Clear()
Clear the decoding status and set the output wide text buffer to be empty.
virtual ~CFX_DataFilter()
The destructor. Destroy this filter and all its chain.
void ByteAlign()
Get to byte boundary. If current bit position is not multiplication of 8, the rest of the current byt...
void SetUnitSize(int unit_size, int segment_units, int index_size=8)
Change the unit size and the segment units. This can only be called when array is empty.
void FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf &dest_buf)
Input a data block to the filter (and its filter chain), and receive the final output.
void ClearAll()
Release all remaining data.
int GetSize() const
Get the number of elements in the array.
Definition: fx_basic.h:1360
FX_BOOL Flush()
Flush internal buffer.
FX_BOOL EstimateSize(FX_STRSIZE size, FX_STRSIZE alloc_step=0)
Change the allocated buffer size, and set the allocation step if alloc_step is non-zero.
FX_POSITION GetNextPosition(FX_POSITION pos) const
Get the next position.
Definition: fx_basic.h:3102
T & operator *(void)
Get the object reference operator.
Definition: fx_basic.h:3936
Definition: fx_basic.h:774
FX_LPVOID GetPrivateData(FX_LPVOID module_id)
Get previously stored private data. Returns NULL for not stored.
FX_INT32 Copy(const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
Copy from an array.
Definition: fx_basic.h:1777
Definition: fx_basic.h:2193
CFX_UTF8Encoder(IFX_Allocator *pAllocator=0)
A constructor. Set the encoder to initial.
Definition: fx_basic.h:1091
void SetStream(IFX_FileStream *pStream)
Set the attached stream.
Definition: fx_basic.h:639
void operator=(FX_LPCWSTR lpsz)
Assignment(=) operator overload. From a zero terminated wide character string.
CFX_TempBuf(int size, IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2317
#define FX_MIN(a, b)
A macro that returns the minimum of a and b.
Definition: fx_system.h:814
FX_BOOL Abort() const
Indicate whether to abort the filter process.
Definition: fx_basic.h:3847
FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover=false)
Attach file.
void GetResult(CFX_ByteStringL &result) const
Get the result.
Definition: fx_basic.h:1125
CFX_CMapDWordToDWord(IFX_Allocator *pAllocator=0)
Constructor with allocator.
Definition: fx_basic.h:2646
int GetUnitSize() const
Get number of bytes for each element.
Definition: fx_basic.h:2156
Definition: fx_basic.h:1944
WIDE STRING CLASS.
Definition: fx_string.h:1452
FX_BOOL AppendFill(FX_BYTE byte, FX_STRSIZE count)
Append a byte for specified number times. Not a byte-by-byte processing, but a byte filling processin...
CFX_UTF8Decoder(IFX_Allocator *pAllocator=0)
A constructor. Set the decoder to initial.
Definition: fx_basic.h:1021
CFX_CountRef< ObjClass > Ref
Type definition: it is used short for CFX_CountRef<ObjClass>.
Definition: fx_basic.h:3517
CFX_ObjectArray(IFX_Allocator *pAllocator=0)
The constructor.
Definition: fx_basic.h:1653
Stream writing interface.
Definition: fx_stream.h:424
CFX_Stack()
Construct.
Definition: fx_basic.h:1873
virtual FX_DWORD AddRef()=0
Increments reference count.
CFX_MapByteStringToPtr(int nBlockSize=10, IFX_Allocator *pAllocator=0)
Construct with specified block size.
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:649
CFX_PrivateData(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:3294
virtual FX_DWORD Release()=0
Decrements reference count and release the current object.
int GetSegmentSize() const
Get number of elements in each segment.
Definition: fx_basic.h:2149
void Input(FX_WCHAR unicode)
Input a unicode.
FX_INTPTR GetLength() const
Get the length of saved data.
Definition: fx_basic.h:623
Memory allocation error.
Definition: fx_basic.h:1310
FX_LPCBYTE GetBuffer() const
Get the constant byte pointer to the saved data.
Definition: fx_basic.h:630
FX_BOOL Read(void *pBuf, FX_DWORD dwSize)
De-serialize a memory block.
virtual FX_BOOL NeedToPauseNow()=0
Check whether callers need to pause now.
void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow=true)
Initialize the hash table.
ObjectClass & operator[](int index) const
Subscript([]) operator overload. This function returns a reference to the specified object specified ...
Definition: fx_basic.h:1818
FX_BOOL Copy(const CFX_ArrayTemplate &src)
Copy from an array.
Definition: fx_basic.h:1498
FX_BOOL SetSize(int nNewSize, int nGrowBy=-1)
Change the allocated size and the grow amount.
Definition: fx_basic.h:1377
FX_LPCBYTE GetPtr() const
Get a constant byte string pointer to the byte string.
Definition: fx_string.h:215
void Clear()
Set the binary buffer to be empty.
void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject *pObj)
Set private object.
Definition: fx_basic.h:345
void Clear()
Remove all remaining data from stack.
Definition: fx_basic.h:1932
FX_DWORD HashKey(FX_BSTR key) const
Routine used to user-provided hash keys.
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL means to use default allocator.
Definition: fx_basic.h:229
__int64 FX_INT64
Signed 64-bit integer.
Definition: fx_system.h:729
int m_RefCount
The reference count.
Definition: fx_basic.h:3536
Definition: fx_basic.h:3911
CFX_FileBufferArchive(FX_STRSIZE size=32768, IFX_Allocator *pAllocator=0)
A constructor with size and allocator.
Header file for Strings, variable-length sequence of characters. There are two strings here,...
void * value
Value data.
Definition: fx_basic.h:2360
CFX_MapPtrToPtr(int nBlockSize=10, IFX_Allocator *pAllocator=0)
Construct with specified block size.
FX_INT64 GetSrcPos() const
Get current position in the source stream (byte offset from the beginning of all input data).
Definition: fx_basic.h:3805
FX_BOOL Append(const CFX_ArrayTemplate &src)
Append an array.
Definition: fx_basic.h:1489
FX_BOOL RemoveKey(KeyType key)
Remove existing (key, ?) pair.
Definition: fx_basic.h:2612
T * operator ->(void)
Get the object pointer operator.
Definition: fx_basic.h:3943
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:674
FX_BOOL Lookup(KeyType key, ValueType &rValue) const
Lookup by a key.
Definition: fx_basic.h:2577
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
CFX_CountRef()
Construct a null reference.
Definition: fx_basic.h:3542
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
void RemoveAll()
Clean up the array.
Definition: fx_basic.h:1387
FX_POSITION GetHeadPosition() const
Get the header position.
Definition: fx_basic.h:3062
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
FX_BOOL Add(TYPE newElement)
Add an element at the tail. Potentially growing the array.
Definition: fx_basic.h:1472
CFX_ArrayTemplate< FX_INT32 > CFX_Int32Array
Type definition for INT32 array.
Definition: fx_basic.h:1632
Definition: fx_basic.h:2926
Definition: fx_basic.h:251
FX_BOOL IsEOF()
Check whether de-serializing is to the end of the loading buffer.
CFX_ByteTextBuf(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:260
Association in CFX_MapPtrToPtr.
Definition: fx_basic.h:2353
int GetCount() const
Get the number of elements.
Definition: fx_basic.h:2746
~CFX_PrivateData()
The destructor.
~CFX_BinaryBuf()
The destructor.
void * Iterate(FX_BOOL(*callback)(void *param, void *pData), void *param) const
Iterate all units, with a callback function for each unit.
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:682
ErrorType
Enumeration for error type.
Definition: fx_basic.h:1305
void RemoveAll()
Remove all (key, value) pair.
Definition: fx_basic.h:2701
virtual void Clear()
Clear the text buffer.
~CFX_TempBuf()
The Destructor.
Definition: fx_basic.h:2325
Definition: fx_basic.h:3953
void SetDestFilter(CFX_DataFilter *pFilter)
Set destination filter. Note the filter will be appended to the end of current filter chain.
Definition: fx_basic.h:4111
void ByteAlign()
Get to byte boundary. If current bit position is not multiplication of 8, the rest of the current byt...
CFX_ArchiveSaver & operator<<(FX_BYTE i)
Left shifts(<<) operator overload. Serialize a single byte.
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:696
void AppendChar(FX_DWORD ch)
Append characters to wide text buffer.
Definition: fx_basic.h:3033
FX_INT32 Append(const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
Append an array.
Definition: fx_basic.h:1742
FX_INT32 count
The data count.
Definition: fx_basic.h:3961
T * Get(void)
Get the object pointer.
Definition: fx_basic.h:3929
CFX_WideString FX_DecodeURI(const CFX_ByteString &bsURI)
A simple URI Decode.
CFX_WideString(* m_GetWideString)(CFX_CharMap *pMap, const CFX_ByteString &bstr)
A pointer type to GetWideString function.
Definition: fx_basic.h:982
The data list.
Definition: fx_basic.h:3957
void GetNextAssoc(FX_POSITION &rNextPosition, KeyType &rKey, ValueType &rValue) const
Get the current association and set the position to next association.
Definition: fx_basic.h:2623
FX_BOOL IsExhaustBuffer() const
Indicate whether this filter exhausts the input buffer.
Definition: fx_basic.h:3833
FX_LPBYTE GetAt(FX_INT32 nIndex)
Get the data.
Definition: fx_basic.h:4046
File stream interface, reading & writing.
Definition: fx_stream.h:669
FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
Set an element value at specified position. Potentially growing the array.
Definition: fx_basic.h:1456
Found.
Definition: fx_basic.h:4183
void AppendStr(FX_BSTR str)
Append a non-buffered byte string.
Definition: fx_basic.h:1109
CFX_ObjectStack()
Construct.
Definition: fx_basic.h:1948
FX_INT32 AppendBlock(const void *pBuf, size_t size)
Append a binary buffer block.
void GetResult(CFX_WideStringL &result) const
Get the result.
Definition: fx_basic.h:1069
CFX_ArrayTemplate< FX_INT64 > CFX_FileSizeArray
Type definition for file size array type.
Definition: fx_basic.h:1628
UINT_PTR FX_UINTPTR
Unsigned integral type for pointer precision.
Definition: fx_system.h:741
TYPE * InsertSpaceAt(int nIndex, int nCount)
Insert a number of elements.
Definition: fx_basic.h:1524
void RemoveAt(FX_POSITION pos)
Remove a node at specified position.
FX_BOOL RemoveKey(FX_BSTR key)
Remove existing key.
int RefCount() const
Get the reference count.
Definition: fx_basic.h:3724
FX_BOOL RemoveAt(int nIndex, int nCount=1)
Remove a number of elements at specified position.
Definition: fx_basic.h:1591
Definition: fx_basic.h:3761
void Rewind()
Rewind a bit-stream. Simply set the current bit position to be zero.
Definition: fx_basic.h:3452
FX_DWORD GetHashTableSize() const
Get the internal hash table size. Advanced features for derived classes.
Definition: fx_basic.h:2832
CFX_ObjectArray< CFX_WideString > CFX_WideStringArray
Type definition for a CFX_WideString array type.
Definition: fx_basic.h:1863
void *& operator[](void *key)
Subscript([]) operator overload. Lookup and add if not there.
void AttachData(void *pBuf, FX_STRSIZE size)
Attach to a buffer (this buffer will belong to this object). The buffer must be allocated by FX_Alloc...
void operator=(const Ref &ref)
Assignment(=) operator overload. Assign from another reference.
Definition: fx_basic.h:3598
void * GetNext(FX_POSITION &rPosition) const
Get the the current value and set the position to next node.
Definition: fx_basic.h:3078
FX_DWORD nHashValue
Cached hash value, needed for efficient iteration.
Definition: fx_basic.h:2724
void DetachBuffer()
Detach the buffer. Just set buffer pointer to NULL, and set the binary buffer size to zero.
void * GetPrev(FX_POSITION &rPosition) const
Get the the current value and set the position to previous node.
Definition: fx_basic.h:3090
CFX_ArrayTemplate(const CFX_ArrayTemplate &other, IFX_Allocator *pAllocator=0)
The copy constructor.
Definition: fx_basic.h:1330
void * AddSpace()
Add an empty space to the array.
Definition: fx_basic.h:1727
TYPE & Top()
Get the top byte string.
Definition: fx_basic.h:1975
FX_POSITION AddTail(void *newElement)
Add a value to the tail.
void Write(const void *pData, FX_STRSIZE dwSize)
Serialize a memory block.
CFX_SmartPointer(T *pObj)
The constructor.
Definition: fx_basic.h:3919
Definition: fx_basic.h:3513
void ResetStatistics()
Reset statistics.
Definition: fx_basic.h:1297
const TYPE GetAt(int nIndex) const
This method retrieves an element specified by an index number.
Definition: fx_basic.h:1396
ObjectClass & Add()
Add an empty object to the array.
Definition: fx_basic.h:1711
CFX_ArrayTemplate(IFX_Allocator *pAllocator=0)
Constructor, from an allocator.
Definition: fx_basic.h:1321
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:658
FX_BOOL AppendByte(FX_BYTE byte)
Append a single byte.
Definition: fx_basic.h:128
FX_POSITION Find(void *searchValue, FX_POSITION startAfter=0) const
Find a value starting after specified position.
CFX_ByteString FX_EncodeURI(const CFX_WideString &wsURI)
A simple URI encode.
void Append(FX_INT32 nStart, FX_INT32 nCount)
Append a list data.
Definition: fx_basic.h:4009
void EstimateSize(FX_DWORD size, FX_DWORD grow_by)
Change internal allocation size and grow amount.
CountedObj(const CountedObj &src)
The copy constructor.
Definition: fx_basic.h:3533
FX_BOOL Lookup(FX_DWORD key, FX_DWORD &value) const
Lookup by a key.
FX_BOOL AppendBlock(const void *pBuf, FX_STRSIZE size)
Append a binary buffer block.
const TYPE * GetData() const
Direct Access to the element data (may return NULL).
Definition: fx_basic.h:1439
CFX_ArrayTemplate & operator=(const CFX_ArrayTemplate &src)
Assignment operator overload.
Definition: fx_basic.h:1533
void FreeData()
Free the private data pointed by m_pData.
const TYPE operator[](int nIndex) const
Subscript([]) operator overload. It retrieves a element specified by the zero-based index in nIndex.
Definition: fx_basic.h:1542
CFX_ArrayTemplate< FX_BYTE > CFX_ByteArray
Type definition for a byte array type.
Definition: fx_basic.h:1620
Foxit allocator interface.
Definition: fx_memory.h:997
void AppendChar(int ch)
Append a single character or byte.
Definition: fx_basic.h:278
void SkipBits(FX_DWORD nBits)
Skip a number of bits.
Definition: fx_basic.h:3445
CFX_SegmentedArray(int segment_units, int index_size=8, IFX_Allocator *pAllocator=0)
Construct with specified segment units.
Definition: fx_basic.h:2203
CNode * pPrev
Pointer to previous node.
Definition: fx_basic.h:3042
void Pop()
Pop the byte string from stack.
Definition: fx_basic.h:2051
Definition: fx_basic.h:956
void RemoveAll()
Remove all key-value pairs in the map.
Invalid array size.
Definition: fx_basic.h:1307
FX_STRSIZE GetLength() const
Get the length of the wide text buffer.
Definition: fx_basic.h:442
void Add(ElementType data)
Add an element.
Definition: fx_basic.h:2215
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:676
FX_BOOL IsEmpty() const
Verify whether the map is empty.
Definition: fx_basic.h:2753
FX_POSITION FindIndex(int index) const
Find a value by index number.
CFX_CountRef(const Ref &ref)
Copy constructor from another reference.
Definition: fx_basic.h:3552
#define FXSYS_assert
Assertion.
Definition: fx_system.h:792
TYPE * AddSpace()
Add an element's space.
Definition: fx_basic.h:1514
CAssoc * pNext
Pointer to next association.
Definition: fx_basic.h:2721
TYPE * GetDataPtr(int index)
Get a pointer to the specified element in the array. Direct pointer access.
Definition: fx_basic.h:1507
FX_INT32 AppendByte(FX_BYTE byte)
Append a single byte.
int GetCount() const
Get the number of elements.
Definition: fx_basic.h:2384
void SetAt(FX_POSITION pos, void *newElement)
Change the value at specified position.
Definition: fx_basic.h:3158
FX_POSITION AddHead(void *newElement)
Add a value to the head.
CFX_ArchiveSaver(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:494
virtual void Clear()
Clear buffer.
void WriteBits(FX_INT64 value, FX_INT32 nBits)
Write a value of bits.
void Delete(int start_index, int count)
Delete a inter-zone buffer defining by parameters start_index and count in the wide text buffer.
Definition: fx_basic.h:459
FX_BOOL SetAt(int nIndex, TYPE newElement)
This method overwrites an element specified by an index number.
Definition: fx_basic.h:1412
int GetSize() const
Get the size of the array.
Definition: fx_basic.h:1808
CFX_ByteString & Top()
Get the top byte string.
Definition: fx_basic.h:2041
FX_BOOL InsertBlock(FX_STRSIZE pos, const void *pBuf, FX_STRSIZE size)
Insert a binary buffer block at the specified position.
void * GetAt(FX_POSITION rPosition) const
Get an value at specified position.
Definition: fx_basic.h:3120
FX_POSITION GetTailPosition() const
Get the tail position.
Definition: fx_basic.h:3069
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:1880
~CFX_AutoRestorer()
The destructor.
Definition: fx_basic.h:3903
~CFX_BaseSegmentedArray()
The destructor.
CFX_MapPtrTemplate(IFX_Allocator *pAllocator=0)
Default constructor.
Definition: fx_basic.h:2567
Definition: fx_basic.h:1011
FX_STRSIZE GetLength() const
Get the length of the byte text buffer.
Definition: fx_basic.h:339
Definition: fx_basic.h:2559
void AppendString(FX_BSTR str)
Append a non-buffered byte string.
Definition: fx_basic.h:119
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:2021
Definition: fx_basic.h:3258
Definition: fx_basic.h:2307
FX_LPVOID GetNextValue(FX_POSITION &rNextPosition) const
Get the the current value and set the position to next association.
Definition: fx_basic.h:651
void GetNextAssoc(FX_POSITION &rNextPosition, CFX_ByteString &rKey, void *&rValue) const
Get the current association and set the position to next association.
CFX_SortListArray(IFX_Allocator *pAllocator=0)
The constructor.
Definition: fx_basic.h:3976
CFX_BinaryBuf m_Buffer
Definition: fx_basic.h:2705
Failed.
Definition: fx_basic.h:4187
void * key
Key data.
Definition: fx_basic.h:2358
FX_LPWSTR GetBuffer() const
Get a wide character pointer.
Definition: fx_basic.h:449
~CFX_FixedBufGrow()
The Destructor.
Definition: fx_basic.h:2292
Done.
Definition: fx_basic.h:4189
void FX_Error(ErrorType error, FX_INT32 badIndex=0) const
The function is called when raise a fatal error.Print error info an exit(1).
Definition: fx_basic.h:1341
CFX_FixedBufGrow(int data_size, IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2260
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
TYPE * GetData()
Direct Access to the element data (may return NULL).
Definition: fx_basic.h:1446
Definition: fx_basic.h:1645
CFX_ObjectArray< CFX_ByteString > CFX_ByteStringArray
Type definition for a CFX_ByteString array type.
Definition: fx_basic.h:1861
FX_BOOL LookupPrivateData(FX_LPVOID module_id, FX_LPVOID &pData) const
Lookup a private data.
Definition: fx_basic.h:3358
~CFX_SmartPointer()
The destructor.
Definition: fx_basic.h:3922
ObjClass * New()
Create a new object and refer to it. The returned pointer to the object can be used to modify the con...
Definition: fx_basic.h:3577
Define a class here derived from user data class, with an additional reference count member.
Definition: fx_basic.h:3522
CFX_ArrayTemplate< FX_FLOAT > CFX_FloatArray
Type definition for float array.
Definition: fx_basic.h:1630
void ClearStatus()
Clear the decoding status.
Definition: fx_basic.h:1053
~CFX_SortListArray()
The destructor.
Definition: fx_basic.h:3979
IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator *pAllocator=0)
Construct with buffer size and special allocator.
FX_DWORD GetHashTableSize() const
Get the internal hash table size. Advanced features for derived classes.
Definition: fx_basic.h:2473
void *& operator[](FX_BSTR key)
Subscript([]) operator overload. Lookup and add if not there.
FX_BOOL NotNull() const
Check if the pointer of the object is not NULL.
Definition: fx_basic.h:3663
TYPE & Top()
Get the top byte data.
Definition: fx_basic.h:1900
FX_BOOL RemoveKey(void *key)
Removing existing (key, ?) pair.
FX_INT32 AppendDWord(FX_DWORD i)
Append a FX_DWORD value.
FX_BOOL Lookup(FX_BSTR key, void *&rValue) const
Lookup by a key.
void SetAt(FX_BSTR key, void *value)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2237
CFX_BitWriter(CFX_BinaryBuf *pBinBuf)
A constructor with bits write.
Definition: fx_basic.h:3474
FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray *pNewArray)
Inset an array at specified position.
Definition: fx_basic.h:1601
~CFX_FileBufferArchive()
The destructor.
void Clear()
Clear data.
Definition: fx_basic.h:4119
void Delete(int start_index, int count)
Delete a inter-zone buffer defining by parameters start_index and count in the binary buffer.
To be continued.
Definition: fx_basic.h:4181
CFX_WideString FX_UrlDecode(const CFX_ByteString &bsUrl)
A simple URL decode.
FX_DWORD GetBits(FX_DWORD nBits)
Get specified number of bits (maximum 32 bits).
ValueType & operator[](KeyType key)
Subscript([]) operator overload. Lookup and add if not there.
Definition: fx_basic.h:2593
BYTE STRING CLASS.
Definition: fx_string.h:317
FX_BOOL Lookup(FX_BSTR key, void *&rValue) const
Lookup by a key.
void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback)
Set private data.
void operator=(FX_BSTR str)
Assignment(=) operator overload. From a non-buffered byte string.
CFX_CMapByteStringToPtr(IFX_Allocator *pAllocator=0)
The constructor.
virtual ~IFX_BufferArchive()
The destructor.
Definition: fx_basic.h:790
Definition: fx_basic.h:1176
FX_BOOL CopyData(const void *pBuf, FX_STRSIZE size)
Copy from another buffer.
CFX_AutoRestorer(T *location)
The constructor.
Definition: fx_basic.h:3897
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:660
FX_LPBYTE GetBuffer() const
Get a byte pointer to the binary buffer.
Definition: fx_basic.h:196
Header file for Memory management related definitions and classes.
void SetDataSize(int data_size)
Construct with allocator.
Definition: fx_basic.h:2278
FX_BOOL Lookup(void *key, void *&rValue) const
Lookup by a key.
FX_ProgressiveStatus
Enumeration for progressive status.
Definition: fx_basic.h:4177
void Pop()
Pop the data from stack.
Definition: fx_basic.h:1910
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:723
FX_BOOL NeedNewSrc()
Indicate whether this filter needs to input new src data.
FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount=1)
Inset one or more continuous element at specified position.
Definition: fx_basic.h:1575
Index out of range.
Definition: fx_basic.h:1313
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL means to use default allocator.
Definition: fx_basic.h:2169
FX_BOOL IsEOF() const
Detect EOF.
Definition: fx_basic.h:3798
void Push(const TYPE &val)
Push the byte string to stack.
Definition: fx_basic.h:1997
~CFX_CMapByteStringToPtr()
The destructor.
void TakeOver(CFX_BinaryBuf &other)
Takeover another buffer.
#define NULL
The null-pointer value.
Definition: fx_system.h:780
void * GetValueAt(void *key) const
Get a value pointer by a key.
FX_INT32 AppendInt64(FX_INT64 i)
Append a FX_INT64 value.
CFX_ArchiveLoader & operator >>(FX_BYTE &i)
Right shifts(>>) operator overload. De-serialize a byte.
int GetUpperBound() const
Get the upper bound in the array, actually the maximum valid index.
Definition: fx_basic.h:1367
int Size() const
Get size of the container.
Definition: fx_basic.h:1965
void RemoveKey(FX_BSTR key)
Removing existing (key, ?) pair.
Definition: fx_basic.h:2638
Definition: fx_basic.h:2347
Definition: fx_basic.h:3466
FX_BOOL IsEOF() const
Check if reached end of the stream.
Definition: fx_basic.h:3436
CFX_ByteString FX_UrlEncode(const CFX_WideString &wsUrl)
A simple URL encode.
void Push(const TYPE &val)
Push the data to stack.
Definition: fx_basic.h:1922
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:138
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:2452
Definition: fx_basic.h:2712
void Clear()
Clear the data list.
Definition: fx_basic.h:3989
CountedObj()
The constructor.
Definition: fx_basic.h:3526
void RemoveAll()
Remove all objects in the array.
Definition: fx_basic.h:1852
int GetCount() const
Get the number of nodes.
Definition: fx_basic.h:3130
FX_BOOL AbortAll()
Indicate whether to abort the filter process, including all dest filter.
ObjClass * GetModify()
Get a modifiable copy of the object.
Definition: fx_basic.h:3676
void GetNextAssoc(FX_POSITION &pos, FX_DWORD &key, FX_DWORD &value) const
Get the next association.
void RemoveAll()
Remove all the (key, value) pairs in the map.
int Size() const
Get size of the container.
Definition: fx_basic.h:1890
#define FX_Allocator_Free(fxAllocator, ptr)
Free memory block on an allocator.
Definition: fx_memory.h:1094
FX_POSITION GetPrevPosition(FX_POSITION pos) const
Get the previous position.
Definition: fx_basic.h:3111
CFX_WideStringC GetWideString() const
Get a wide string from the wide text buffer.
~CFX_MapPtrToPtr()
The Destructor.
CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize)
Construct a loading archive.
PD_CALLBACK_FREEDATA m_pCallback
Pointer of a callback function provided by custom module for deallocating private data.
Definition: fx_basic.h:3274
FX_STRSIZE GetSize() const
Get the length of the binary buffer.
Definition: fx_basic.h:203
CFX_ByteString(* m_GetByteString)(CFX_CharMap *pMap, const CFX_WideString &wstr)
A pointer type to GetByteString function.
Definition: fx_basic.h:995
Definition: fx_basic.h:3402
void SetNull()
Set the pointer of the object to be null.
Definition: fx_basic.h:3698
Definition: fx_basic.h:3890
CFX_ArrayTemplate< FX_WCHAR > CFX_WCHARArray
Type definition for FX_WHAR array.
Definition: fx_basic.h:1634
FX_INT32 AppendString(FX_BSTR lpsz)
Append a byte string value.
void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow=true)
Initialize the hash table.
FX_BOOL operator==(const Ref &ref) const
Comparison(==) operator overload. Compare with another reference.
Definition: fx_basic.h:3714
ObjectClass * GetDataPtr(int index) const
Get a pointer to the specified element in the array. Direct pointer access.
Definition: fx_basic.h:1831
void * value
Value data.
Definition: fx_basic.h:2728
INT_PTR FX_INTPTR
Signed integral type for pointer precision.
Definition: fx_system.h:739
Header file for exception class.
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:656
void * GetAt(int index) const
Get a typeless pointer to an element data.
void RemoveAll()
Remove all elements in the array.
void Pop()
Pop the byte string from stack.
Definition: fx_basic.h:1985
Definition: fx_basic.h:877
void Decref()
Decrease the reference.
Definition: fx_basic.h:3745
virtual ~IFX_Pause()
Destructor.
Definition: fx_basic.h:3765
CFX_ArrayTemplate< void * > CFX_PtrArray
Type definition for: a typeless pointer array type.
Definition: fx_basic.h:1626
Definition: fx_basic.h:485
CFX_BaseSegmentedArray(int unit_size=1, int segment_units=512, int index_size=8, IFX_Allocator *pAllocator=0)
Construct with specified unit size, segment units, and number of index levels.
int Find(const TYPE &data, int iStart=0) const
Find an element from specified position to last.
Definition: fx_basic.h:1610
void Input(FX_BYTE byte)
Input a byte.
Header file for system related definitions.
FX_LPVOID GetNextValue(FX_POSITION &rNextPosition) const
Get the the current value and set the position to next association.
CFX_ByteStringC GetByteString() const
Get a byte string from the buffer.
void Add(FX_INT32 nStart, FX_INT32 nCount)
Add a list data.
Definition: fx_basic.h:4132
CAssoc * pNext
Pointer to next association.
Definition: fx_basic.h:2356