EPOC   SDK Home Glossary Indexes Previous   Up

TFixedArray class


Contents


TFixedArray<class T,TInt S> class — Wrapper for C++ arrays

Section Contents


Overview

Derivation

Not applicable

Defined in

e32std.h

Description

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


Construction


TFixedArray() — Default C++ constructor

TFixedArray();

Description

The default C++ constructor is used to construct an uninitialised C++ array.


TFixedArray() — C++ constructor (with list of objects and number of objects)

TFixedArray(const T* aList,TInt aLength);

Description

The C++ constructor is used to construct a C++ array initialized with aLength type T objects located at aList.

Arguments

const T* aList

A pointer to a set of contiguous type T objects.

TInt aLength

The number of type T objects at the location aList.

In a debug build, this value must be strictly less than the template value <TInt S>, the size of the C++ array, otherwise the constructor raises a USER 133 panic.


Copying elements into the array


Copy() — Copy list of objects into the array

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

Description

Use this function to copy aLength type T objects located at aList into the C++ array. The copy operation starts at the beginning of the array, replacing any existing data.

Arguments

const T* aList

A pointer to a set of contiguous type T objects.

TInt aLength

The number of type T objects at the location aList.

In a debug build, this value must be strictly less than the template value <TInt S>, the size of the C++ array, otherwise the constructor raises a USER 133 panic.


Other actions on the array


Reset() — Zero fill the array

void Reset();

Description

Use this function to zero fill the array; i.e. to fill every element of the array with binary zeroes.


DeleteAll() — Invoke delete operator on all elements of the array

void DeleteAll();

Description

Use this function to invoke the delete operator for every member of the array. This 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, then Reset() should be called to set the array elements to NULL.


Information about the array


Count() — Fetch the size of the array

TInt Count();

Description

Use this function to return the size of the array; i.e. the number of elements in the array.

The size of the C++ array is always fixed and is the same value as the template parameter <TInt S>.

Return value

TInt

The size of the C++ array


Length() — Fetch the length of an array element

TInt Length();

Description

Use this function to return the length of an array element, in bytes.

Return value

TInt

The length of an array element, in bytes.


Accessing the array


At() — Access the array (range check always done)

T& At(TInt aIndex);

const T& At(TInt aIndex) const;

Description

Use these functions to return a reference to the element at index aIndex within the C++ array.

An index is relative to zero so that the first element has index zero, the second element has index one etc. The specified value is checked to ensure that it is within the valid range in both release and debug builds.

The compiler chooses the appropriate function variant depending on the context of the call.

Arguments

TInt aIndex

The index of the element within the array.

This value must be greater than or equal to zero and less than the size of the array (i.e. the number of elements as defined by the <TInt S> template parameter), otherwise the function raises a USER 133 panic.

Return value

T&

A reference to an element of the array.

const T&

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


Operator[] — Access the array (range check only done in debug build)

T& operator[](TInt aIndex);

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

Description

Use these operators to return a reference to the element at index aIndex within the C++ array.

An index is relative to zero so that the first element has index zero, the second element has index one etc. The specified value is only checked to ensure that it is within the valid range in debug builds.

The compiler chooses the appropriate operator variant depending on the context of the call.

Arguments

TInt aIndex

The index of the element within the array.

In a debug build, this value must be greater than or equal to zero and less than the size of the array (i.e. the number of elements as defined by the <TInt S> template parameter), otherwise the function raises a USER 133 panic.

In a release build, this value is not checked.

Return value

T&

A reference to an element of the array.

const T&

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


Pointers to beginning and end of the array


Begin() — Fetch pointer to the beginning of the array

T* Begin();

const T* Begin() const;

Description

Use these functions to return a pointer to the beginning of the array; i.e. the first element of the array.

The compiler chooses the appropriate function variant depending on the context of the call.

Return value

T*

A pointer to the first element of the array.

const T*

A pointer to the first element of the array; the element cannot be changed through this pointer.


End() — Fetch pointer to the end of the array

T* End();

const T* End() const;

Description

Use these functions to return a pointer to the first byte following the end of the array.

The compiler chooses the appropriate function variant depending on the context of the call.

Return value

T*

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

const T*

A pointer to the first byte following the end of the array; the data cannot be changed through this pointer.


Returning a generic array


Array() — Create & return a TArray

TArray<T> Array() const;

Description

Use this function to construct and return a TArray<T> object. This is a templated class taking the value of the template parameter <class T>.

The subject of generic arrays is discussed in the section on Dynamic Arrays in the EPOC C++ Standard Edition.

Return value

TArray<T>

A TArray<T> generic array for this array.

EPOC       SDK Home Glossary Indexes Previous   Up