Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



Location: e32des8.h
Link against: euser.lib

Class HBufC8

class HBufC8 : public TBufCBase8;

Description

8-bit heap descriptor.

This is a descriptor class which provides a buffer of fixed length, allocated on the heap, for containing and accessing data.

The class is intended for instantiation.

Heap descriptors have the important property that they can be made larger or smaller, changing the size of the descriptor buffer. This is achieved by reallocating the descriptor. Unlike the behaviour of dynamic buffers, reallocation is not done automatically.

Data is intended to be accessed, but not modified; however, it can be completely replaced using the assignment operators of this class. The base class (TDesC8) provides the functions through which the data is accessed.

The descriptor is hosted by a heap cell, and the 8-bit data that the descriptor represents is part of the descriptor object itself. The size of the cell depends on the requested maximum length of the descriptor buffer when the descriptor is created or re-allocated.

It is important to note that the size of the allocated cell, and, therefore, the resulting maximum length of the descriptor, may be larger than requested due to the way memory is allocated in Symbian OS. The amount by which this may be rounded up depends on the platform and build type.

Derivation

Members

Defined in HBufC8:
Des(), New(), NewL(), NewL(), NewLC(), NewLC(), NewMax(), NewMaxL(), NewMaxLC(), ReAlloc(), ReAllocL(), operator=(), operator=(), operator=()

See also:


Construction and destruction


NewL()

static IMPORT_C HBufC8 *NewL(TInt aMaxLength);

Description

Creates, and returns a pointer to, a new 8-bit heap descriptor, and leaves on failure.

The heap descriptor is empty and its length is zero.

Data can, subsequently, be assigned into it using the assignment operators.

Parameters

TInt aMaxLength

The requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested.

Return value

HBufC8 *

A pointer to the new 8 bit heap descriptor. The function leaves, if the new 8-bit heap descriptor cannot be created.

Panic codes

USER

30 if aMaxLength is negative.

See also:


NewLC()

static IMPORT_C HBufC8 *NewLC(TInt aMaxLength);

Description

Creates, adds a pointer onto the cleanup stack, and returns a pointer to, a new 8 bit heap descriptor; leaves on failure.

The heap descriptor is empty and its length is zero.

Data can, subsequently, be assigned into it using the assignment operators.

Parameters

TInt aMaxLength

The requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested.

Return value

HBufC8 *

A pointer to the new 8-bit heap descriptor. The function leaves, if the new 8-bit heap descriptor cannot be created.

Panic codes

USER

30 if aMaxLength is negative.

See also:


NewL()

static IMPORT_C HBufC8 *NewL(RReadStream &aStream, TInt aMaxLength);

Description

Parameters

RReadStream &aStream

TInt aMaxLength

Return value

HBufC8 *


NewLC()

static IMPORT_C HBufC8 *NewLC(RReadStream &aStream, TInt aMaxLength);

Description

Parameters

RReadStream &aStream

TInt aMaxLength

Return value

HBufC8 *

[Top]


Member functions


New()

static IMPORT_C HBufC8 *New(TInt aMaxLength);

Description

Creates, and returns a pointer to, a new 8-bit heap descriptor.

The heap descriptor is empty and its length is zero.

Data can, subsequently, be assigned into it using the assignment operators.

Parameters

TInt aMaxLength

The requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested.

Return value

HBufC8 *

A pointer to the new 8-bit heap descriptor. NULL, if the 8-bit heap descriptor cannot be created.

Panic codes

USER

30 if aMaxLength is negative.

See also:


NewMax()

static IMPORT_C HBufC8 *NewMax(TInt aMaxLength);

Description

Creates, and returns a pointer to, a new 8-bit heap descriptor.

No data is assigned into the new descriptor but its length is set to aMaxLength.

Data can, subsequently, be assigned into it using the assignment operators.

Parameters

TInt aMaxLength

The requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested. This also means that the resulting maximum length of the descriptor may be greater than its length.

Return value

HBufC8 *

A pointer to the new 8-bit heap descriptor. NULL, if the new 8-bit heap descriptor cannot be created.

Panic codes

USER

30 if aMaxLength is negative.

See also:


NewMaxL()

static IMPORT_C HBufC8 *NewMaxL(TInt aMaxLength);

Description

Creates, and returns a pointer to, a new 8-bit heap descriptor; leaves on failure.

No data is assigned into the new descriptor but its length is set to aMaxLength.

Data can, subsequently, be assigned into it using the assignment operators.

Parameters

TInt aMaxLength

The requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested. This also means that the resulting maximum length of the descriptor may be greater than its length.

Return value

HBufC8 *

A pointer to the new 8-bit heap descriptor. The function leaves, if the new 8-bit heap descriptor cannot be created.

Panic codes

USER

30 if aMaxLength is negative.

See also:


NewMaxLC()

static IMPORT_C HBufC8 *NewMaxLC(TInt aMaxLength);

Description

Creates, adds a pointer onto the cleanup stack and returns a pointer to, a new 8-bit heap descriptor; leaves on failure.

