ReactOS  0.4.12-dev-18-gf469aca
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 854 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 857 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 1022 of file atlcom.h.

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

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 865 of file atlcom.h.

866  {
867  m_dwFlags = 0;
868  m_begin = NULL;
869  m_end = NULL;
870  m_iter = NULL;
871  }
smooth NULL
Definition: ftsmooth.c:416
DWORD m_dwFlags
Definition: atlcom.h:860

◆ ~CComEnumImpl()

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

Definition at line 873 of file atlcom.h.

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

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 996 of file atlcom.h.

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

◆ 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 885 of file atlcom.h.

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

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

◆ 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 927 of file atlcom.h.

928  {
929  ULONG numAvailable;
930  ULONG numToFetch;
931  T *rgeltTemp;
932  HRESULT hResult;
933 
934  if (pceltFetched != NULL)
935  *pceltFetched = 0;
936  if (celt == 0)
937  return E_INVALIDARG;
938  if (rgelt == NULL || (celt != 1 && pceltFetched == NULL))
939  return E_POINTER;
940  if (m_begin == NULL || m_end == NULL || m_iter == NULL)
941  return E_FAIL;
942 
943  numAvailable = static_cast<ULONG>(m_end - m_iter);
944  if (celt < numAvailable)
945  numToFetch = celt;
946  else
947  numToFetch = numAvailable;
948  if (pceltFetched != NULL)
949  *pceltFetched = numToFetch;
950  rgeltTemp = rgelt;
951  while (numToFetch != 0)
952  {
953  hResult = Copy::copy(rgeltTemp, m_iter);
954  if (FAILED(hResult))
955  {
956  while (rgelt < rgeltTemp)
957  Copy::destroy(rgelt++);
958  if (pceltFetched != NULL)
959  *pceltFetched = 0;
960  return hResult;
961  }
962  rgeltTemp++;
963  m_iter++;
964  numToFetch--;
965  }
966  if (numAvailable < celt)
967  return S_FALSE;
968  return S_OK;
969  }
#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
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
void destroy(_Tp *__pointer)
Definition: _construct.h:278
#define S_OK
Definition: intsafe.h:59
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
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 990 of file atlcom.h.

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

◆ 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 971 of file atlcom.h.

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

Member Data Documentation

◆ m_begin

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

Definition at line 861 of file atlcom.h.

◆ m_dwFlags

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

Definition at line 860 of file atlcom.h.

◆ m_end

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

Definition at line 862 of file atlcom.h.

◆ m_iter

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

Definition at line 863 of file atlcom.h.

◆ m_spUnk

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

Definition at line 859 of file atlcom.h.


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