Share via


Using CComEnum, _Copy, CComIEnum, and CComEnumImpl to Create Enumerators in ATL

In ATL, CComEnum<Base, piid, T, Copy> defines an enumerator object that enumerates objects of type T. The parameter Base is the name of the interface that represents this enumerator (for example, IEnumVARIANT), and piid is a pointer to the IID of that interface. The parameter Copy is the name of a class used by CComEnum to implement copying the type and is typically used when cloning the enumerator.

A _Copy<classT**>** class performs deep copy semantics for the particular type T. ATL predefines certain copy classes for your convenience: _Copy<VARIANT>, _Copy<LPOLESTR>, _Copy<OLEVERB>, _Copy<CONNECTDATA>, and _CopyInterface<>. These can be used to quickly build many of the standard enumerators.

CComIEnum is a pure virtual class that defines an enumeration interface.

CComEnumImpl implements the methods on the enumeration interface: Next, Skip, Reset, and Clone. Generally, this class is only used internally by ATL during the implementation of CComIEnum.