No data is assigned into the new descriptor but its length is set to aMaxLength.

Data can, subsequently, be assigned into it using the assignment operators.

Parameters

TInt aMaxLength

The requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested. This also means that the resulting maximum length of the descriptor may be greater than its length.

Return value

HBufC8 *

A pointer to the new 8-bit heap descriptor. This is also put onto the cleanup stack. The function leaves, if the new 8-bit heap descriptor cannot be created.

Panic codes

USER

30 if aMaxLength is negative.

See also:


operator=()

IMPORT_C HBufC8 &operator=(const TUint8 *aString);

Description

Copies data into this 8-bit heap descriptor replacing any existing data.

The length of this descriptor is set to reflect the new data.

Note that the maximum length of this (target) descriptor is the length of the descriptor buffer in the allocated host heap cell; this may be greater than the maximum length specified when this descriptor was created or last re-allocated.

Parameters

const TUint8 *aString

A pointer to a zero-terminated string.

Return value

HBufC8 &

A reference to this 8 bit heap descriptor.

Panic codes

USER

23 if the length of the string, excluding the zero terminator, is greater than the maximum length of this (target) descriptor,


operator=()

IMPORT_C HBufC8 &operator=(const TDesC8 &aDes);

Description

Copies data into this 8-bit heap descriptor replacing any existing data.

The length of this descriptor is set to reflect the new data.

Note that the maximum length of this (target) descriptor is the length of the descriptor buffer in the allocated host heap cell; this may be greater than the maximum length specified when this descriptor was created or last re-allocated.

Parameters

const TDesC8 &aDes

An 8-bit non-modifiable descriptor.

Return value

HBufC8 &

A reference to this 8-bit heap descriptor.

Panic codes

USER

23 if the length of the descriptor aDes is greater than the maximum length of this (target) descriptor


operator=()

inline HBufC8 &operator=(const HBufC8 &aLcb);

Description

Copies data into this 8-bit heap descriptor replacing any existing data.

The length of this descriptor is set to reflect the new data.

Note that the maximum length of this (target) descriptor is the length of the descriptor buffer in the allocated host heap cell; this may be greater than the maximum length specified when this descriptor was created or last re-allocated.

Parameters

const HBufC8 &aLcb

The source 8-bit heap descriptor.

Return value

HBufC8 &

A reference to this 8-bit heap descriptor.

Panic codes

USER

23, if the length of the descriptor aLcb is greater than the maximum length of this (target) descriptor


ReAlloc()

IMPORT_C HBufC8 *ReAlloc(TInt aMaxLength);

Description

Expands or contracts the heap descriptor.

This is done by:

1. creating a new heap descriptor.

2. copying the original data into the new descriptor.

3. deleting the original descriptor.

Parameters

TInt aMaxLength

The new requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested.

Return value

HBufC8 *

A pointer to the new expanded or contracted 8 bit heap descriptor - the original descriptor is deleted. NULL, if the new 8-bit heap descriptor cannot be created - the original descriptor remains unchanged

Panic codes

USER

26 if aMaxLength is less than the length of the existing data.

USER

30 if aMaxLength is negative.


ReAllocL()

IMPORT_C HBufC8 *ReAllocL(TInt aMaxLength);

Description

Expands or contracts the descriptor; leaves on failure.

This is done by:

1. creating a new heap descriptor.

2. copying the original data into the new descriptor.

3. deleting the original descriptor.

Parameters

TInt aMaxLength

The new requested maximum length of the descriptor. Note that the resulting heap cell size and, therefore, the resulting maximum length of the descriptor may be larger than requested.

Return value

HBufC8 *

A pointer to the new expanded or contracted 8 bit heap descriptor - the original descriptor is deleted. NULL, if the new 8-bit heap descriptor cannot be created - the original descriptor remains unchanged

Panic codes

USER

26 if aMaxLength is less than the length of the existing data.

USER

30 if aMaxLength is negative.


Des()

IMPORT_C TPtr8 Des();

Description

Creates and returns an 8-bit modifiable pointer descriptor for the data represented by this 8-bit heap descriptor.

The content of a heap descriptor normally cannot be altered, other than by complete replacement of the data. Creating a modifiable pointer descriptor provides a way of changing the data.

The modifiable pointer descriptor is set to point to this heap descriptor's data.

The length of the modifiable pointer descriptor is set to the length of this heap descriptor.

The maximum length of the modifiable pointer descriptor is set to the length of the heap descriptor's buffer. Note that the maximum length is the length of the descriptor buffer in the allocated host heap cell; this may be greater than the maximum length requested when this descriptor was originally created or last re-allocated.

When data is modified through this new pointer descriptor, the lengths of both it and this heap descriptor are changed.

Note that it is a common mistake to use Des() to create a TDesC8& reference. While not incorrect, it is simpler and much more efficient to simply dereference the heap descriptor.

Return value

TPtr8

An 8-bit modifiable pointer descriptor representing the data in this 8-bit heap descriptor.