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.
Public Member Functions | |
---|---|
~CBufSeg() | |
IMPORT_C TPtr8 | BackPtr(TInt) |
IMPORT_C void | Compress() |
IMPORT_C void | Delete(TInt, TInt) |
IMPORT_C CBufSeg * | NewL(TInt) |
IMPORT_C TPtr8 | Ptr(TInt) |
Protected Member Functions | |
---|---|
CBufSeg(TInt) | |
void | AllocSegL(TBufSegLink *, TInt) |
void | DeleteFromSegment(TBufSegLink *, TInt, TInt) |
void | FreeSegment(TBufSegLink *) |
void | InsertIntoSegment(TBufSegLink *, TInt, const TAny *, TInt) |
void | SetSBO(TInt) |
Private Member Functions | |
---|---|
IMPORT_C void | DoInsertL(TInt, const TAny *, TInt) |
Private Attributes | |
---|---|
TInt | iBase |
TInt | iOffset |
TDblQue< TBufSegLink > | iQue |
TBufSegLink * | iSeg |
Inherited Attributes | |
---|---|
CBufBase::iExpandSize | |
CBufBase::iSize |
void | AllocSegL | ( | TBufSegLink * | aSeg, |
TInt | aNumber | |||
) | [protected] |
TBufSegLink * aSeg | |
TInt aNumber |
IMPORT_C TPtr8 | BackPtr | ( | TInt | aPos | ) | [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.
TInt aPos | Buffer position: must be in range zero to Size(). |
IMPORT_C void | Compress | ( | ) | [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.
IMPORT_C void | Delete | ( | TInt | aPos, |
TInt | aLength | |||
) | [virtual] |
Deletes data from the buffer.
Derived classes provide the implementation.
void | DeleteFromSegment | ( | TBufSegLink * | aSeg, |
TInt | anOffset, | |||
TInt | aLength | |||
) | [protected] |
IMPORT_C void | DoInsertL | ( | TInt | aPos, |
const TAny * | aPtr, | |||
TInt | aLength | |||
) | [private, virtual] |
void | FreeSegment | ( | TBufSegLink * | aSeg | ) | [protected] |
TBufSegLink * aSeg |
void | InsertIntoSegment | ( | TBufSegLink * | aSeg, |
TInt | anOffset, | |||
const TAny * | aPtr, | |||
TInt | aLength | |||
) | [protected] |
IMPORT_C TPtr8 | Ptr | ( | TInt | aPos | ) | [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().
TInt aPos | Buffer position: must be in range zero to Size(). |