ReactOS  0.4.15-dev-3181-g4acf100
ATL::CComEnumImpl< Base, piid, T, Copy > Class Template Reference

#include <atlcom.h>

Inheritance diagram for ATL::CComEnumImpl< Base, piid, T, Copy >:
Collaboration diagram for ATL::CComEnumImpl< Base, piid, T, Copy >:

Public Member Functions

 CComEnumImpl ()
 
virtual ~CComEnumImpl ()
 
HRESULT Init (T *begin, T *end, IUnknown *pUnk, CComEnumFlags flags=AtlFlagNoCopy)
 
STDMETHOD() Next (ULONG celt, T *rgelt, ULONG *pceltFetched)
 
STDMETHOD() Skip (ULONG celt)
 
STDMETHOD() Reset ()
 
STDMETHOD() Clone (Base **ppEnum)
 

Public Attributes

CComPtr< IUnknownm_spUnk
 
DWORD m_dwFlags
 
Tm_begin
 
Tm_end
 
Tm_iter
 

Protected Types

enum  FlagBits { BitCopy = 1, BitOwn = 2 }
 

Private Types

typedef CComObject< CComEnum< Base, piid, T, Copy > > enumeratorClass
 

Detailed Description

template<class Base, const IID * piid, class T, class Copy>
class ATL::CComEnumImpl< Base, piid, T, Copy >

Definition at line 855 of file atlcom.h.

Member Typedef Documentation

◆ enumeratorClass

template<class Base , const IID * piid, class T , class Copy >
typedef CComObject<CComEnum<Base, piid, T, Copy> > ATL::CComEnumImpl< Base, piid, T, Copy >::enumeratorClass
private

Definition at line 858 of file atlcom.h.

Member Enumeration Documentation

◆ FlagBits

template<class Base , const IID * piid, class T , class Copy >
enum ATL::CComEnumImpl::FlagBits
protected
Enumerator
BitCopy 
BitOwn 

Definition at line 1023 of file atlcom.h.

1024  {
1025  BitCopy = 1,
1026  BitOwn = 2
1027  };

Constructor & Destructor Documentation

◆ CComEnumImpl()

template<class Base , const IID * piid, class T , class Copy >
ATL::CComEnumImpl< Base, piid, T, Copy >::CComEnumImpl ( )
inline

Definition at line 866 of file atlcom.h.

867  {
868  m_dwFlags = 0;
869  m_begin = NULL;
870  m_end = NULL;
871  m_iter = NULL;
872  }
DWORD m_dwFlags
Definition: atlcom.h:861
#define NULL
Definition: types.h:112

◆ ~CComEnumImpl()

template<class Base , const IID * piid, class T , class Copy >
virtual ATL::CComEnumImpl< Base, piid, T, Copy >::~CComEnumImpl ( )
inlinevirtual

Definition at line 874 of file atlcom.h.

875  {
876  T *x;
877 
878  if ((m_dwFlags & BitOwn) != 0)
879  {
880  for (x = m_begin; x != m_end; x++)
881  Copy::destroy(x);
882  delete [] m_begin;
883  }
884  }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define T
Definition: mbstring.h:31
DWORD m_dwFlags
Definition: atlcom.h:861
void destroy(_Tp *__pointer)
Definition: _construct.h:278

Member Function Documentation

◆ Clone()

template<class Base , const IID * piid, class T , class Copy >
STDMETHOD() ATL::CComEnumImpl< Base, piid, T, Copy >::Clone ( Base **  ppEnum)
inline

Definition at line 997 of file atlcom.h.

998  {
999  enumeratorClass *newInstance;
1000  HRESULT hResult;
1001 
1002  hResult = E_POINTER;
1003  if (ppEnum != NULL)
1004  {
1005  *ppEnum = NULL;
1006  hResult = enumeratorClass::CreateInstance(&newInstance);
1007  if (SUCCEEDED(hResult))
1008  {
1009  hResult = newInstance->Init(m_begin, m_end, (m_dwFlags & BitOwn) ? this : m_spUnk);
1010  if (SUCCEEDED(hResult))
1011  {
1012  newInstance->m_iter = m_iter;
1013  hResult = newInstance->_InternalQueryInterface(*piid, (void **)ppEnum);
1014  }
1015  if (FAILED(hResult))
1016  delete newInstance;
1017  }
1018  }
1019  return hResult;
1020  }
CComObject< CComEnum< Base, piid, T, Copy > > enumeratorClass
Definition: atlcom.h:858
if SUCCEEDED(hr)
LONG HRESULT
Definition: typedefs.h:79
DWORD m_dwFlags
Definition: atlcom.h:861
#define NULL
Definition: types.h:112
#define E_POINTER
Definition: winerror.h:2365
CComPtr< IUnknown > m_spUnk
Definition: atlcom.h:860
static HRESULT WINAPI CreateInstance(CComObject< Base > **pp)
Definition: atlcom.h:166

◆ Init()

template<class Base , const IID * piid, class T , class Copy >
HRESULT ATL::CComEnumImpl< Base, piid, T, Copy >::Init ( T begin,
T end,
IUnknown pUnk,
CComEnumFlags  flags = AtlFlagNoCopy 
)
inline

Definition at line 886 of file atlcom.h.

