CComSafeArrayBound Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

This class is a wrapper for a SAFEARRAYBOUND structure.

class CComSafeArrayBound : public SAFEARRAYBOUND

Methods

CComSafeArrayBoundThe constructor.
GetCountCall this method to return the number of elements.
GetLowerBoundCall this method to return the lower bound.
GetUpperBoundCall this method to return the upper bound.
SetCountCall this method to set the number of elements.
SetLowerBoundCall this method to set the lower bound.

Operators

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();

Parameters

ulCount
The number of elements in the array.

lLowerBound
The lower bound from which the array is numbered.

Remarks

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.

Call this method to return the number of elements.

ULONG GetCount() const throw();

Return Value

Returns the number of elements.

Remarks

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();

Return Value

Returns the lower bound of the CComSafeArrayBound object.

Call this method to return the upper bound.

LONG GetUpperBound() const throw();

Return Value

Returns the upper bound of the CComSafeArrayBound object.

Remarks

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();

Parameters

bound
A CComSafeArrayBound object.

ulCount
The number of elements.

Return Value

Returns a pointer to the CComSafeArrayBound object.

Remarks

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();

Parameters

ulCount
The number of elements.

Return Value

Returns the number of elements in the CComSafeArrayBound object.

Call this method to set the lower bound.

LONG SetLowerBound(LONG lLowerBound) throw();

Parameters

lLowerBound
The lower bound.

Return Value

Returns the new lower bound of the CComSafeArrayBound object.

Remarks

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.

Class Overview

Show: