TBufBuf Class Reference

class TBufBuf : public TStreamBuf

A stream buffer that uses a dynamic buffer for its implementation.

A stream of this type is used by RBufWriteStream and RBufReadStream objects. It also has intermediate buffering capabilities.

This is a seekable stream buffer.

There are three write modes:

insert mode - inserts new data into the buffer at the offset passed to Set()

overwrite mode - replaces the data in the buffer starting at the offset passed to Set(). Once the end of the buffer is reached, it is automatically extended as more data is written. This is the default mode.

truncate mode - truncates the buffer to the offset passed to Set() before data is written, extending the buffer. When writing, the buffer size as reported by CBufBase::Size() may be larger than the data written to the stream. To synchronise the buffer's reported size with the stream, call the MStreamBuf::SynchL() function.

Note that this object never takes ownership of the dynamic buffer, the CBufBase type object.

RBufWriteStream RBufReadStream CBufBase::Size() MStreamBuf::SynchL()

Inherits from

Public Member Functions
TBufBuf()
IMPORT_C voidSet(CBufBase &, TInt, TInt)
Protected Member Functions
IMPORT_C TStreamPosDoSeekL(TMark, TStreamLocation, TInt)
IMPORT_C voidDoSynchL()
IMPORT_C voidDoWriteL(const TAny *, TInt)
IMPORT_C voidOverflowL()
IMPORT_C TIntUnderflowL(TInt)
Private Member Functions
CBufBase &Buf()
voidConsolidate()
TInt Mark(TRead)
TInt Mark(TWrite)
TInt MovePos(TRead, TInt)
TInt MovePos(TWrite, TInt)
TInt Pos(TMark)
TInt Pos(TRead)
TInt Pos(TWrite)
voidSetPos(TMark, TInt)
voidSetPos(TRead, TInt)
voidSetPos(TWrite, TInt)
Inherited Functions
MStreamBuf::Close()
MStreamBuf::MStreamBuf()
MStreamBuf::PushL()
MStreamBuf::Read(TDes8 &,TInt,TRequestStatus &)
MStreamBuf::Read(TDes8 &,TRequestStatus &)
MStreamBuf::ReadL(MStreamInput &)
MStreamBuf::ReadL(MStreamInput &,TInt)
MStreamBuf::ReadL(MStreamInput &,TStreamTransfer)
MStreamBuf::ReadL(TAny *,TInt)
MStreamBuf::ReadL(TDes8 &,TInt,TRequestStatus &)
MStreamBuf::ReadL(TDes8 &,TRequestStatus &)
MStreamBuf::Release()
MStreamBuf::SeekL(TMark,TStreamLocation,TInt)
MStreamBuf::SeekL(TMark,TStreamPos)
MStreamBuf::SeekL(TRead,TInt)
MStreamBuf::SeekL(TRead,TStreamLocation,TInt)
MStreamBuf::SeekL(TWrite,TInt)
MStreamBuf::SeekL(TWrite,TStreamLocation,TInt)
MStreamBuf::SizeL()const
MStreamBuf::Synch()
MStreamBuf::SynchL()
MStreamBuf::TellL(TRead)const
MStreamBuf::TellL(TWrite)const
MStreamBuf::Write(const TDesC8 &,TInt,TRequestStatus &)
MStreamBuf::Write(const TDesC8 &,TRequestStatus &)
MStreamBuf::WriteL(MStreamOutput &)
MStreamBuf::WriteL(MStreamOutput &,TInt)
MStreamBuf::WriteL(MStreamOutput &,TStreamTransfer)
MStreamBuf::WriteL(const TAny *,TInt)
MStreamBuf::WriteL(const TDesC8 &,TInt,TRequestStatus &)
MStreamBuf::WriteL(const TDesC8 &,TRequestStatus &)
TStreamBuf::Avail(TArea)const
TStreamBuf::Avail(TRead)const
TStreamBuf::Avail(TWrite)const
TStreamBuf::DoReadL(MStreamInput &,TStreamTransfer)
TStreamBuf::DoReadL(TAny *,TInt)
TStreamBuf::DoWriteL(MStreamOutput &,TStreamTransfer)
TStreamBuf::End(TArea)const
TStreamBuf::End(TRead)const
TStreamBuf::End(TWrite)const
TStreamBuf::Ptr(TArea)const
TStreamBuf::Ptr(TRead)const
TStreamBuf::Ptr(TWrite)const
TStreamBuf::SetBuf(TArea,TUint8 *,TUint8 *)
TStreamBuf::SetBuf(TRead,TUint8 *,TUint8 *)
TStreamBuf::SetBuf(TWrite,TUint8 *,TUint8 *)
TStreamBuf::SetEnd(TArea,TUint8 *)
TStreamBuf::SetEnd(TRead,TUint8 *)
TStreamBuf::SetEnd(TWrite,TUint8 *)
TStreamBuf::SetPtr(TArea,TUint8 *)
TStreamBuf::SetPtr(TRead,TUint8 *)
TStreamBuf::SetPtr(TWrite,TUint8 *)
TStreamBuf::TStreamBuf()
Inherited Enumerations
MStreamBuf:TRead
MStreamBuf:TWrite
Private Attributes
CBufBase *iBuf
TInt iMode
TInt iRPos
TInt iWPos

