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.

241 lines
5.6 KiB

  1. /*++
  2. Module Name:
  3. JPEnum.cpp
  4. Abstract:
  5. This file contains the Implementation of the Class CJunctionPointEnum.
  6. This class implements IEnumVARIANT for DfsJunctionPoint enumeration.
  7. --*/
  8. #include "stdafx.h"
  9. #include "DfsCore.h"
  10. #include "DfsJP.h"
  11. #include "JPEnum.h"
  12. /////////////////////////////////////////////////////////////////////////////
  13. // ~CJunctionPointEnum
  14. CJunctionPointEnum :: ~CJunctionPointEnum ()
  15. {
  16. _FreeMemberVariables();
  17. }
  18. /////////////////////////////////////////////////////////////////////////////
  19. // Initialize
  20. STDMETHODIMP CJunctionPointEnum :: Initialize
  21. (
  22. JUNCTIONNAMELIST* i_pjiList, // Pointer to the list of junction points.
  23. FILTERDFSLINKS_TYPE i_lLinkFilterType,
  24. BSTR i_bstrEnumFilter, // Filtering string expresseion
  25. ULONG* o_pulCount // count of links that matches the filter
  26. )
  27. {
  28. /*++
  29. Routine Description:
  30. Initializes the JunctionPointEnum object.
  31. It copies the JunctionPoint list passed to it by the junction point
  32. object.
  33. Arguments:
  34. i_pjiList - Pointer to the list of junction points.
  35. i_lLinkFilterType - The type of link filtering.
  36. i_bstrEnumFilter - The string expression to do prefix filtering.
  37. o_pulCount - to hold the count of links that matches the specified filter.
  38. --*/
  39. if (!i_pjiList)
  40. return E_INVALIDARG;
  41. if (i_lLinkFilterType != FILTERDFSLINKS_TYPE_NO_FILTER &&
  42. (!i_bstrEnumFilter || !*i_bstrEnumFilter))
  43. return E_INVALIDARG;
  44. if (o_pulCount)
  45. *o_pulCount = 0;
  46. HRESULT hr = S_OK;
  47. JUNCTIONNAMELIST::iterator i;
  48. JUNCTIONNAMELIST::iterator j;
  49. for (i = i_pjiList->begin(); i != i_pjiList->end(); i++)
  50. { // Copy filtered junctions to its own internal list
  51. if (i_lLinkFilterType != FILTERDFSLINKS_TYPE_NO_FILTER)
  52. {
  53. if ( !FilterMatch((*i)->m_bstrJPName, i_lLinkFilterType, i_bstrEnumFilter) )
  54. continue;
  55. }
  56. JUNCTIONNAME* pTemp = (*i)->Copy();
  57. BREAK_OUTOFMEMORY_IF_NULL(pTemp, &hr);
  58. m_JunctionPoints.push_back(pTemp);
  59. }
  60. if (SUCCEEDED(hr))
  61. {
  62. m_iCurrentInEnumOfJunctionPoints = m_JunctionPoints.begin();
  63. if (o_pulCount)
  64. *o_pulCount = m_JunctionPoints.size();
  65. } else
  66. _FreeMemberVariables();
  67. return hr;
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. // IEnumVariant Methods
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Next
  73. STDMETHODIMP CJunctionPointEnum::Next
  74. (
  75. ULONG i_ulNumOfJunctionPoints, //To fetch.
  76. VARIANT* o_pIJunctionPointArray, //Array to fetch into.
  77. ULONG* o_ulNumOfJunctionPointsFetched //The number of values fetched, (Arg can be NULL)
  78. )
  79. {
  80. /*++
  81. Routine Description:
  82. Gets the next object in the list.
  83. Arguments:
  84. i_ulNumOfJunctionPoints - the number of objects to return
  85. o_pIJunctionPointArray - an array of variants in which to return the objects
  86. o_ulNumOfJunctionPointsFetched - the number of objects that are actually returned
  87. Return value:
  88. S_OK, On success
  89. S_FALSE if the end of the list has been reached
  90. --*/
  91. if (!o_pIJunctionPointArray || !i_ulNumOfJunctionPoints)
  92. return E_INVALIDARG;
  93. HRESULT hr = S_OK;
  94. ULONG nCount = 0;
  95. for (nCount = 0;
  96. nCount < i_ulNumOfJunctionPoints && m_iCurrentInEnumOfJunctionPoints != m_JunctionPoints.end();
  97. m_iCurrentInEnumOfJunctionPoints++)
  98. {
  99. IDfsJunctionPoint *pIJunctionPointPtr = (*m_iCurrentInEnumOfJunctionPoints)->m_piDfsJunctionPoint;
  100. pIJunctionPointPtr->AddRef();
  101. o_pIJunctionPointArray[nCount].vt = VT_DISPATCH;
  102. o_pIJunctionPointArray[nCount].pdispVal = pIJunctionPointPtr;
  103. nCount++;
  104. }
  105. if (o_ulNumOfJunctionPointsFetched)
  106. *o_ulNumOfJunctionPointsFetched = nCount;
  107. if (SUCCEEDED(hr) && !nCount)
  108. return S_FALSE;
  109. else
  110. return hr;
  111. }
  112. /////////////////////////////////////////////////////////////////////////////
  113. // Skip
  114. STDMETHODIMP CJunctionPointEnum :: Skip
  115. (
  116. unsigned long i_ulJunctionPointsToSkip //Items to skip
  117. )
  118. {
  119. /*++
  120. Routine Description:
  121. Skips the next 'n' objects in the list.
  122. Arguments:
  123. i_ulJunctionPointsToSkip - the number of objects to skip over
  124. Return value:
  125. S_OK, On success
  126. S_FALSE, if the end of the list is reached
  127. --*/
  128. for (unsigned int j = 0; j < i_ulJunctionPointsToSkip &&
  129. m_iCurrentInEnumOfJunctionPoints != m_JunctionPoints.end(); j++)
  130. {
  131. m_iCurrentInEnumOfJunctionPoints++;
  132. }
  133. return (m_iCurrentInEnumOfJunctionPoints != m_JunctionPoints.end()) ? S_OK : S_FALSE;
  134. }
  135. /////////////////////////////////////////////////////////////////////////////
  136. // Reset
  137. STDMETHODIMP CJunctionPointEnum :: Reset()
  138. {
  139. /*++
  140. Routine Description:
  141. Resets the current enumeration pointer to the start of the list
  142. --*/
  143. m_iCurrentInEnumOfJunctionPoints = m_JunctionPoints.begin();
  144. return S_OK;
  145. }
  146. /////////////////////////////////////////////////////////////////////////////
  147. // Clone
  148. STDMETHODIMP CJunctionPointEnum :: Clone
  149. (
  150. IEnumVARIANT FAR* FAR* ppenum
  151. )
  152. {
  153. /*++
  154. Routine Description:
  155. Creates a clone of the enumerator object
  156. Arguments:
  157. ppenum - address of the pointer to the IEnumVARIANT interface
  158. of the newly created enumerator object
  159. Notes:
  160. This has not been implemented.
  161. --*/
  162. return E_NOTIMPL;
  163. }