home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / Profiler / heapmon / utils.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-04  |  1.9 KB  |  83 lines

  1. // utils.hpp
  2. //
  3. // Created 10/02/98
  4. //
  5. // (C)Copyright 1998-1999 Microsoft Corporation, All rights reserved.
  6. //
  7.  
  8. #ifndef __UTILS_HPP__
  9. #define __UTILS_HPP__
  10.  
  11.  
  12. typedef int PTRMAPENUMFN (PCVOID key, PVOID value, PVOID token);
  13. typedef PTRMAPENUMFN *PPTRMAPENUMFN;
  14.  
  15. #define MAP_PTR_TO_PTR_SLOTS            17
  16.  
  17. class CMapPtrToPtr
  18. {
  19. private:
  20.     struct MapPtrToPtrNode {
  21.         MapPtrToPtrNode *m_pNext;
  22.         PCVOID m_pvKey;
  23.         PVOID m_pvValue;
  24.     };
  25.  
  26.     MapPtrToPtrNode *m_Table[MAP_PTR_TO_PTR_SLOTS];
  27.  
  28.     static DWORD GetBucketIndex(PCVOID pvKey) {
  29.         return ((DWORD) pvKey) % MAP_PTR_TO_PTR_SLOTS;
  30.     }
  31.  
  32. public:
  33.     CMapPtrToPtr();
  34.     ~CMapPtrToPtr();
  35.  
  36.     HRESULT Add(PCVOID pvKey, PVOID pvValue);
  37.     HRESULT Lookup(PCVOID pvKey, PVOID *ppvValue);
  38.     HRESULT Delete(PCVOID pvKey);
  39.  
  40.     int Iterate (PPTRMAPENUMFN filterfn, PVOID token);
  41.  
  42.     VOID Filter (PPTRMAPENUMFN filterfn, PVOID token);
  43. };
  44.  
  45.  
  46. enum WalkTreeFlags {
  47.     WT_LEAF_ONLY    = 0x00000001,  // enumerate only nodes with no children
  48. };
  49.  
  50. enum WalkTreeCBResults {
  51.     WTCB_STOP,
  52.     WTCB_CONTINUE,
  53.     WTCB_DELETE,
  54.     WTCB_MODIFIED,
  55. };
  56.  
  57. typedef WalkTreeCBResults (*PWALKTREECBFN) (HWND htree, HTREEITEM hti, PVOID token);
  58.  
  59. // Performs a prefix traversal of a TreeView control from the given node.
  60. // Returns TRUE if any callback returned a non-WTCB_STOP result.
  61. BOOL WalkTree (HWND htree, HTREEITEM root, DWORD flags, PWALKTREECBFN pfn, PVOID token);
  62.  
  63.  
  64. /*
  65.  * UnicodeToANSI
  66.  *
  67.  * If ncUnicodeLen is -1, pcwszUnicode must be null terminated.
  68.  * Otherwise, pcwszUnicode may or may not be null terminated and
  69.  * this function returns a null terminated ansi string.
  70.  */
  71. HRESULT UnicodeToANSI(LPCOLESTR pcwszUnicode, int ncUnicodeLen, PSTR *ppszANSI);
  72.  
  73.  
  74. int FitText (PSTR buf, int bufsize, PCSTR src);
  75. int FormatNumber (PSTR buf, int bufsize, PCSTR fmt, ...);
  76.  
  77.  
  78. VOID DeletePtrArray (PVOID *rgpv, int len);
  79.  
  80.  
  81. #endif /* __UTILS_HPP__ */
  82.  
  83.