Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32base.h
Link against: euser.lib

Class CBufFlat

CBufFlat

Support

Supported from 5.0

Description

Provides a flat storage dynamic buffer. This class should be used when high-speed pointer lookup is an important consideration, and you are reasonably confident that the insertion of data will not fail.

This class is an implementation of the abstract buffer interface provided by CBufBase and uses a single heap cell to contain the data.

Its data members include a pointer to the heap cell, and the size of the allocated cell.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CBufBaseSpecifies the interface for dynamic buffers
CBufFlatProvides a flat storage dynamic buffer

Defined in CBufFlat:
BackPtr(), Capacity(), Compress(), Delete(), NewL(), Ptr(), SetReserveL(), ~CBufFlat()

Inherited from CBase:
operator new()

Inherited from CBufBase:
ExpandL(), InsertL(), Read(), Reset(), ResizeL(), Size(), Write()


Construction and destruction


NewL()

static CBufFlat* NewL(TInt anExpandSize);

Description

Allocates and constructs a flat buffer.

If there is insufficient memory available to allocate the flat buffer, the function leaves.

Parameters

TInt anExpandSize

The granularity of buffer expansion. Additional space, when required, is always allocated in multiples of this number.

Return value

CBufFlat*

If successful, a pointer to the allocated buffer.


~CBufFlat()

~CBufFlat();

Description

Frees all resources owned by the object, prior to its destruction. Specifically, it frees the allocated cell used as a buffer.

[Top]


Reserving space


SetReserveL()

void SetReserveL(TInt aSize);

Description

Specifies a minimum amount of space which the flat buffer should occupy.

If the required size is zero, the heap cell is deleted. If it is different from the current size, the heap cell is rellocated accordingly.

Parameters

TInt aSize

The size of the heap cell required. It must not be negative, otherwise the function raises a E32USER-CBase 10 panic If there is data in the buffer, the specified size must not be less than the value returned by Size(), otherwise the function raises a E32USER-CBase 11 panic. If there is no data in the buffer, i.e. Size() returns zero, the specified size value can be zero which causes the buffer's allocated heap cell to be deleted.

Leave codes

 

This function leaves if it is impossible to re-allocate the heap cell to a sufficiently large size.


Capacity()

TInt Capacity() const;

Description

Returns the size to which the buffer may expand without re-allocation.

Return value

TInt

The size of the allocated cell associated with the buffer. This is the maximum size the buffer may be expanded to without re-allocation.

[Top]


Deleting data


Delete()

virtual void Delete(TInt aPos,TInt aLength);

Description

Deletes data from the buffer. During deletion, any data beyond the deleted data is shuffled up so that the buffer contents are contiguous. No memory is freed.

See also:

[Top]


Compressing data


Compress()

virtual void Compress();

Description

Compresses the buffer so as to occupy minimal space. This frees any unused memory at the end of the buffer.

See also:

[Top]


Pointer access


Ptr()

virtual TPtr8 Ptr(TInt aPos);

Description

Returns a pointer descriptor to represent the data starting at the specified data byte through to the end of the contiguous region containing that byte.

Calculation of the pointer and length involves only a few machine instructions and is independent of the data contained in the buffer.

See also:


BackPtr()

virtual TPtr8 BackPtr(TInt aPos);

Description

Returns a pointer descriptor to represent the data starting at beginning of the contiguous region containing that byte through to the byte immediately preceding the specified byte.

The descriptor always points to the beginning of the buffer containing the specified byte. Calculation of the pointer and length involves only a few machine instructions and is independent of the data contained in the buffer.

See also: