CBufSeg Class Reference

class CBufSeg : public CBufBase

Provides a segmented dynamic buffer.

This class should be used when the object has a long life-time and an unpredictable number of insertions, or there is concern about the performance of insertion and deletion operations into large buffers.

This class is an implementation of the abstract buffer interface provided by CBufBase and uses doubly-linked list of heap cells to contain the data; each cell containing a segment of the buffer.

Its (private) data members include an anchor for the doubly-linked list, and also a reference to the buffer position used by the last operation. This reference acts as a cache; if the next operation uses a similar buffer position, then calculation of the pointer corresponding to its buffer position is much faster.

Inherits from

Constructor & Destructor Documentation

CBufSeg(TInt)

IMPORT_CCBufSeg(TIntanExpandSize)[protected]

Parameters

TInt anExpandSize

~CBufSeg()

IMPORT_C~CBufSeg()

Member Functions Documentation

AllocSegL(TBufSegLink *, TInt)

voidAllocSegL(TBufSegLink *aSeg,
TIntaNumber
)[protected]

Parameters

TBufSegLink * aSeg
TInt aNumber

BackPtr(TInt)

IMPORT_C TPtr8BackPtr(TIntaPos)[virtual]

Gets a pointer descriptor to represent data from just before the specified data byte backward to the beginning of the contiguous region containing that byte.

Derived classes provide the implementation.

Descriptor representing the back contiguous region. The address in the descriptor is the pointer to the bytes at the buffer position, unless the buffer position was at the beginning of a non-first segment in the buffer: in this case, the address is a pointer just beyond the last data byte in the previous segment. The length is the number of contiguous bytes from the address backwards to the beginning of the segment.

CBufFlat::BackPtr

CBufSeg::BackPtr

Parameters

TInt aPosBuffer position: must be in range zero to Size().

Compress()

IMPORT_C voidCompress()[virtual]

Compresses the buffer so as to occupy minimal space.

Normally, you would call this when a buffer has reached its final size, or when you know it will not expand again for a while, or when an out-of-memory error has occurred and your program is taking measures to save space. Compression in these circumstances releases memory for other programs to use, but has no adverse effect on performance.

Derived classes provide the implementation.

CBufFlat::Compress

CBufSeg::Compress

Delete(TInt, TInt)

IMPORT_C voidDelete(TIntaPos,
TIntaLength
)[virtual]

Deletes data from the buffer.

Derived classes provide the implementation.

CBufFlat::Delete

CBufSeg::Delete

Parameters

TInt aPosBuffer position where the deletion will begin; must be in the range zero to (Size() minus the length of the data to be deleted).
TInt aLengthThe number of bytes to be deleted; must be non-negative.

DeleteFromSegment(TBufSegLink *, TInt, TInt)

voidDeleteFromSegment(TBufSegLink *aSeg,
TIntanOffset,
TIntaLength
)[protected]

Parameters

TBufSegLink * aSeg
TInt anOffset
TInt aLength

DoInsertL(TInt, const TAny *, TInt)

IMPORT_C voidDoInsertL(TIntaPos,
const TAny *aPtr,
TIntaLength
)[private, virtual]

Parameters

TInt aPos
const TAny * aPtr
TInt aLength

FreeSegment(TBufSegLink *)

voidFreeSegment(TBufSegLink *aSeg)[protected]

Parameters

TBufSegLink * aSeg

InsertIntoSegment(TBufSegLink *, TInt, const TAny *, TInt)

voidInsertIntoSegment(TBufSegLink *aSeg,
TIntanOffset,
const TAny *aPtr,
TIntaLength
)[protected]

Parameters

TBufSegLink * aSeg
TInt anOffset
const TAny * aPtr
TInt aLength

NewL(TInt)

IMPORT_C CBufSeg *NewL(TIntanExpandSize)[static]

Parameters

TInt anExpandSize

Ptr(TInt)

IMPORT_C TPtr8Ptr(TIntaPos)[virtual]

Gets a pointer descriptor to represent the data from the specified position to the end of the contiguous region containing that byte.

Derived classes provide the implementation.

Descriptor representing the data starting at aPos, and whose length indicates the number of contiguous bytes stored in the buffer, forward from that point. The length will be non-zero unless aPos==Size().

CBufFlat::Ptr

CBufSeg::Ptr

Parameters

TInt aPosBuffer position: must be in range zero to Size().

SetSBO(TInt)

voidSetSBO(TIntaPos)[protected]

Parameters

TInt aPos

Member Data Documentation

TInt iBase

TInt iBase[private]

TInt iOffset

TInt iOffset[private]

TDblQue< TBufSegLink > iQue

TDblQue< TBufSegLink >iQue[private]

TBufSegLink * iSeg

TBufSegLink *iSeg[private]