887  {
888  T *newBuffer;
889  T *sourcePtr;
890  T *destPtr;
891  T *cleanupPtr;
892  HRESULT hResult;
893 
894  if (flags == AtlFlagCopy)
895  {
896  ATLTRY(newBuffer = new T[end - begin])
897  if (newBuffer == NULL)
898  return E_OUTOFMEMORY;
899  destPtr = newBuffer;
900  for (sourcePtr = begin; sourcePtr != end; sourcePtr++)
901  {
902  Copy::init(destPtr);
903  hResult = Copy::copy(destPtr, sourcePtr);
904  if (FAILED(hResult))
905  {
906  cleanupPtr = m_begin;
907  while (cleanupPtr < destPtr)
908  Copy::destroy(cleanupPtr++);
909  delete [] newBuffer;
910  return hResult;
911  }
912  destPtr++;
913  }
914  m_begin = newBuffer;
915  m_end = m_begin + (end - begin);
916  }
917  else
918  {
919  m_begin = begin;
920  m_end = end;
921  }
922  m_spUnk = pUnk;
923  m_dwFlags = flags;
924  m_iter = m_begin;
925  return S_OK;
926  }
#define ATLTRY(x)
Definition: atlcomcli.h:44
#define T
Definition: mbstring.h:31
static int init
Definition: wintirpc.c:33
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static clock_t begin
Definition: xmllint.c:467
LONG HRESULT
Definition: typedefs.h:79
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995
GLbitfield flags
Definition: glext.h:7161
GLuint GLuint end
Definition: gl.h:1545
DWORD m_dwFlags
Definition: atlcom.h:861
void destroy(_Tp *__pointer)
Definition: _construct.h:278
#define S_OK
Definition: intsafe.h:52
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define NULL
Definition: types.h:112
CComPtr< IUnknown > m_spUnk
Definition: atlcom.h:860
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by ATL::IConnectionPointContainerImpl< CShellBrowser >::EnumConnectionPoints().

◆ Next()

template<class Base , const IID * piid, class T , class Copy >
STDMETHOD() ATL::CComEnumImpl< Base, piid, T, Copy >::Next ( ULONG  celt,
T rgelt,
ULONG pceltFetched 
)
inline

Definition at line 928 of file atlcom.h.

929  {
930  ULONG numAvailable;
931  ULONG numToFetch;
932  T *rgeltTemp;
933  HRESULT hResult;
934 
935  if (pceltFetched != NULL)
936  *pceltFetched = 0;
937  if (celt == 0)
938  return E_INVALIDARG;
939  if (rgelt == NULL || (celt != 1 && pceltFetched == NULL))
940  return E_POINTER;
941  if (m_begin == NULL || m_end == NULL || m_iter == NULL)
942  return E_FAIL;
943 
944  numAvailable = static_cast<ULONG>(m_end - m_iter);
945  if (celt < numAvailable)
946  numToFetch = celt;
947  else
948  numToFetch = numAvailable;
949  if (pceltFetched != NULL)
950  *pceltFetched = numToFetch;
951  rgeltTemp = rgelt;
952  while (numToFetch != 0)
953  {
954  hResult = Copy::copy(rgeltTemp, m_iter);
955  if (FAILED(hResult))
956  {
957  while (rgelt < rgeltTemp)
958  Copy::destroy(rgelt++);
959  if (pceltFetched != NULL)
960  *pceltFetched = 0;
961  return hResult;
962  }
963  rgeltTemp++;
964  m_iter++;
965  numToFetch--;
966  }
967  if (numAvailable < celt)
968  return S_FALSE;
969  return S_OK;
970  }
#define E_FAIL
Definition: ddrawi.h:102
#define T
Definition: mbstring.h:31
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG HRESULT
Definition: typedefs.h:79
void destroy(_Tp *__pointer)
Definition: _construct.h:278
#define S_OK
Definition: intsafe.h:52
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define E_POINTER
Definition: winerror.h:2365

◆ Reset()

template<class Base , const IID * piid, class T , class Copy >
STDMETHOD() ATL::CComEnumImpl< Base, piid, T, Copy >::Reset ( void  )
inline

Definition at line 991 of file atlcom.h.

992  {
993  m_iter = m_begin;
994  return S_OK;
995  }
#define S_OK
Definition: intsafe.h:52

◆ Skip()

template<class Base , const IID * piid, class T , class Copy >
STDMETHOD() ATL::CComEnumImpl< Base, piid, T, Copy >::Skip ( ULONG  celt)
inline

Definition at line 972 of file atlcom.h.

973  {
974  ULONG numAvailable;
975  ULONG numToSkip;
976 
977  if (celt == 0)
978  return E_INVALIDARG;
979 
980  numAvailable = static_cast<ULONG>(m_end - m_iter);
981  if (celt < numAvailable)
982  numToSkip = celt;
983  else
984  numToSkip = numAvailable;
985  m_iter += numToSkip;
986  if (numAvailable < celt)
987  return S_FALSE;
988  return S_OK;
989  }
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_OK
Definition: intsafe.h:52
unsigned int ULONG
Definition: retypes.h:1

Member Data Documentation

◆ m_begin

◆ m_dwFlags

◆ m_end

◆ m_iter

◆ m_spUnk

template<class Base , const IID * piid, class T , class Copy >
CComPtr<IUnknown> ATL::CComEnumImpl< Base, piid, T, Copy >::m_spUnk

The documentation for this class was generated from the following file: