CBufBase Class Reference

class CBufBase : public CBase

Defines the interface for dynamic buffers.

The basic functions, InsertL(), Read(), Write(), Delete(), Reset() and Size(), transfer data between the buffer and other places, and allow that data to be deleted

The ExpandL() and Resize() functions allow some operations to be carried out with greater efficiency

A Compress() function frees (back to the heap) any space which may have been allocated, but not used

Ptr() and BackPtr() allow look-up of contiguous data from any given position, forward or backward

Inherits from

Public Member Functions
~CBufBase()
TPtr8 BackPtr(TInt)
voidCompress()
voidDelete(TInt, TInt)
IMPORT_C voidExpandL(TInt, TInt)
IMPORT_C voidInsertL(TInt, const TDesC8 &)
IMPORT_C voidInsertL(TInt, const TDesC8 &, TInt)
IMPORT_C voidInsertL(TInt, const TAny *, TInt)
TPtr8 Ptr(TInt)
IMPORT_C voidRead(TInt, TDes8 &)
IMPORT_C voidRead(TInt, TDes8 &, TInt)
IMPORT_C voidRead(TInt, TAny *, TInt)
IMPORT_C voidReset()
IMPORT_C voidResizeL(TInt)
TInt Size()
IMPORT_C voidWrite(TInt, const TDesC8 &)
IMPORT_C voidWrite(TInt, const TDesC8 &, TInt)
IMPORT_C voidWrite(TInt, const TAny *, TInt)
Protected Member Functions
CBufBase(TInt)
Private Member Functions
voidDoInsertL(TInt, const TAny *, TInt)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Protected Attributes
TInt iExpandSize
TInt iSize

Constructor & Destructor Documentation

CBufBase(TInt)

IMPORT_CCBufBase(TIntanExpandSize)[protected]

Parameters

TInt anExpandSize

~CBufBase()

IMPORT_C~CBufBase()

Member Functions Documentation

BackPtr(TInt)

TPtr8 BackPtr(TIntaPos)[pure 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()

voidCompress()[pure 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)

voidDelete(TIntaPos,
TIntaLength
)[pure 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.

DoInsertL(TInt, const TAny *, TInt)

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

Parameters

TInt aPos
const TAny * aPtr
TInt aLength

ExpandL(TInt, TInt)

IMPORT_C voidExpandL(TIntaPos,
TIntaLength
)

Parameters

TInt aPos
TInt aLength

InsertL(TInt, const TDesC8 &)

IMPORT_C voidInsertL(TIntaPos,
const TDesC8 &aDes
)

Parameters

TInt aPos
const TDesC8 & aDes

InsertL(TInt, const TDesC8 &, TInt)

IMPORT_C voidInsertL(TIntaPos,
const TDesC8 &aDes,
TIntaLength
)

Parameters

TInt aPos
const TDesC8 & aDes
TInt aLength

InsertL(TInt, const TAny *, TInt)

IMPORT_C voidInsertL(TIntaPos,
const TAny *aPtr,
TIntaLength
)

Parameters

TInt aPos
const TAny * aPtr
TInt aLength

Ptr(TInt)

TPtr8 Ptr(TIntaPos)[pure 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().

Read(TInt, TDes8 &)

IMPORT_C voidRead(TIntaPos,
TDes8 &aDes
)const

Parameters

TInt aPos
TDes8 & aDes

Read(TInt, TDes8 &, TInt)

IMPORT_C voidRead(TIntaPos,
TDes8 &aDes,
TIntaLength
)const

Parameters

TInt aPos
TDes8 & aDes
TInt aLength

Read(TInt, TAny *, TInt)

IMPORT_C voidRead(TIntaPos,
TAny *aPtr,
TIntaLength
)const

Parameters

TInt aPos
TAny * aPtr
TInt aLength

Reset()

IMPORT_C voidReset()

ResizeL(TInt)

IMPORT_C voidResizeL(TIntaSize)

Parameters

TInt aSize

Size()

TInt Size()const [inline]

Gets the number of data bytes in the buffer.

Note that the number of heap bytes used by the buffer may be greater than its size, because there is typically extra room to allow for expansion. Use the Compress() function to reduce the extra allocation as much as possible.

The number of data bytes in the buffer.

Write(TInt, const TDesC8 &)

IMPORT_C voidWrite(TIntaPos,
const TDesC8 &aDes
)

Parameters

TInt aPos
const TDesC8 & aDes

Write(TInt, const TDesC8 &, TInt)

IMPORT_C voidWrite(TIntaPos,
const TDesC8 &aDes,
TIntaLength
)

Parameters

TInt aPos
const TDesC8 & aDes
TInt aLength

Write(TInt, const TAny *, TInt)

IMPORT_C voidWrite(TIntaPos,
const TAny *aPtr,
TIntaLength
)

Parameters

TInt aPos
const TAny * aPtr
TInt aLength

Member Data Documentation

TInt iExpandSize

TInt iExpandSize[protected]

TInt iSize

TInt iSize[protected]