My Project
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  protected:
1173  /*
1174  * @brief Construct with specified unit size.
1175  *
1176  * @param[in] unit_size The specified unit size. Must be greater than 0 and less than 2^28.
1177  * @param[in] pAllocator Allocator used in this class. <b>NULL</b> means to use default allocator.
1178  * Default value: <b>NULL</b>.
1179  */
1180  CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL);
1181  //<<<+++OPENSOURCE_END
1182 
1183  /*
1184  * @brief The destructor.
1185  */
1186  ~CFX_BasicArray();
1187 
1188  /*
1189  * @brief The copy constructor.
1190  *
1191  * @param[in] other The other CFX_BasicArray object.
1192  * @param[in] pAllocator An allocator.
1193  */
1194  CFX_BasicArray(const CFX_BasicArray& other, IFX_Allocator* pAllocator = NULL);
1195 
1196  /*
1197  * @brief The assignment operator.
1198  *
1199  * @param[in] other The other CFX_BasicArray object.
1200  *
1201  * @return Reference to current object itself.
1202  */
1203  CFX_BasicArray& operator=(const CFX_BasicArray& other);
1204 
1205  /*
1206  * @brief Change the allocated size and the grow amount.
1207  *
1208  * @param[in] nNewSize The new size in elements expected.
1209  * @param[in] nGrowBy The grow amount in elements expected, nGrowBy can be -1 for the grow amount unchanged.
1210  *
1211  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter or memory error).
1212  */
1213  FX_BOOL SetSize(int nNewSize, int nGrowBy);
1214 
1215  /*
1216  * @brief Append a basic array.
1217  *
1218  * @param[in] src The input basic array. It must have the save unit size as the current array.
1219  *
1220  * @return <b>true</b> means success, while <b>false</b> means failure (such as memory error).
1221  */
1222  FX_BOOL Append(const CFX_BasicArray& src);
1223 
1224  /*
1225  * @brief Copy from a basic array.
1226  *
1227  * @param[in] src The input basic array. It must have the save unit size as the current array.
1228  *
1229  * @return <b>true</b> means success, while <b>false</b> means failure (such as memory error).
1230  */
1231  FX_BOOL Copy(const CFX_BasicArray& src);
1232 
1233  /*
1234  * @brief Insert spaces at specified position.
1235  *
1236  * @param[in] nIndex Specifies the zero-based index of element in the basic array.
1237  * @param[in] nCount Specifies the count of element to insert.
1238  *
1239  * @return A byte pointer to the inserted space. <b>NULL</b> means error.
1240  */
1241  FX_LPBYTE InsertSpaceAt(int nIndex, int nCount);
1242 
1243  /*
1244  * @brief Remove a number of elements.
1245  *
1246  * @param[in] nIndex Specifies the zero-based index of start element in the basic array to be removed.
1247  * @param[in] nCount Specifies the count of element to remove.
1248  *
1249  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter error).
1250  */
1251  FX_BOOL RemoveAt(int nIndex, int nCount);
1252 
1253  /*
1254  * @brief Insert a basic array at specified position.
1255  *
1256  * @param[in] nStartIndex Specifies the zero-based index of start element to insert at.
1257  * @param[in] pNewArray The input basic array. It must have the save unit size as the current array.
1258  *
1259  * @return <b>true</b> means success, while <b>false</b> means failure (such as parameter or memory error).
1260  */
1261  FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray);
1262 
1263  /*
1264  * @brief Get a typeless pointer to an element data.
1265  *
1266  * @param[in] index Specifies the zero-based index of element.
1267  *
1268  * @return A typeless pointer to the element data. <b>NULL</b> means error.
1269  */
1270  const void* GetDataPtr(int index) const;
1271 
1272  protected:
1273  /* The actual array of data */
1274  FX_LPBYTE m_pData;
1275  /* # of elements (upperBound - 1) */
1276  int m_nSize;
1277  /* Max allocated */
1278  int m_nMaxSize;
1279  /* Grow amount. */
1280  int m_nGrowBy;
1281  /* Number of bytes in one unit. */
1282  int m_nUnitSize;
1283 };
1284 
1286 template<class TYPE>
1288 {
1289  public:
1295  enum ErrorType {
1298 
1301 
1304  };
1305 
1311  CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(TYPE), pAllocator) {}
1312  //<<<+++OPENSOURCE_END
1313 
1320  CFX_ArrayTemplate(const CFX_ArrayTemplate& other, IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(other, pAllocator) {}
1321 
1331  void FX_Error(ErrorType error, FX_INT32 badIndex = 0) const
1332  {
1333  const char *errorMsg[] = {
1334  "Invalid array size",
1335  "Memory allocation error",
1336  "Invalid index:"
1337  };
1338 
1339  fprintf(stderr, "%s\n", errorMsg[error]);
1340  if (error == indexOutOfRange)
1341  fprintf(stderr, "%i\n", badIndex);
1342  abort();
1343  }
1344 
1350  int GetSize() const { return m_nSize; }
1351 
1357  int GetUpperBound() const { return m_nSize - 1; }
1358 
1367  FX_BOOL SetSize(int nNewSize, int nGrowBy = -1)
1368  {
1369  return CFX_BasicArray::SetSize(nNewSize, nGrowBy);
1370  }
1371 
1377  void RemoveAll() { SetSize(0, -1); }
1378 
1386  const TYPE GetAt(int nIndex) const {
1387  if (nIndex < 0 || nIndex >= m_nSize)
1388  //return (const TYPE&)(*(volatile const TYPE*)NULL);
1389  //In order to avoid crash, we input the index.(For reasons unknown)
1390  FX_Error(indexOutOfRange, nIndex);
1391  return ((const TYPE*)m_pData)[nIndex];
1392  }
1393 
1402  FX_BOOL SetAt(int nIndex, TYPE newElement) {
1403  if (nIndex < 0 || nIndex >= m_nSize) return false;
1404  ((TYPE*)m_pData)[nIndex] = newElement;
1405  return true;
1406  }
1407 
1415  TYPE& ElementAt(int nIndex)
1416  {
1417  if (nIndex < 0 || nIndex >= m_nSize)
1418  //return *(TYPE*)NULL;
1419  //In order to avoid crash, we input the index.(For reasons unknown)
1420  FX_Error(indexOutOfRange, nIndex);
1421  return ((TYPE*)m_pData)[nIndex];
1422  }
1423 
1429  const TYPE* GetData() const { return (const TYPE*)m_pData; }
1430 
1436  TYPE* GetData() { return (TYPE*)m_pData; }
1437 
1446  FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
1447  {
1448  if (nIndex < 0) return false;
1449  if (nIndex >= m_nSize)
1450  if (!SetSize(nIndex+1, -1)) return false;
1451  ((TYPE*)m_pData)[nIndex] = newElement;
1452  return true;
1453  }
1454 
1462  FX_BOOL Add(TYPE newElement)
1463  {
1464  if (m_nSize < m_nMaxSize)
1465  m_nSize++;
1466  else
1467  if (!SetSize(m_nSize+1, -1)) return false;
1468  ((TYPE*)m_pData)[m_nSize-1] = newElement;
1469  return true;
1470  }
1478  FX_BOOL Append(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Append(src); }
1479 
1487  FX_BOOL Copy(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Copy(src); }
1488 
1496  TYPE* GetDataPtr(int index) { return (TYPE*)CFX_BasicArray::GetDataPtr(index); }
1497 
1503  TYPE* AddSpace() { return (TYPE*)CFX_BasicArray::InsertSpaceAt(m_nSize, 1); }
1504 
1513  TYPE* InsertSpaceAt(int nIndex, int nCount) { return (TYPE*)CFX_BasicArray::InsertSpaceAt(nIndex, nCount); }
1514 
1522  CFX_ArrayTemplate& operator=(const CFX_ArrayTemplate& src) { CFX_BasicArray::operator=(src); return *this; }
1523 
1531  const TYPE operator[](int nIndex) const
1532  {
1533  if (nIndex < 0 || nIndex >= m_nSize)
1534  //Merge from google trunk r2049, author: Johnson, date:2012.12.07
1535  *(volatile char*)0 = '\0';
1536  return ((const TYPE*)m_pData)[nIndex];
1537  }
1538 
1547  TYPE& operator[](int nIndex)
1548  {
1549  if (nIndex < 0 || nIndex >= m_nSize)
1550  //Merge from google trunk r2049, author: Johnson, date:2012.12.07
1551  *(volatile char*)0 = '\0';
1552  return ((TYPE*)m_pData)[nIndex];
1553  }
1554 
1564  FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1)
1565  {
1566  if (!InsertSpaceAt(nIndex, nCount)) return false;
1567  while (nCount--)
1568  ((TYPE*)m_pData)[nIndex++] = newElement;
1569  return true;
1570  }
1571 
1580  FX_BOOL RemoveAt(int nIndex, int nCount = 1) { return CFX_BasicArray::RemoveAt(nIndex, nCount); }
1581 
1590  FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) { return CFX_BasicArray::InsertAt(nStartIndex, pNewArray); }
1591 
1600  int Find(const TYPE& data, int iStart = 0) const
1601  {
1602  if (iStart < 0) return -1;
1603  for (; iStart < (int)m_nSize; iStart++)
1604  if (((TYPE*)m_pData)[iStart] == data) return iStart;
1605  return -1;
1606  }
1607 };
1608 
1625 
1634 template <class ObjectClass>
1636 {
1637  public:
1643  CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(ObjectClass), pAllocator) {}
1644 
1649 
1656  CFX_ObjectArray(const CFX_ObjectArray& other, IFX_Allocator* pAllocator = NULL)
1657  : CFX_BasicArray(sizeof(ObjectClass), pAllocator)
1658  {
1659  Copy(other);
1660  }
1661 
1670  {
1671  Copy(other);
1672  return *this;
1673  }
1674 
1684  void Add(const ObjectClass& data)
1685  {
1686 #ifndef _FX_NOPLACEMENTNEW_
1687  new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
1688 #else
1689  ::new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
1690 #endif
1691 
1692  }
1693 
1701  ObjectClass& Add()
1702  {
1703 #ifndef _FX_NOPLACEMENTNEW_
1704  return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
1705 #else
1706  return *(ObjectClass*) ::new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
1707 #endif
1708  }
1709 
1717  void* AddSpace()
1718  {
1719  return InsertSpaceAt(m_nSize, 1);
1720  }
1721 
1732  FX_INT32 Append(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
1733  {
1734  if (nCount == 0) return 0;
1735  FX_INT32 nSize = src.GetSize();
1736  if (!nSize) return 0;
1737  FXSYS_assert(nStart > -1 && nStart < nSize);
1738  if (nCount < 0) nCount = nSize;
1739  if (nStart + nCount > nSize) nCount = nSize - nStart;
1740  if (nCount < 1) return 0;
1741  nSize = m_nSize;
1742  InsertSpaceAt(m_nSize, nCount);
1743  ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
1744  nSize = nStart + nCount;
1745  for (FX_INT32 i = nStart; i < nSize; i++, pStartObj++)
1746  {
1747 #ifndef _FX_NOPLACEMENTNEW_
1748  new ((void*)pStartObj) ObjectClass(src[i]);
1749 #else
1750  ::new ((void*)pStartObj) ObjectClass(src[i]);
1751 #endif
1752 
1753  }
1754  return nCount;
1755  }
1756 
1767  FX_INT32 Copy(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1)
1768  {
1769  if (this == &src) return 0;
1770  RemoveAll();
1771  if (nCount == 0) return 0;
1772  FX_INT32 nSize = src.GetSize();
1773  if (!nSize) return 0;
1774  FXSYS_assert(nStart > -1 && nStart < nSize);
1775  if (nCount < 0) nCount = nSize;
1776  if (nStart + nCount > nSize) nCount = nSize - nStart;
1777  if (nCount < 1) return 0;
1778  nSize = nStart + nCount;
1779  SetSize(nCount, -1);
1780  ObjectClass* pStartObj = (ObjectClass*)m_pData;
1781  for (FX_INT32 i = nStart; i < nSize; i++, pStartObj++)
1782  {
1783 #ifndef _FX_NOPLACEMENTNEW_
1784  new ((void*)pStartObj) ObjectClass(src[i]);
1785 #else
1786  ::new ((void*)pStartObj) ObjectClass(src[i]);
1787 #endif
1788 
1789  }
1790  return nCount;
1791  }
1792 
1798  int GetSize() const { return m_nSize; }
1799 
1808  ObjectClass& operator[] (int index) const
1809  {
1810  FXSYS_assert(index < m_nSize);
1811  return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
1812  }
1813 
1821  ObjectClass* GetDataPtr(int index) const { return (ObjectClass*)CFX_BasicArray::GetDataPtr(index); }
1822 
1830  void RemoveAt(int index)
1831  {
1832  FXSYS_assert(index < m_nSize);
1833  ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
1834  CFX_BasicArray::RemoveAt(index, 1);
1835  }
1836 
1842  void RemoveAll()
1843  {
1844  for (int i = 0; i < m_nSize; i++)
1845  ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
1846  CFX_BasicArray::SetSize(0, -1);
1847  }
1848 };
1849 
1854 
1858 template <class TYPE>
1859 class CFX_Stack : CFX_Object
1860 {
1861  public:
1864 
1870  FX_BOOL Empty() const
1871  {
1872  return m_Container.GetSize() == 0;
1873  }
1874 
1880  int Size() const
1881  {
1882  return m_Container.GetSize();
1883  }
1884 
1890  TYPE& Top()
1891  {
1892  return m_Container[Size() - 1];
1893  }
1894 
1900  void Pop()
1901  {
1902  m_Container.RemoveAt(Size() - 1);
1903  }
1904 
1912  void Push(const TYPE& val)
1913  {
1914  m_Container.Add(val);
1915  }
1916 
1917  private:
1918  CFX_ArrayTemplate<TYPE> m_Container;
1919 };
1920 
1924 template <class TYPE>
1925 class CFX_ObjectStack : CFX_Object
1926 {
1927  public:
1930 
1936  FX_BOOL Empty() const
1937  {
1938  return m_Container.GetSize() == 0;
1939  }
1940 
1946  int Size() const
1947  {
1948  return m_Container.GetSize();
1949  }
1950 
1956  TYPE& Top()
1957  {
1958  return m_Container[Size() - 1];
1959  }
1960 
1966  void Pop()
1967  {
1968  m_Container.RemoveAt(Size() - 1);
1969  }
1970 
1978  void Push(const TYPE& val)
1979  {
1980  m_Container.Add(val);
1981  }
1982 
1983  private:
1984  CFX_ObjectArray<TYPE> m_Container;
1985 };
1986 
1990 template <>
1991 class CFX_Stack<CFX_ByteString> : CFX_Object
1992 {
1993  public:
1996 
2002  FX_BOOL Empty() const
2003  {
2004  return m_Container.GetSize() == 0;
2005  }
2006 
2012  int Size() const
2013  {
2014  return m_Container.GetSize();
2015  }
2016 
2023  {
2024  return m_Container[Size() - 1];
2025  }
2026 
2032  void Pop()
2033  {
2034  m_Container.RemoveAt(Size() - 1);
2035  }
2036 
2044  void Push(const CFX_ByteString& val)
2045  {
2046  m_Container.Add(val);
2047  }
2048 
2049  private:
2050  CFX_ObjectArray<CFX_ByteString> m_Container;
2051 };
2052 
2056 class CFX_BaseSegmentedArray : public CFX_Object
2057 {
2058  public:
2067  CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8, IFX_Allocator* pAllocator = NULL);
2068 
2073 
2083  void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
2084 
2090  void* Add();
2091 
2099  void* GetAt(int index) const;
2100 
2106  void RemoveAll();
2107 
2116  void Delete(int index, int count = 1);
2117 
2123  int GetSize() const { return m_DataSize; }
2124 
2130  int GetSegmentSize() const { return m_SegmentSize; }
2131 
2137  int GetUnitSize() const { return m_UnitSize; }
2138 
2147  void* Iterate(FX_BOOL(*callback)(void* param, void* pData), void* param) const;
2148 
2151  private:
2152  /* Unit size */
2153  int m_UnitSize;
2154  /* Count of units in each segment. */
2155  short m_SegmentSize;
2156  /* Number of index level in the array. */
2157  FX_BYTE m_IndexSize;
2158  /* The current level in the index tree. */
2159  FX_BYTE m_IndexDepth;
2160  /* The current number of units in the array. */
2161  int m_DataSize;
2162  /* index to segments or indices, or directly pointing to the segment if only one segment. */
2163  void* m_pIndex;
2164 
2165  void** GetIndex(int seg_index) const;
2166  void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL(*callback)(void* param, void* pData), void* param) const;
2167  void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL(*callback)(void* param, void* pData), void* param) const;
2168 };
2169 
2173 template <class ElementType>
2175 {
2176  public:
2184  CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAllocator = NULL)
2185  : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size, pAllocator)
2186  {}
2187  //<<<+++OPENSOURCE_END
2188 
2196  void Add(ElementType data)
2197  {
2198  *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
2199  }
2200 
2208  ElementType& operator [] (int index)
2209  {
2210  return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
2211  }
2212 };
2213 
2217 template <class DataType, int FixedSize>
2218 class CFX_FixedBufGrow : public CFX_Object
2219 {
2220  public:
2228  : m_pAllocator(pAllocator)
2229  , m_pData(NULL)
2230  {
2231  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2232  }
2233 
2241  CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL)
2242  : m_pAllocator(pAllocator)
2243  , m_pData(NULL)
2244  {
2245  if (data_size > FixedSize)
2246  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
2247  else
2248  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2249  }
2250  //<<<+++OPENSOURCE_END
2251 
2259  void SetDataSize(int data_size) {
2260  if (m_pData)
2261  FX_Allocator_Free(m_pAllocator, m_pData);
2262  m_pData = NULL;
2263  if (data_size > FixedSize)
2264  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
2265  else {
2266  FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
2267  }
2268  }
2269 
2273  ~CFX_FixedBufGrow() { if (m_pData) FX_Allocator_Free(m_pAllocator, m_pData); }
2274 
2275  operator DataType*() { return m_pData ? m_pData : m_Data; }
2276 
2277  private:
2278  IFX_Allocator * m_pAllocator;
2279 
2280  DataType m_Data[FixedSize];
2281  DataType* m_pData;
2282 };
2283 
2287 template <class DataType>
2289 {
2290  public:
2298  CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllocator)
2299  {
2300  m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size);
2301  }
2302 
2307  {
2308  if (m_pData) FX_Allocator_Free(m_pAllocator, m_pData);
2309  }
2310  //<<<+++OPENSOURCE_END
2311 
2312  DataType& operator[](int i) { FXSYS_assert(m_pData != NULL); return m_pData[i]; }
2313  operator DataType*() const { return m_pData; }
2314 
2315  private:
2316  IFX_Allocator * m_pAllocator;
2317 
2318  DataType* m_pData;
2319 };
2320 
2321 //*****************************************************************************
2322 //* Map
2323 //*****************************************************************************
2324 
2328 class CFX_MapPtrToPtr : public CFX_Object
2329 {
2330  protected:
2334  struct CAssoc
2335  {
2339  void* key;
2341  void* value;
2342  };
2343 
2344  public:
2352  CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
2353  //<<<+++OPENSOURCE_END
2354 
2358  ~CFX_MapPtrToPtr();
2359 
2365  int GetCount() const { return m_nCount; }
2366 
2372  FX_BOOL IsEmpty() const { return m_nCount == 0; }
2373 
2382  FX_BOOL Lookup(void* key, void*& rValue) const;
2383 
2391  void* GetValueAt(void* key) const;
2392 
2400  void*& operator[](void* key);
2401 
2410  void SetAt(void* key, void* newValue) { (*this)[key] = newValue; }
2411 
2419  FX_BOOL RemoveKey(void* key);
2420 
2426  void RemoveAll();
2427 
2433  FX_POSITION GetStartPosition() const { return (m_nCount == 0) ? NULL : (FX_POSITION)-1; }
2434 
2447  void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const;
2448 
2454  FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
2455 
2465  void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = true);
2466 
2467  protected:
2468  /* Special allocator pointer. NULL to use default allocator. */
2469  IFX_Allocator * m_pAllocator;
2470 
2471  /* The hash table. */
2472  CAssoc** m_pHashTable;
2473  /* The size of hash table. */
2474  FX_DWORD m_nHashTableSize;
2475  /* The number of key-value pair in the map. */
2476  int m_nCount;
2477  /* The freed association list internal. */
2478  CAssoc* m_pFreeList;
2479  /* The block list internal. */
2480  struct CFX_Plex* m_pBlocks;
2481  /* The size in associations of each block. */
2482  int m_nBlockSize;
2483 
2484  /*
2485  * Routine used to user-provided hash keys.
2486  *
2487  * @note Overwrite-able: special non-virtual (see map implementation for details).
2488  *
2489  * @param[in] key The key used to produce hash key.
2490  * @return A hash value.
2491  */
2492  FX_DWORD HashKey(void* key) const;
2493 
2494  /*
2495  * Allocate a new association.
2496  *
2497  * @return The pointer to the new allocated association.
2498  */
2499  CAssoc* NewAssoc();
2500  /*
2501  * Free an association.
2502  *
2503  * @param[in] pAssoc A pointer to an association.
2504  */
2505  void FreeAssoc(CAssoc* pAssoc);
2506  /*
2507  * @brief Retrieve an association by a key.
2508  *
2509  * @param[in] key The input key.
2510  * @param[out] hash The hash value computed.
2511  *
2512  * @return Current association object.
2513  */
2514  CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const;
2515  /*
2516  * @brief Retrieve current association by position.
2517  *
2518  * @param[in, out] rNextPosition Input a position, and receive the next association position.
2519  *
2520  * @return Current association object.
2521  */
2522  CAssoc* GetCurrentAssoc(FX_POSITION& rNextPosition) const;
2523  /*
2524  * @brief Expand 2 times HashTable Size than before.
2525  *
2526  * @details The MaxHashTableSize is 10000.
2527  *
2528  * @return <b>true</b> means success, while <b>false</b> means failure.
2529  */
2530  FX_BOOL ExpandHashTable();
2531 };
2532 
2536 template <class KeyType, class ValueType>
2538 {
2539  public:
2545  CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, pAllocator) {}
2546 
2555  FX_BOOL Lookup(KeyType key, ValueType& rValue) const
2556  {
2557  FX_LPVOID pValue = NULL;
2558  if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue))
2559  return false;
2560  rValue = (ValueType)(FX_UINTPTR)pValue;
2561  return true;
2562  }
2563 
2571  ValueType& operator[](KeyType key) { return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(FX_UINTPTR)key); }
2572 
2581  void SetAt(KeyType key, ValueType newValue) { CFX_MapPtrToPtr::SetAt((void*)(FX_UINTPTR)key, (void*)(FX_UINTPTR)newValue); }
2582 
2590  FX_BOOL RemoveKey(KeyType key) { return CFX_MapPtrToPtr::RemoveKey((void*)(FX_UINTPTR)key); }
2591 
2601  void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rValue) const
2602  {
2603  void* pKey = NULL; void* pValue = NULL;
2604  CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
2605  rKey = (KeyType)(FX_UINTPTR)pKey; rValue = (ValueType)(FX_UINTPTR)pValue;
2606  }
2607 };
2608 
2613 class CFX_CMapDWordToDWord : public CFX_Object
2614 {
2615  public:
2621  CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) {}
2622 
2631  FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
2632 
2641  void SetAt(FX_DWORD key, FX_DWORD value);
2642 
2651  void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
2652 
2658  FX_POSITION GetStartPosition() const;
2659 
2669  void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
2670 
2676  void RemoveAll() { m_Buffer.Clear(); }
2677 
2678  protected:
2681  private:
2682  CFX_CMapDWordToDWord(const CFX_CMapDWordToDWord &) FX_EQDELETE;
2683  CFX_CMapDWordToDWord &operator=(const CFX_CMapDWordToDWord &) FX_EQDELETE;
2684 };
2685 
2687 class CFX_MapByteStringToPtr : public CFX_Object
2688 {
2689  protected:
2693  struct CAssoc
2694  {
2697 
2703  void* value;
2704  };
2705 
2706  public:
2714  CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
2715 
2721  int GetCount() const { return m_nCount; }
2722 
2728  FX_BOOL IsEmpty() const { return m_nCount == 0; }
2729 
2738  FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
2739 
2747  void*& operator[](FX_BSTR key);
2748 
2757  void SetAt(FX_BSTR key, void* newValue) { (*this)[key] = newValue; }
2758 
2766  FX_BOOL RemoveKey(FX_BSTR key);
2767 
2773  void RemoveAll();
2774 
2780  FX_POSITION GetStartPosition() const { return (m_nCount == 0) ? NULL : (FX_POSITION)-1; }
2781 
2791  void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
2792 
2800  FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
2801 
2807  FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
2808 
2818  void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = true);
2819 
2829  FX_DWORD HashKey(FX_BSTR key) const;
2830 
2831  protected:
2832  /* Special allocator pointer. NULL to use default allocator. */
2833  IFX_Allocator * m_pAllocator;
2834 
2835  /* The hash table. */
2836  CAssoc** m_pHashTable;
2837  /* The size of hash table. */
2838  FX_DWORD m_nHashTableSize;
2839  /* The number of key-value pair in the map. */
2840  int m_nCount;
2841  /* The freed association list internal. */
2842  CAssoc* m_pFreeList;
2843  /* The block list internal. */
2844  struct CFX_Plex* m_pBlocks;
2845  /* The size in associations of each block. */
2846  int m_nBlockSize;
2847 
2848  /*
2849  * @brief Allocate a new association.
2850  *
2851  * @return The pointer to the new allocated association.
2852  */
2853  CAssoc* NewAssoc();
2854  /*
2855  * @brief Free an association.
2856  *
2857  * @param[in] pAssoc A pointer to an association.
2858  *
2859  * @return None.
2860  */
2861  void FreeAssoc(CAssoc* pAssoc);
2862  /*
2863  * @brief Retrieve an association by a key.
2864  *
2865  * @param[in] key The input key.
2866  * @param[out] hash The hash value computed.
2867  *
2868  * @return An association object.
2869  */
2870  CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const;
2871  /*
2872  * @brief Retrieve current association by position.
2873  *
2874  * @param[in] rNextPosition The current position.
2875  *
2876  * @return An association object.
2877  */
2878  CAssoc* GetCurrentAssoc(FX_POSITION& rNextPosition) const;
2879  /*
2880  * @brief Expand 2 times HashTable Size than before.
2881  *
2882  * @details The MaxHashTableSize is 10000.
2883  *
2884  * @return <b>true</b> means success, while <b>false</b> means failure.
2885  */
2886  FX_BOOL ExpendHashTable();
2887 
2888  public:
2891 };
2892 
2901 class CFX_CMapByteStringToPtr : public CFX_Object
2902 {
2903  public:
2910  //<<<+++OPENSOURCE_END
2911 
2914 
2920  void RemoveAll();
2921 
2927  FX_POSITION GetStartPosition() const;
2928 
2938  void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& rValue) const;
2939 
2947  FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const;
2948 
2957  FX_BOOL Lookup(FX_BSTR key, void*& rValue) const;
2958 
2967  void SetAt(FX_BSTR key, void* value);
2968 
2976  void RemoveKey(FX_BSTR key);
2977 
2983  int GetCount() const;
2984 
2996  void AddValue(FX_BSTR key, void* pValue);
2997 
2998  protected:
2999  /* A chained buffer storing keys and values. */
3000  CFX_BaseSegmentedArray m_Buffer;
3001 };
3002 
3004 // Lists
3006 
3008 class CFX_PtrList : public CFX_Object
3009 {
3010  protected:
3012  struct CNode
3013  {
3019  void* data;
3020  };
3021 
3022  public:
3029  CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
3030  //<<<+++OPENSOURCE_END
3031 
3037  FX_POSITION GetHeadPosition() const { return (FX_POSITION)m_pNodeHead; }
3038 
3044  FX_POSITION GetTailPosition() const { return (FX_POSITION)m_pNodeTail; }
3045 
3053  void* GetNext(FX_POSITION& rPosition) const
3054  {
3055  CNode* pNode = (CNode*)rPosition; rPosition = (FX_POSITION)pNode->pNext; return pNode->data;
3056  }
3057 
3065  void* GetPrev(FX_POSITION& rPosition) const
3066  {
3067  CNode* pNode = (CNode*)rPosition; rPosition = (FX_POSITION)pNode->pPrev; return pNode->data;
3068  }
3069 
3077  FX_POSITION GetNextPosition(FX_POSITION pos) const { return ((CNode*)pos)->pNext; }
3078 
3086  FX_POSITION GetPrevPosition(FX_POSITION pos) const { return ((CNode*)pos)->pPrev; }
3087 
3095  void* GetAt(FX_POSITION rPosition) const
3096  {
3097  CNode* pNode = (CNode*)rPosition; return pNode ? pNode->data : NULL;
3098  }
3099 
3105  int GetCount() const { return m_nCount; }
3106 
3114  FX_POSITION AddTail(void* newElement);
3115 
3123  FX_POSITION AddHead(void* newElement);
3124 
3133  void SetAt(FX_POSITION pos, void* newElement)
3134  {
3135  CNode* pNode = (CNode*)pos; pNode->data = newElement;
3136  }
3137 
3146  FX_POSITION InsertAfter(FX_POSITION pos, void* newElement);
3147 
3156  FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL) const;
3157 
3165  FX_POSITION FindIndex(int index) const;
3166 
3174  void RemoveAt(FX_POSITION pos);
3175 
3181  void RemoveAll();
3182 
3183  protected:
3184  /* Special allocator pointer. <b>NULL</b> means to use default allocator. */
3185  IFX_Allocator * m_pAllocator;
3186 
3187  /* Pointer to the head. */
3188  CNode* m_pNodeHead;
3189  /* Pointer to the tail. */
3190  CNode* m_pNodeTail;
3191  /* The count of nodes in the list. */
3192  int m_nCount;
3193  /* The freed node list internal. */
3194  CNode* m_pNodeFree;
3195  /* The block list internal. */
3196  struct CFX_Plex* m_pBlocks;
3197  /* The size in nodes of each block. */
3198  int m_nBlockSize;
3199 
3200  /*
3201  * Allocate a new node.
3202  *
3203  * @param[in] pPrev The pointer to the previous node.
3204  * @param[in] pNext The pointer to the next node.
3205  *
3206  * @return The pointer to the new node.
3207  */
3208  CNode* NewNode(CNode* pPrev, CNode* pNext);
3209  /*
3210  * Free a node.
3211  *
3212  * @param[in] pNode The node pointer.
3213  */
3214  void FreeNode(CNode* pNode);
3215 
3216  public:
3218  ~CFX_PtrList();
3219 };
3220 
3221 //*****************************************************************************
3222 //* Utilities
3223 //*****************************************************************************
3224 
3228 typedef void(*PD_CALLBACK_FREEDATA)(FX_LPVOID pData);
3229 
3234 {
3240  void FreeData();
3241 
3244 
3247 
3250 
3256 };
3257 
3262 {
3263  public:
3269  CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {}
3270 
3272  ~CFX_PrivateData();
3273 
3279  void ClearAll();
3280 
3297  void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback);
3298 
3311  void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject* pObj);
3312 
3323  FX_LPVOID GetPrivateData(FX_LPVOID module_id);
3324 
3334  {
3335  if (!module_id) return false;
3336  FX_DWORD nCount = m_DataList.GetSize();
3337  for (FX_DWORD n = 0; n < nCount; n++) {
3338  if (m_DataList[n].m_pModuleId == module_id) {
3339  pData = m_DataList[n].m_pData;
3340  return true;
3341  }
3342  }
3343  return false;
3344  }
3345 
3355  FX_BOOL RemovePrivateData(FX_LPVOID module_id);
3356 
3357  protected:
3358  /* Private data array. */
3360  /*
3361  * Add a private data. Add if not exist, otherwise modify.
3362  *
3363  * @param[in] module_id The module id.
3364  * @param[in] pData The private data.
3365  * @param[in] callback The callback function for deallocating provided private data.
3366  * @param[in] bSelfDestruct Whether the private data is a CFX_DestructObject derived object actually.
3367  *
3368  * @return None.
3369  */
3370  void AddData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct);
3371 };
3372 
3377 class CFX_BitStream : public CFX_Object
3378 {
3379  public:
3388  void Init(FX_LPCBYTE pData, FX_DWORD dwSize);
3389 
3397  FX_DWORD GetBits(FX_DWORD nBits);
3398 
3404  void ByteAlign();
3405 
3411  FX_BOOL IsEOF() const { return m_BitPos >= m_BitSize; }
3412 
3420  void SkipBits(FX_DWORD nBits) { m_BitPos += nBits; }
3421 
3427  void Rewind() { m_BitPos = 0; }
3428 
3429  protected:
3430  /* Bit position (zero-based). */
3431  FX_DWORD m_BitPos;
3432  /* Total bit counts in the memory block. */
3433  FX_DWORD m_BitSize;
3434  /* bit-stream stream buffer. */
3435  FX_LPCBYTE m_pData;
3436 };
3437 
3442 template <class ObjClass> class CFX_CountRef : public CFX_Object
3443 {
3444  public:
3447 
3451  class CountedObj : public ObjClass
3452  {
3453  public:
3456 
3462  CountedObj(const CountedObj& src) : ObjClass(src), m_RefCount(0) {}
3463 
3466  };
3467 
3472  {
3473  m_pObject = NULL;
3474  }
3475 
3481  CFX_CountRef(const Ref& ref)
3482  {
3483  m_pObject = ref.m_pObject;
3484  if (m_pObject) m_pObject->m_RefCount++;
3485  }
3486 
3491  {
3492  if (!m_pObject) return;
3493  m_pObject->m_RefCount--;
3494  if (m_pObject->m_RefCount <= 0) {
3495  delete m_pObject;
3496  m_pObject = NULL;
3497  }
3498  }
3499 
3506  ObjClass* New()
3507  {
3508  if (m_pObject) {
3509  m_pObject->m_RefCount--;
3510  if (m_pObject->m_RefCount <= 0)
3511  delete m_pObject;
3512  m_pObject = NULL;
3513  }
3514  m_pObject = FX_NEW CountedObj;
3515  if (!m_pObject) return NULL;
3516  m_pObject->m_RefCount = 1;
3517  return m_pObject;
3518  }
3519 
3527  void operator = (const Ref& ref)
3528  {
3529  if (ref.m_pObject)
3530  ref.m_pObject->m_RefCount++;
3531  if (m_pObject) {
3532  m_pObject->m_RefCount--;
3533  if (m_pObject->m_RefCount <= 0)
3534  delete m_pObject;
3535  }
3536  m_pObject = ref.m_pObject;
3537  }
3538 
3546  void operator = (void* p)
3547  {
3548  FXSYS_assert(p == 0);
3549  if (m_pObject == NULL) return;
3550  m_pObject->m_RefCount--;
3551  if (m_pObject->m_RefCount <= 0)
3552  delete m_pObject;
3553  m_pObject = NULL;
3554  }
3555 
3556 #if defined(_FX_MANAGED_CODE_) && defined(GetObject)
3557 #undef GetObject
3558 #endif
3559 
3564  const ObjClass* GetObject() const
3565  {
3566  return m_pObject;
3567  }
3573  operator const ObjClass*() const
3574  {
3575  return m_pObject;
3576  }
3577 
3583  FX_BOOL IsNull() const
3584  {
3585  return m_pObject == NULL;
3586  }
3593  {
3594  return m_pObject != NULL;
3595  }
3596 
3605  ObjClass* GetModify()
3606  {
3607  if (m_pObject == NULL) {
3608  m_pObject = FX_NEW CountedObj;
3609  if (m_pObject)
3610  m_pObject->m_RefCount = 1;
3611  } else if (m_pObject->m_RefCount > 1) {
3612  m_pObject->m_RefCount --;
3613  CountedObj* pOldObject = m_pObject;
3614  m_pObject = NULL;
3615  m_pObject = FX_NEW CountedObj(*pOldObject);
3616  if (m_pObject)
3617  m_pObject->m_RefCount = 1;
3618  }
3619  return m_pObject;
3620  }
3621 
3627  void SetNull()
3628  {
3629  if (m_pObject == NULL) return;
3630  m_pObject->m_RefCount--;
3631  if (m_pObject->m_RefCount <= 0)
3632  delete m_pObject;
3633  m_pObject = NULL;
3634  }
3635 
3643  FX_BOOL operator == (const Ref& ref) const
3644  {
3645  return m_pObject == ref.m_pObject;
3646  }
3647 
3653  int RefCount() const
3654  {
3655  return m_pObject ? m_pObject->m_RefCount : 0;
3656  }
3657 
3663  void Incref()
3664  {
3665  if (m_pObject == NULL) return;
3666  m_pObject->m_RefCount++;
3667  }
3668 
3674  void Decref()
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  }
3683 
3684  protected:
3685  /* Reference counted object internal. */
3686  CountedObj * m_pObject;
3687 };
3688 
3691 {
3692  public:
3694  virtual ~IFX_Pause() {}
3695 
3701  virtual FX_BOOL NeedToPauseNow() = 0;
3702 };
3703 
3705 class CFX_DataFilter : public CFX_Object
3706 {
3707  public:
3711  virtual ~CFX_DataFilter();
3712 
3720  void SetDestFilter(CFX_DataFilter* pFilter);
3721 
3727  FX_BOOL IsEOF() const { return m_bEOF; }
3728 
3734  FX_FILESIZE GetSrcPos() const { return m_SrcPos; }
3735 
3745  void FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf& dest_buf);
3746 
3755  void FilterFinish(CFX_BinaryBuf& dest_buf);
3756 
3762  FX_BOOL IsExhaustBuffer() const { return m_bExhaustBuffer; }
3763 
3769  FX_BOOL NeedNewSrc();
3770 
3776  FX_BOOL Abort() const { return m_bAbort; }
3777 
3783  FX_BOOL AbortAll();
3784 
3790  void ResetStatistics();
3791 
3792  protected:
3793  /* The constructor. */
3794  CFX_DataFilter();
3795 
3796  virtual void v_FilterIn(FX_LPCBYTE src_buf, size_t src_size, CFX_BinaryBuf& dest_buf) = 0;
3797  virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0;
3798  virtual void v_ResetStatistics() {};
3799  void ReportEOF(FX_FILESIZE left_input);
3800 
3801  /* Indicate whether we met the EOF. */
3802  FX_BOOL m_bEOF;
3803  /* Current position in the source stream. */
3804  FX_FILESIZE m_SrcPos;
3805  /* Filter chain. */
3806  CFX_DataFilter* m_pDestFilter;
3807 
3808  /* Indicate whether this filter exhausts the input buffer. */
3809  FX_BOOL m_bExhaustBuffer;
3810  /* Store the output data of the FilterIn function.*/
3811  CFX_BinaryBuf m_FilterInBuffer;
3812 
3813  /* Indicate whether this filter aborts the filter process. For instance, RunLenFilter meets bad input data */
3814  FX_BOOL m_bAbort;
3815 };
3816 
3818 template<typename T>
3820  public:
3826  explicit CFX_AutoRestorer(T* location) {
3827  m_Location = location;
3828  m_OldValue = *location;
3829  }
3830 
3832  ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
3833  private:
3834  T * m_Location;
3835  T m_OldValue;
3836 };
3837 
3839 template <class T>
3841 {
3842  public:
3848  CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
3849 
3851  ~CFX_SmartPointer() { m_pObj->Release(); }
3852 
3858  T* Get(void) { return m_pObj; }
3859 
3865  T& operator *(void) { return *m_pObj; }
3866 
3872  T* operator ->(void) { return m_pObj; }
3873 
3874  protected:
3875  T * m_pObj;
3876 };
3877 
3878 #define FX_DATALIST_LENGTH 1024
3879 
3881 template<size_t unit>
3882 class CFX_SortListArray : public CFX_Object
3883 {
3884  protected:
3886  struct DataList {
3891  FX_LPBYTE data;
3892  DataList()
3893  {
3894  start = count = 0;
3895  data = NULL;
3896  }
3897  };
3898 
3899  public:
3905  CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLists(pAllocator) {}
3906 
3909  {
3910  Clear();
3911  }
3912 
3918  void Clear()
3919  {
3920  IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
3921 
3922  for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) {
3923  DataList list = m_DataLists.ElementAt(i);
3924  if (list.data) FX_Allocator_Free(pAllocator, list.data);
3925  }
3926  m_DataLists.RemoveAll();
3927  m_CurList = 0;
3928  }
3929 
3938  void Append(FX_INT32 nStart, FX_INT32 nCount)
3939  {
3940  if (nStart < 0) return;
3941 
3942  IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
3943 
3944  while (nCount > 0) {
3945  FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
3946  DataList list;
3947 
3948  list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * unit);
3949  if (!list.data) break;
3950  FXSYS_memset32(list.data, 0, temp_count * unit);
3951  list.start = nStart;
3952  list.count = temp_count;
3953 
3954  FX_BOOL ret = Append(list);
3955  if (ret)
3956  {
3957  nCount -= temp_count;
3958  nStart += temp_count;
3959  }
3960  else
3961  {
3962  if (list.data) FX_Allocator_Free(pAllocator, list.data);
3963  return;
3964  }
3965  }
3966  }
3967 
3976  {
3977  if (nIndex < 0) return NULL;
3978  if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) return NULL;
3979  DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
3980  if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) {
3981  pCurList = NULL;
3982  FX_INT32 iStart = 0;
3983  FX_INT32 iEnd = m_DataLists.GetUpperBound();
3984  while (iStart <= iEnd) {
3985  FX_INT32 iMid = (iStart + iEnd) / 2;
3986  DataList* list = m_DataLists.GetDataPtr(iMid);
3987  if (nIndex < list->start)
3988  iEnd = iMid - 1;
3989  else if (nIndex >= list->start + list->count)
3990  iStart = iMid + 1;
3991  else {
3992  pCurList = list;
3993  m_CurList = iMid;
3994  break;
3995  }
3996  }
3997  }
3998  return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : NULL;
3999  }
4000 
4001  protected:
4002  FX_BOOL Append(const DataList& list)
4003  {
4004  FX_INT32 iStart = 0;
4005  FX_INT32 iEnd = m_DataLists.GetUpperBound();
4006  FX_INT32 iFind = 0;
4007  while (iStart <= iEnd) {
4008  FX_INT32 iMid = (iStart + iEnd) / 2;
4009  DataList* cur_list = m_DataLists.GetDataPtr(iMid);
4010  if (list.start == cur_list->start){
4011  return false; // lists overlap, no op
4012  } else if (list.start < cur_list->start + cur_list->count)
4013  iEnd = iMid - 1;
4014  else{
4015  if (iMid == iEnd){
4016  iFind = iMid + 1;
4017  break;
4018  }
4019  DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
4020  if (list.start == next_list->start){
4021  return false; // lists overlap, no op
4022  } else if (list.start < next_list->start){
4023  iFind = iMid + 1;
4024  break;
4025  } else {
4026  iStart = iMid + 1;
4027  }
4028  }
4029  }
4030  m_DataLists.InsertAt(iFind, list);
4031  return true;
4032  }
4033 
4034  FX_INT32 m_CurList;
4035  CFX_ArrayTemplate<DataList> m_DataLists;
4036 };
4037 
4039 template<typename T1, typename T2>
4040 class CFX_ListArrayTemplate : public CFX_Object
4041 {
4042  public:
4048  void Clear()
4049  {
4050  m_Data.Clear();
4051  }
4052 
4061  void Add(FX_INT32 nStart, FX_INT32 nCount)
4062  {
4063  m_Data.Append(nStart, nCount);
4064  }
4065 
4074  {
4075  FX_LPBYTE data = m_Data.GetAt(nIndex);
4076  FXSYS_assert(data != NULL);
4077 
4078  return (T2&)(*(volatile T2*)data);
4079  }
4080 
4088  T2* GetPtrAt(FX_INT32 nIndex)
4089  {
4090  return (T2*)m_Data.GetAt(nIndex);
4091  }
4092  protected:
4093  T1 m_Data;
4094 };
4095 
4100 
4106 typedef enum {
4120 
4121 #define ProgressiveStatus FX_ProgressiveStatus
4122 
4123 #ifdef _FX_NO_NAMESPACE_
4124 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT
4125 #define FX_NAMESPACE_DECLARE(namespace, type) type
4126 //<<<+++OPENSOURCE_END
4127 #else
4128 //<<<+++OPENSOURCE_BEGIN LIC==GOOGLE
4129 #define FX_NAMESPACE_DECLARE(namespace, type) namespace::type
4130 //<<<+++OPENSOURCE_END
4131 #endif
4132 
4135 {
4136  public:
4142  virtual FX_DWORD Release() = 0;
4143 
4149  virtual FX_DWORD AddRef() = 0;
4150 
4151  protected:
4152  virtual ~IFX_Unknown() {}
4153 };
4154 
4156 #define FX_IsOdd(a) ((a) & 1)
4157 
4158 //<<<+++OPENSOURCE_MUST_END
4159 
4160 //<<<+++OPENSOURCE_MUST_BEGIN
4161 #endif // _FX_BASIC_H_
4162 //<<<+++OPENSOURCE_MUST_END
4163 
4166 //<<<+++OPENSOURCE_END
CFX_WideTextBuf(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:345
FX_BOOL IsEmpty() const
Verify whether the map is empty.
Definition: fx_basic.h:2372
~CFX_BinaryBuf()
The destructor.
FX_INT32 count
The data count.
Definition: fx_basic.h:3890
ElementType & operator [](int index)
Subscript([]) operator overload. This function returns a ref to the specified element specified by th...
Definition: fx_basic.h:2208
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:644
The data list.
Definition: fx_basic.h:3886
CFX_CountRef()
Construct a null reference.
Definition: fx_basic.h:3471
Definition: fx_basic.h:3705
CFX_ArchiveLoader & operator >>(FX_BYTE &i)
Right shifts(>>) operator overload. De-serialize a byte.
TYPE & operator[](int nIndex)
Subscript([]) operator overload. This function returns a reference to the specified element specified...
Definition: fx_basic.h:1547
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:703
FX_BOOL IsEmpty() const
Verify whether the map is empty.
Definition: fx_basic.h:2728
Definition: fx_basic.h:2328
Definition: fx_basic.h:4134
void RemoveAll()
Remove all elements in the array.
FX_DWORD GetBits(FX_DWORD nBits)
Get specified number of bits (maximum 32 bits).
CFX_PtrList(int nBlockSize=10, IFX_Allocator *pAllocator=0)
Construct with block size and allocator.
CFX_PrivateData(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:3269
FX_POSITION GetNextPosition(FX_POSITION pos) const
Get the next position.
Definition: fx_basic.h:3077
int GetSize() const
Get the number of elements in the array.
Definition: fx_basic.h:1350
FX_BOOL IsEOF() const
Detect EOF.
Definition: fx_basic.h:3727
void Clear()
Clear the data list.
Definition: fx_basic.h:3918
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.
CFX_Stack()
Construct.
Definition: fx_basic.h:1995
CFX_Stack()
Construct.
Definition: fx_basic.h:1863
void SetAt(KeyType key, ValueType newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2581
CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize)
Construct a loading archive.
~CFX_SortListArray()
The destructor.
Definition: fx_basic.h:3908
int m_RefCount
The reference count.
Definition: fx_basic.h:3465
PD_CALLBACK_FREEDATA m_pCallback
Pointer of a callback function provided by custom module for deallocating private data.
Definition: fx_basic.h:3249
void SetPrivateObj(FX_LPVOID module_id, CFX_DestructObject *pObj)
Set private object.
FX_LPCBYTE GetBuffer() const
Get the constant byte pointer to the saved data.
Definition: fx_basic.h:621
Ready.
Definition: fx_basic.h:4108
void Pop()
Pop the byte string from stack.
Definition: fx_basic.h:2032
Invalid array size.
Definition: fx_basic.h:1297
FX_INT32 start
The start index.
Definition: fx_basic.h:3888
void AddValue(FX_BSTR key, void *pValue)
Add a key-value pair to the dictionary, assuming there is no duplicated key existing.
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:713
void SetAt(void *key, void *newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2410
Definition: fx_basic.h:1074
CFX_CMapDWordToDWord(IFX_Allocator *pAllocator=0)
Constructor with allocator.
Definition: fx_basic.h:2621
void operator=(const Ref &ref)
Assignment(=) operator overload. Assign from another reference.
Definition: fx_basic.h:3527
void GetByteStringL(CFX_ByteStringL &str) const
Get a byte string from current buffer object.
FX_BOOL operator==(const Ref &ref) const
Comparison(==) operator overload. Compare with another reference.
Definition: fx_basic.h:3643
FX_BOOL AppendChar(FX_WCHAR wch)
Append a single wide character.
int GetCount() const
Get the number of key-value pairs.
virtual void Clear()
Clear buffer.
Definition: fx_basic.h:3233
Definition: fx_basic.h:2288
void * Add()
Add an element.
INT_PTR FX_INTPTR
Signed integral type for pointer precision.
Definition: fx_system.h:732
TYPE & Top()
Get the top byte data.
Definition: fx_basic.h:1890
CFX_BinaryBuf m_Buffer
Definition: fx_basic.h:2680
void(* PD_CALLBACK_FREEDATA)(FX_LPVOID pData)
Definition: fx_basic.h:3228
Definition: fx_basic.h:4040
int GetUnitSize() const
Get number of bytes for each element.
Definition: fx_basic.h:2137
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
T * Get(void)
Get the object pointer.
Definition: fx_basic.h:3858
CFX_ByteStringC GetResult() const
Get the result.
Definition: fx_basic.h:1107
Not Found.
Definition: fx_basic.h:4114
Definition: fx_basic.h:868
int Find(const TYPE &data, int iStart=0) const
Find an element from specified position to last.
Definition: fx_basic.h:1600
void * GetAt(int index) const
Get a typeless pointer to an element data.
Definition: fx_basic.h:3882
FX_STRSIZE GetSize() const
Get the length of the binary buffer.
Definition: fx_basic.h:203
int GetSize() const
Get number of elements in the array.
Definition: fx_basic.h:2123
FX_ProgressiveStatus
Enumeration for progressive status.
Definition: fx_basic.h:4106
Definition: fx_basic.h:2687
FX_STRSIZE GetLength() const
Get the length of the wide text buffer.
Definition: fx_basic.h:433
~CFX_MapByteStringToPtr()
The destructor.
void SetNull()
Set the pointer of the object to be null.
Definition: fx_basic.h:3627
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
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:2601
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 SetAt(FX_DWORD key, FX_DWORD value)
Add a new (key, value) pair. Add if not exist, otherwise modify.
void GetNextAssoc(FX_POSITION &rNextPosition, void *&rKey, void *&rValue) const
Get the current association and set the position to next association.
CFX_ObjectArray(const CFX_ObjectArray &other, IFX_Allocator *pAllocator=0)
The copy constructor.
Definition: fx_basic.h:1656
CFX_WideStringC GetWideString() const
Get a wide string from the wide text buffer.
CFX_WideStringC GetResult() const
Get the result.
Definition: fx_basic.h:1051
Definition: fx_basic.h:3840
void RemoveAll()
Remove all nodes in the list.
FX_DWORD HashKey(FX_BSTR key) const
Routine used to user-provided hash keys.
virtual FX_BOOL NeedToPauseNow()=0
Check whether callers need to pause now.
Definition: fx_basic.h:1925
FX_LPVOID m_pData
Private data.
Definition: fx_basic.h:3246
void GetResult(CFX_ByteStringL &result) const
Get the result.
Definition: fx_basic.h:1116
void Write(const void *pData, FX_STRSIZE dwSize)
Serialize a memory block.
CFX_ByteStringC GetByteString() const
Get a byte string from the buffer.
FX_LPVOID m_pModuleId
Module ID.
Definition: fx_basic.h:3243
File stream interface, reading & writing.
Definition: fx_stream.h:650
void Delete(int start_index, int count)
Delete a inter-zone buffer defining by parameters start_index and count in the binary buffer.
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:1870
FX_LPBYTE GetAt(FX_INT32 nIndex)
Get the data.
Definition: fx_basic.h:3975
CFX_ObjectArray & operator=(const CFX_ObjectArray &other)
The assignment operator.
Definition: fx_basic.h:1669
Definition: fx_basic.h:1859
ObjectClass & operator[](int index) const
Subscript([]) operator overload. This function returns a reference to the specified object specified ...
Definition: fx_basic.h:1808
void Delete(int index, int count=1)
Delete a number of elements.
T * operator ->(void)
Get the object pointer operator.
Definition: fx_basic.h:3872
void * data
Node data.
Definition: fx_basic.h:3019
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_STRSIZE GetLength() const
Get the length of the byte string.
Definition: fx_string.h:227
void Input(FX_WCHAR unicode)
Input a unicode.
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow=true)
Initialize the hash table.
FX_BOOL SetSize(int nNewSize, int nGrowBy=-1)
Change the allocated size and the grow amount.
Definition: fx_basic.h:1367
int FX_STRSIZE
String size is limited to 2^31-1.
Definition: fx_string.h:35
CAssoc * pNext
Pointer to next association.
Definition: fx_basic.h:2337
int GetSegmentSize() const
Get number of elements in each segment.
Definition: fx_basic.h:2130
Definition: fx_basic.h:1287
FX_BOOL Copy(const CFX_ArrayTemplate &src)
Copy from an array.
Definition: fx_basic.h:1487
CFX_ArrayTemplate< FX_INT32 > CFX_Int32Array
Type definition for INT32 array.
Definition: fx_basic.h:1622
FX_BOOL IsEOF()
Check whether de-serializing is to the end of the loading buffer.
CFX_CountRef< ObjClass > Ref
Type definition: it is used short for CFX_CountRef<ObjClass>.
Definition: fx_basic.h:3446
void SetStream(IFX_FileStream *pStream)
Set the attached stream.
Definition: fx_basic.h:630
void Clear()
Clear the decoding status and set the output wide text buffer to be empty.
CONSTANT WIDE STRING CLASS.
Definition: fx_string.h:1223
void Pop()
Pop the byte string from stack.
Definition: fx_basic.h:1966
TYPE & ElementAt(int nIndex)
This method retrieves a ref to an element specified by an index number.
Definition: fx_basic.h:1415
CFX_ArrayTemplate< FX_BYTE > CFX_ByteArray
Type definition for a byte array type.
Definition: fx_basic.h:1610
CFX_UTF8Encoder(IFX_Allocator *pAllocator=0)
A constructor. Set the encoder to initial.
Definition: fx_basic.h:1082
FX_BOOL Append(const CFX_ArrayTemplate &src)
Append an array.
Definition: fx_basic.h:1478
CFX_MapPtrTemplate(IFX_Allocator *pAllocator=0)
Default constructor.
Definition: fx_basic.h:2545
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:3255
FX_BOOL Flush()
Flush internal buffer of the file.
CFX_MapPtrToPtr(int nBlockSize=10, IFX_Allocator *pAllocator=0)
Construct with specified block size.
FX_BOOL Lookup(KeyType key, ValueType &rValue) const
Lookup by a key.
Definition: fx_basic.h:2555
CFX_ByteTextBuf(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:260
CNode * pNext
Pointer to next node.
Definition: fx_basic.h:3015
FX_BOOL SetAtGrow(int nIndex, TYPE newElement)
Set an element value at specified position. Potentially growing the array.
Definition: fx_basic.h:1446
void Decref()
Decrease the reference.
Definition: fx_basic.h:3674
void AppendStr(FX_BSTR str)
Append a non-buffered byte string.
Definition: fx_basic.h:1100
FX_BOOL Read(void *pBuf, FX_DWORD dwSize)
De-serialize a memory block.
Stream writing interface.
Definition: fx_stream.h:422
CFX_WideString FX_DecodeURI(const CFX_ByteString &bsURI)
A simple URI Decode.
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:715
~CFX_FileBufferArchive()
The destructor.
void Add(ElementType data)
Add an element.
Definition: fx_basic.h:2196
void operator=(FX_BSTR str)
Assignment(=) operator overload. From a non-buffered byte string.
void Clear()
Set the binary buffer to be empty.
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:633
void Add(const ObjectClass &data)
Add a copy of an existing object to the array.
Definition: fx_basic.h:1684
Definition: fx_basic.h:1167
void Init(FX_LPCBYTE pData, FX_DWORD dwSize)
Initialize the bit-stream with a memory block. Must call Init() first.
FX_BOOL Lookup(FX_BSTR key, void *&rValue) const
Lookup by a key.
T & operator *(void)
Get the object reference operator.
Definition: fx_basic.h:3865
FX_INT64 GetSrcPos() const
Get current position in the source stream (byte offset from the beginning of all input data).
Definition: fx_basic.h:3734
Definition: fx_basic.h:2537
virtual void Clear()
Clear the text buffer.
int RefCount() const
Get the reference count.
Definition: fx_basic.h:3653
void EstimateSize(FX_DWORD size, FX_DWORD grow_by)
Change internal allocation size and grow amount.
CFX_SegmentedArray(int segment_units, int index_size=8, IFX_Allocator *pAllocator=0)
Construct with specified segment units.
Definition: fx_basic.h:2184
CFX_ByteString key
Key data.
Definition: fx_basic.h:2701
void ResetStatistics()
Reset statistics.
CFX_ObjectArray(IFX_Allocator *pAllocator=0)
The constructor.
Definition: fx_basic.h:1643
CFX_TempBuf(int size, IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2298
~CFX_TempBuf()
The Destructor.
Definition: fx_basic.h:2306
void RemoveAll()
Remove all (key, value) pair.
Definition: fx_basic.h:2676
FX_DWORD GetHashTableSize() const
Get the internal hash table size. Advanced features for derived classes.
Definition: fx_basic.h:2807
void operator=(FX_LPCWSTR lpsz)
Assignment(=) operator overload. From a zero terminated wide character string.
CFX_UTF8Decoder(IFX_Allocator *pAllocator=0)
A constructor. Set the decoder to initial.
Definition: fx_basic.h:1012
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:637
CFX_ArrayTemplate(const CFX_ArrayTemplate &other, IFX_Allocator *pAllocator=0)
The copy constructor.
Definition: fx_basic.h:1320
void GetNextAssoc(FX_POSITION &rNextPosition, CFX_ByteString &rKey, void *&rValue) const
Get the current association and set the position to next association.
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:662
FX_BOOL LookupPrivateData(FX_LPVOID module_id, FX_LPVOID &pData) const
Lookup a private data.
Definition: fx_basic.h:3333
Definition: fx_basic.h:2056
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:3506
#define FX_Allocator_Alloc(fxAllocator, type, size)
Release-mode allocation on an allocator.
Definition: fx_memory.h:1051
void * AddSpace()
Add an empty space to the array.
Definition: fx_basic.h:1717
CFX_ArrayTemplate(IFX_Allocator *pAllocator=0)
Constructor, from an allocator.
Definition: fx_basic.h:1311
Definition: fx_basic.h:2901
virtual FX_DWORD Release()=0
Decrements reference count and release the current object.
void FreeData()
Free the private data pointed by m_pData.
FX_POSITION GetHeadPosition() const
Get the header position.
Definition: fx_basic.h:3037
Found.
Definition: fx_basic.h:4112
const TYPE * GetData() const
Direct Access to the element data (may return NULL).
Definition: fx_basic.h:1429
FX_BOOL Lookup(FX_DWORD key, FX_DWORD &value) const
Lookup by a key.
FX_POSITION Find(void *searchValue, FX_POSITION startAfter=0) const
Find a value starting after specified position.
BYTE STRING CLASS.
Definition: fx_string.h:317
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
ErrorType
Enumeration for error type.
Definition: fx_basic.h:1295
Definition: fx_basic.h:3442
FX_BOOL RemoveAt(int nIndex, int nCount=1)
Remove a number of elements at specified position.
Definition: fx_basic.h:1580
void * Iterate(FX_BOOL(*callback)(void *param, void *pData), void *param) const
Iterate all units, with a callback function for each unit.
FX_BOOL Lookup(FX_BSTR key, void *&rValue) const
Lookup by a key.
Foxit allocator interface.
Definition: fx_memory.h:961
Definition: fx_basic.h:2218
void AppendString(FX_BSTR str)
Append a non-buffered byte string.
Definition: fx_basic.h:119
Header file for Memory management related definitions and classes.
FX_POSITION FindIndex(int index) const
Find a value by index number.
void SetPrivateData(FX_LPVOID module_id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback)
Set private data.
FX_STRSIZE GetLength() const
Get the length of the byte text buffer.
Definition: fx_basic.h:330
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...
Header file for exception class.
FX_BOOL NeedNewSrc()
Indicate whether this filter needs to input new src data.
void AppendChar(int ch)
Append a single character or byte.
Definition: fx_basic.h:278
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:717
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 Rewind()
Rewind a bit-stream. Simply set the current bit position to be zero.
Definition: fx_basic.h:3427
Definition: fx_basic.h:642
~CFX_SmartPointer()
The destructor.
Definition: fx_basic.h:3851
#define FXSYS_assert
Assertion.
Definition: fx_system.h:785
CFX_ObjectArray< CFX_WideString > CFX_WideStringArray
Type definition for a CFX_WideString array type.
Definition: fx_basic.h:1853
Definition: fx_basic.h:336
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...
Header file for Streams related definitions and classes.
void SetAt(FX_POSITION pos, void *newElement)
Change the value at specified position.
Definition: fx_basic.h:3133
ObjectClass & Add()
Add an empty object to the array.
Definition: fx_basic.h:1701
const TYPE GetAt(int nIndex) const
This method retrieves an element specified by an index number.
Definition: fx_basic.h:1386
FX_LPCBYTE GetPtr() const
Get a constant byte string pointer to the byte string.
Definition: fx_string.h:215
CFX_ArrayTemplate & operator=(const CFX_ArrayTemplate &src)
Assignment operator overload.
Definition: fx_basic.h:1522
void SetAt(FX_BSTR key, void *value)
Add a new (key, value) pair. Add if not exist, otherwise modify.
FX_LPVOID GetNextValue(FX_POSITION &rNextPosition) const
Get the the current value and set the position to next association.
Header file for system related definitions.
void RemoveAll()
Clean up the array.
Definition: fx_basic.h:1377
FX_BOOL Add(TYPE newElement)
Add an element at the tail. Potentially growing the array.
Definition: fx_basic.h:1462
int GetSize() const
Get the size of the array.
Definition: fx_basic.h:1798
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:1531
FX_BOOL IsNull() const
Check if the pointer of the object is NULL.
Definition: fx_basic.h:3583
void RemoveAt(FX_POSITION pos)
Remove a node at specified position.
~CFX_BaseSegmentedArray()
The destructor.
void FilterFinish(CFX_BinaryBuf &dest_buf)
Indicate the input finished. For some filters, there might be some last output generated.
FX_BOOL RemoveKey(FX_BSTR key)
Remove existing key.
Definition: fx_basic.h:251
void *& operator[](void *key)
Subscript([]) operator overload. Lookup and add if not there.
Definition: fx_basic.h:947
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:684
FX_INT32 Append(const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
Append an array.
Definition: fx_basic.h:1732
void Push(const TYPE &val)
Push the data to stack.
Definition: fx_basic.h:1912
FX_BOOL CopyData(const void *pBuf, FX_STRSIZE size)
Copy from another buffer.
FX_LPVOID GetNextValue(FX_POSITION &rNextPosition) const
Get the the current value and set the position to next association.
#define FX_FILESIZE
Support large file directly.
Definition: fx_stream.h:138
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:648
void SetAt(FX_BSTR key, void *newValue)
Add a new (key, value) pair. Add if not exist, otherwise modify.
Definition: fx_basic.h:2757
FX_LPBYTE GetBuffer() const
Get a byte pointer to the binary buffer.
Definition: fx_basic.h:196
Definition: fx_basic.h:1635
void * GetPrev(FX_POSITION &rPosition) const
Get the the current value and set the position to previous node.
Definition: fx_basic.h:3065
CFX_MapByteStringToPtr(int nBlockSize=10, IFX_Allocator *pAllocator=0)
Construct with specified block size.
TYPE * GetDataPtr(int index)
Get a pointer to the specified element in the array. Direct pointer access.
Definition: fx_basic.h:1496
void ClearStatus()
Clear the decoding status.
Definition: fx_basic.h:1044
FX_POSITION AddTail(void *newElement)
Add a value to the tail.
CFX_ObjectArray< CFX_ByteString > CFX_ByteStringArray
Type definition for a CFX_ByteString array type.
Definition: fx_basic.h:1851
int GetCount() const
Get the number of elements.
Definition: fx_basic.h:2365
FX_BOOL AbortAll()
Indicate whether to abort the filter process, including all dest filter.
CFX_ArchiveSaver & operator<<(FX_BYTE i)
Left shifts(<<) operator overload. Serialize a single byte.
FX_BOOL Abort() const
Indicate whether to abort the filter process.
Definition: fx_basic.h:3776
FX_LPWSTR GetBuffer() const
Get a wide character pointer.
Definition: fx_basic.h:440
void AppendChar(FX_DWORD ch)
Append characters to wide text buffer.
FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray *pNewArray)
Inset an array at specified position.
Definition: fx_basic.h:1590
FX_BOOL NotNull() const
Check if the pointer of the object is not NULL.
Definition: fx_basic.h:3592
CFX_ByteString FX_EncodeURI(const CFX_WideString &wsURI)
A simple URI encode.
void RemoveAll()
Remove all the (key, value) pairs in the map.
void SkipBits(FX_DWORD nBits)
Skip a number of bits.
Definition: fx_basic.h:3420
Definition: fx_basic.h:765
FX_BOOL AppendBlock(const void *pBuf, FX_STRSIZE size)
Append a binary buffer block.
void RemoveAll()
Remove all key-value pairs in the map.
virtual ~CFX_DataFilter()
The destructor. Destroy this filter and all its chain.
void SetDestFilter(CFX_DataFilter *pFilter)
Set destination filter. Note the filter will be appended to the end of current filter chain.
Dynamic binary buffers designed for more efficient appending.
Definition: fx_basic.h:52
CountedObj()
The constructor.
Definition: fx_basic.h:3455
FX_BOOL RemovePrivateData(FX_LPVOID module_id)
Remove previously stored private data. FPDFAPI assumes the module has deallocated the data,...
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:2002
FX_POSITION GetTailPosition() const
Get the tail position.
Definition: fx_basic.h:3044
UINT_PTR FX_UINTPTR
Unsigned integral type for pointer precision.
Definition: fx_system.h:734
void GetResult(CFX_WideStringL &result) const
Get the result.
Definition: fx_basic.h:1060
Definition: fx_basic.h:3690
CFX_ArrayTemplate< FX_INT64 > CFX_FileSizeArray
Type definition for file size array type.
Definition: fx_basic.h:1618
Definition: fx_basic.h:3008
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:664
Association in CFX_MapByteStringToPtr.
Definition: fx_basic.h:2693
CFX_ArrayTemplate< void * > CFX_PtrArray
Type definition for: a typeless pointer array type.
Definition: fx_basic.h:1616
CAssoc * pNext
Pointer to next association.
Definition: fx_basic.h:2696
CFX_WideString FX_UrlDecode(const CFX_ByteString &bsUrl)
A simple URL decode.
~CFX_FixedBufGrow()
The Destructor.
Definition: fx_basic.h:2273
CFX_ByteTextBuf & operator<<(int i)
Left shifts(<<) operator overload. Output an integer to the byte text buffer.
int Size() const
Get size of the container.
Definition: fx_basic.h:2012
FX_INT32 AppendBlock(const void *pBuf, size_t size)
Append a binary buffer block.
Definition: fx_basic.h:2174
CFX_WideString(* m_GetWideString)(CFX_CharMap *pMap, const CFX_ByteString &bstr)
A pointer type to GetWideString function.
Definition: fx_basic.h:973
CFX_CountRef(const Ref &ref)
Copy constructor from another reference.
Definition: fx_basic.h:3481
Bidirectional node in CFX_PtrList.
Definition: fx_basic.h:3012
CFX_ByteString & Top()
Get the top byte string.
Definition: fx_basic.h:2022
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:1331
void RemoveAt(int index)
Remove an object at specified position.
Definition: fx_basic.h:1830
TYPE * InsertSpaceAt(int nIndex, int nCount)
Insert a number of elements.
Definition: fx_basic.h:1513
Index out of range.
Definition: fx_basic.h:1303
Association in CFX_MapPtrToPtr.
Definition: fx_basic.h:2334
void * GetNext(FX_POSITION &rPosition) const
Get the the current value and set the position to next node.
Definition: fx_basic.h:3053
ObjClass * GetModify()
Get a modifiable copy of the object.
Definition: fx_basic.h:3605
void Pop()
Pop the data from stack.
Definition: fx_basic.h:1900
T2 & operator [](FX_INT32 nIndex)
Subscript([]) operator overload.
Definition: fx_basic.h:4073
void RemoveKey(FX_BSTR key)
Removing existing (key, ?) pair.
CFX_SmartPointer(T *pObj)
The constructor.
Definition: fx_basic.h:3848
TYPE * GetData()
Direct Access to the element data (may return NULL).
Definition: fx_basic.h:1436
void * GetAt(FX_POSITION rPosition) const
Get an value at specified position.
Definition: fx_basic.h:3095
virtual FX_DWORD AddRef()=0
Increments reference count.
FX_INT32 AppendDWord(FX_DWORD i)
Append a FX_DWORD value.
CNode * pPrev
Pointer to previous node.
Definition: fx_basic.h:3017
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:2780
#define NULL
The null-pointer value.
Definition: fx_system.h:773
FX_BOOL RemoveKey(void *key)
Removing existing (key, ?) pair.
int GetCount() const
Get the number of nodes.
Definition: fx_basic.h:3105
void Push(const CFX_ByteString &val)
Push the byte string to stack.
Definition: fx_basic.h:2044
CFX_BinaryBuf(IFX_Allocator *pAllocator=0)
A default constructor creating an empty buffer.
int GetCount() const
Get the number of elements.
Definition: fx_basic.h:2721
FX_INT32 Copy(const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
Copy from an array.
Definition: fx_basic.h:1767
~CFX_PrivateData()
The destructor.
virtual ~IFX_BufferArchive()
The destructor.
Definition: fx_basic.h:781
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL means to use default allocator.
Definition: fx_basic.h:229
Define a class here derived from user data class, with an additional reference count member.
Definition: fx_basic.h:3451
CFX_WideTextBuf & operator<<(int i)
Left shifts(<<) operator overload. Output a integer to the wide text buffer.
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:670
void Add(FX_INT32 nStart, FX_INT32 nCount)
Add a list data.
Definition: fx_basic.h:4061
FX_BOOL IsExhaustBuffer() const
Indicate whether this filter exhausts the input buffer.
Definition: fx_basic.h:3762
int Size() const
Get size of the container.
Definition: fx_basic.h:1946
~CFX_CountRef()
Destruct a reference and release the object it refers to.
Definition: fx_basic.h:3490
CFX_SortListArray(IFX_Allocator *pAllocator=0)
The constructor.
Definition: fx_basic.h:3905
Definition: fx_basic.h:3819
Failed.
Definition: fx_basic.h:4116
#define FX_Allocator_Free(fxAllocator, ptr)
Free memory block on an allocator.
Definition: fx_memory.h:1058
void ByteAlign()
Get to byte boundary. If current bit position is not multiplication of 8, the rest of the current byt...
void DetachBuffer()
Detach the buffer. Just set buffer pointer to NULL, and set the binary buffer size to zero.
FX_BOOL Flush()
Flush internal buffer.
FX_BOOL RemoveKey(KeyType key)
Remove existing (key, ?) pair.
Definition: fx_basic.h:2590
FX_BOOL Lookup(void *key, void *&rValue) const
Lookup by a key.
void RemoveAll()
Remove all objects in the array.
Definition: fx_basic.h:1842
Done.
Definition: fx_basic.h:4118
void ClearAll()
Release all remaining data.
~CFX_AutoRestorer()
The destructor.
Definition: fx_basic.h:3832
void * value
Value data.
Definition: fx_basic.h:2703
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL to use default allocator.
Definition: fx_basic.h:1171
IFX_Allocator * m_pAllocator
Special allocator pointer. NULL means to use default allocator.
Definition: fx_basic.h:2150
FX_POSITION AddHead(void *newElement)
Add a value to the head.
Header file for Strings, variable-length sequence of characters. There are two strings here,...
CFX_ArrayTemplate< FX_DWORD > CFX_DWordArray
Type definition for a double-word array type.
Definition: fx_basic.h:1614
FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover=false)
Attach file.
FX_INT32 AppendByte(FX_BYTE byte)
Append a single byte.
CFX_FileBufferArchive(FX_STRSIZE size=32768, IFX_Allocator *pAllocator=0)
A constructor with size and allocator.
CFX_ArrayTemplate< FX_FLOAT > CFX_FloatArray
Type definition for float array.
Definition: fx_basic.h:1620
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.
CFX_ArrayTemplate< FX_WORD > CFX_WordArray
Type definition for a word array type.
Definition: fx_basic.h:1612
CFX_AutoRestorer(T *location)
The constructor.
Definition: fx_basic.h:3826
CFX_FixedBufGrow(int data_size, IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2241
TYPE * AddSpace()
Add an element's space.
Definition: fx_basic.h:1503
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:646
CFX_ObjectStack()
Construct.
Definition: fx_basic.h:1929
CFX_ArrayTemplate< FX_WCHAR > CFX_WCHARArray
Type definition for FX_WHAR array.
Definition: fx_basic.h:1624
CFX_ArchiveSaver(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:485
int GetUpperBound() const
Get the upper bound in the array, actually the maximum valid index.
Definition: fx_basic.h:1357
FX_BOOL Empty() const
Empty the container.
Definition: fx_basic.h:1936
void * value
Value data.
Definition: fx_basic.h:2341
void TakeOver(CFX_BinaryBuf &other)
Takeover another buffer.
CFX_ByteString(* m_GetByteString)(CFX_CharMap *pMap, const CFX_WideString &wstr)
A pointer type to GetByteString function.
Definition: fx_basic.h:986
FX_POSITION GetStartPosition() const
Get the first key-value pair position. iterating all (key, value) pairs.
Definition: fx_basic.h:2433
FX_DWORD GetHashTableSize() const
Get the internal hash table size. Advanced features for derived classes.
Definition: fx_basic.h:2454
CFX_CMapByteStringToPtr(IFX_Allocator *pAllocator=0)
The constructor.
FX_BOOL SetAt(int nIndex, TYPE newElement)
This method overwrites an element specified by an index number.
Definition: fx_basic.h:1402
void * GetValueAt(void *key) const
Get a value pointer by a key.
ValueType & operator[](KeyType key)
Subscript([]) operator overload. Lookup and add if not there.
Definition: fx_basic.h:2571
~CFX_CMapByteStringToPtr()
The destructor.
void Append(FX_INT32 nStart, FX_INT32 nCount)
Append a list data.
Definition: fx_basic.h:3938
To be continued.
Definition: fx_basic.h:4110
CountedObj(const CountedObj &src)
The copy constructor.
Definition: fx_basic.h:3462
FX_BOOL IsEOF() const
Check if reached end of the stream.
Definition: fx_basic.h:3411
CFX_ByteString FX_UrlEncode(const CFX_WideString &wsUrl)
A simple URL encode.
void SetDataSize(int data_size)
Construct with allocator.
Definition: fx_basic.h:2259
TYPE & Top()
Get the top byte string.
Definition: fx_basic.h:1956
T2 * GetPtrAt(FX_INT32 nIndex)
Get a point to data.
Definition: fx_basic.h:4088
FX_INT32 AppendString(FX_BSTR lpsz)
Append a byte string value.
Definition: fx_basic.h:476
void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow=true)
Initialize the hash table.
int Size() const
Get size of the container.
Definition: fx_basic.h:1880
virtual ~IFX_Pause()
Destructor.
Definition: fx_basic.h:3694
FX_POSITION GetPrevPosition(FX_POSITION pos) const
Get the previous position.
Definition: fx_basic.h:3086
FX_BOOL InsertBlock(FX_STRSIZE pos, const void *pBuf, FX_STRSIZE size)
Insert a binary buffer block at the specified position.
ObjectClass * GetDataPtr(int index) const
Get a pointer to the specified element in the array. Direct pointer access.
Definition: fx_basic.h:1821
WIDE STRING CLASS.
Definition: fx_string.h:1470
Memory allocation error.
Definition: fx_basic.h:1300
FX_INT32 AppendInt64(FX_INT64 i)
Append a FX_INT64 value.
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 Input(FX_BYTE byte)
Input a byte.
Definition: fx_basic.h:2613
Definition: fx_basic.h:1002
FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount=1)
Inset one or more continuous element at specified position.
Definition: fx_basic.h:1564
FX_INTPTR GetLength() const
Get the length of saved data.
Definition: fx_basic.h:614
void Incref()
Increase the reference.
Definition: fx_basic.h:3663
#define FX_MIN(a, b)
A macro that returns the minimum of a and b.
Definition: fx_system.h:807
void Clear()
Clear data.
Definition: fx_basic.h:4048
#define GetObject
Get object information. GetObjectW defined for unicode-mode, GetObjectA for ansi-mode.
Definition: fx_system.h:541
Definition: fx_basic.h:3261
FX_POSITION InsertAfter(FX_POSITION pos, void *newElement)
Insert a value after specified position.
void RemoveAll()
Remove all the (key, value) pairs in the map.
IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator *pAllocator=0)
Construct with buffer size and special allocator.
FX_DWORD nHashValue
Cached hash value, needed for efficient iteration.
Definition: fx_basic.h:2699
CONSTANT BYTE STRING CLASS.
Definition: fx_string.h:51
void GetNextAssoc(FX_POSITION &rNextPosition, CFX_ByteString &rKey, void *&rValue) const
Get the current association and set the position to next association.
void GetNextAssoc(FX_POSITION &pos, FX_DWORD &key, FX_DWORD &value) const
Get the next association.
void * key
Key data.
Definition: fx_basic.h:2339
void Push(const TYPE &val)
Push the byte string to stack.
Definition: fx_basic.h:1978
Definition: fx_basic.h:3377
~CFX_ObjectArray()
The destructor.
Definition: fx_basic.h:1648
CFX_FixedBufGrow(IFX_Allocator *pAllocator=0)
Construct with allocator.
Definition: fx_basic.h:2227
FX_LPVOID GetPrivateData(FX_LPVOID module_id)
Get previously stored private data. Returns NULL for not stored.
~CFX_MapPtrToPtr()
The Destructor.
FX_BOOL AppendByte(FX_BYTE byte)
Append a single byte.
Definition: fx_basic.h:128
void *& operator[](FX_BSTR key)
Subscript([]) operator overload. Lookup and add if not there.

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