Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1446 lines
40 KiB

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1995 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #ifndef __AFXCOLL_H__
  11. #define __AFXCOLL_H__
  12. /*
  13. #ifndef __AFX_H__
  14. #include <afx.h>
  15. #endif
  16. #ifdef _AFX_MINREBUILD
  17. #pragma component(minrebuild, off)
  18. #endif
  19. #ifndef _AFX_FULLTYPEINFO
  20. #pragma component(mintypeinfo, on)
  21. #endif
  22. #ifdef _AFX_PACKING
  23. #pragma pack(push, _AFX_PACKING)
  24. #endif
  25. */
  26. /////////////////////////////////////////////////////////////////////////////
  27. // Classes declared in this file
  28. //CObject
  29. // Arrays
  30. class CByteArray; // array of BYTE
  31. class CWordArray; // array of WORD
  32. class CDWordArray; // array of DWORD
  33. class CUIntArray; // array of UINT
  34. class CPtrArray; // array of void*
  35. class CObArray; // array of CObject*
  36. // Lists
  37. class CPtrList; // list of void*
  38. class CObList; // list of CObject*
  39. // Maps (aka Dictionaries)
  40. class CMapWordToOb; // map from WORD to CObject*
  41. class CMapWordToPtr; // map from WORD to void*
  42. class CMapPtrToWord; // map from void* to WORD
  43. class CMapPtrToPtr; // map from void* to void*
  44. // Special String variants
  45. class CStringArray; // array of CStrings
  46. class CStringList; // list of CStrings
  47. class CMapStringToPtr; // map from CString to void*
  48. class CMapStringToOb; // map from CString to CObject*
  49. class CMapStringToString; // map from CString to CString
  50. /////////////////////////////////////////////////////////////////////////////
  51. #undef AFX_DATA
  52. #define AFX_DATA AFX_CORE_DATA
  53. ////////////////////////////////////////////////////////////////////////////
  54. class CByteArray : public CObject
  55. {
  56. DECLARE_SERIAL(CByteArray)
  57. public:
  58. // Construction
  59. CByteArray();
  60. // Attributes
  61. int GetSize() const;
  62. int GetUpperBound() const;
  63. void SetSize(int nNewSize, int nGrowBy = -1);
  64. // Operations
  65. // Clean up
  66. void FreeExtra();
  67. void RemoveAll();
  68. // Accessing elements
  69. BYTE GetAt(int nIndex) const;
  70. void SetAt(int nIndex, BYTE newElement);
  71. BYTE& ElementAt(int nIndex);
  72. // Direct Access to the element data (may return NULL)
  73. const BYTE* GetData() const;
  74. BYTE* GetData();
  75. // Potentially growing the array
  76. void SetAtGrow(int nIndex, BYTE newElement);
  77. int Add(BYTE newElement);
  78. int Append(const CByteArray& src);
  79. void Copy(const CByteArray& src);
  80. // overloaded operator helpers
  81. BYTE operator[](int nIndex) const;
  82. BYTE& operator[](int nIndex);
  83. // Operations that move elements around
  84. void InsertAt(int nIndex, BYTE newElement, int nCount = 1);
  85. void RemoveAt(int nIndex, int nCount = 1);
  86. void InsertAt(int nStartIndex, CByteArray* pNewArray);
  87. // Implementation
  88. protected:
  89. BYTE* m_pData; // the actual array of data
  90. int m_nSize; // # of elements (upperBound - 1)
  91. int m_nMaxSize; // max allocated
  92. int m_nGrowBy; // grow amount
  93. public:
  94. ~CByteArray();
  95. void Serialize(CArchive&);
  96. #ifdef _DEBUG
  97. void Dump(CDumpContext&) const;
  98. void AssertValid() const;
  99. #endif
  100. protected:
  101. // local typedefs for class templates
  102. typedef BYTE BASE_TYPE;
  103. typedef BYTE BASE_ARG_TYPE;
  104. };
  105. ////////////////////////////////////////////////////////////////////////////
  106. class CWordArray : public CObject
  107. {
  108. DECLARE_SERIAL(CWordArray)
  109. public:
  110. // Construction
  111. CWordArray();
  112. // Attributes
  113. int GetSize() const;
  114. int GetUpperBound() const;
  115. void SetSize(int nNewSize, int nGrowBy = -1);
  116. // Operations
  117. // Clean up
  118. void FreeExtra();
  119. void RemoveAll();
  120. // Accessing elements
  121. WORD GetAt(int nIndex) const;
  122. void SetAt(int nIndex, WORD newElement);
  123. WORD& ElementAt(int nIndex);
  124. // Direct Access to the element data (may return NULL)
  125. const WORD* GetData() const;
  126. WORD* GetData();
  127. // Potentially growing the array
  128. void SetAtGrow(int nIndex, WORD newElement);
  129. int Add(WORD newElement);
  130. int Append(const CWordArray& src);
  131. void Copy(const CWordArray& src);
  132. // overloaded operator helpers
  133. WORD operator[](int nIndex) const;
  134. WORD& operator[](int nIndex);
  135. // Operations that move elements around
  136. void InsertAt(int nIndex, WORD newElement, int nCount = 1);
  137. void RemoveAt(int nIndex, int nCount = 1);
  138. void InsertAt(int nStartIndex, CWordArray* pNewArray);
  139. // Implementation
  140. protected:
  141. WORD* m_pData; // the actual array of data
  142. int m_nSize; // # of elements (upperBound - 1)
  143. int m_nMaxSize; // max allocated
  144. int m_nGrowBy; // grow amount
  145. public:
  146. ~CWordArray();
  147. void Serialize(CArchive&);
  148. #ifdef _DEBUG
  149. void Dump(CDumpContext&) const;
  150. void AssertValid() const;
  151. #endif
  152. protected:
  153. // local typedefs for class templates
  154. typedef WORD BASE_TYPE;
  155. typedef WORD BASE_ARG_TYPE;
  156. };
  157. ////////////////////////////////////////////////////////////////////////////
  158. class CDWordArray : public CObject
  159. {
  160. DECLARE_SERIAL(CDWordArray)
  161. public:
  162. // Construction
  163. CDWordArray();
  164. // Attributes
  165. int GetSize() const;
  166. int GetUpperBound() const;
  167. void SetSize(int nNewSize, int nGrowBy = -1);
  168. // Operations
  169. // Clean up
  170. void FreeExtra();
  171. void RemoveAll();
  172. // Accessing elements
  173. DWORD GetAt(int nIndex) const;
  174. void SetAt(int nIndex, DWORD newElement);
  175. DWORD& ElementAt(int nIndex);
  176. // Direct Access to the element data (may return NULL)
  177. const DWORD* GetData() const;
  178. DWORD* GetData();
  179. // Potentially growing the array
  180. void SetAtGrow(int nIndex, DWORD newElement);
  181. int Add(DWORD newElement);
  182. int Append(const CDWordArray& src);
  183. void Copy(const CDWordArray& src);
  184. // overloaded operator helpers
  185. DWORD operator[](int nIndex) const;
  186. DWORD& operator[](int nIndex);
  187. // Operations that move elements around
  188. void InsertAt(int nIndex, DWORD newElement, int nCount = 1);
  189. void RemoveAt(int nIndex, int nCount = 1);
  190. void InsertAt(int nStartIndex, CDWordArray* pNewArray);
  191. // Implementation
  192. protected:
  193. DWORD* m_pData; // the actual array of data
  194. int m_nSize; // # of elements (upperBound - 1)
  195. int m_nMaxSize; // max allocated
  196. int m_nGrowBy; // grow amount
  197. public:
  198. ~CDWordArray();
  199. void Serialize(CArchive&);
  200. #ifdef _DEBUG
  201. void Dump(CDumpContext&) const;
  202. void AssertValid() const;
  203. #endif
  204. protected:
  205. // local typedefs for class templates
  206. typedef DWORD BASE_TYPE;
  207. typedef DWORD BASE_ARG_TYPE;
  208. };
  209. ////////////////////////////////////////////////////////////////////////////
  210. class CUIntArray : public CObject
  211. {
  212. DECLARE_DYNAMIC(CUIntArray)
  213. public:
  214. // Construction
  215. CUIntArray();
  216. // Attributes
  217. int GetSize() const;
  218. int GetUpperBound() const;
  219. void SetSize(int nNewSize, int nGrowBy = -1);
  220. // Operations
  221. // Clean up
  222. void FreeExtra();
  223. void RemoveAll();
  224. // Accessing elements
  225. UINT GetAt(int nIndex) const;
  226. void SetAt(int nIndex, UINT newElement);
  227. UINT& ElementAt(int nIndex);
  228. // Direct Access to the element data (may return NULL)
  229. const UINT* GetData() const;
  230. UINT* GetData();
  231. // Potentially growing the array
  232. void SetAtGrow(int nIndex, UINT newElement);
  233. int Add(UINT newElement);
  234. int Append(const CUIntArray& src);
  235. void Copy(const CUIntArray& src);
  236. // overloaded operator helpers
  237. UINT operator[](int nIndex) const;
  238. UINT& operator[](int nIndex);
  239. // Operations that move elements around
  240. void InsertAt(int nIndex, UINT newElement, int nCount = 1);
  241. void RemoveAt(int nIndex, int nCount = 1);
  242. void InsertAt(int nStartIndex, CUIntArray* pNewArray);
  243. // Implementation
  244. protected:
  245. UINT* m_pData; // the actual array of data
  246. int m_nSize; // # of elements (upperBound - 1)
  247. int m_nMaxSize; // max allocated
  248. int m_nGrowBy; // grow amount
  249. public:
  250. ~CUIntArray();
  251. #ifdef _DEBUG
  252. void Dump(CDumpContext&) const;
  253. void AssertValid() const;
  254. #endif
  255. protected:
  256. // local typedefs for class templates
  257. typedef UINT BASE_TYPE;
  258. typedef UINT BASE_ARG_TYPE;
  259. };
  260. ////////////////////////////////////////////////////////////////////////////
  261. class CPtrArray : public CObject
  262. {
  263. DECLARE_DYNAMIC(CPtrArray)
  264. public:
  265. // Construction
  266. CPtrArray();
  267. // Attributes
  268. int GetSize() const;
  269. int GetUpperBound() const;
  270. void SetSize(int nNewSize, int nGrowBy = -1);
  271. // Operations
  272. // Clean up
  273. void FreeExtra();
  274. void RemoveAll();
  275. // Accessing elements
  276. void* GetAt(int nIndex) const;
  277. void SetAt(int nIndex, void* newElement);
  278. void*& ElementAt(int nIndex);
  279. // Direct Access to the element data (may return NULL)
  280. const void** GetData() const;
  281. void** GetData();
  282. // Potentially growing the array
  283. void SetAtGrow(int nIndex, void* newElement);
  284. int Add(void* newElement);
  285. int Append(const CPtrArray& src);
  286. void Copy(const CPtrArray& src);
  287. // overloaded operator helpers
  288. void* operator[](int nIndex) const;
  289. void*& operator[](int nIndex);
  290. // Operations that move elements around
  291. void InsertAt(int nIndex, void* newElement, int nCount = 1);
  292. void RemoveAt(int nIndex, int nCount = 1);
  293. void InsertAt(int nStartIndex, CPtrArray* pNewArray);
  294. // Implementation
  295. protected:
  296. void** m_pData; // the actual array of data
  297. int m_nSize; // # of elements (upperBound - 1)
  298. int m_nMaxSize; // max allocated
  299. int m_nGrowBy; // grow amount
  300. public:
  301. ~CPtrArray();
  302. #ifdef _DEBUG
  303. void Dump(CDumpContext&) const;
  304. void AssertValid() const;
  305. #endif
  306. protected:
  307. // local typedefs for class templates
  308. typedef void* BASE_TYPE;
  309. typedef void* BASE_ARG_TYPE;
  310. };
  311. ////////////////////////////////////////////////////////////////////////////
  312. class CObArray : public CObject
  313. {
  314. DECLARE_SERIAL(CObArray)
  315. public:
  316. // Construction
  317. CObArray();
  318. // Attributes
  319. int GetSize() const;
  320. int GetUpperBound() const;
  321. void SetSize(int nNewSize, int nGrowBy = -1);
  322. // Operations
  323. // Clean up
  324. void FreeExtra();
  325. void RemoveAll();
  326. // Accessing elements
  327. CObject* GetAt(int nIndex) const;
  328. void SetAt(int nIndex, CObject* newElement);
  329. CObject*& ElementAt(int nIndex);
  330. // Direct Access to the element data (may return NULL)
  331. const CObject** GetData() const;
  332. CObject** GetData();
  333. // Potentially growing the array
  334. void SetAtGrow(int nIndex, CObject* newElement);
  335. int Add(CObject* newElement);
  336. int Append(const CObArray& src);
  337. void Copy(const CObArray& src);
  338. // overloaded operator helpers
  339. CObject* operator[](int nIndex) const;
  340. CObject*& operator[](int nIndex);
  341. // Operations that move elements around
  342. void InsertAt(int nIndex, CObject* newElement, int nCount = 1);
  343. void RemoveAt(int nIndex, int nCount = 1);
  344. void InsertAt(int nStartIndex, CObArray* pNewArray);
  345. // Implementation
  346. protected:
  347. CObject** m_pData; // the actual array of data
  348. int m_nSize; // # of elements (upperBound - 1)
  349. int m_nMaxSize; // max allocated
  350. int m_nGrowBy; // grow amount
  351. public:
  352. ~CObArray();
  353. void Serialize(CArchive&);
  354. #ifdef _DEBUG
  355. void Dump(CDumpContext&) const;
  356. void AssertValid() const;
  357. #endif
  358. protected:
  359. // local typedefs for class templates
  360. typedef CObject* BASE_TYPE;
  361. typedef CObject* BASE_ARG_TYPE;
  362. };
  363. ////////////////////////////////////////////////////////////////////////////
  364. class CStringArray : public CObject
  365. {
  366. DECLARE_SERIAL(CStringArray)
  367. public:
  368. // Construction
  369. CStringArray();
  370. // Attributes
  371. int GetSize() const;
  372. int GetUpperBound() const;
  373. void SetSize(int nNewSize, int nGrowBy = -1);
  374. // Operations
  375. // Clean up
  376. void FreeExtra();
  377. void RemoveAll();
  378. // Accessing elements
  379. CString GetAt(int nIndex) const;
  380. void SetAt(int nIndex, LPCTSTR newElement);
  381. CString& ElementAt(int nIndex);
  382. // Direct Access to the element data (may return NULL)
  383. const CString* GetData() const;
  384. CString* GetData();
  385. // Potentially growing the array
  386. void SetAtGrow(int nIndex, LPCTSTR newElement);
  387. int Add(LPCTSTR newElement);
  388. int Append(const CStringArray& src);
  389. void Copy(const CStringArray& src);
  390. // overloaded operator helpers
  391. CString operator[](int nIndex) const;
  392. CString& operator[](int nIndex);
  393. // Operations that move elements around
  394. void InsertAt(int nIndex, LPCTSTR newElement, int nCount = 1);
  395. void RemoveAt(int nIndex, int nCount = 1);
  396. void InsertAt(int nStartIndex, CStringArray* pNewArray);
  397. // Implementation
  398. protected:
  399. CString* m_pData; // the actual array of data
  400. int m_nSize; // # of elements (upperBound - 1)
  401. int m_nMaxSize; // max allocated
  402. int m_nGrowBy; // grow amount
  403. public:
  404. ~CStringArray();
  405. void Serialize(CArchive&);
  406. #ifdef _DEBUG
  407. void Dump(CDumpContext&) const;
  408. void AssertValid() const;
  409. #endif
  410. protected:
  411. // local typedefs for class templates
  412. typedef CString BASE_TYPE;
  413. typedef LPCTSTR BASE_ARG_TYPE;
  414. };
  415. /////////////////////////////////////////////////////////////////////////////
  416. class CPtrList : public CObject
  417. {
  418. DECLARE_DYNAMIC(CPtrList)
  419. protected:
  420. struct CNode
  421. {
  422. CNode* pNext;
  423. CNode* pPrev;
  424. void* data;
  425. };
  426. public:
  427. // Construction
  428. CPtrList(int nBlockSize = 10);
  429. // Attributes (head and tail)
  430. // count of elements
  431. int GetCount() const;
  432. BOOL IsEmpty() const;
  433. // peek at head or tail
  434. void*& GetHead();
  435. void* GetHead() const;
  436. void*& GetTail();
  437. void* GetTail() const;
  438. // Operations
  439. // get head or tail (and remove it) - don't call on empty list!
  440. void* RemoveHead();
  441. void* RemoveTail();
  442. // add before head or after tail
  443. POSITION AddHead(void* newElement);
  444. POSITION AddTail(void* newElement);
  445. // add another list of elements before head or after tail
  446. void AddHead(CPtrList* pNewList);
  447. void AddTail(CPtrList* pNewList);
  448. // remove all elements
  449. void RemoveAll();
  450. // iteration
  451. POSITION GetHeadPosition() const;
  452. POSITION GetTailPosition() const;
  453. void*& GetNext(POSITION& rPosition); // return *Position++
  454. void* GetNext(POSITION& rPosition) const; // return *Position++
  455. void*& GetPrev(POSITION& rPosition); // return *Position--
  456. void* GetPrev(POSITION& rPosition) const; // return *Position--
  457. // getting/modifying an element at a given position
  458. void*& GetAt(POSITION position);
  459. void* GetAt(POSITION position) const;
  460. void SetAt(POSITION pos, void* newElement);
  461. void RemoveAt(POSITION position);
  462. // inserting before or after a given position
  463. POSITION InsertBefore(POSITION position, void* newElement);
  464. POSITION InsertAfter(POSITION position, void* newElement);
  465. // helper functions (note: O(n) speed)
  466. POSITION Find(void* searchValue, POSITION startAfter = NULL) const;
  467. // defaults to starting at the HEAD
  468. // return NULL if not found
  469. POSITION FindIndex(int nIndex) const;
  470. // get the 'nIndex'th element (may return NULL)
  471. // Implementation
  472. protected:
  473. CNode* m_pNodeHead;
  474. CNode* m_pNodeTail;
  475. int m_nCount;
  476. CNode* m_pNodeFree;
  477. struct CPlex* m_pBlocks;
  478. int m_nBlockSize;
  479. CNode* NewNode(CNode*, CNode*);
  480. void FreeNode(CNode*);
  481. public:
  482. ~CPtrList();
  483. #ifdef _DEBUG
  484. void Dump(CDumpContext&) const;
  485. void AssertValid() const;
  486. #endif
  487. // local typedefs for class templates
  488. typedef void* BASE_TYPE;
  489. typedef void* BASE_ARG_TYPE;
  490. };
  491. /////////////////////////////////////////////////////////////////////////////
  492. class CObList : public CObject
  493. {
  494. DECLARE_SERIAL(CObList)
  495. protected:
  496. struct CNode
  497. {
  498. CNode* pNext;
  499. CNode* pPrev;
  500. CObject* data;
  501. };
  502. public:
  503. // Construction
  504. CObList(int nBlockSize = 10);
  505. // Attributes (head and tail)
  506. // count of elements
  507. int GetCount() const;
  508. BOOL IsEmpty() const;
  509. // peek at head or tail
  510. CObject*& GetHead();
  511. CObject* GetHead() const;
  512. CObject*& GetTail();
  513. CObject* GetTail() const;
  514. // Operations
  515. // get head or tail (and remove it) - don't call on empty list!
  516. CObject* RemoveHead();
  517. CObject* RemoveTail();
  518. // add before head or after tail
  519. POSITION AddHead(CObject* newElement);
  520. POSITION AddTail(CObject* newElement);
  521. // add another list of elements before head or after tail
  522. void AddHead(CObList* pNewList);
  523. void AddTail(CObList* pNewList);
  524. // remove all elements
  525. void RemoveAll();
  526. // iteration
  527. POSITION GetHeadPosition() const;
  528. POSITION GetTailPosition() const;
  529. CObject*& GetNext(POSITION& rPosition); // return *Position++
  530. CObject* GetNext(POSITION& rPosition) const; // return *Position++
  531. CObject*& GetPrev(POSITION& rPosition); // return *Position--
  532. CObject* GetPrev(POSITION& rPosition) const; // return *Position--
  533. // getting/modifying an element at a given position
  534. CObject*& GetAt(POSITION position);
  535. CObject* GetAt(POSITION position) const;
  536. void SetAt(POSITION pos, CObject* newElement);
  537. void RemoveAt(POSITION position);
  538. // inserting before or after a given position
  539. POSITION InsertBefore(POSITION position, CObject* newElement);
  540. POSITION InsertAfter(POSITION position, CObject* newElement);
  541. // helper functions (note: O(n) speed)
  542. POSITION Find(CObject* searchValue, POSITION startAfter = NULL) const;
  543. // defaults to starting at the HEAD
  544. // return NULL if not found
  545. POSITION FindIndex(int nIndex) const;
  546. // get the 'nIndex'th element (may return NULL)
  547. // Implementation
  548. protected:
  549. CNode* m_pNodeHead;
  550. CNode* m_pNodeTail;
  551. int m_nCount;
  552. CNode* m_pNodeFree;
  553. struct CPlex* m_pBlocks;
  554. int m_nBlockSize;
  555. CNode* NewNode(CNode*, CNode*);
  556. void FreeNode(CNode*);
  557. public:
  558. ~CObList();
  559. void Serialize(CArchive&);
  560. #ifdef _DEBUG
  561. void Dump(CDumpContext&) const;
  562. void AssertValid() const;
  563. #endif
  564. // local typedefs for class templates
  565. typedef CObject* BASE_TYPE;
  566. typedef CObject* BASE_ARG_TYPE;
  567. };
  568. /////////////////////////////////////////////////////////////////////////////
  569. class CStringList : public CObject
  570. {
  571. DECLARE_SERIAL(CStringList)
  572. protected:
  573. struct CNode
  574. {
  575. CNode* pNext;
  576. CNode* pPrev;
  577. CString data;
  578. };
  579. public:
  580. // Construction
  581. CStringList(int nBlockSize = 10);
  582. // Attributes (head and tail)
  583. // count of elements
  584. int GetCount() const;
  585. BOOL IsEmpty() const;
  586. // peek at head or tail
  587. CString& GetHead();
  588. CString GetHead() const;
  589. CString& GetTail();
  590. CString GetTail() const;
  591. // Operations
  592. // get head or tail (and remove it) - don't call on empty list!
  593. CString RemoveHead();
  594. CString RemoveTail();
  595. // add before head or after tail
  596. POSITION AddHead(LPCTSTR newElement);
  597. POSITION AddTail(LPCTSTR newElement);
  598. // add another list of elements before head or after tail
  599. void AddHead(CStringList* pNewList);
  600. void AddTail(CStringList* pNewList);
  601. // remove all elements
  602. void RemoveAll();
  603. // iteration
  604. POSITION GetHeadPosition() const;
  605. POSITION GetTailPosition() const;
  606. CString& GetNext(POSITION& rPosition); // return *Position++
  607. CString GetNext(POSITION& rPosition) const; // return *Position++
  608. CString& GetPrev(POSITION& rPosition); // return *Position--
  609. CString GetPrev(POSITION& rPosition) const; // return *Position--
  610. // getting/modifying an element at a given position
  611. CString& GetAt(POSITION position);
  612. CString GetAt(POSITION position) const;
  613. void SetAt(POSITION pos, LPCTSTR newElement);
  614. void RemoveAt(POSITION position);
  615. // inserting before or after a given position
  616. POSITION InsertBefore(POSITION position, LPCTSTR newElement);
  617. POSITION InsertAfter(POSITION position, LPCTSTR newElement);
  618. // helper functions (note: O(n) speed)
  619. POSITION Find(LPCTSTR searchValue, POSITION startAfter = NULL) const;
  620. // defaults to starting at the HEAD
  621. // return NULL if not found
  622. POSITION FindIndex(int nIndex) const;
  623. // get the 'nIndex'th element (may return NULL)
  624. // Implementation
  625. protected:
  626. CNode* m_pNodeHead;
  627. CNode* m_pNodeTail;
  628. int m_nCount;
  629. CNode* m_pNodeFree;
  630. struct CPlex* m_pBlocks;
  631. int m_nBlockSize;
  632. CNode* NewNode(CNode*, CNode*);
  633. void FreeNode(CNode*);
  634. public:
  635. ~CStringList();
  636. void Serialize(CArchive&);
  637. #ifdef _DEBUG
  638. void Dump(CDumpContext&) const;
  639. void AssertValid() const;
  640. #endif
  641. // local typedefs for class templates
  642. typedef CString BASE_TYPE;
  643. typedef LPCTSTR BASE_ARG_TYPE;
  644. };
  645. /////////////////////////////////////////////////////////////////////////////
  646. class CMapWordToPtr : public CObject
  647. {
  648. DECLARE_DYNAMIC(CMapWordToPtr)
  649. protected:
  650. // Association
  651. struct CAssoc
  652. {
  653. CAssoc* pNext;
  654. WORD key;
  655. void* value;
  656. };
  657. public:
  658. // Construction
  659. CMapWordToPtr(int nBlockSize = 10);
  660. // Attributes
  661. // number of elements
  662. int GetCount() const;
  663. BOOL IsEmpty() const;
  664. // Lookup
  665. BOOL Lookup(WORD key, void*& rValue) const;
  666. // Operations
  667. // Lookup and add if not there
  668. void*& operator[](WORD key);
  669. // add a new (key, value) pair
  670. void SetAt(WORD key, void* newValue);
  671. // removing existing (key, ?) pair
  672. BOOL RemoveKey(WORD key);
  673. void RemoveAll();
  674. // iterating all (key, value) pairs
  675. POSITION GetStartPosition() const;
  676. void GetNextAssoc(POSITION& rNextPosition, WORD& rKey, void*& rValue) const;
  677. // advanced features for derived classes
  678. UINT GetHashTableSize() const;
  679. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  680. // Overridables: special non-virtual (see map implementation for details)
  681. // Routine used to user-provided hash keys
  682. UINT HashKey(WORD key) const;
  683. // Implementation
  684. protected:
  685. CAssoc** m_pHashTable;
  686. UINT m_nHashTableSize;
  687. int m_nCount;
  688. CAssoc* m_pFreeList;
  689. struct CPlex* m_pBlocks;
  690. int m_nBlockSize;
  691. CAssoc* NewAssoc();
  692. void FreeAssoc(CAssoc*);
  693. CAssoc* GetAssocAt(WORD, UINT&) const;
  694. public:
  695. ~CMapWordToPtr();
  696. #ifdef _DEBUG
  697. void Dump(CDumpContext&) const;
  698. void AssertValid() const;
  699. #endif
  700. protected:
  701. // local typedefs for CTypedPtrMap class template
  702. typedef WORD BASE_KEY;
  703. typedef WORD BASE_ARG_KEY;
  704. typedef void* BASE_VALUE;
  705. typedef void* BASE_ARG_VALUE;
  706. };
  707. /////////////////////////////////////////////////////////////////////////////
  708. class CMapPtrToWord : public CObject
  709. {
  710. DECLARE_DYNAMIC(CMapPtrToWord)
  711. protected:
  712. // Association
  713. struct CAssoc
  714. {
  715. CAssoc* pNext;
  716. void* key;
  717. WORD value;
  718. };
  719. public:
  720. // Construction
  721. CMapPtrToWord(int nBlockSize = 10);
  722. // Attributes
  723. // number of elements
  724. int GetCount() const;
  725. BOOL IsEmpty() const;
  726. // Lookup
  727. BOOL Lookup(void* key, WORD& rValue) const;
  728. // Operations
  729. // Lookup and add if not there
  730. WORD& operator[](void* key);
  731. // add a new (key, value) pair
  732. void SetAt(void* key, WORD newValue);
  733. // removing existing (key, ?) pair
  734. BOOL RemoveKey(void* key);
  735. void RemoveAll();
  736. // iterating all (key, value) pairs
  737. POSITION GetStartPosition() const;
  738. void GetNextAssoc(POSITION& rNextPosition, void*& rKey, WORD& rValue) const;
  739. // advanced features for derived classes
  740. UINT GetHashTableSize() const;
  741. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  742. // Overridables: special non-virtual (see map implementation for details)
  743. // Routine used to user-provided hash keys
  744. UINT HashKey(void* key) const;
  745. // Implementation
  746. protected:
  747. CAssoc** m_pHashTable;
  748. UINT m_nHashTableSize;
  749. int m_nCount;
  750. CAssoc* m_pFreeList;
  751. struct CPlex* m_pBlocks;
  752. int m_nBlockSize;
  753. CAssoc* NewAssoc();
  754. void FreeAssoc(CAssoc*);
  755. CAssoc* GetAssocAt(void*, UINT&) const;
  756. public:
  757. ~CMapPtrToWord();
  758. #ifdef _DEBUG
  759. void Dump(CDumpContext&) const;
  760. void AssertValid() const;
  761. #endif
  762. protected:
  763. // local typedefs for CTypedPtrMap class template
  764. typedef void* BASE_KEY;
  765. typedef void* BASE_ARG_KEY;
  766. typedef WORD BASE_VALUE;
  767. typedef WORD BASE_ARG_VALUE;
  768. };
  769. /////////////////////////////////////////////////////////////////////////////
  770. class CMapPtrToPtr : public CObject
  771. {
  772. DECLARE_DYNAMIC(CMapPtrToPtr)
  773. protected:
  774. // Association
  775. struct CAssoc
  776. {
  777. CAssoc* pNext;
  778. void* key;
  779. void* value;
  780. };
  781. public:
  782. // Construction
  783. CMapPtrToPtr(int nBlockSize = 10);
  784. // Attributes
  785. // number of elements
  786. int GetCount() const;
  787. BOOL IsEmpty() const;
  788. // Lookup
  789. BOOL Lookup(void* key, void*& rValue) const;
  790. // Operations
  791. // Lookup and add if not there
  792. void*& operator[](void* key);
  793. // add a new (key, value) pair
  794. void SetAt(void* key, void* newValue);
  795. // removing existing (key, ?) pair
  796. BOOL RemoveKey(void* key);
  797. void RemoveAll();
  798. // iterating all (key, value) pairs
  799. POSITION GetStartPosition() const;
  800. void GetNextAssoc(POSITION& rNextPosition, void*& rKey, void*& rValue) const;
  801. // advanced features for derived classes
  802. UINT GetHashTableSize() const;
  803. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  804. // Overridables: special non-virtual (see map implementation for details)
  805. // Routine used to user-provided hash keys
  806. UINT HashKey(void* key) const;
  807. // Implementation
  808. protected:
  809. CAssoc** m_pHashTable;
  810. UINT m_nHashTableSize;
  811. int m_nCount;
  812. CAssoc* m_pFreeList;
  813. struct CPlex* m_pBlocks;
  814. int m_nBlockSize;
  815. CAssoc* NewAssoc();
  816. void FreeAssoc(CAssoc*);
  817. CAssoc* GetAssocAt(void*, UINT&) const;
  818. public:
  819. ~CMapPtrToPtr();
  820. #ifdef _DEBUG
  821. void Dump(CDumpContext&) const;
  822. void AssertValid() const;
  823. #endif
  824. void* GetValueAt(void* key) const;
  825. protected:
  826. // local typedefs for CTypedPtrMap class template
  827. typedef void* BASE_KEY;
  828. typedef void* BASE_ARG_KEY;
  829. typedef void* BASE_VALUE;
  830. typedef void* BASE_ARG_VALUE;
  831. };
  832. /////////////////////////////////////////////////////////////////////////////
  833. class CMapWordToOb : public CObject
  834. {
  835. DECLARE_SERIAL(CMapWordToOb)
  836. protected:
  837. // Association
  838. struct CAssoc
  839. {
  840. CAssoc* pNext;
  841. WORD key;
  842. CObject* value;
  843. };
  844. public:
  845. // Construction
  846. CMapWordToOb(int nBlockSize = 10);
  847. // Attributes
  848. // number of elements
  849. int GetCount() const;
  850. BOOL IsEmpty() const;
  851. // Lookup
  852. BOOL Lookup(WORD key, CObject*& rValue) const;
  853. // Operations
  854. // Lookup and add if not there
  855. CObject*& operator[](WORD key);
  856. // add a new (key, value) pair
  857. void SetAt(WORD key, CObject* newValue);
  858. // removing existing (key, ?) pair
  859. BOOL RemoveKey(WORD key);
  860. void RemoveAll();
  861. // iterating all (key, value) pairs
  862. POSITION GetStartPosition() const;
  863. void GetNextAssoc(POSITION& rNextPosition, WORD& rKey, CObject*& rValue) const;
  864. // advanced features for derived classes
  865. UINT GetHashTableSize() const;
  866. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  867. // Overridables: special non-virtual (see map implementation for details)
  868. // Routine used to user-provided hash keys
  869. UINT HashKey(WORD key) const;
  870. // Implementation
  871. protected:
  872. CAssoc** m_pHashTable;
  873. UINT m_nHashTableSize;
  874. int m_nCount;
  875. CAssoc* m_pFreeList;
  876. struct CPlex* m_pBlocks;
  877. int m_nBlockSize;
  878. CAssoc* NewAssoc();
  879. void FreeAssoc(CAssoc*);
  880. CAssoc* GetAssocAt(WORD, UINT&) const;
  881. public:
  882. ~CMapWordToOb();
  883. void Serialize(CArchive&);
  884. #ifdef _DEBUG
  885. void Dump(CDumpContext&) const;
  886. void AssertValid() const;
  887. #endif
  888. protected:
  889. // local typedefs for CTypedPtrMap class template
  890. typedef WORD BASE_KEY;
  891. typedef WORD BASE_ARG_KEY;
  892. typedef CObject* BASE_VALUE;
  893. typedef CObject* BASE_ARG_VALUE;
  894. };
  895. /////////////////////////////////////////////////////////////////////////////
  896. class CMapStringToPtr : public CObject
  897. {
  898. DECLARE_DYNAMIC(CMapStringToPtr)
  899. protected:
  900. // Association
  901. struct CAssoc
  902. {
  903. CAssoc* pNext;
  904. UINT nHashValue; // needed for efficient iteration
  905. CString key;
  906. void* value;
  907. };
  908. public:
  909. // Construction
  910. CMapStringToPtr(int nBlockSize = 10);
  911. // Attributes
  912. // number of elements
  913. int GetCount() const;
  914. BOOL IsEmpty() const;
  915. // Lookup
  916. BOOL Lookup(LPCTSTR key, void*& rValue) const;
  917. BOOL LookupKey(LPCTSTR key, LPCTSTR& rKey) const;
  918. // Operations
  919. // Lookup and add if not there
  920. void*& operator[](LPCTSTR key);
  921. // add a new (key, value) pair
  922. void SetAt(LPCTSTR key, void* newValue);
  923. // removing existing (key, ?) pair
  924. BOOL RemoveKey(LPCTSTR key);
  925. void RemoveAll();
  926. // iterating all (key, value) pairs
  927. POSITION GetStartPosition() const;
  928. void GetNextAssoc(POSITION& rNextPosition, CString& rKey, void*& rValue) const;
  929. // advanced features for derived classes
  930. UINT GetHashTableSize() const;
  931. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  932. // Overridables: special non-virtual (see map implementation for details)
  933. // Routine used to user-provided hash keys
  934. UINT HashKey(LPCTSTR key) const;
  935. // Implementation
  936. protected:
  937. CAssoc** m_pHashTable;
  938. UINT m_nHashTableSize;
  939. int m_nCount;
  940. CAssoc* m_pFreeList;
  941. struct CPlex* m_pBlocks;
  942. int m_nBlockSize;
  943. CAssoc* NewAssoc();
  944. void FreeAssoc(CAssoc*);
  945. CAssoc* GetAssocAt(LPCTSTR, UINT&) const;
  946. public:
  947. ~CMapStringToPtr();
  948. #ifdef _DEBUG
  949. void Dump(CDumpContext&) const;
  950. void AssertValid() const;
  951. #endif
  952. protected:
  953. // local typedefs for CTypedPtrMap class template
  954. typedef CString BASE_KEY;
  955. typedef LPCTSTR BASE_ARG_KEY;
  956. typedef void* BASE_VALUE;
  957. typedef void* BASE_ARG_VALUE;
  958. };
  959. /////////////////////////////////////////////////////////////////////////////
  960. class CMapStringToOb : public CObject
  961. {
  962. DECLARE_SERIAL(CMapStringToOb)
  963. protected:
  964. // Association
  965. struct CAssoc
  966. {
  967. CAssoc* pNext;
  968. UINT nHashValue; // needed for efficient iteration
  969. CString key;
  970. CObject* value;
  971. };
  972. public:
  973. // Construction
  974. CMapStringToOb(int nBlockSize = 10);
  975. // Attributes
  976. // number of elements
  977. int GetCount() const;
  978. BOOL IsEmpty() const;
  979. // Lookup
  980. BOOL Lookup(LPCTSTR key, CObject*& rValue) const;
  981. BOOL LookupKey(LPCTSTR key, LPCTSTR& rKey) const;
  982. // Operations
  983. // Lookup and add if not there
  984. CObject*& operator[](LPCTSTR key);
  985. // add a new (key, value) pair
  986. void SetAt(LPCTSTR key, CObject* newValue);
  987. // removing existing (key, ?) pair
  988. BOOL RemoveKey(LPCTSTR key);
  989. void RemoveAll();
  990. // iterating all (key, value) pairs
  991. POSITION GetStartPosition() const;
  992. void GetNextAssoc(POSITION& rNextPosition, CString& rKey, CObject*& rValue) const;
  993. // advanced features for derived classes
  994. UINT GetHashTableSize() const;
  995. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  996. // Overridables: special non-virtual (see map implementation for details)
  997. // Routine used to user-provided hash keys
  998. UINT HashKey(LPCTSTR key) const;
  999. // Implementation
  1000. protected:
  1001. CAssoc** m_pHashTable;
  1002. UINT m_nHashTableSize;
  1003. int m_nCount;
  1004. CAssoc* m_pFreeList;
  1005. struct CPlex* m_pBlocks;
  1006. int m_nBlockSize;
  1007. CAssoc* NewAssoc();
  1008. void FreeAssoc(CAssoc*);
  1009. CAssoc* GetAssocAt(LPCTSTR, UINT&) const;
  1010. public:
  1011. ~CMapStringToOb();
  1012. void Serialize(CArchive&);
  1013. #ifdef _DEBUG
  1014. void Dump(CDumpContext&) const;
  1015. void AssertValid() const;
  1016. #endif
  1017. protected:
  1018. // local typedefs for CTypedPtrMap class template
  1019. typedef CString BASE_KEY;
  1020. typedef LPCTSTR BASE_ARG_KEY;
  1021. typedef CObject* BASE_VALUE;
  1022. typedef CObject* BASE_ARG_VALUE;
  1023. };
  1024. /////////////////////////////////////////////////////////////////////////////
  1025. class CMapStringToString : public CObject
  1026. {
  1027. DECLARE_SERIAL(CMapStringToString)
  1028. protected:
  1029. // Association
  1030. struct CAssoc
  1031. {
  1032. CAssoc* pNext;
  1033. UINT nHashValue; // needed for efficient iteration
  1034. CString key;
  1035. CString value;
  1036. };
  1037. public:
  1038. // Construction
  1039. CMapStringToString(int nBlockSize = 10);
  1040. // Attributes
  1041. // number of elements
  1042. int GetCount() const;
  1043. BOOL IsEmpty() const;
  1044. // Lookup
  1045. BOOL Lookup(LPCTSTR key, CString& rValue) const;
  1046. BOOL LookupKey(LPCTSTR key, LPCTSTR& rKey) const;
  1047. // Operations
  1048. // Lookup and add if not there
  1049. CString& operator[](LPCTSTR key);
  1050. // add a new (key, value) pair
  1051. void SetAt(LPCTSTR key, LPCTSTR newValue);
  1052. // removing existing (key, ?) pair
  1053. BOOL RemoveKey(LPCTSTR key);
  1054. void RemoveAll();
  1055. // iterating all (key, value) pairs
  1056. POSITION GetStartPosition() const;
  1057. void GetNextAssoc(POSITION& rNextPosition, CString& rKey, CString& rValue) const;
  1058. // advanced features for derived classes
  1059. UINT GetHashTableSize() const;
  1060. void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
  1061. // Overridables: special non-virtual (see map implementation for details)
  1062. // Routine used to user-provided hash keys
  1063. UINT HashKey(LPCTSTR key) const;
  1064. // Implementation
  1065. protected:
  1066. CAssoc** m_pHashTable;
  1067. UINT m_nHashTableSize;
  1068. int m_nCount;
  1069. CAssoc* m_pFreeList;
  1070. struct CPlex* m_pBlocks;
  1071. int m_nBlockSize;
  1072. CAssoc* NewAssoc();
  1073. void FreeAssoc(CAssoc*);
  1074. CAssoc* GetAssocAt(LPCTSTR, UINT&) const;
  1075. public:
  1076. ~CMapStringToString();
  1077. void Serialize(CArchive&);
  1078. #ifdef _DEBUG
  1079. void Dump(CDumpContext&) const;
  1080. void AssertValid() const;
  1081. #endif
  1082. protected:
  1083. // local typedefs for CTypedPtrMap class template
  1084. typedef CString BASE_KEY;
  1085. typedef LPCTSTR BASE_ARG_KEY;
  1086. typedef CString BASE_VALUE;
  1087. typedef LPCTSTR BASE_ARG_VALUE;
  1088. };
  1089. /////////////////////////////////////////////////////////////////////////////
  1090. // Special include for Win32s compatibility
  1091. //
  1092. // This is a part of the Microsoft Foundation Classes C++ library.
  1093. // Copyright (C) 1992-1995 Microsoft Corporation
  1094. // All rights reserved.
  1095. //
  1096. // This source code is only intended as a supplement to the
  1097. // Microsoft Foundation Classes Reference and related
  1098. // electronic documentation provided with the library.
  1099. // See these sources for detailed information regarding the
  1100. // Microsoft Foundation Classes product.
  1101. #ifdef _AFX_PACKING
  1102. #pragma pack(pop)
  1103. #endif
  1104. #ifndef __AFXSTATE_H__
  1105. #include <afxstat_.h> // for MFC private state structures
  1106. #endif
  1107. /////////////////////////////////////////////////////////////////////////////
  1108. // Inline function declarations
  1109. #ifdef _AFX_ENABLE_INLINES
  1110. #define _AFXCOLL_INLINE inline
  1111. #include <afxcoll.inl>
  1112. #endif
  1113. #undef AFX_DATA
  1114. #define AFX_DATA
  1115. #ifdef _AFX_MINREBUILD
  1116. #pragma component(minrebuild, on)
  1117. #endif
  1118. #ifndef _AFX_FULLTYPEINFO
  1119. #pragma component(mintypeinfo, off)
  1120. #endif
  1121. #endif //!__AFXCOLL_H__
  1122. /////////////////////////////////////////////////////////////////////////////