home *** CD-ROM | disk | FTP | other *** search
- // utils.hpp
- //
- // Created 10/02/98
- //
- // (C)Copyright 1998-1999 Microsoft Corporation, All rights reserved.
- //
-
- #ifndef __UTILS_HPP__
- #define __UTILS_HPP__
-
-
- typedef int PTRMAPENUMFN (PCVOID key, PVOID value, PVOID token);
- typedef PTRMAPENUMFN *PPTRMAPENUMFN;
-
- #define MAP_PTR_TO_PTR_SLOTS 17
-
- class CMapPtrToPtr
- {
- private:
- struct MapPtrToPtrNode {
- MapPtrToPtrNode *m_pNext;
- PCVOID m_pvKey;
- PVOID m_pvValue;
- };
-
- MapPtrToPtrNode *m_Table[MAP_PTR_TO_PTR_SLOTS];
-
- static DWORD GetBucketIndex(PCVOID pvKey) {
- return ((DWORD) pvKey) % MAP_PTR_TO_PTR_SLOTS;
- }
-
- public:
- CMapPtrToPtr();
- ~CMapPtrToPtr();
-
- HRESULT Add(PCVOID pvKey, PVOID pvValue);
- HRESULT Lookup(PCVOID pvKey, PVOID *ppvValue);
- HRESULT Delete(PCVOID pvKey);
-
- int Iterate (PPTRMAPENUMFN filterfn, PVOID token);
-
- VOID Filter (PPTRMAPENUMFN filterfn, PVOID token);
- };
-
-
- enum WalkTreeFlags {
- WT_LEAF_ONLY = 0x00000001, // enumerate only nodes with no children
- };
-
- enum WalkTreeCBResults {
- WTCB_STOP,
- WTCB_CONTINUE,
- WTCB_DELETE,
- WTCB_MODIFIED,
- };
-
- typedef WalkTreeCBResults (*PWALKTREECBFN) (HWND htree, HTREEITEM hti, PVOID token);
-
- // Performs a prefix traversal of a TreeView control from the given node.
- // Returns TRUE if any callback returned a non-WTCB_STOP result.
- BOOL WalkTree (HWND htree, HTREEITEM root, DWORD flags, PWALKTREECBFN pfn, PVOID token);
-
-
- /*
- * UnicodeToANSI
- *
- * If ncUnicodeLen is -1, pcwszUnicode must be null terminated.
- * Otherwise, pcwszUnicode may or may not be null terminated and
- * this function returns a null terminated ansi string.
- */
- HRESULT UnicodeToANSI(LPCOLESTR pcwszUnicode, int ncUnicodeLen, PSTR *ppszANSI);
-
-
- int FitText (PSTR buf, int bufsize, PCSTR src);
- int FormatNumber (PSTR buf, int bufsize, PCSTR fmt, ...);
-
-
- VOID DeletePtrArray (PVOID *rgpv, int len);
-
-
- #endif /* __UTILS_HPP__ */
-
-