Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CSafeArray Class Reference

SAFEARRAY wrapper class. More...

#include <SafeArray.h>

List of all members.

Public Member Functions

 CSafeArray (SAFEARRAY *psa, bool bTakeOwn=false)
 Construct a wrapper around an existing SAFEARRAY.
 CSafeArray ()
 Construct an empty SAFEARRAY.
 ~CSafeArray ()
 Tidy up any owned SAFEARRAY.
SAFEARRAY * Copy ()
 Return a copy of the encapsulated SAFEARRAY.
SAFEARRAY * Detach ()
 Detach the encapsulated SAFEARRAY.
void Attach (SAFEARRAY *psa, bool bTakeOwn=true)
 Attach an existing SAFEARRAY.
void Clear ()
 Free the encapsulated array.
HRESULT CreateVector (VARTYPE vt, ULONG cElements, LONG lBound=0)
 Create a vector of the given element type and length.
HRESULT Create (VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
 Create a safearray of the given element type and dimensions.
HRESULT Redim (ULONG cElements, LONG lBound=0)
 Redimension a safe array along the lowest bound.
UINT Dimensions () const
 Return the number of dimensions that the array has.
LONG UBound (UINT dim) const
 Return the upper bound for the given dimension.
LONG LBound (UINT dim) const
 Return the lower bound for the given dimension.
ULONG Count (UINT dim) const
 Return the number of elements for the given dimension.
HRESULT PutElement (LONG *rgIndexes, void *elt)
 Put an element.
HRESULT GetElement (LONG *rgIndexes, void *elt)
 Get an element.
ULONG ElementSize () const
 Return the byte size of a single element.
template<class T>
HRESULT AccessData (T **pbData)
 Return a direct pointer to the encapsulated array's data.
 DECLARE_ACCESSOR (CHAR)
 Access for CHAR arrays.
 DECLARE_ACCESSOR (BYTE)
 Access for BYTE arrays.
 DECLARE_ACCESSOR (SHORT)
 Access for SHORT arrays.
 DECLARE_ACCESSOR (USHORT)
 Access for USHORT arrays.
 DECLARE_ACCESSOR (LONG)
 Access for LONG arrays.
 DECLARE_ACCESSOR (ULONG)
 Access for ULONG arrays.
 DECLARE_ACCESSOR (VARIANT)
 Access for VARIANT arrays.
 DECLARE_ACCESSOR (BSTR)
 Access for BSTR arrays.
IDispatch ** AccessIDispatch ()
 Access for IDispatch arrays.
IUnknown ** AccessIUnknown ()
 Access for IUnknown arrays.
HRESULT UnaccessData ()
 Release access to the encapsulated data if it has been retrieved.
 operator SAFEARRAY * ()
 Extractor for the encapsulated SAFEARRAY.


Detailed Description

SAFEARRAY wrapper class.


Constructor & Destructor Documentation

OW32::CSafeArray::CSafeArray SAFEARRAY *  psa,
bool  bTakeOwn = false
[inline]
 

Construct a wrapper around an existing SAFEARRAY.

Parameters:
psa The array to wrap
bTakeOwn Flag that can be set to manage the memory for the array.


Member Function Documentation

template<class T>
HRESULT OW32::CSafeArray::AccessData T **  pbData  )  [inline]
 

Return a direct pointer to the encapsulated array's data.

Parameters:
pbData Output pointer to the data.

IDispatch** OW32::CSafeArray::AccessIDispatch  )  [inline]
 

Access for IDispatch arrays.

Returns:
An IDispatch* pointer to the array data.

IUnknown** OW32::CSafeArray::AccessIUnknown  )  [inline]
 

Access for IUnknown arrays.

Returns:
An IUnknown* pointer to the array data.

void OW32::CSafeArray::Attach SAFEARRAY *  psa,
bool  bTakeOwn = true
[inline]
 

Attach an existing SAFEARRAY.

Parameters:
psa The array to wrap
bTakeOwn Flag that can be set to manage the memory for the array.

SAFEARRAY* OW32::CSafeArray::Copy  )  [inline]
 

Return a copy of the encapsulated SAFEARRAY.

Returns:
NULL on error, or a pointer to the array copy.

ULONG OW32::CSafeArray::Count UINT  dim  )  const [inline]
 

Return the number of elements for the given dimension.

Parameters:
dim The dimension to retrieve information for
Returns:
The number of elements, or 0 if the dimension is not valid

HRESULT OW32::CSafeArray::Create VARTYPE  vt,
UINT  cDims,
SAFEARRAYBOUND *  rgsabound
[inline]
 

Create a safearray of the given element type and dimensions.

Parameters:
vt The type of the array elements.
cDims The number of array dimensions.
rgsabound An array of boundaries, one per dimension.
Returns:
E_OUTOFMEMORY on failure, S_OK on success

HRESULT OW32::CSafeArray::CreateVector VARTYPE  vt,
ULONG  cElements,
LONG  lBound = 0
[inline]
 

Create a vector of the given element type and length.

Parameters:
vt The type of the array elements.
cElements The number array elements.
lBound The lower bound of the array.

OW32::CSafeArray::DECLARE_ACCESSOR BSTR   ) 
 

Access for BSTR arrays.

Returns:
An BSTR* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR VARIANT   ) 
 

Access for VARIANT arrays.

Returns:
An VARIANT* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR ULONG   ) 
 

Access for ULONG arrays.

Returns:
An ULONG* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR LONG   ) 
 

Access for LONG arrays.

Returns:
An LONG* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR USHORT   ) 
 

Access for USHORT arrays.

Returns:
An USHORT* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR SHORT   ) 
 

Access for SHORT arrays.

Returns:
An SHORT* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR BYTE   ) 
 

Access for BYTE arrays.

Returns:
An BYTE* pointer to the array data.

OW32::CSafeArray::DECLARE_ACCESSOR CHAR   ) 
 

Access for CHAR arrays.

Returns:
An CHAR* pointer to the array data.

SAFEARRAY* OW32::CSafeArray::Detach  )  [inline]
 

Detach the encapsulated SAFEARRAY.

Returns:
A pointer to the previously encapsulated array.

HRESULT OW32::CSafeArray::GetElement LONG *  rgIndexes,
void *  elt
[inline]
 

Get an element.

Parameters:
rgIndexes Array of indexes (must conform to Dimensions)
elt The output element
Returns:
HRESULT indicating success or failure

LONG OW32::CSafeArray::LBound UINT  dim  )  const [inline]
 

Return the lower bound for the given dimension.

Parameters:
dim The dimension to retrieve information for
Returns:
The lower bound, or -1 on error

HRESULT OW32::CSafeArray::PutElement LONG *  rgIndexes,
void *  elt
[inline]
 

Put an element.

Parameters:
rgIndexes Array of indexes (must conform to Dimensions)
elt The element to put
Returns:
HRESULT indicating success or failure

HRESULT OW32::CSafeArray::Redim ULONG  cElements,
LONG  lBound = 0
[inline]
 

Redimension a safe array along the lowest bound.

Parameters:
cElements The new number of elements.
lBound The new lower bound of the array

LONG OW32::CSafeArray::UBound UINT  dim  )  const [inline]
 

Return the upper bound for the given dimension.

Parameters:
dim The dimension to retrieve information for
Returns:
The upper bound, or -1 on error

HRESULT OW32::CSafeArray::UnaccessData  )  [inline]
 

Release access to the encapsulated data if it has been retrieved.

This function is automatically called when the class is destroyed.


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:26 2005 for OW32 by  doxygen 1.3.9.1