CBufSeg Class Reference

#include <e32base.h>

class CBufSeg : public CBufBase

Inherits from

Detailed Description

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.

Constructor & Destructor Documentation

CBufSeg ( TInt )

IMPORT_CCBufSeg(TIntanExpandSize)[protected]

~CBufSeg ( )

IMPORT_C~CBufSeg()

Destructor.

Frees all resources owned by the object, prior to its destruction.

Specifically, it frees all segments allocated to the buffer.

Member Function Documentation

AllocSegL ( TBufSegLink *, TInt )

voidAllocSegL(TBufSegLink *aSeg,
TIntaNumber
)[protected]

BackPtr ( TInt )

IMPORT_C TPtr8BackPtr(TIntaPos)[virtual]

Reimplemented from CBufBase::BackPtr(TInt)

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 segment containing the specified byte. The time needed for calculation of the pointer depends on how many segments there are in the buffer, and how near the target segment is to the segment which was last used in the buffer.

See also: CBufBase::BackPtr

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

Returns: Descriptor representing the back contiguous region.

Compress ( )

IMPORT_C voidCompress()[virtual]

Reimplemented from CBufBase::Compress()

Compresses the buffer so as to occupy minimal space.

Fills any space in each segment of the buffer by moving contents from the next segment to the current one. Where this activity results in empty segments, it frees the memory associated with these segments.

See also: CBufBase::Compress

Delete ( TInt, TInt )

IMPORT_C voidDelete(TIntaPos,
TIntaLength
)[virtual]

Reimplemented from CBufBase::Delete(TInt,TInt)

Deletes data from the buffer.

During deletion, shuffling is minimised by deleting intermediate segments and allowing segments to contain less data than the buffer granularity.

See also: CBufBase::Delete

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

DeleteFromSegment ( TBufSegLink *, TInt, TInt )

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

FreeSegment ( TBufSegLink * )

voidFreeSegment(TBufSegLink *aSeg)[protected]

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

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

NewL ( TInt )

IMPORT_C CBufSeg *NewL(TIntanExpandSize)[static]

Allocates and constructs a segmented buffer.

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

panic
E32USER-CBase 3 if the granularity is negative.
ParameterDescription
anExpandSizeThe granularity of the buffer. Each segment contains (in addition to 16 bytes of overhead) this number of bytes for data. 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.

Returns: If successful, a pointer to the segmented buffer object.

Ptr ( TInt )

IMPORT_C TPtr8Ptr(TIntaPos)[virtual]

Reimplemented from CBufBase::Ptr(TInt)

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.

The time needed for calculation of the pointer depends on how many segments there are in the buffer, and how near the target segment is to the segment which was last used in the buffer.

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

Returns: Descriptor representing the data starting at aPos to the end of the contiguous region containing that byte.

SetSBO ( TInt )

voidSetSBO(TIntaPos)[protected]