Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32base.h>
Link against: euser.lib

Class CBufFlat

class CBufFlat : public CBufBase;

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.

Derivation

Members

Defined in CBufFlat:

Inherited from CBase:

Inherited from CBufBase:


Construction and destruction


~CBufFlat()

IMPORT_C ~CBufFlat();

Description

Destructor.

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


NewL(TInt)

IMPORT_C 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. Note: although a value of zero is permitted by this interface, it has no meaning, and risks raising panics later during execution. We suggest that you pass a positive value.

Return value

CBufFlat *

A pointer to the flat buffer object.

Panic codes

E32USER-CBase

3 if the granularity is negative.

[Top]


Member functions


Capacity()const

inline TInt Capacity() const;

Description

Gets 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.


SetReserveL(TInt)

IMPORT_C 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 buffer required. If there is no data in the buffer, i.e. CBufBase::Size()const returns zero, then this value can be zero, which causes the buffer's allocated heap cell to be deleted.

Panic codes

E32USER-CBase

10, if aSize is negative.

E32USER-CBase

11, if there is data in the buffer, and aSize is less than the value returned by Size().


Compress()

IMPORT_C 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:


Delete(TInt,TInt)

IMPORT_C 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.

Parameters

TInt aPos

Buffer position where the deletion will begin; must be in the range zero to (CBufBase::Size()const minus the length of the data to be deleted).

TInt aLength

The number of bytes to be deleted.

Panic codes

E32USER-CBase

12, if aPos is negative or is greater than the current size of the buffer.

E32USER-CBase

13, if aPos + aLength is greater than the current size of the buffer.

See also:


Ptr(TInt)

IMPORT_C virtual TPtr8 Ptr(TInt aPos);

Description

Gets 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.

Parameters

TInt aPos

Buffer position: must be in range zero to CBufBase::Size()const.

Return value

TPtr8

Descriptor representing the data starting at aPos to the end of the buffer.


BackPtr(TInt)

IMPORT_C virtual TPtr8 BackPtr(TInt aPos);

Description

Gets a pointer descriptor to represent the data starting at the 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.

Parameters

TInt aPos

Buffer position: must be in range zero to CBufBase::Size()const.

Return value

TPtr8

Descriptor representing the back contiguous region.

See also:


DoInsertL(TInt,const TAny *,TInt)

private: IMPORT_C virtual void DoInsertL(TInt aPos, const TAny *aPtr, TInt aLength);

Description

Parameters

TInt aPos

const TAny *aPtr

TInt aLength