Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <S32MEM.H>
Link against: estor.lib

Class TBufBuf

class TBufBuf : public TStreamBuf;

Description

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 TBufBuf::Set(CBufBase &,TInt,TInt)

overwrite mode - replaces the data in the buffer starting at the offset passed to TBufBuf::Set(CBufBase &,TInt,TInt). 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 TBufBuf::Set(CBufBase &,TInt,TInt) before data is written, extending the buffer. When writing, the buffer size as reported by CBufBase::Size()const 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.

Derivation

Members

Defined in TBufBuf:

Inherited from MStreamBuf:

Inherited from TStreamBuf:

See also:


Construction and destruction


TBufBuf()

IMPORT_C TBufBuf();

Description

Constructs an empty object.

Call TBufBuf::Set(CBufBase &,TInt,TInt) before using the object.

[Top]


Member functions


Set(CBufBase &,TInt,TInt)

IMPORT_C void Set(CBufBase &aBuf, TInt aPos, TInt aMode=ERead|EWrite);

Description

Sets up the stream to use the specified dynamic buffer.

Parameters

CBufBase &aBuf

The dynamic buffer that hosts the stream and that also acts as the intermediate buffer.

TInt aPos

The offset within the dynamic buffer where the stream starts.

TInt aMode

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

See also:


UnderflowL(TInt)

protected: IMPORT_C virtual TInt UnderflowL(TInt aMaxLength);

Description

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 aMaxLength

The maximum amount of data required for the intermediate buffer.

Return value

TInt

The amount of data available in the intermediate buffer.


OverflowL()

protected: IMPORT_C virtual void OverflowL();

Description

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.


DoSynchL()

protected: IMPORT_C virtual void DoSynchL();

Description

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 MStreamBuf::SynchL().

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

See also:


DoWriteL(const TAny *,TInt)

protected: IMPORT_C virtual void DoWriteL(const TAny *aPtr, TInt aLength);

Description

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

Parameters

const TAny *aPtr

A pointer to the source memory location for the data to be written to the intermediate buffer.

TInt aLength

The number of bytes to be written.

See also:


DoSeekL(TMark,TStreamLocation,TInt)

protected: IMPORT_C virtual TStreamPos DoSeekL(TMark aMark, TStreamLocation aLocation, TInt anOffset);

Description

Parameters

MStreamBuf::TMark aMark

TStreamLocation aLocation

TInt anOffset

Return value

TStreamPos

[Top]


Member enumerations


Enum anonymous

n/a

Description

ETruncate

EInsert