Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32std.h

Class TFixedArray

class TFixedArray;

Description

A thin wrapper class for C++ arrays allowing automatic checking of index values to ensure that all accesses are legal.

The class also supports the deletion of objects.

The class is templated, based on a class type and an integer value. The class type defines the type of object contained in the array; the integer value defines the size (dimension) of the array.

A wrapper object can be:

1. embedded in objects allocated on the heap.

2. used on the program stack.

Members

Defined in TFixedArray:
Array(), At(), At(), AtFunctionR(), Begin(), Begin(), Copy(), Count(), CountFunctionR(), DeleteAll(), End(), End(), InRange(), Length(), Reset(), TFixedArray(), TFixedArray(), iRep, operator[](), operator[]()


Construction and destruction


TFixedArray()

inline TFixedArray();

Description

Default constructor.

Constructs an uninitialised C++ array.


TFixedArray()

inline TFixedArray(const T *aList, TInt aLength);

Description

Constructs a C++ array initialised with the specified objects.

Parameters

const T *aList

A pointer to a set of contiguous objects.

TInt aLength

The number of contiguous objects to be copied. This value must not be negative and must not be greater than the size of the array as defined by the integer template parameter.

Panic codes

USER

133, in a debug build only, if aLength is negative or is greater than the size of the array as defined by the integer template parameter.

[Top]


Member functions


Copy()

inline void Copy(const T *aList, TInt aLength);

Description

Copies the specified set of contiguous objects into the C++ array.

The copy operation starts at the beginning of the array, replacing any existing data.

Parameters

const T *aList

A pointer to a set of contiguous objects.

TInt aLength

The number of contiguous objects to be copied. This value must not be negative and must not be greater than the size of the array as defined by the integer template parameter.

Panic codes

USER

133, in a debug build only, if aLength is negative or is greater than the size of the array as defined by the integer template parameter.


Reset()

inline void Reset();

Description

Fills every element of the array with binary zeroes.


DeleteAll()

inline void DeleteAll();

Description

Invokes the delete operator on every member of the array.

The function can only be used for arrays of pointers to CBase derived objects.

If the array is to be used after a call to this function, it is good practice to call TFixedArray<class T,TInt S>::Reset() to set all array elements to NULL.


Count()

inline TInt Count() const;

Description

Gets the size of the array.

For any instance of this class, the array size is fixed and has the same value as the integer template parameter.

Return value

TInt

The size of the array.


Length()

inline TInt Length() const;

Description

Gets the size of an array element, in bytes.

Return value

TInt

The size of an array element, in bytes.


operator[]()

inline T &operator[](TInt aIndex);

Description

Gets a reference to the specified element within the C++ array.

Parameters

TInt aIndex

The position of the element within the array. This is an offset value; a zero value refers to the first element in the array. This value must be greater than or equal to zero and less than the size of the array.

Return value

T &

A reference to an element of the array.

Panic codes

USER

133, in a debug build only, if aIndex is negative or greater than or equal to the size of the array as defined by the integer template parameter.


operator[]()

inline const T &operator[](TInt aIndex) const;

Description

Gets a const reference to the specified element within the C++ array.

Parameters

TInt aIndex

The position of the element within the array. This is an offset value; a zero value refers to the first element in the array. This value must be greater than or equal to zero and less than the size of the array.

Return value

const T &

A const reference to an element of the array; the element cannot be changed through this reference.

Panic codes

USER

133, in a debug build only, if aIndex is negative or greater than or equal to the size of the array as defined by the integer template parameter.


At()

inline T &At(TInt aIndex);

Description

Gets a reference to the specified element within the C++ array.

Parameters

TInt aIndex

The position of the element within the array. This is an offset value; a zero value refers to the first element in the array. This value must be greater than or equal to zero and less than the size of the array.

Return value

T &

A reference to an element of the array.

Panic codes

USER

133, if aIndex is negative or greater than or equal to the size of the array as defined by the integer template parameter.


At()

inline const T &At(TInt aIndex) const;

Description

Gets a const reference to the specified element within the C++ array.

Parameters

TInt aIndex

The position of the element within the array. This is an offset value; a zero value refers to the first element in the array. This value must be greater than or equal to zero and less than the size of the array.

Return value

const T &

A const reference to an element of the array; the element cannot be changed through this reference.

Panic codes

USER

133, in a debug build only, if aIndex is negative or greater than or equal to the size of the array as defined by the integer template parameter.


Begin()

inline T *Begin();

Description

Gets a pointer to the first element of the array.

Return value

T *

A pointer to the first element of the array.


End()

inline T *End();

Description

Gets a pointer to the first byte following the end of the array.

Return value

T *

A pointer to the first byte following the end of the array.


Begin()

inline const T *Begin() const;

Description

Gets a pointer to the first element of the array.

Return value

const T *

A pointer to a const element of the array.


End()

inline const T *End() const;

Description

Gets a pointer to the first byte following the end of the array.

Return value

const T *

A pointer to the const first byte following the end of the array.


Array()

inline TArray< T > Array() const;

Description

Creates and returns a generic array for this C++ array.

Return value

TArray< T >

A generic array for this C++ array.


InRange()

protected: static inline TBool InRange(TInt aIndex);

Description

Parameters

TInt aIndex

Return value

TBool


CountFunctionR()

protected: static inline TInt CountFunctionR(const CBase *aThis);

Description

Parameters

const CBase *aThis

Return value

TInt


AtFunctionR()

protected: static inline const TAny *AtFunctionR(const CBase *aThis, TInt aIndex);

Description

Parameters

const CBase *aThis

TInt aIndex

Return value

const TAny *

[Top]


Member data


iRep

protected: T iRep;

Description