Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: e32base.h
Link against: euser.lib

Class CBufSeg

CBufSeg

Support

Supported from 5.0

Description

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 contains a segment of the buffer.

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

Derivation

CBaseBase class for all classes to be instantiated on the heap
CBufBaseSpecifies the interface for dynamic buffers
CBufSegSegmented dynamic buffer

Defined in CBufSeg:
BackPtr(), Compress(), Delete(), NewL(), Ptr(), ~CBufSeg()

Inherited from CBase:
operator new()

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


Construction and destruction


NewL()

static CBufSeg* NewL(TInt anExpandSize);

Description

Allocates and constructs a segmented buffer.

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

Parameters

TInt anExpandSize

The granularity of the buffer: each segment contains (in addition to 16 bytes of overhead) this number of bytes for data

Return value

CBufSeg*

If successful, a pointer to the allocated buffer.


~CBufSeg()

~CBufSeg();

Description

Frees all resources owned by the object, prior to its destruction. Specifically, it frees all segments allocated to the buffer.

[Top]


Deleting data


Delete()

virtual void Delete(TInt aPos,TInt aLength);

Description

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:

[Top]


Compressing data


Compress()

virtual void Compress();

Description

Compresses the buffer so as to occupy minimal space. This frees unused memory at the end of each segment. It may also optimise segment allocations.

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.

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:


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