VARIANTs, SAFEARRAYs, and Interface Pointers


COM has a number of data types beyond the numeric types available in the C and C++ languages. Three such data types are the VARIANT data type, interface pointers, and the SAFEARRAY data type. ATL provides useful classes that encapsulate each of these data types and their special idiosyncrasies.

The CComVariant class is a smart VARIANT class. The class implements the special initialization, copy, and destruction semantics of the COM VARIANT data type. CComVariant instances can be used in most, but not all, of the places you would use a VARIANT.

The CComPtr, CComQIPtr, and CComGITPtr classes are smart pointer classes. Smart pointer classes are definitions of objects that "act" like a pointerspecifically, a pointer with extra semantics. The major additional semantic for the ATL smart pointer classes is automatic reference counting, which eliminates entire classes of errors.

The CComSafeArray class manages the Automation array type SAFEARRAY. These arrays require special handling with dedicated API functions for allocating, deallocating, and interrogating members of the array.




ATL Internals. Working with ATL 8
ATL Internals: Working with ATL 8 (2nd Edition)
ISBN: 0321159624
EAN: 2147483647
Year: 2004
Pages: 172

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net