CComSafeArrayBound Class
This class is a wrapper for a SAFEARRAYBOUND structure.
class CComSafeArrayBound : public SAFEARRAYBOUND
Function | Description |
---|---|
CComSafeArrayBound | The constructor. |
GetCount | Call this method to return the number of elements. |
GetLowerBound | Call this method to return the lower bound. |
GetUpperBound | Call this method to return the upper bound. |
SetCount | Call this method to set the number of elements. |
SetLowerBound | Call this method to set the lower bound. |
Operator | Description |
---|---|
operator = | Sets the CComSafeArrayBound to a new value. |
This class is a wrapper for the SAFEARRAYBOUND
structure used by CComSafeArray. It provides methods for querying and setting the upper and lower bounds of a single dimension of a CComSafeArray
object and the number of elements it contains. A multidimensional CComSafeArray
object uses an array of CComSafeArrayBound
objects, one for each dimension. Therefore, when using methods such as GetCount, be aware that this method will not return the total number of elements in a multidimensional array.
Header: atlsafe.h
Header: atlsafe.h
The constructor.
CComSafeArrayBound(ULONG ulCount = 0, LONG lLowerBound = 0) throw();
ulCount
The number of elements in the array.
lLowerBound
The lower bound from which the array is numbered.
If the array is to be accessed from a C++ program, it is recommended that the lower bound be defined as 0. It may be preferable to use a different lower bound value if the array is to be used with other languages, such as Visual Basic.
Call this method to return the number of elements.
ULONG GetCount() const throw();
Returns the number of elements.
If the associated CComSafeArray
object represents a multidimensional array, this method will only return the total number of elements in the rightmost dimension. Use CComSafeArray::GetCount to obtain the total number of elements.
Call this method to return the lower bound.
LONG GetLowerBound() const throw();
Returns the lower bound of the CComSafeArrayBound
object.
Call this method to return the upper bound.
LONG GetUpperBound() const throw();
Returns the upper bound of the CComSafeArrayBound
object.
The upper bound depends on the number of elements and the lower bound value. For example, if the lower bound is 0 and the number of elements is 10, the upper bound will automatically be set to 9.
Sets the CComSafeArrayBound
to a new value.
CComSafeArrayBound& operator= (const CComSafeArrayBound& bound) throw();
CComSafeArrayBound& operator= (ULONG ulCount) throw();
bound
A CComSafeArrayBound
object.
ulCount
The number of elements.
Returns a pointer to the CComSafeArrayBound
object.
The CComSafeArrayBound
object can be assigned using an existing CComSafeArrayBound
, or by supplying the number of elements, in which case the lower bound is set to 0 by default.
Call this method to set the number of elements.
ULONG SetCount(ULONG ulCount) throw();
ulCount
The number of elements.
Returns the number of elements in the CComSafeArrayBound
object.
Call this method to set the lower bound.
LONG SetLowerBound(LONG lLowerBound) throw();
lLowerBound
The lower bound.
Returns the new lower bound of the CComSafeArrayBound
object.
If the array is to be accessed from a Visual C++ program, it is recommended that the lower bound be defined as 0. It may be preferable to use a different lower bound value if the array is to be used with other languages, such as Visual Basic.
The upper bound depends on the number of elements and the lower bound value. For example, if the lower bound is 0 and the number of elements is 10, the upper bound will automatically be set to 9.