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 
305  CFX_ByteTextBuf& operator << (double f);
306 
315 
324 
330  FX_STRSIZE GetLength() const { return m_DataSize; }
331 };
332 
337 {
338  public:
345  CFX_WideTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
346 
354  void operator = (FX_LPCWSTR lpsz);
355 
363  void operator = (FX_WSTR str);
364 
373 
382 
390  CFX_WideTextBuf& operator << (double f);
391 
400 
409 
418 
427 
433  FX_STRSIZE GetLength() const { return m_DataSize/sizeof(FX_WCHAR); }
434 
440  FX_LPWSTR GetBuffer() const { return (FX_LPWSTR)m_pBuffer; }
441 
450  void Delete(int start_index, int count)
451  {
452  CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_WCHAR));
453  }
454 
461 
462  void GetWideStringL(CFX_WideStringL& wideText) const;
463 
464 };
465 
466 //*****************************************************************************
467 //* Archive
468 //*****************************************************************************
476 class CFX_ArchiveSaver : public CFX_Object
477 {
478  public:
485  CFX_ArchiveSaver(IFX_Allocator* pAllocator = NULL) : m_SavingBuf(pAllocator), m_pStream(NULL) {}
486 
495 
504 
513 
522 
530  CFX_ArchiveSaver& operator << (FX_INT64 i);
531 
540 
548  CFX_ArchiveSaver& operator << (double i);
549 
558 
567 
576 
587 
598 
607  void Write(const void* pData, FX_STRSIZE dwSize);
608 
614  FX_INTPTR GetLength() const { return m_SavingBuf.GetSize(); }
615 
621  FX_LPCBYTE GetBuffer() const { return m_SavingBuf.GetBuffer(); }
622 
630  void SetStream(IFX_FileStream* pStream) { m_pStream = pStream; }
631 
632  protected:
633  /* Saving data. */
634  CFX_BinaryBuf m_SavingBuf;
635  /* Stream data. */
636  IFX_FileStream* m_pStream;
637 };
638 
642 class CFX_ArchiveLoader : public CFX_Object
643 {
644  public:
653  CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize);
654 
663 
672 
681 
689  CFX_ArchiveLoader& operator >> (FX_INT64& i);
690 
699 
708 
716  CFX_ArchiveLoader& operator >> (double& i);
717 
726 
735 
741  FX_BOOL IsEOF();
742 
751  FX_BOOL Read(void* pBuf, FX_DWORD dwSize);
752 
753  protected:
754  /* Current loading position. */
755  FX_DWORD m_LoadingPos;
756  /* Loading buffer. */
757  FX_LPCBYTE m_pLoadingBuf;
758  /* The size in bytes of the loading buffer. */
759  FX_DWORD m_LoadingSize;
760 };
761 
766 {
767  public:
775  IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
776  //<<<+++OPENSOURCE_END
777 
781  virtual ~IFX_BufferArchive() {}
782 
788  virtual void Clear();
789 
795  FX_BOOL Flush();
796 
805  FX_INT32 AppendBlock(const void* pBuf, size_t size);
806 
815 
824 
832  FX_INT32 AppendInt64(FX_INT64 i);
833 
842 
843  protected:
844  /*
845  * @brief Do work, it will be called when the text buffer is full.
846  *
847  * @param[in] pBuf A pointer to a binary buffer block.
848  * @param[in] size The size in bytes of the buffer block.
849  *
850  * @return <b>true</b> means success, while <b>false</b> means failure.
851  */
852  virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
853 
854  /* Special allocator pointer. NULL to use default allocator. */
855  IFX_Allocator* m_pAllocator;
856 
857  /* The buffer size*/
858  FX_STRSIZE m_BufSize;
859  /* Buffer. */
860  FX_LPBYTE m_pBuffer;
861  /* Current buffer length. */
862  FX_STRSIZE m_Length;
863 };
864 
868 class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object
869 {
870  public:
877  CFX_FileBufferArchive(FX_STRSIZE size = 32768, IFX_Allocator* pAllocator = NULL);
878 
883 
889  virtual void Clear();
890 
896  FX_BOOL Flush();
897 
906  FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = false);
907 
915  FX_BOOL AttachFile(FX_LPCWSTR filename);
916 
924  FX_BOOL AttachFile(FX_LPCSTR filename);
925 
926  private:
927  /*
928  * Do work, it will be called when the text buffer is full.
929  *
930  * @param[in] pBuf A pointer to a binary buffer block.
931  * @param[in] size The size in bytes of the buffer block.
932  *
933  * @return <b>true</b> means success, while <b>false</b> means failure.
934  */
935  virtual FX_BOOL DoWork(const void* pBuf, size_t size);
936 
937  /* The file stream. */
938  IFX_StreamWrite *m_pFile;
939  /* whether take over the file. */
940  FX_BOOL m_bTakeover;
941 };
942 
948 {
959  static CFX_CharMap* GetDefaultMapper(FX_INT32 codepage = 0);
960 
974 
987 
994 };
995 
996 //*****************************************************************************
997 //* UTF-8
998 //*****************************************************************************
1003 {
1004  public:
1012  CFX_UTF8Decoder(IFX_Allocator* pAllocator = NULL) : m_PendingBytes(0),m_PendingChar(0),m_Buffer(pAllocator) { }
1013 
1019  void Clear();
1020 
1028  void Input(FX_BYTE byte);
1029 
1037  void AppendChar(FX_DWORD ch);
1038 
1044  void ClearStatus() { m_PendingBytes = 0; }
1045 
1051  CFX_WideStringC GetResult() const { return m_Buffer.GetWideString(); }
1052 
1060  void GetResult(CFX_WideStringL &result) const {m_Buffer.GetWideStringL(result);}
1061 
1062  protected:
1063  /* The decoding status. */
1064  int m_PendingBytes;
1065  /* Cached value. */
1066  FX_DWORD m_PendingChar;
1067  /* The output wide text buffer. */
1068  CFX_WideTextBuf m_Buffer;
1069 };
1070 
1075 {
1076  public:
1082  CFX_UTF8Encoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) { m_UTF16First = 0; }
1083 
1091  void Input(FX_WCHAR unicode);
1092 
1100  void AppendStr(FX_BSTR str) { m_UTF16First = 0; m_Buffer << str; }
1101 
1107  CFX_ByteStringC GetResult() const { return m_Buffer.GetByteString(); }
1108 
1116  void GetResult(CFX_ByteStringL &result) const {m_Buffer.GetByteStringL(result);}
1117 
1118  protected:
1119  /* The output byte text buffer. */
1120  CFX_ByteTextBuf m_Buffer;
1121  /* The encoding status. */
1122  FX_DWORD m_UTF16First;
1123 };
1124 
1133 
1142 
1151 
1160 
1161 //*****************************************************************************
1162 //* Array
1163 //*****************************************************************************
1167 class CFX_BasicArray : public CFX_Object
1168 {
1169  public:
1172 
1173  protected:
1174  /*
1175  * @brief Construct with specified unit size.
1176  *
1177  * @param[in] unit_size The specified unit size. Must be greater than 0 and less than 2^28.
1178  * @param[in] pAllocator Allocator used in this class. <b>NULL</b> means to use default allocator.
1179  * Default value: <b>NULL</b>.
1180  */
1181  CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL);
1182  //<<<+++OPENSOURCE_END
1183 
1184  /*
1185  * @brief The destructor.
1186  */
1187  ~CFX_BasicArray();
1188 
1189  /*
1190  * @brief The copy constructor.
1191  *
1192  * @param[in] other The other CFX_BasicArray object.
1193  * @param[in] pAllocator An allocator.
1194  */
1195  CFX_BasicArray(const CFX_BasicArray& other, IFX_Allocator* pAllocator = NULL);
1196 
1197  /*
1198  * @brief The assignment operator.
1199  *
1200  * @param[in] other The other CFX_BasicArray object.
1201  *
1202  * @return Reference to current object itself.
1203  */
1204  CFX_BasicArray& operator=(const CFX_BasicArray& other);
1205 
1206  /*
1207  * @brief Change the allocated size and the grow amount.
1208  *
1209  * @param[in] nNewSize The new size in elements expected.
1210  * @param[in] nGrowBy The grow amount in elements expected, nGrowBy can be -1 for the grow amount unchanged.
1211  *
1212  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter or memory error).
1213  */
1214  FX_BOOL SetSize(int nNewSize, int nGrowBy);
1215 
1216  /*
1217  * @brief Append a basic array.
1218  *
1219  * @param[in] src The input basic array. It must have the save unit size as the current array.
1220  *
1221  * @return <b>true</b> means success, while <b>false</b> means failure (such as memory error).
1222  */
1223  FX_BOOL Append(const CFX_BasicArray& src);
1224 
1225  /*
1226  * @brief Copy from 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 Copy(const CFX_BasicArray& src);
1233 
1234  /*
1235  * @brief Insert spaces at specified position.
1236  *
1237  * @param[in] nIndex Specifies the zero-based index of element in the basic array.
1238  * @param[in] nCount Specifies the count of element to insert.
1239  *
1240  * @return A byte pointer to the inserted space. <b>NULL</b> means error.
1241  */
1242  FX_LPBYTE InsertSpaceAt(int nIndex, int nCount);
1243 
1244  /*
1245  * @brief Remove a number of elements.
1246  *
1247  * @param[in] nIndex Specifies the zero-based index of start element in the basic array to be removed.
1248  * @param[in] nCount Specifies the count of element to remove.
1249  *
1250  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter error).
1251  */
1252  FX_BOOL RemoveAt(int nIndex, int nCount);
1253 
1254  /*
1255  * @brief Insert a basic array at specified position.
1256  *
1257  * @param[in] nStartIndex Specifies the zero-based index of start element to insert at.
1258  * @param[in] pNewArray The input basic array. It must have the save unit size as the current array.
1259  *
1260  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter or memory error).
1261  */
1262  FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
1263 
1264  /*
1265  * @brief Get a typeless pointer to an element data.
1266  *
1267  * @param[in] index Specifies the zero-based index of element.
1268  *
1269  * @return A typeless pointer to the element data. <b>NULL</b> means error.
1270  */
1271  const void* GetDataPtr(int index) const;
1272 
1273  protected:
1274  /* The actual array of data */
1275  FX_LPBYTE m_pData;
1276  /* # of elements (upperBound - 1) */
1277  int m_nSize;
1278  /* Max allocated */
1279  int m_nMaxSize;
1280  /* Grow amount. */
1281  int m_nGrowBy;
1282  /* Number of bytes in one unit. */
1283  int m_nUnitSize;
1284 };
1285 
1287 template<class TYPE>
1289 {
1290  public:
1299 
1302 
1305  };
1306 
1312  CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(TYPE), pAllocator) {}
1313  //<<<+++OPENSOURCE_END
1314 
1321  CFX_ArrayTemplate(const CFX_ArrayTemplate& other, IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(other, pAllocator) {}
1322 
1332  void FX_Error(ErrorType error,FX_INT32 badIndex=0) const
1333  {
1334  const char *errorMsg[] = {
1335  "Invalid array size",
1336  "Memory allocation error",
1337  "Invalid index:"
1338  };
1339 
1340  fprintf(stderr, "%s\n", errorMsg[error]);
1341  if(error == indexOutOfRange)
1342  fprintf(stderr, "%i\n", badIndex);
1343  abort();
1344  }
1345 
1351  int GetSize() const { return m_nSize; }
1352 
1358  int GetUpperBound() const { return m_nSize-1; }
1359 
1368  FX_BOOL SetSize(int nNewSize, int nGrowBy = -1)
1369  {
1370  return CFX_BasicArray::SetSize(nNewSize, nGrowBy);
1371  }
1372 
1378  void RemoveAll() { SetSize(0, -1); }
1379 
1387  const TYPE GetAt(int nIndex) const {
1388  if (nIndex < 0 || nIndex >= m_nSize)
1389  //return (const TYPE&)(*(volatile const TYPE*)NULL);
1390  //In order to avoid crash, we input the index.(For reasons unknown)
1391  FX_Error(indexOutOfRange, nIndex);
1392  return ((const TYPE*)m_pData)[nIndex];
1393  }
1394 
1403  FX_BOOL SetAt(int nIndex, TYPE newElement) {
1404  if (nIndex < 0 || nIndex >= m_nSize) return false;
1405  ((TYPE*)m_pData)[nIndex] = newElement;
1406  return true;
1407  }
1408 
1416  TYPE& ElementAt(int nIndex)
1417  {
1418  if (nIndex < 0 || nIndex >= m_nSize)
1419  //return *(TYPE*)NULL;
1420  //In order to avoid crash, we input the index.(For reasons unknown)
1421  FX_Error(indexOutOfRange, nIndex);
1422  return ((TYPE*)m_pData)[nIndex];
1423  }
1424 
1430  const TYPE* GetData() const { return (const TYPE*)m_pData; }
1431 
1437  TYPE* GetData() { return (TYPE*)m_pData; }
1438 
1447  FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
1448  {
1449  if (nIndex < 0) return false;
1450  if (nIndex >= m_nSize)
1451  if (!SetSize(nIndex+1, -1)) return false;
1452  ((TYPE*)m_pData)[nIndex] = newElement;
1453  return true;
1454  }
1455 
1463  FX_BOOL Add(TYPE newElement)
1464  {
1465  if (m_nSize < m_nMaxSize)
1466  m_nSize ++;
1467  else
1468  if (!SetSize(m_nSize+1, -1)) return false;
1469  ((TYPE*)m_pData)[m_nSize-1] = newElement;
1470  return true;
1471  }
1472 
1480  FX_BOOL Append(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Append(src); }
1481 
1489  FX_BOOL Copy(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Copy(src); }
1490 
1498  TYPE* GetDataPtr(int index) { return (TYPE*)CFX_BasicArray::GetDataPtr(index); }
1499 
1505  TYPE* AddSpace() { return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1); }
1506 
1515  TYPE* InsertSpaceAt(int nIndex, int nCount) { return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount); }
1516 
1524  CFX_ArrayTemplate& operator=(const CFX_ArrayTemplate& src) { CFX_BasicArray::operator=(src); return *this; }
1525 
1533  const TYPE operator[](int nIndex) const
1534  {
1535  if (nIndex < 0 || nIndex >= m_nSize)
1536  //Merge from google trunk r2049, author: Johnson, date:2012.12.07
1537  *(volatile char*)0 = '\0';
1538  return ((const TYPE*)m_pData)[nIndex];
1539  }
1540 
1549  TYPE& operator[](int nIndex)
1550  {
1551  if (nIndex < 0 || nIndex >= m_nSize)
1552  //Merge from google trunk r2049, author: Johnson, date:2012.12.07
1553  *(volatile char*)0 = '\0';
1554  return ((TYPE*)m_pData)[nIndex];
1555  }
1556 
1566  FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1)
1567  {
1568  if (!InsertSpaceAt(nIndex, nCount)) return false;
1569  while (nCount--)
1570  ((TYPE*)m_pData)[nIndex++] = newElement;
1571  return true;
1572  }
1573 
1582  FX_BOOL RemoveAt(int nIndex, int nCount = 1) { return CFX_BasicArray::RemoveAt(nIndex, nCount); }
1583 
1592  FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) { return CFX_BasicArray::InsertAt(nStartIndex, pNewArray); }
1601  int Find(const TYPE& data, int iStart = 0) const
1602  {
1603  if (iStart < 0) return -1;
1604  for (; iStart < (int)m_nSize; iStart ++)
1605  if (((TYPE*)m_pData)[iStart] == data) return iStart;
1606  return -1;
1607  }
1608 };
1609 
1626 
1635 template <class ObjectClass>
1637 {
1638  public:
1644  CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(ObjectClass), pAllocator) {}
1645 
1650 
1657  CFX_ObjectArray(const CFX_ObjectArray& other, IFX_Allocator* pAllocator = NULL)
1658  : CFX_BasicArray(sizeof(ObjectClass), pAllocator)
1659  {
1660  Copy(other);
1661  }
1662 
1671  {
1672  Copy(other);
1673  return *this;
1674  }
1675 
1685  void Add(const ObjectClass& data)
1686  {
1687  #ifndef _FX_NOPLACEMENTNEW_
1688  new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
1689  #else
1690  ::new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
1691  #endif
1692 
1693  }
1694 
1702  ObjectClass& Add()
1703  {
1704  #ifndef _FX_NOPLACEMENTNEW_
1705  return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
1706  #else
1707  return *(ObjectClass*) ::new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
1708  #endif
1709  }
1710 
1718  void* AddSpace()
1719  {
1720  return InsertSpaceAt(m_nSize, 1);
1721  }
1722 
1733  FX_INT32 Append(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
1734  {
1735  if (nCount == 0) return 0;
1736  FX_INT32 nSize = src.GetSize();
1737  if (!nSize) return 0;
1738  FXSYS_assert(nStart > -1 && nStart < nSize);
1739  if (nCount < 0) nCount = nSize;
1740  if (nStart + nCount > nSize) nCount = nSize - nStart;
1741  if (nCount < 1) return 0;
1742  nSize = m_nSize;
1743  InsertSpaceAt(m_nSize, nCount);
1744  ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
1745  nSize = nStart + nCount;
1746  for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++)
1747  {
1748  #ifndef _FX_NOPLACEMENTNEW_
1749  new ((void*)pStartObj) ObjectClass(src[i]);
1750  #else
1751  ::new ((void*)pStartObj) ObjectClass(src[i]);
1752  #endif
1753 
1754  }
1755  return nCount;
1756  }
1757 
1768  FX_INT32 Copy(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
1769  {
1770  if (this == &src) return 0;
1771  RemoveAll();
1772  if (nCount == 0) return 0;
1773  FX_INT32 nSize = src.GetSize();
1774  if (!nSize) return 0;
1775  FXSYS_assert(nStart > -1 && nStart < nSize);
1776  if (nCount < 0) nCount = nSize;
1777  if (nStart + nCount > nSize) nCount = nSize - nStart;
1778  if (nCount < 1) return 0;
1779  nSize = nStart + nCount;
1780  SetSize(nCount, -1);
1781  ObjectClass* pStartObj = (ObjectClass*)m_pData;
1782  for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++)
1783  {
1784  #ifndef _FX_NOPLACEMENTNEW_
1785  new ((void*)pStartObj) ObjectClass(src[i]);
1786  #else
1787  ::new ((void*)pStartObj) ObjectClass(src[i]);
1788  #endif
1789 
1790  }
1791  return nCount;
1792  }
1793 
1799  int GetSize() const {return m_nSize;}
1800 
1809  ObjectClass& operator[] (int index) const
1810  {
1811  FXSYS_assert(index < m_nSize);
1812  return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
1813  }
1814 
1822  ObjectClass* GetDataPtr(int index) const {return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);}
1823 
1831  void RemoveAt(int index)
1832  {
1833  FXSYS_assert(index < m_nSize);
1834  ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
1835  CFX_BasicArray::RemoveAt(index, 1);
1836  }
1837 
1843  void RemoveAll()
1844  {
1845  for (int i = 0; i < m_nSize; i ++)
1846  ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
1847  CFX_BasicArray::SetSize(0, -1);
1848  }
1849 };
1850 
1855 
1859 template <class TYPE>
1860 class CFX_Stack : CFX_Object
1861 {
1862  public:
1865 
1871  FX_BOOL Empty() const
1872  {
1873  return m_Container.GetSize() == 0;
1874  }
1875 
1881  int Size() const
1882  {
1883  return m_Container.GetSize();
1884  }
1885 
1891  TYPE& Top()
1892  {
1893  return m_Container[Size() - 1];
1894  }
1895 
1901  void Pop()
1902  {
1903  m_Container.RemoveAt(Size() - 1);
1904  }
1905 
1913  void Push(const TYPE& val)
1914  {
1915  m_Container.Add(val);
1916  }
1917 
1918  private:
1919  CFX_ArrayTemplate<TYPE> m_Container;
1920 };
1921 
1925 template <class TYPE>
1926 class CFX_ObjectStack : CFX_Object
1927 {
1928  public:
1931 
1937  FX_BOOL Empty() const
1938  {
1939  return m_Container.GetSize() == 0;
1940  }
1941 
1947  int Size() const
1948  {
1949  return m_Container.GetSize();
1950  }
1951 
1957  TYPE& Top()
1958  {
1959  return m_Container[Size() - 1];
1960  }
1961 
1967  void Pop()
1968  {
1969  m_Container.RemoveAt(Size() - 1);
1970  }
1971 
1979  void Push(const TYPE& val)
1980  {
1981  m_Container.Add(val);
1982  }
1983 
1984  private:
1985  CFX_ObjectArray<TYPE> m_Container;
1986 };
1987 
1991 template <>
1992 class CFX_Stack<CFX_ByteString> : CFX_Object
1993 {
1994  public:
1997 
2003  FX_BOOL Empty() const
2004  {
2005  return m_Container.GetSize() == 0;
2006  }
2007 
2013  int Size() const
2014  {
2015  return m_Container.GetSize();
2016  }
2017 
2024  {
2025  return m_Container[Size() - 1];
2026  }
2027 
2033  void Pop()
2034  {
2035  m_Container.RemoveAt(Size() - 1);
2036  }
2037 
2045  void Push(const CFX_ByteString& val)
2046  {
2047  m_Container.Add(val);
2048  }
2049 
2050  private:
2051  CFX_ObjectArray<CFX_ByteString> m_Container;
2052 };
2053 
2057 class CFX_BaseSegmentedArray : public CFX_Object
2058 {
2059  public:
2068  CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8, IFX_Allocator* pAllocator = NULL);
2069 
2074 
2084  void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
2085 
2091  void* Add();
2092 
2100  void* GetAt(int index) const;
2101 
2107  void RemoveAll();
2108 
2117  void Delete(int index, int count = 1);
2118 
2124  int GetSize() const { return m_DataSize; }
2125 
2131  int GetSegmentSize() const { return m_SegmentSize; }
2132 
2138  int GetUnitSize() const { return m_UnitSize; }
2139 
2148  void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const;
2149 
2152  private:
2153  /* Unit size */
2154  int m_UnitSize;
2155  /* Count of units in each segment. */
2156  short m_SegmentSize;
2157  /* Number of index level in the array. */
2158  FX_BYTE m_IndexSize;
2159  /* The current level in the index tree. */
2160  FX_BYTE m_IndexDepth;
2161  /* The current number of units in the array. */
2162  int m_DataSize;
2163  /* index to segments or indices, or directly pointing to the segment if only one segment. */
2164  void* m_pIndex;
2165 
2166  void** GetIndex(int seg_index) const;
2167  void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
2168  void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const;
2169 };
2170 
2174 template <class ElementType>
2176 {
2177  public:
2185  CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAllocator = NULL)
2186  : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size, pAllocator)
2187  {}
2188  //<<<+++OPENSOURCE_END
2189 
2197  void Add(ElementType data)
2198  {
2199  *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
2200  }
2201 
2209  ElementType& operator [] (int index)
2210  {
2211  return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
2212  }
2213 };
2214 
2218 template <class DataType, int FixedSize>
2219 class CFX_FixedBufGrow : public CFX_Object
2220 {
2221  public:
2229  : m_pAllocator(pAllocator)
2230  , m_pData(NULL)
2231  {
2232  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2233  }
2234 
2242  CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL)
2243  : m_pAllocator(pAllocator)
2244  , m_pData(NULL)
2245  {
2246  if (data_size > FixedSize)
2247  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
2248  else
2249  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2250  }
2251  //<<<+++OPENSOURCE_END
2252 
2260  void SetDataSize(int data_size) {
2261  if (m_pData)
2262  FX_Allocator_Free(m_pAllocator, m_pData);
2263  m_pData = NULL;
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  }
2270 
2274  ~CFX_FixedBufGrow() { if (m_pData) FX_Allocator_Free(m_pAllocator, m_pData); }
2275 
2276  operator DataType*() { return m_pData ? m_pData : m_Data; }
2277 
2278  private:
2279  IFX_Allocator* m_pAllocator;
2280 
2281  DataType m_Data[FixedSize];
2282  DataType* m_pData;
2283 };
2284 
2288 template <class DataType>
2290 {
2291  public:
2299  CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllocator)
2300  {
2301  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size);
2302  }
2303 
2308  {
2309  if (m_pData) FX_Allocator_Free(m_pAllocator, m_pData);
2310  }
2311  //<<<+++OPENSOURCE_END
2312 
2313  DataType& operator[](int i) { FXSYS_assert(m_pData != NULL); return m_pData[i]; }
2314  operator DataType*() const { return m_pData; }
2315 
2316  private:
2317  IFX_Allocator* m_pAllocator;
2318 
2319  DataType* m_pData;
2320 };
2321 
2322 //*****************************************************************************
2323 //* Map
2324 //*****************************************************************************
2325 
2329 class CFX_MapPtrToPtr : public CFX_Object
2330 {
2331  protected:
2335  struct CAssoc
2336  {
2340  void* key;
2342  void* value;
2343  };
2344 
2345  public:
2353  CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
2354  //<<<+++OPENSOURCE_END
2355 
2359  ~CFX_MapPtrToPtr();
2360 
2366  int GetCount() const { return m_nCount; }
2367 
2373  FX_BOOL IsEmpty() const { return m_nCount == 0; }
2374 
2383  FX_BOOL Lookup(void* key, void*& rValue) const;
2384 
2392  void* GetValueAt(void* key) const;
2393 
2401  void*& operator[](void* key);
2402 
2411  void SetAt(void* key, void* newValue) { (*this)[key] = newValue; }
2412 
2420  FX_BOOL RemoveKey(void* key);
2421 
2427  void RemoveAll();
2428 
2434  FX_POSITION GetStartPosition() const { return (m_nCount == 0) ? NULL : (FX_POSITION)-1; }
2435 
2448  void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const;
2449 
2455  FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
2456 
2466  void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = true);
2467 
2468  protected:
2469  /* Special allocator pointer. NULL to use default allocator. */
2470  IFX_Allocator* m_pAllocator;
2471 
2472  /* The hash table. */
2473  CAssoc** m_pHashTable;
2474  /* The size of hash table. */
2475  FX_DWORD m_nHashTableSize;
2476  /* The number of key-value pair in the map. */
2477  int m_nCount;
2478  /* The freed association list internal. */
2479  CAssoc* m_pFreeList;
2480  /* The block list internal. */
2481  struct CFX_Plex* m_pBlocks;
2482  /* The size in associations of each block. */
2483  int m_nBlockSize;
2484 
2485  /*
2486  * Routine used to user-provided hash keys.
2487  *
2488  * @note Overwrite-able: special non-virtual (see map implementation for details).
2489  *
2490  * @param[in] key The key used to produce hash key.
2491  * @return A hash value.
2492  */
2493  FX_DWORD HashKey(void* key) const;
2494 
2495  /*
2496  * Allocate a new association.
2497  *
2498  * @return The pointer to the new allocated association.
2499  */
2500  CAssoc* NewAssoc();
2501  /*
2502  * Free an association.
2503  *
2504  * @param[in] pAssoc A pointer to an association.
2505  */
2506  void FreeAssoc(CAssoc* pAssoc);
2507  /*
2508  * @brief Retrieve an association by a key.
2509  *
2510  * @param[in] key The input key.
2511  * @param[out] hash The hash value computed.
2512  *
2513  * @return Current association object.
2514  */
2515  CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
2516  /*
2517  * @brief Retrieve current association by position.
2518  *
2519  * @param[in, out] rNextPosition Input a position, and receive the next association position.
2520  *
2521  * @return Current association object.
2522  */
2523  CAssoc* GetCurrentAssoc(FX_POSITION& rNextPosition) const;
2524  /*
2525  * @brief Expand 2 times HashTable Size than before.
2526  *
2527  * @details The MaxHashTableSize is 10000.
2528  *
2529  * @return <b>true</b> means success, while <b>false</b> means failure.
2530  */
2531  FX_BOOL ExpandHashTable();
2532 };
2533 
2537 template <class KeyType, class ValueType>
2539 {
2540  public:
2546  CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, pAllocator) {}
2547 
2556  FX_BOOL Lookup(KeyType key, ValueType& rValue) const
2557  {
2558  FX_LPVOID pValue = NULL;
2559  if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue))
2560  return false;
2561  rValue = (ValueType)(FX_UINTPTR)pValue;
2562  return true;
2563  }
2564 
2572  ValueType& operator[](KeyType key) { return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(FX_UINTPTR)key); }
2573 
2582  void SetAt(KeyType key, ValueType newValue) { CFX_MapPtrToPtr::SetAt((void*)(FX_UINTPTR)key, (void*)(FX_UINTPTR)newValue); }
2583 
2591  FX_BOOL RemoveKey(KeyType key) { return CFX_MapPtrToPtr::RemoveKey((void*)(FX_UINTPTR)key); }
2592 
2602  void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const
2603  {
2604  void* pKey = NULL; void* pValue = NULL;
2605  CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
2606  rKey = (KeyType)(FX_UINTPTR)pKey; rValue = (ValueType)(FX_UINTPTR)pValue;
2607  }
2608 };
2609 
2614 class CFX_CMapDWordToDWord : public CFX_Object
2615 {
2616  public:
2622  CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) {}
2623 
2632  FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
2633 
2642  void SetAt(FX_DWORD key, FX_DWORD value);
2643 
2652  void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
2653 
2659  FX_POSITION GetStartPosition() const;
2660 
2670  void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
2671 
2677  void RemoveAll() { m_Buffer.Clear(); }
2678 
2679  protected:
2682  private:
2683  CFX_CMapDWordToDWord(const CFX_CMapDWordToDWord &) FX_EQDELETE;
2684  CFX_CMapDWordToDWord &operator=(const CFX_CMapDWordToDWord &) FX_EQDELETE;
2685 };
2686 
2688 class CFX_MapByteStringToPtr : public CFX_Object
2689 {
2690  protected:
2694  struct CAssoc
2695  {
2698 
2704  void* value;
2705  };
2706 
2707  public:
2715  CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
2716 
2722  int GetCount() const { return m_nCount; }
2723 
2729  FX_BOOL IsEmpty() const { return m_nCount == 0; }
2730 
2739  FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
2740 
2748  void*& operator[](FX_BSTR key);
2749 
2758  void SetAt(FX_BSTR key, void* newValue) { (*this)[key] = newValue; }
2759 
2767  FX_BOOL RemoveKey(FX_BSTR key);
2768 
2774  void RemoveAll();
2775 
2781  FX_POSITION GetStartPosition() const { return (m_nCount == 0) ? NULL : (FX_POSITION)-1; }
2782 
2792  void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
2793 
2801  FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
2802 
2808  FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
2809 
2819  void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = true);
2820 
2830  FX_DWORD HashKey(FX_BSTR key) const;
2831 
2832  protected:
2833  /* Special allocator pointer. NULL to use default allocator. */
2834  IFX_Allocator* m_pAllocator;
2835 
2836  /* The hash table. */
2837  CAssoc** m_pHashTable;
2838  /* The size of hash table. */
2839  FX_DWORD m_nHashTableSize;
2840  /* The number of key-value pair in the map. */
2841  int m_nCount;
2842  /* The freed association list internal. */
2843  CAssoc* m_pFreeList;
2844  /* The block list internal. */
2845  struct CFX_Plex* m_pBlocks;
2846  /* The size in associations of each block. */
2847  int m_nBlockSize;
2848 
2849  /*
2850  * @brief Allocate a new association.
2851  *
2852  * @return The pointer to the new allocated association.
2853  */
2854  CAssoc* NewAssoc();
2855  /*
2856  * @brief Free an association.
2857  *
2858  * @param[in] pAssoc A pointer to an association.
2859  *
2860  * @return None.
2861  */
2862  void FreeAssoc(CAssoc* pAssoc);
2863  /*
2864  * @brief Retrieve an association by a key.
2865  *
2866  * @param[in] key The input key.
2867  * @param[out] hash The hash value computed.
2868  *
2869  * @return An association object.
2870  */
2871  CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const;
2872  /*
2873  * @brief Retrieve current association by position.
2874  *
2875  * @param[in] rNextPosition The current position.
2876  *
2877  * @return An association object.
2878  */
2879  CAssoc* GetCurrentAssoc(FX_POSITION& rNextPosition) const;
2880  /*
2881  * @brief Expand 2 times HashTable Size than before.
2882  *
2883  * @details The MaxHashTableSize is 10000.
2884  *
2885  * @return <b>true</b> means success, while <b>false</b> means failure.
2886  */
2887  FX_BOOL ExpendHashTable();
2888 
2889  public:
2892 };
2893 
2902 class CFX_CMapByteStringToPtr : public CFX_Object
2903 {
2904  public:
2911  //<<<+++OPENSOURCE_END
2912 
2915 
2921  void RemoveAll();
2922 
2928  FX_POSITION GetStartPosition() const;
2929 
2939  void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
2940 
2948  FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
2949 
2958  FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
2959 
2968  void SetAt(FX_BSTR key, void* value);
2969 
2977  void RemoveKey(FX_BSTR key);
2978 
2984  int GetCount() const;
2985 
2997  void AddValue(FX_BSTR key, void* pValue);
2998 
2999  protected:
3000  /* A chained buffer storing keys and values. */
3001  CFX_BaseSegmentedArray m_Buffer;
3002 };
3003 
3005 // Lists
3007 
3009 class CFX_PtrList : public CFX_Object
3010 {
3011  protected:
3013  struct CNode
3014  {
3020  void* data;
3021  };
3022 
3023  public:
3030  CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
3031  //<<<+++OPENSOURCE_END
3032 
3038  FX_POSITION GetHeadPosition() const { return (FX_POSITION)m_pNodeHead; }
3039 
3045  FX_POSITION GetTailPosition() const { return (FX_POSITION)m_pNodeTail; }
3046 
3054  void* GetNext(FX_POSITION& rPosition) const
3055  {
3056  CNode* pNode = (CNode*)rPosition; rPosition = (FX_POSITION)pNode->pNext; return pNode->data;
3057  }
3058 
3066  void* GetPrev(FX_POSITION& rPosition) const
3067  {
3068  CNode* pNode = (CNode*)rPosition; rPosition = (FX_POSITION)pNode->pPrev; return pNode->data;
3069  }
3070 
3078  FX_POSITION GetNextPosition(FX_POSITION pos) const { return ((CNode*)pos)->pNext; }
3079 
3087  FX_POSITION GetPrevPosition(FX_POSITION pos) const { return ((CNode*)pos)->pPrev; }
3088 
3096  void* GetAt(FX_POSITION rPosition) const
3097  {
3098  CNode* pNode = (CNode*)rPosition; return pNode ? pNode->data : NULL;
3099  }
3100 
3106  int GetCount() const { return m_nCount; }
3107 
3115  FX_POSITION AddTail(void* newElement);
3116 
3124  FX_POSITION AddHead(void* newElement);
3125 
3134  void SetAt(FX_POSITION pos, void* newElement)
3135  {
3136  CNode* pNode = (CNode*)pos; pNode->data = newElement;
3137  }
3138 
3147  FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
3148 
3157  FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const;
3158 
3166  FX_POSITION FindIndex(int index) const;
3167 
3175  void RemoveAt(FX_POSITION pos);
3176 
3182  void RemoveAll();
3183 
3184  protected:
3185  /* Special allocator pointer. <b>NULL</b> means to use default allocator. */
3186  IFX_Allocator* m_pAllocator;
3187 
3188  /* Pointer to the head. */
3189  CNode* m_pNodeHead;
3190  /* Pointer to the tail. */
3191  CNode* m_pNodeTail;
3192  /* The count of nodes in the list. */
3193  int m_nCount;
3194  /* The freed node list internal. */
3195  CNode* m_pNodeFree;
3196  /* The block list internal. */
3197  struct CFX_Plex* m_pBlocks;
3198  /* The size in nodes of each block. */
3199  int m_nBlockSize;
3200 
3201  /*
3202  * Allocate a new node.
3203  *
3204  * @param[in] pPrev The pointer to the previous node.
3205  * @param[in] pNext The pointer to the next node.
3206  *
3207  * @return The pointer to the new node.
3208  */
3209  CNode* NewNode(CNode* pPrev, CNode* pNext);
3210  /*
3211  * Free a node.
3212  *
3213  * @param[in] pNode The node pointer.
3214  */
3215  void FreeNode(CNode* pNode);
3216 
3217  public:
3219  ~CFX_PtrList();
3220 };
3221 
3222 //*****************************************************************************
3223 //* Utilities
3224 //*****************************************************************************
3225 
3229 typedef void (*PD_CALLBACK_FREEDATA)(FX_LPVOID pData);
3230 
3235 {
3241  void FreeData();
3242 
3245 
3248 
3251 
3257 };
3258 
3263 {
3264  public:
3270  CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {}
3271 
3273  ~CFX_PrivateData();
3274 
3280  void ClearAll();
3281 
3298  void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
3299 
3312  void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject* pObj);
3313 
3324  FX_LPVOID GetPrivateData(FX_LPVOID module_id);
3325 
3335  {
3336  if (!module_id) return false;
3337  FX_DWORD nCount = m_DataList.GetSize();
3338  for (FX_DWORD n = 0; n < nCount; n++) {
3339  if (m_DataList[n].m_pModuleId == module_id) {
3340  pData = m_DataList[n].m_pData;
3341  return true;
3342  }
3343  }
3344  return false;
3345  }
3346 
3356  FX_BOOL RemovePrivateData(FX_LPVOID module_id);
3357 
3358  protected:
3359  /* Private data array. */
3361  /*
3362  * Add a private data. Add if not exist, otherwise modify.
3363  *
3364  * @param[in] module_id The module id.
3365  * @param[in] pData The private data.
3366  * @param[in] callback The callback function for deallocating provided private data.
3367  * @param[in] bSelfDestruct Whether the private data is a CFX_DestructObject derived object actually.
3368  *
3369  * @return None.
3370  */
3371  void AddData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct);
3372 };
3373 
3378 class CFX_BitStream : public CFX_Object
3379 {
3380  public:
3389  void Init(FX_LPCBYTE pData, FX_DWORD dwSize);
3390 
3398  FX_DWORD GetBits(FX_DWORD nBits);
3399 
3405  void ByteAlign();
3406 
3412  FX_BOOL IsEOF() const { return m_BitPos >= m_BitSize; }
3413 
3421  void SkipBits(FX_DWORD nBits) { m_BitPos += nBits; }
3422 
3428  void Rewind() { m_BitPos = 0; }
3429 
3430  protected:
3431  /* Bit position (zero-based). */
3432  FX_DWORD m_BitPos;
3433  /* Total bit counts in the memory block. */
3434  FX_DWORD m_BitSize;
3435  /* bit-stream stream buffer. */
3436  FX_LPCBYTE m_pData;
3437 };
3438 
3442 class CFX_BitWriter : public CFX_Object
3443 {
3444  public:
3450  CFX_BitWriter(CFX_BinaryBuf* pBinBuf) :m_pBinBuf(pBinBuf), m_BitPos(0), m_BytePos(0) {}
3451 
3460  void WriteBits(FX_INT64 value, FX_INT32 nBits);
3461 
3467  void ByteAlign();
3468 
3474  int GetCurBytePos() { return m_BytePos; }
3475 
3476  protected:
3477  /* Dynamic binary buffer. */
3478  CFX_BinaryBuf * m_pBinBuf;
3479  /* Bit position (zero-based). */
3480  int m_BitPos;
3481  /* Byte position (zero-based). */
3482  int m_BytePos;
3483 };
3484 
3489 template <class ObjClass> class CFX_CountRef : public CFX_Object
3490 {
3491  public:
3494 
3498  class CountedObj : public ObjClass
3499  {
3500  public:
3503 
3509  CountedObj(const CountedObj& src) : ObjClass(src) ,m_RefCount(0){}
3510 
3513  };
3514 
3519  {
3520  m_pObject = NULL;
3521  }
3522 
3528  CFX_CountRef(const Ref& ref)
3529  {
3530  m_pObject = ref.m_pObject;
3531  if (m_pObject) m_pObject->m_RefCount ++;
3532  }
3533 
3538  {
3539  if (!m_pObject) return;
3540  m_pObject->m_RefCount --;
3541  if (m_pObject->m_RefCount <= 0) {
3542  delete m_pObject;
3543  m_pObject = NULL;
3544  }
3545  }
3546 
3553  ObjClass* New()
3554  {
3555  if (m_pObject) {
3556  m_pObject->m_RefCount --;
3557  if (m_pObject->m_RefCount <= 0)
3558  delete m_pObject;
3559  m_pObject = NULL;
3560  }
3561  m_pObject = FX_NEW CountedObj;
3562  if (!m_pObject) return NULL;
3563  m_pObject->m_RefCount = 1;
3564  return m_pObject;
3565  }
3566 
3574  void operator = (const Ref& ref)
3575  {
3576  if (ref.m_pObject)
3577  ref.m_pObject->m_RefCount ++;
3578  if (m_pObject) {
3579  m_pObject->m_RefCount --;
3580  if (m_pObject->m_RefCount <= 0)
3581  delete m_pObject;
3582  }
3583  m_pObject = ref.m_pObject;
3584  }
3585 
3593  void operator = (void* p)
3594  {
3595  FXSYS_assert(p == 0);
3596  if (m_pObject == NULL) return;
3597  m_pObject->m_RefCount --;
3598  if (m_pObject->m_RefCount <= 0)
3599  delete m_pObject;
3600  m_pObject = NULL;
3601  }
3602 
3603 #if defined(_FX_MANAGED_CODE_) && defined(GetObject)
3604  #undef GetObject
3605 #endif
3606 
3611  const ObjClass* GetObject() const
3612  {
3613  return m_pObject;
3614  }
3620  operator const ObjClass*() const
3621  {
3622  return m_pObject;
3623  }
3624 
3630  FX_BOOL IsNull() const
3631  {
3632  return m_pObject == NULL;
3633  }
3640  {
3641  return m_pObject != NULL;
3642  }
3643 
3652  ObjClass* GetModify()
3653  {
3654  if (m_pObject == NULL) {
3655  m_pObject = FX_NEW CountedObj;
3656  if (m_pObject)
3657  m_pObject->m_RefCount = 1;
3658  } else if (m_pObject->m_RefCount > 1) {
3659  m_pObject->m_RefCount --;
3660  CountedObj* pOldObject = m_pObject;
3661  m_pObject = NULL;
3662  m_pObject = FX_NEW CountedObj(*pOldObject);
3663  if (m_pObject)
3664  m_pObject->m_RefCount = 1;
3665  }
3666  return m_pObject;
3667  }
3668 
3674  void SetNull()
3675  {
3676  if (m_pObject == NULL) return;
3677  m_pObject->m_RefCount --;
3678  if (m_pObject->m_RefCount <= 0)
3679  delete m_pObject;
3680  m_pObject = NULL;
3681  }
3682 
3690  FX_BOOL operator == (const Ref& ref) const
3691  {
3692  return m_pObject == ref.m_pObject;
3693  }
3694 
3700  int RefCount() const
3701  {
3702  return m_pObject ? m_pObject->m_RefCount : 0;
3703  }
3704 
3710  void Incref()
3711  {
3712  if (m_pObject == NULL) return;
3713  m_pObject->m_RefCount++;
3714  }
3715 
3721  void Decref()
3722  {
3723  if (m_pObject == NULL) return;
3724  m_pObject->m_RefCount--;
3725  if (m_pObject->m_RefCount <= 0) {
3726  delete m_pObject;
3727  m_pObject = NULL;
3728  }
3729  }
3730 
3731  protected:
3732  /* Reference counted object internal. */
3733  CountedObj* m_pObject;
3734 };
3735 
3738 {
3739  public:
3741  virtual ~IFX_Pause() {}
3742 
3748  virtual FX_BOOL NeedToPauseNow() = 0;
3749 };
3750 
3752 class CFX_DataFilter : public CFX_Object
3753 {
3754  public:
3758  virtual ~CFX_DataFilter();
3759 
3767  void SetDestFilter(CFX_DataFilter* pFilter);
3768 
3774  FX_BOOL IsEOF() const { return m_bEOF; }
3775 
3781  FX_FILESIZE GetSrcPos() const { return m_SrcPos; }
3782 
3792  void FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf& dest_buf);
3793 
3802  void FilterFinish(CFX_BinaryBuf& dest_buf);
3803 
3809  FX_BOOL IsExhaustBuffer() const { return m_bExhaustBuffer; }
3810 
3816  FX_BOOL NeedNewSrc();
3817 
3823  FX_BOOL Abort() const { return m_bAbort; }
3824 
3830  FX_BOOL AbortAll();
3831 
3837  void ResetStatistics();
3838 
3839  protected:
3840  /* The constructor. */
3841  CFX_DataFilter();
3842 
3843  virtual void v_FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf& dest_buf) = 0;
3844  virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
3845  virtual void v_ResetStatistics() {};
3846  void ReportEOF(FX_FILESIZE left_input);
3847 
3848  /* Indicate whether we met the EOF. */
3849  FX_BOOL m_bEOF;
3850  /* Current position in the source stream. */
3851  FX_FILESIZE m_SrcPos;
3852  /* Filter chain. */
3853  CFX_DataFilter* m_pDestFilter;
3854 
3855  /* Indicate whether this filter exhausts the input buffer. */
3856  FX_BOOL m_bExhaustBuffer;
3857  /* Store the output data of the FilterIn function.*/
3858  CFX_BinaryBuf m_FilterInBuffer;
3859 
3860  /* Indicate whether this filter aborts the filter process. For instance, RunLenFilter meets bad input data */
3861  FX_BOOL m_bAbort;
3862 };
3863 
3865 template<typename T>
3867  public:
3873  explicit CFX_AutoRestorer(T* location) {
3874  m_Location = location;
3875  m_OldValue = *location;
3876  }
3877 
3879  ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
3880  private:
3881  T* m_Location;
3882  T m_OldValue;
3883 };
3884 
3886 template <class T>
3888 {
3889  public:
3895  CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
3896 
3898  ~CFX_SmartPointer() {m_pObj->Release();}
3899 
3905  T* Get(void) {return m_pObj;}
3906 
3912  T& operator *(void) {return *m_pObj;}
3913 
3919  T* operator ->(void) {return m_pObj;}
3920 
3921  protected:
3922  T *m_pObj;
3923 };
3924 
3925 #define FX_DATALIST_LENGTH 1024
3926 
3928 template<size_t unit>
3929 class CFX_SortListArray : public CFX_Object
3930 {
3931  protected:
3933  struct DataList {
3938  FX_LPBYTE data;
3939  DataList()
3940  {
3941  start = count = 0;
3942  data = NULL;
3943  }
3944  };
3945 
3946  public:
3952  CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLists(pAllocator) {}
3953 
3956  {
3957  Clear();
3958  }
3959 
3965  void Clear()
3966  {
3967  IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
3968 
3969  for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--){
3970  DataList list = m_DataLists.ElementAt(i);
3971  if (list.data) FX_Allocator_Free(pAllocator, list.data);
3972  }
3973  m_DataLists.RemoveAll();
3974  m_CurList = 0;
3975  }
3976 
3985  void Append(FX_INT32 nStart, FX_INT32 nCount)
3986  {
3987  if (nStart < 0) return;
3988 
3989  IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
3990 
3991  while (nCount > 0){
3992  FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
3993  DataList list;
3994 
3995  list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * unit);
3996  if (!list.data) break;
3997  FXSYS_memset32(list.data, 0, temp_count * unit);
3998  list.start = nStart;
3999  list.count = temp_count;
4000 
4001  FX_BOOL ret = Append(list);
4002  if(ret)
4003  {
4004  nCount -= temp_count;
4005  nStart += temp_count;
4006  }
4007  else
4008  {
4009  if (list.data) FX_Allocator_Free(pAllocator, list.data);
4010  return;
4011  }
4012  }
4013  }
4014 
4023  {
4024  if (nIndex < 0) return NULL;
4025  if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) return NULL;
4026  DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
4027  if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count){
4028  pCurList = NULL;
4029  FX_INT32 iStart = 0;
4030  FX_INT32 iEnd = m_DataLists.GetUpperBound();
4031  while (iStart <= iEnd){
4032  FX_INT32 iMid = (iStart + iEnd) / 2;
4033  DataList* list = m_DataLists.GetDataPtr(iMid);
4034  if (nIndex < list->start)
4035  iEnd = iMid - 1;
4036  else if (nIndex >= list->start + list->count)
4037  iStart = iMid + 1;
4038  else {
4039  pCurList = list;
4040  m_CurList = iMid;
4041  break;
4042  }
4043  }
4044  }
4045  return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
4046  }
4047 
4048  protected:
4049  FX_BOOL Append(const DataList& list)
4050  {
4051  FX_INT32 iStart = 0;
4052  FX_INT32 iEnd = m_DataLists.GetUpperBound();
4053  FX_INT32 iFind = 0;
4054  while (iStart <= iEnd) {
4055  FX_INT32 iMid = (iStart + iEnd) / 2;
4056  DataList* cur_list = m_DataLists.GetDataPtr(iMid);
4057  if (list.start == cur_list->start){
4058  return false; // lists overlap, no op
4059  } else if (list.start < cur_list->start + cur_list->count)
4060  iEnd = iMid - 1;
4061  else{
4062  if (iMid == iEnd){
4063  iFind = iMid + 1;
4064  break;
4065  }
4066  DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
4067  if (list.start == next_list->start){
4068  return false; // lists overlap, no op
4069  } else if (list.start < next_list->start){
4070  iFind = iMid + 1;
4071  break;
4072  } else {
4073  iStart = iMid + 1;
4074  }
4075  }
4076  }
4077  m_DataLists.InsertAt(iFind, list);
4078  return true;
4079  }
4080 
4081  FX_INT32 m_CurList;
4082  CFX_ArrayTemplate<DataList> m_DataLists;
4083 };
4084 
4086 template<typename T1, typename T2>
4087 class CFX_ListArrayTemplate : public CFX_Object
4088 {
4089  public:
4095  void Clear()
4096  {
4097  m_Data.Clear();
4098  }
4099 
4108  void Add(FX_INT32 nStart, FX_INT32 nCount)
4109  {
4110  m_Data.Append(nStart, nCount);
4111  }
4112 
4121  {
4122  FX_LPBYTE data = m_Data.GetAt(nIndex);
4123  FXSYS_assert(data != NULL);
4124 
4125  return (T2&)(*(volatile T2*)data);
4126  }
4127 
4135  T2* GetPtrAt(FX_INT32 nIndex)
4136  {
4137  return (T2*)m_Data.GetAt(nIndex);
4138  }
4139  protected:
4140  T1 m_Data;
4141 };
4142 
4147 
4153 typedef enum {
4167 
4168 #define ProgressiveStatus FX_ProgressiveStatus
4169 
4170 #ifdef _FX_NO_NAMESPACE_
4171 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT
4172 #define FX_NAMESPACE_DECLARE(namespace, type) type
4173 //<<<+++OPENSOURCE_END
4174 #else
4175 //<<<+++OPENSOURCE_BEGIN LIC==GOOGLE
4176 #define FX_NAMESPACE_DECLARE(namespace, type) namespace::type
4177 //<<<+++OPENSOURCE_END
4178 #endif
4179 
4182 {
4183  public:
4189  virtual FX_DWORD Release() = 0;
4190 
4196  virtual FX_DWORD AddRef() = 0;
4197 
4198  protected:
4199  virtual ~IFX_Unknown() {}
4200 };
4201 
4203 #define FX_IsOdd(a) ((a) & 1)
4204 
4205 //<<<+++OPENSOURCE_MUST_END
4206 
4207 //<<<+++OPENSOURCE_MUST_BEGIN
4208 #endif // _FX_BASIC_H_
4209 //<<<+++OPENSOURCE_MUST_END
4210 
4213 //<<<+++OPENSOURCE_END
Definition: fx_basic.h:3752
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:2758
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:3262
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:3016
CFX_WideStringC GetResult() const
Get the result.
Definition: fx_basic.h:1051
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:632
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:2057
Definition: fx_basic.h:4181
Ready.
Definition: fx_basic.h:4155
~CFX_MapByteStringToPtr()
The destructor.
void Add(const ObjectClass &data)
Add a copy of an existing object to the array.
Definition: fx_basic.h:1685
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:708
Bidirectional node in CFX_PtrList.
Definition: fx_basic.h:3013
FX_LPVOID m_pModuleId
Module ID.
Definition: fx_basic.h:3244
CFX_ByteStringC GetResult() const
Get the result.
Definition: fx_basic.h:1107
TYPE & operator[](int nIndex)
Subscript([]) operator overload. This function returns a reference to the specified element specified...
Definition: fx_basic.h:1549
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:702
Definition: fx_basic.h:1074
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:2013
FX_BOOL IsEmpty() const
Verify whether the map is empty.
Definition: fx_basic.h:2373
FX_POSITION InsertAfter(FX_POSITION pos, void *newElement)
Insert a value after specified position.
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1205
ElementType & operator[](int index)
Subscript([]) operator overload. This function returns a ref to the specified element specified by th...
Definition: fx_basic.h:2209
Not Found.
Definition: fx_basic.h:4161
Association in CFX_MapByteStringToPtr.
Definition: fx_basic.h:2694
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL to use default allocator.
Definition: fx_basic.h:1171
void Incref()
Increase the reference.
Definition: fx_basic.h:3710
void Delete(int index, int count=1)
Delete a number of elements.
Definition: fx_basic.h:1860
~CFX_ObjectArray()
The destructor.
Definition: fx_basic.h:1649
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:1050
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:1615
TYPE & ElementAt(int nIndex)
This method retrieves a ref to an element specified by an index number.
Definition: fx_basic.h:1416
CFX_ObjectArray(const CFX_ObjectArray &other, IFX_Allocator *pAllocator=0)
The copy constructor.
Definition: fx_basic.h:1657
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:4135
void Push(const CFX_ByteString &val)
Push the byte string to stack.
Definition: fx_basic.h:2045
CFX_ArrayTemplate< FX_WORD > CFX_WordArray
Type definition for a word array type.
Definition: fx_basic.h:1613
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:3630
CFX_FixedBufGrow(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2228
void * data
Node data.
Definition: fx_basic.h:3020
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:1937
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:2702
void SetAt(KeyType key, ValueType newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2582
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:2781
FX_INT32(* m_GetCodePage)()
A pointer type to GetCodePage function. The function return a code page of the platform.
Definition: fx_basic.h:993
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:2411
void(* PD_CALLBACK_FREEDATA)(FX_LPVOID pData)
Definition: fx_basic.h:3229
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:712
CFX_ObjectArray & operator=(const CFX_ObjectArray &other)
The assignment operator.
Definition: fx_basic.h:1670
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:3256
void * Add()
Add an element.
#define GetObject
Get object information. GetObjectW defined for unicode-mode, GetObjectA for ansi-mode.
Definition: fx_system.h:540
FX_LPVOID m_pData
Private data.
Definition: fx_basic.h:3247
CFX_WideTextBuf(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:345
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:3935
CFX_Stack()
Construct.
Definition: fx_basic.h:1996
~CFX_CountRef()
Destruct a reference and release the object it refers to.
Definition: fx_basic.h:3537
void RemoveAt(int index)
Remove an object at specified position.
Definition: fx_basic.h:1831
int GetSize() const
Get number of elements in the array.
Definition: fx_basic.h:2124
int GetCurBytePos()
Get current byte position.
Definition: fx_basic.h:3474
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:1351
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:3078
Definition: fx_basic.h:765
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:1768
Definition: fx_basic.h:2175
CFX_UTF8Encoder(IFX_Allocator *pAllocator=0)
A constructor. Set the encoder to initial.
Definition: fx_basic.h:1082
void SetStream(IFX_FileStream *pStream)
Set the attached stream.
Definition: fx_basic.h:630
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:2299
#define FX_MIN(a, b)
A macro that returns the minimum of a and b.
Definition: fx_system.h:801
FX_BOOL Abort() const
Indicate whether to abort the filter process.
Definition: fx_basic.h:3823
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:1116
CFX_CMapDWordToDWord(IFX_Allocator *pAllocator=0)
Constructor with allocator.
Definition: fx_basic.h:2622
int GetUnitSize() const
Get number of bytes for each element.
Definition: fx_basic.h:2138
Definition: fx_basic.h:1926
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_ListArrayTemplate< CFX_SortListArray< sizeof(FX_INT64)>, FX_INT64 > CFX_FileSizeListArray
Type definition for file size list array.
Definition: fx_basic.h:4144
CFX_UTF8Decoder(IFX_Allocator *pAllocator=0)
A constructor. Set the decoder to initial.
Definition: fx_basic.h:1012
CFX_CountRef< ObjClass > Ref
Type definition: it is used short for CFX_CountRef<ObjClass>.
Definition: fx_basic.h:3493
CFX_ObjectArray(IFX_Allocator *pAllocator=0)
The constructor.
Definition: fx_basic.h:1644
Stream writing interface.
Definition: fx_stream.h:422
CFX_Stack()
Construct.
Definition: fx_basic.h:1864
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:636
CFX_PrivateData(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:3270
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:2131
void Input(FX_WCHAR unicode)
Input a unicode.
FX_INTPTR GetLength() const
Get the length of saved data.
Definition: fx_basic.h:614
Memory allocation error.
Definition: fx_basic.h:1301
FX_LPCBYTE GetBuffer() const
Get the constant byte pointer to the saved data.
Definition: fx_basic.h:621
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.
T & operator*(void)
Get the object reference operator.
Definition: fx_basic.h:3912
ObjectClass & operator[](int index) const
Subscript([]) operator overload. This function returns a reference to the specified object specified ...
Definition: fx_basic.h:1809
FX_BOOL Copy(const CFX_ArrayTemplate &src)
Copy from an array.
Definition: fx_basic.h:1489
FX_BOOL SetSize(int nNewSize, int nGrowBy=-1)
Change the allocated size and the grow amount.
Definition: fx_basic.h:1368
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:336
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
int m_RefCount
The reference count.
Definition: fx_basic.h:3512
Definition: fx_basic.h:3887
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:2342
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:3781
FX_BOOL Append(const CFX_ArrayTemplate &src)
Append an array.
Definition: fx_basic.h:1480
FX_BOOL RemoveKey(KeyType key)
Remove existing (key, ?) pair.
Definition: fx_basic.h:2591
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:661
FX_BOOL Lookup(KeyType key, ValueType &rValue) const
Lookup by a key.
Definition: fx_basic.h:2556
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:3518
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:1378
FX_POSITION GetHeadPosition() const
Get the header position.
Definition: fx_basic.h:3038
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:1463
CFX_ArrayTemplate< FX_INT32 > CFX_Int32Array
Type definition for INT32 array.
Definition: fx_basic.h:1623
Definition: fx_basic.h:2902
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
T * operator->(void)
Get the object pointer operator.
Definition: fx_basic.h:3919
Association in CFX_MapPtrToPtr.
Definition: fx_basic.h:2335
int GetCount() const
Get the number of elements.
Definition: fx_basic.h:2722
~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:669
ErrorType
Enumeration for error type.
Definition: fx_basic.h:1296
void RemoveAll()
Remove all (key, value) pair.
Definition: fx_basic.h:2677
virtual void Clear()
Clear the text buffer.
~CFX_TempBuf()
The Destructor.
Definition: fx_basic.h:2307
Definition: fx_basic.h:3929
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:4087
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:683
void AppendChar(FX_DWORD ch)
Append characters to wide text buffer.
Definition: fx_basic.h:3009
FX_INT32 Append(const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
Append an array.
Definition: fx_basic.h:1733
FX_INT32 count
The data count.
Definition: fx_basic.h:3937
T * Get(void)
Get the object pointer.
Definition: fx_basic.h:3905
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:973
The data list.
Definition: fx_basic.h:3933
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:2602
FX_BOOL IsExhaustBuffer() const
Indicate whether this filter exhausts the input buffer.
Definition: fx_basic.h:3809
FX_LPBYTE GetAt(FX_INT32 nIndex)
Get the data.
Definition: fx_basic.h:4022
File stream interface, reading & writing.
Definition: fx_stream.h:649
FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
Set an element value at specified position. Potentially growing the array.
Definition: fx_basic.h:1447
Found.
Definition: fx_basic.h:4159
void AppendStr(FX_BSTR str)
Append a non-buffered byte string.
Definition: fx_basic.h:1100
CFX_ObjectStack()
Construct.
Definition: fx_basic.h:1930
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:1060
CFX_ArrayTemplate< FX_INT64 > CFX_FileSizeArray
Type definition for file size array type.
Definition: fx_basic.h:1619
UINT_PTR FX_UINTPTR
Unsigned integral type for pointer precision.
Definition: fx_system.h:728
TYPE * InsertSpaceAt(int nIndex, int nCount)
Insert a number of elements.
Definition: fx_basic.h:1515
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:3700
FX_BOOL RemoveAt(int nIndex, int nCount=1)
Remove a number of elements at specified position.
Definition: fx_basic.h:1582
Definition: fx_basic.h:3737
void Rewind()
Rewind a bit-stream. Simply set the current bit position to be zero.
Definition: fx_basic.h:3428
FX_DWORD GetHashTableSize() const
Get the internal hash table size. Advanced features for derived classes.
Definition: fx_basic.h:2808
CFX_ObjectArray< CFX_WideString > CFX_WideStringArray
Type definition for a CFX_WideString array type.
Definition: fx_basic.h:1854
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:3574
void * GetNext(FX_POSITION &rPosition) const
Get the the current value and set the position to next node.
Definition: fx_basic.h:3054
FX_DWORD nHashValue
Cached hash value, needed for efficient iteration.
Definition: fx_basic.h:2700
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:3066
CFX_ArrayTemplate(const CFX_ArrayTemplate &other, IFX_Allocator *pAllocator=0)
The copy constructor.
Definition: fx_basic.h:1321
void * AddSpace()
Add an empty space to the array.
Definition: fx_basic.h:1718
TYPE & Top()
Get the top byte string.
Definition: fx_basic.h:1957
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:3895
Definition: fx_basic.h:3489
void ResetStatistics()
Reset statistics.
Definition: fx_basic.h:1288
T2 & operator[](FX_INT32 nIndex)
Subscript([]) operator overload.
Definition: fx_basic.h:4120
const TYPE GetAt(int nIndex) const
This method retrieves an element specified by an index number.
Definition: fx_basic.h:1387
ObjectClass & Add()
Add an empty object to the array.
Definition: fx_basic.h:1702
CFX_ArrayTemplate(IFX_Allocator *pAllocator=0)
Constructor, from an allocator.
Definition: fx_basic.h:1312
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:645
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:3985
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:3509
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:1430
CFX_ArrayTemplate & operator=(const CFX_ArrayTemplate &src)
Assignment operator overload.
Definition: fx_basic.h:1524
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:1533
CFX_ArrayTemplate< FX_BYTE > CFX_ByteArray
Type definition for a byte array type.
Definition: fx_basic.h:1611
Foxit allocator interface.
Definition: fx_memory.h:960
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:3421
CFX_SegmentedArray(int segment_units, int index_size=8, IFX_Allocator *pAllocator=0)
Construct with specified segment units.
Definition: fx_basic.h:2185
CNode * pPrev
Pointer to previous node.
Definition: fx_basic.h:3018
void Pop()
Pop the byte string from stack.
Definition: fx_basic.h:2033
Definition: fx_basic.h:947
void RemoveAll()
Remove all key-value pairs in the map.
Invalid array size.
Definition: fx_basic.h:1298
FX_STRSIZE GetLength() const
Get the length of the wide text buffer.
Definition: fx_basic.h:433
CFX_ListArrayTemplate< CFX_SortListArray< sizeof(FX_DWORD)>, FX_DWORD > CFX_DWordListArray
Type definition for FX_DWORD list array.
Definition: fx_basic.h:4146
void Add(ElementType data)
Add an element.
Definition: fx_basic.h:2197
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:663
FX_BOOL IsEmpty() const
Verify whether the map is empty.
Definition: fx_basic.h:2729
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:3528
#define FXSYS_assert
Assertion.
Definition: fx_system.h:779
TYPE * AddSpace()
Add an element's space.
Definition: fx_basic.h:1505
CFX_ArchiveLoader & operator>>(FX_BYTE &i)
Right shifts(>>) operator overload. De-serialize a byte.
CAssoc * pNext
Pointer to next association.
Definition: fx_basic.h:2697
TYPE * GetDataPtr(int index)
Get a pointer to the specified element in the array. Direct pointer access.
Definition: fx_basic.h:1498
FX_INT32 AppendByte(FX_BYTE byte)
Append a single byte.
int GetCount() const
Get the number of elements.
Definition: fx_basic.h:2366
void SetAt(FX_POSITION pos, void *newElement)
Change the value at specified position.
Definition: fx_basic.h:3134
FX_POSITION AddHead(void *newElement)
Add a value to the head.
CFX_ArchiveSaver(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:485
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:450
FX_BOOL SetAt(int nIndex, TYPE newElement)
This method overwrites an element specified by an index number.
Definition: fx_basic.h:1403
int GetSize() const
Get the size of the array.
Definition: fx_basic.h:1799
CFX_ByteString & Top()
Get the top byte string.
Definition: fx_basic.h:2023
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:3096
FX_POSITION GetTailPosition() const
Get the tail position.
Definition: fx_basic.h:3045
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:1871
~CFX_AutoRestorer()
The destructor.
Definition: fx_basic.h:3879
~CFX_BaseSegmentedArray()
The destructor.
CFX_MapPtrTemplate(IFX_Allocator *pAllocator=0)
Default constructor.
Definition: fx_basic.h:2546
Definition: fx_basic.h:1002
FX_STRSIZE GetLength() const
Get the length of the byte text buffer.
Definition: fx_basic.h:330
Definition: fx_basic.h:2538
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:2003
Definition: fx_basic.h:3234
Definition: fx_basic.h:2289
FX_LPVOID GetNextValue(FX_POSITION &rNextPosition) const
Get the the current value and set the position to next association.
Definition: fx_basic.h:642
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:3952
CFX_BinaryBuf m_Buffer
Definition: fx_basic.h:2681
Failed.
Definition: fx_basic.h:4163
void * key
Key data.
Definition: fx_basic.h:2340
FX_LPWSTR GetBuffer() const
Get a wide character pointer.
Definition: fx_basic.h:440
~CFX_FixedBufGrow()
The Destructor.
Definition: fx_basic.h:2274
Done.
Definition: fx_basic.h:4165
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:1332
CFX_FixedBufGrow(int data_size, IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2242
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
TYPE * GetData()
Direct Access to the element data (may return NULL).
Definition: fx_basic.h:1437
Definition: fx_basic.h:1636
CFX_ObjectArray< CFX_ByteString > CFX_ByteStringArray
Type definition for a CFX_ByteString array type.
Definition: fx_basic.h:1852
FX_BOOL LookupPrivateData(FX_LPVOID module_id, FX_LPVOID &pData) const
Lookup a private data.
Definition: fx_basic.h:3334
~CFX_SmartPointer()
The destructor.
Definition: fx_basic.h:3898
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:3553
Define a class here derived from user data class, with an additional reference count member.
Definition: fx_basic.h:3498
CFX_ArrayTemplate< FX_FLOAT > CFX_FloatArray
Type definition for float array.
Definition: fx_basic.h:1621
void ClearStatus()
Clear the decoding status.
Definition: fx_basic.h:1044
~CFX_SortListArray()
The destructor.
Definition: fx_basic.h:3955
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:2455
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:3639
TYPE & Top()
Get the top byte data.
Definition: fx_basic.h:1891
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:2219
CFX_BitWriter(CFX_BinaryBuf *pBinBuf)
A constructor with bits write.
Definition: fx_basic.h:3450
FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray *pNewArray)
Inset an array at specified position.
Definition: fx_basic.h:1592
~CFX_FileBufferArchive()
The destructor.
void Clear()
Clear data.
Definition: fx_basic.h:4095
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:4157
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:2572
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:781
Definition: fx_basic.h:1167
FX_BOOL CopyData(const void *pBuf, FX_STRSIZE size)
Copy from another buffer.
CFX_AutoRestorer(T *location)
The constructor.
Definition: fx_basic.h:3873
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:647
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:2260
FX_BOOL Lookup(void *key, void *&rValue) const
Lookup by a key.
FX_ProgressiveStatus
Enumeration for progressive status.
Definition: fx_basic.h:4153
void Pop()
Pop the data from stack.
Definition: fx_basic.h:1901
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:710
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:1566
Index out of range.
Definition: fx_basic.h:1304
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL means to use default allocator.
Definition: fx_basic.h:2151
FX_BOOL IsEOF() const
Detect EOF.
Definition: fx_basic.h:3774
void Push(const TYPE &val)
Push the byte string to stack.
Definition: fx_basic.h:1979
~CFX_CMapByteStringToPtr()
The destructor.
void TakeOver(CFX_BinaryBuf &other)
Takeover another buffer.
#define NULL
The null-pointer value.
Definition: fx_system.h:767
void * GetValueAt(void *key) const
Get a value pointer by a key.
FX_INT32 AppendInt64(FX_INT64 i)
Append a FX_INT64 value.
int GetUpperBound() const
Get the upper bound in the array, actually the maximum valid index.
Definition: fx_basic.h:1358
int Size() const
Get size of the container.
Definition: fx_basic.h:1947
void RemoveKey(FX_BSTR key)
Removing existing (key, ?) pair.
Definition: fx_basic.h:2614
Definition: fx_basic.h:2329
Definition: fx_basic.h:3442
FX_BOOL IsEOF() const
Check if reached end of the stream.
Definition: fx_basic.h:3412
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:1913
#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:2434
Definition: fx_basic.h:2688
void Clear()
Clear the data list.
Definition: fx_basic.h:3965
CountedObj()
The constructor.
Definition: fx_basic.h:3502
void RemoveAll()
Remove all objects in the array.
Definition: fx_basic.h:1843
int GetCount() const
Get the number of nodes.
Definition: fx_basic.h:3106
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:3652
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:1881
#define FX_Allocator_Free(fxAllocator, ptr)
Free memory block on an allocator.
Definition: fx_memory.h:1057
FX_POSITION GetPrevPosition(FX_POSITION pos) const
Get the previous position.
Definition: fx_basic.h:3087
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:3250
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:986
Definition: fx_basic.h:3378
void SetNull()
Set the pointer of the object to be null.
Definition: fx_basic.h:3674
Definition: fx_basic.h:3866
CFX_ArrayTemplate< FX_WCHAR > CFX_WCHARArray
Type definition for FX_WHAR array.
Definition: fx_basic.h:1625
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:3690
ObjectClass * GetDataPtr(int index) const
Get a pointer to the specified element in the array. Direct pointer access.
Definition: fx_basic.h:1822
void * value
Value data.
Definition: fx_basic.h:2704
INT_PTR FX_INTPTR
Signed integral type for pointer precision.
Definition: fx_system.h:726
Header file for exception class.
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:643
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:1967
Definition: fx_basic.h:868
void Decref()
Decrease the reference.
Definition: fx_basic.h:3721
virtual ~IFX_Pause()
Destructor.
Definition: fx_basic.h:3741
CFX_ArrayTemplate< void * > CFX_PtrArray
Type definition for: a typeless pointer array type.
Definition: fx_basic.h:1617
Definition: fx_basic.h:476
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:1601
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:4108
CAssoc * pNext
Pointer to next association.
Definition: fx_basic.h:2338