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.

75 lines
2.9 KiB

  1. //=--------------------------------------------------------------------------=
  2. // StdEnum.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1996 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 _STDENUM_H_
  15. #include "Unknown.H"
  16. // to support a generic Enumerator object, we'll just define this
  17. // interface. it can be safely cast to any other enumerator, since all
  18. // they differ in is their pointer type in Next().
  19. //
  20. class IEnumGeneric: public IUnknown {
  21. public:
  22. virtual HRESULT __stdcall Next(ULONG celt, LPVOID rgelt, ULONG *pceltFetched) = 0;
  23. virtual HRESULT __stdcall Skip(ULONG celt) = 0;
  24. virtual HRESULT __stdcall Reset(void) = 0;
  25. virtual HRESULT __stdcall Clone(IEnumGeneric **ppenum) = 0;
  26. };
  27. //=--------------------------------------------------------------------------=
  28. // StandardEnum
  29. //=--------------------------------------------------------------------------=
  30. // a generic enumerator object. given a pointer to generic data, some
  31. // information about the elements, and a function to copy the elements,
  32. // we can implement a generic enumerator.
  33. //
  34. // NOTE: this class assumes that rgElements is HeapAlloc'd, and will free it
  35. // in it's destructor [although it IS valid for this to be NULL if there
  36. // are no elements to enumerate over.]
  37. //
  38. class CStandardEnum: public CUnknownObject, public IEnumGeneric {
  39. public:
  40. // IUnknown methods
  41. //
  42. DECLARE_STANDARD_UNKNOWN();
  43. // IEnumVariant methods
  44. //
  45. STDMETHOD(Next)(unsigned long celt, void * rgvar, unsigned long * pceltFetched);
  46. STDMETHOD(Skip)(unsigned long celt);
  47. STDMETHOD(Reset)();
  48. STDMETHOD(Clone)(IEnumGeneric **ppEnumOut);
  49. CStandardEnum(REFIID riid, int cElement, int cbElement, void *rgElements,
  50. void (WINAPI * pfnCopyElement)(void *, const void *, DWORD));
  51. ~CStandardEnum();
  52. private:
  53. virtual HRESULT InternalQueryInterface(REFIID riid, void **ppvObjOut);
  54. IID m_iid; // type of enumerator that we are
  55. int m_cElements; // Total number of elements
  56. int m_cbElementSize; // Size of each element
  57. int m_iCurrent; // Current position: 0 = front, m_cElt = end
  58. VOID * m_rgElements; // Array of elements
  59. CStandardEnum *m_pEnumClonedFrom; // If we were cloned, from whom?
  60. void (WINAPI * m_pfnCopyElement)(void *, const void *, DWORD);
  61. };
  62. #define _STDENUM_H_
  63. #endif // _STDENUM_H_