Source code of Windows XP (NT5)
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.

93 lines
2.7 KiB

  1. #include <linklistt.h>
  2. // put some notes here about how we do things for perf reasons.
  3. // so our behavior is pathological to our client usage
  4. // and is not totall generic.
  5. enum
  6. {
  7. IDLDATAF_MATCH_EXACT = 0x00000001, // self only
  8. IDLDATAF_MATCH_IMMEDIATE = 0x00000003, // includes self and immediate children
  9. IDLDATAF_MATCH_RECURSIVE = 0x00000007, // includes self and all children
  10. // IDLDATAF_IUNKNOWN = 0x80000000,
  11. // IDLDATAF_SINGLETON = 0x10000000,
  12. };
  13. typedef DWORD IDLDATAF;
  14. class CIDLData
  15. {
  16. public: // basically a struct
  17. BOOL Init(IDLDATAF flags, INT_PTR data);
  18. // ~CIDLData() { if (_flags & IDLDATAF_IUNKNOWN) ((IUnknown *)_data)->Release(); }
  19. HRESULT GetData(IDLDATAF flags, INT_PTR *pdata);
  20. IDLDATAF _flags;
  21. INT_PTR _data;
  22. };
  23. class CIDLMatchMany;
  24. class CIDLTree;
  25. class CIDLNode
  26. {
  27. public: // methods
  28. ~CIDLNode();
  29. protected: // methods
  30. HRESULT GetNode(BOOL fCreate, LPCITEMIDLIST pidlChild, CIDLNode **ppin, IDLDATAF *pflagsFound = NULL);
  31. HRESULT IDList(LPITEMIDLIST *ppidl);
  32. BOOL Init(LPCITEMIDLIST pidl, CIDLNode *pinParent);
  33. BOOL _InitSF();
  34. HRESULT _BindToFolder(LPCITEMIDLIST pidl, IShellFolder **ppsf);
  35. BOOL _IsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
  36. CLinkedNode<CIDLNode> *_GetKid(LPCITEMIDLIST pidl);
  37. HRESULT _AddData(IDLDATAF flags, INT_PTR data);
  38. HRESULT _RemoveData(INT_PTR data);
  39. void _FreshenKids(void);
  40. BOOL _IsEmpty(void) { return _listKids.IsEmpty() && _listDatas.IsEmpty();}
  41. protected: // members
  42. LONG _cUsage;
  43. LPITEMIDLIST _pidl;
  44. IShellFolder *_psf;
  45. CIDLNode *_pinParent;
  46. // lists
  47. CLinkedList<CIDLNode> _listKids;
  48. CLinkedList<CIDLData> _listDatas;
  49. friend class CIDLTree;
  50. friend class CIDLMatchMany;
  51. };
  52. typedef DWORD IDLMATCHF;
  53. class CIDLMatchMany
  54. {
  55. public:
  56. HRESULT Next(INT_PTR *pdata, LPITEMIDLIST *ppidl);
  57. CIDLMatchMany(IDLDATAF flags, CIDLNode *pin)
  58. : _flags(flags), _pin(pin) { if (pin) _lw.Init(&pin->_listDatas);}
  59. protected: // members
  60. IDLDATAF _flags;
  61. CIDLNode *_pin;
  62. CLinkedWalk<CIDLData> _lw;
  63. };
  64. class CIDLTree : CIDLNode
  65. {
  66. public:
  67. HRESULT AddData(IDLDATAF flags, LPCITEMIDLIST pidlIndex, INT_PTR data);
  68. HRESULT RemoveData(LPCITEMIDLIST pidlIndex, INT_PTR data);
  69. HRESULT MatchOne(IDLDATAF flags, LPCITEMIDLIST pidlMatch, INT_PTR *pdata, LPITEMIDLIST *ppidl);
  70. HRESULT MatchMany(IDLDATAF flags, LPCITEMIDLIST pidlMatch, CIDLMatchMany **ppmatch);
  71. HRESULT Freshen(void);
  72. static HRESULT Create(CIDLTree **pptree);
  73. protected: // methods
  74. CIDLNode *_MatchNode(LPCITEMIDLIST pidlMatch, IDLMATCHF *pflags);
  75. };