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.

166 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: enumstr.hxx
  7. //
  8. // Contents: Implementation of IEnumString
  9. //
  10. // Classes: CEnumString
  11. //
  12. // History: 3-19-97 srikants Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. //+---------------------------------------------------------------------------
  17. //
  18. // Class: CEnumString
  19. //
  20. // Purpose: A string enumerator class.
  21. //
  22. // History: 3-19-97 srikants Created
  23. //
  24. // Notes: I have assumed that the pointers returned in the "Next" call
  25. // are "read only" pointers. If we are required to make copies,
  26. // we have to change the implementation.
  27. //
  28. //----------------------------------------------------------------------------
  29. class CEnumString : INHERIT_VIRTUAL_UNWIND, public IEnumString
  30. {
  31. INLINE_UNWIND( CEnumString );
  32. public:
  33. CEnumString( ULONG cInitSize = 16 )
  34. : _aStr( cInitSize ),
  35. _iCurrEnum(0),
  36. _cValid(0),
  37. _refCount(1)
  38. {
  39. END_CONSTRUCTION( CEnumString );
  40. }
  41. //
  42. // IUnknown methods.
  43. //
  44. STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppiuk );
  45. STDMETHOD_(ULONG, AddRef) (THIS);
  46. STDMETHOD_(ULONG, Release) (THIS);
  47. //
  48. // IEnumString methods.
  49. //
  50. STDMETHOD(Next) (
  51. ULONG celt,
  52. LPOLESTR *rgelt,
  53. ULONG *pceltFetched);
  54. STDMETHOD(Skip)(ULONG celt);
  55. STDMETHOD(Reset) (void)
  56. {
  57. _iCurrEnum = 0;
  58. return S_OK;
  59. }
  60. STDMETHOD(Clone) (
  61. IEnumString ** ppenum);
  62. //
  63. // Private methods.
  64. //
  65. void Append( WCHAR const * pwszString );
  66. private:
  67. long _refCount;
  68. ULONG _cValid; // Number of valid strings.
  69. CDynArray<WCHAR> _aStr; // Array of NULL terminated WCHAR * pointers.
  70. ULONG _iCurrEnum; // Current enumeration context
  71. };
  72. //+---------------------------------------------------------------------------
  73. //
  74. // Class: CEnumWorkid
  75. //
  76. // Purpose: Implementation of ICiEnumWorkids
  77. //
  78. // History: 3-19-97 srikants Created
  79. //
  80. //----------------------------------------------------------------------------
  81. class CEnumWorkid : INHERIT_VIRTUAL_UNWIND, public ICiEnumWorkids
  82. {
  83. INLINE_UNWIND( CEnumWorkid );
  84. public:
  85. //
  86. // IUnknown methods.
  87. //
  88. STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppiuk );
  89. STDMETHOD_(ULONG, AddRef) (THIS);
  90. STDMETHOD_(ULONG, Release) (THIS);
  91. //
  92. // ICiEnumWorkids methods.
  93. //
  94. STDMETHOD(Count) (
  95. ULONG *pcWorkIds)
  96. {
  97. return _cValid;
  98. }
  99. STDMETHOD(Reset) (void)
  100. {
  101. _iCurrEnum = 0;
  102. return S_OK;
  103. }
  104. STDMETHOD(Next) (
  105. ULONG celt,
  106. WORKID * rgelt,
  107. ULONG * pceltFetched);
  108. STDMETHOD(Skip) (
  109. ULONG celt);
  110. //
  111. // Private methods.
  112. //
  113. CEnumWorkid( ULONG cInitSize = 16 )
  114. : _aWorkids( cInitSize ),
  115. _iCurrEnum(0),
  116. _cValid(0),
  117. _refCount(1)
  118. {
  119. END_CONSTRUCTION( CEnumWorkid );
  120. }
  121. void Append( WORKID wid );
  122. private:
  123. long _refCount;
  124. ULONG _cValid; // Number of valid strings.
  125. CDynArrayInPlace<WORKID>
  126. _aWorkids; // Array of NULL terminated WCHAR * pointers.
  127. ULONG _iCurrEnum; // Current enumeration context
  128. };