CArrayVar< TAny > Class Template Reference

#include <e32base.h>

template <>
class CArrayVar< TAny > : public CArrayVarBase

Inherits from

Detailed Description

A template specialisation base class for variable length arrays.

The array buffer organisation is defined at construction.

The class is useful for constructing an array of variable length buffers, where the length is decided at run time.

This class is also useful as a data member of a base class in a thin template class/base class pair, where the type of the array element is not known until the owning thin template class is instantiated.

Constructor & Destructor Documentation

CArrayVar ( TBufRep, TInt )

CArrayVar(TBufRepaRep,
TIntaGranularity
)[inline]

Constructs a variable array with the specified granularity and buffer organization.

Note that no memory is allocated to the array buffer by this constructor.

Parameters
aRepA pointer to a function used to expand the array buffer. The organisation of the array buffer is implied by the choice of this function. For a flat array buffer, pass (TBufRep)CBufFlat::NewL. For a segmented array buffer, pass (TBufRep)CBufSeg::NewL.
aGranularityThe granularity of the array.
Panic Codes
E32USER-CBase19, if aGranularity is not positive.

Member Function Documentation

AppendL ( const TAny *, TInt )

voidAppendL(const TAny *aPtr,
TIntaLength
)[inline]

Appends an untyped element of specified length onto the end of the array.

Parameters
aPtrA pointer to an untyped element to be appended.
aLengthThe length of the untyped element.

At ( TInt )

const TAny *At(TIntanIndex)const [inline]

Reimplemented from CArrayVarBase::At(TInt)const

Returns a pointer to the untyped element located at the specified position within the array.

The compiler uses this variant of the function if the returned pointer is used in an expression where it cannot be modified.

Parameters
anIndexThe position of the element within the array, relative to zero; i.e. zero implies the first element.
Return Value
A pointer to the const element located at position anIndex within the array.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

At ( TInt )

TAny *At(TIntanIndex)[inline]

Returns a pointer to the untyped element located at the specified position within the array.

The compiler uses this variant of the function if the returned pointer is used in an expression where it can be modified.

Parameters
anIndexThe position of the element within the array, relative to zero; i.e. zero implies the first element.
Return Value
A pointer to the non-const element located at position anIndex within the array.
Panic Codes
E32USER-CBase21, if anIndex is negative or greater than or equal to the number of objects currently within the array.

ExtendL ( TInt )

TAny *ExtendL(TIntaLength)[inline]

Extends the array by one element of specified length at the end of the array, i.e. at position CArrayVarBase::Count(), and returns a pointer to the new element location.

As elements are untyped, no construction is possible and the content of the new location remains undefined.

Note that the function always attempts to allocate a cell to contain the new element and may also attempt to expand the array buffer. If there is insufficient memory available, the function leaves. The leave code is one of the system wide error codes. If the function leaves, the array is left in the state it was in before the call.

Parameters
aLengthThe length of the new element.
Return Value
A pointer to the new element location at the end of the array.