Constructor & Destructor Documentation

TBufBuf()

IMPORT_CTBufBuf()

Constructs an empty object.

Call Set() before using the object.

Member Functions Documentation

Buf()

CBufBase &Buf()const [private, inline]

Consolidate()

voidConsolidate()[private]

DoSeekL(TMark, TStreamLocation, TInt)

IMPORT_C TStreamPosDoSeekL(TMarkaMark,
TStreamLocationaLocation,
TIntanOffset
)[protected, virtual]

Parameters

TMark aMark
TStreamLocation aLocation
TInt anOffset

DoSynchL()

IMPORT_C voidDoSynchL()[protected, virtual]

Synchronises the stream buffer with the stream, leaving if any error occurs.

In effect, this ensures that buffered data is delivered to the stream.

It is called by SynchL().

This implementation is empty, but classes derived from MStreamBuf can provide their own implementation, if necessary.

MStreamBuf::SynchL()

DoWriteL(const TAny *, TInt)

IMPORT_C voidDoWriteL(const TAny *aPtr,
TIntaLength
)[protected, virtual]

Writes data from the specified memory location into the intermediate buffer.

The function calls the virtual function OverfLowL() to give concrete implementations the chance to forward the intermediate buffer content to its destination.

This implementation overrides the one supplied by the base class MStreamBuf, and is called by MStreamBuf::WriteL(const TAny*,TInt).

MStreamBuf::WriteL() MStreamBuf::DoWriteL()

Parameters

const TAny * aPtrA pointer to the source memory location for the data to be written to the intermediate buffer.
TInt aLengthThe number of bytes to be written.

Mark(TRead)

TInt Mark(TRead)const [private, inline]

Parameters

TRead

Mark(TWrite)

TInt Mark(TWrite)const [private, inline]

Parameters

TWrite

MovePos(TRead, TInt)

TInt MovePos(TRead,
TIntanOffset
)[private, inline]

Parameters

TRead
TInt anOffset

MovePos(TWrite, TInt)

TInt MovePos(TWrite,
TIntanOffset
)[private, inline]

Parameters

TWrite
TInt anOffset

OverflowL()

IMPORT_C voidOverflowL()[protected, virtual]

Empties the intermediate buffer and resets the start and end points of the write area.

The implementation of this function depends on the way the stream itself is implemented. For example, the in-memory streams have simple implementations.

Pos(TMark)

TInt Pos(TMarkaMark)const [private]

Parameters

TMark aMark

Pos(TRead)

TInt Pos(TRead)const [private, inline]

Parameters

TRead

Pos(TWrite)

TInt Pos(TWrite)const [private, inline]

Parameters

TWrite

Set(CBufBase &, TInt, TInt)

IMPORT_C voidSet(CBufBase &aBuf,
TIntaPos,
TIntaMode = ERead|EWrite
)

Sets up the stream to use the specified dynamic buffer.

CBufBase MStreamBuf::TRead MStreamBuf::TWrite

Parameters

CBufBase & aBufThe dynamic buffer that hosts the stream and that also acts as the intermediate buffer.
TInt aPosThe offset within the dynamic buffer where the stream starts.
TInt aMode = ERead|EWriteThe mode in which the stream is to be used. It can be used in either or both read and write modes, represented by ERead and EWrite. In addition, specify TBufBuf::EInsert to imply insert mode; specify TBufBuf::ETruncate to imply truncate mode. If neither TBufBuf::EInsert nor TBufBuf::ETruncate are specified, then overwrite mode is implied. Both TBufBuf::EInsert and TBufBuf::ETruncate imply EWrite.

SetPos(TMark, TInt)

voidSetPos(TMarkaMark,
TIntaPos
)[private]

Parameters

TMark aMark
TInt aPos

SetPos(TRead, TInt)

voidSetPos(TRead,
TIntaPos
)[private, inline]

Parameters

TRead
TInt aPos

SetPos(TWrite, TInt)

voidSetPos(TWrite,
TIntaPos
)[private, inline]

Parameters

TWrite
TInt aPos

UnderflowL(TInt)

IMPORT_C TIntUnderflowL(TIntaMaxLength)[protected, virtual]

Re-fills the intermediate buffer and resets the start and end points of the read area.

The implementation of this function depends on the way the stream itself is implemented. For example, the in-memory streams have simple implementations.

Parameters

TInt aMaxLengthThe maximum amount of data required for the intermediate buffer.

Member Data Documentation

CBufBase * iBuf

CBufBase *iBuf[private]

TInt iMode

TInt iMode[private]

TInt iRPos

TInt iRPos[private]

TInt iWPos

TInt iWPos[private]