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.

80 lines
2.9 KiB

  1. //=--------------------------------------------------------------------------=
  2. // StandardEnum.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // object definition for a generic enumerator object.
  13. //
  14. #ifndef _STANDARDENUM_H_
  15. #include "Unknown.H"
  16. #include "Macros.H"
  17. // to support a generic Enumerator object, we'll just define this
  18. // interface. it can be safely cast to any other enumerator, since all
  19. // they differ in is their pointer type in Next().
  20. //
  21. class IEnumGeneric: public IUnknown {
  22. public:
  23. virtual HRESULT __stdcall Next(ULONG celt, LPVOID rgelt, ULONG *pceltFetched) = 0;
  24. virtual HRESULT __stdcall Skip(ULONG celt) = 0;
  25. virtual HRESULT __stdcall Reset(void) = 0;
  26. virtual HRESULT __stdcall Clone(IEnumGeneric **ppenum) = 0;
  27. };
  28. //=--------------------------------------------------------------------------=
  29. // StandardEnum
  30. //=--------------------------------------------------------------------------=
  31. // a generic enumerator object. given a pointer to generic data, some
  32. // information about the elements, and a function to copy the elements,
  33. // we can implement a generic enumerator.
  34. //
  35. // NOTE: this class assumes that rgElements is HeapAlloc'd, and will free it
  36. // in it's destructor [although it IS valid for this to be NULL if there
  37. // are no elements to enumerate over.]
  38. //
  39. class CStandardEnum: public CUnknownObject,
  40. public IEnumGeneric {
  41. public:
  42. // IUnknown methods
  43. //
  44. DECLARE_STANDARD_UNKNOWN();
  45. // IEnumVariant methods
  46. //
  47. STDMETHOD(Next)(unsigned long celt, void * rgvar, unsigned long * pceltFetched);
  48. STDMETHOD(Skip)(unsigned long celt);
  49. STDMETHOD(Reset)();
  50. STDMETHOD(Clone)(IEnumGeneric **ppEnumOut);
  51. CStandardEnum();
  52. CStandardEnum(REFIID riid, int cElement, int cbElement, void *rgElements,
  53. void (WINAPI * pfnCopyElement)(void *, const void *, DWORD));
  54. ~CStandardEnum();
  55. private:
  56. virtual HRESULT InternalQueryInterface(REFIID riid, void **ppvObjOut);
  57. protected:
  58. IID m_iid; // type of enumerator that we are
  59. int m_cElements; // Total number of elements
  60. int m_cbElementSize; // Size of each element
  61. int m_iCurrent; // Current position: 0 = front, m_cElt = end
  62. VOID * m_rgElements; // Array of elements
  63. CStandardEnum *m_pEnumClonedFrom; // If we were cloned, from whom?
  64. void (WINAPI * m_pfnCopyElement)(void *, const void *, DWORD);
  65. };
  66. #define _STANDARDENUM_H_
  67. #endif // _STANDARDENUM_H_
  68.