Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

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

Class TStreamBuf

class TStreamBuf : public MStreamBuf;

Description

Adds buffering capabilities to a stream buffer

The class provides pointers to mark out the current read and write areas within the intermediate buffer. The class also defines the pure virtual functions TStreamBuf::UnderflowL(TInt) and TStreamBuf::OverflowL() which must be provided by a derived class.

Streams which have buffering capabilities derive from this class, otherwise they derive from MStreamBuf.

Note that the class does not provide the buffer; this is left to the class derived from it. For example, the memory buffer classes use the memory area directly, the file buffer class allocate a heap cell to use as a buffer.

Derivation

Members

Defined in TStreamBuf:

Inherited from MStreamBuf:

See also:


Construction and destruction


TStreamBuf()

protected: IMPORT_C TStreamBuf();

Description

Sets the pointers that mark out the read and write areas within the intermediate buffer to null.

[Top]


Member functions


SetBuf(TArea,TUint8 *,TUint8 *)

protected: IMPORT_C void SetBuf(TArea anArea, TUint8 *aPtr, TUint8 *anEnd);

Description

Sets the start and end points of the read and/or the write area within the intermediate buffer.

A start point is always within an area; an end point is always the first byte beyond the end of an area.

Parameters

TStreamBuf::TArea anArea

The areas within the intermediate buffer for which the start and end points are to be set. These can be the read area and/or the write area, as indicated by the ERead and EWrite bits. Only these bits can be set, otherwise the function raises a STORE-Stream 17 panic.

TUint8 *aPtr

The start point.

TUint8 *anEnd

The end point.

See also:


SetPtr(TArea,TUint8 *)

protected: IMPORT_C void SetPtr(TArea anArea, TUint8 *aPtr);

Description

Sets the start point of the read and/or the write area within the intermediate buffer.

A start point is always within an area.

Parameters

TStreamBuf::TArea anArea

The areas within the intermediate buffer for which the start point is to be set. These can be the read area and/or the write area, as indicated by the ERead and EWrite bits. Only these bits can be set, otherwise the function raises a STORE-Stream 17 panic.

TUint8 *aPtr

The start point.

See also:


SetEnd(TArea,TUint8 *)

protected: IMPORT_C void SetEnd(TArea anArea, TUint8 *anEnd);

Description

Parameters

TStreamBuf::TArea anArea

TUint8 *anEnd


Ptr(TArea)const

protected: IMPORT_C TUint8* Ptr(TArea anArea) const;

Description

Gets the current start point of the read or write area within the intermediate buffer.

Parameters

TStreamBuf::TArea anArea

The area within the intermediate buffer for which the start point is to be fetched. This can be either the read area or the write area, as indicated by the ERead and EWrite bits. Only one of these can be set, otherwise the function raises a STORE-Stream 17 panic.

Return value

TUint8 *

The start point.

See also:


End(TArea)const

protected: IMPORT_C TUint8* End(TArea anArea) const;

Description

Gets the current end point of the read or write area within the intermediate buffer.

An end point is always the first byte beyond the end of an area.

Parameters

TStreamBuf::TArea anArea

The area within the intermediate buffer for which the end point is to be fetched. This can be either the read area or the write area, as indicated by the ERead and EWrite bits. Only one of these can be set, otherwise the function raises a STORE-Stream 17 panic.

Return value

TUint8 *

The end point.


Avail(TArea)const

protected: IMPORT_C TInt Avail(TArea anArea) const;

Description

Gets the number of bytes available in the read or write area within the intermediate buffer.

Parameters

TStreamBuf::TArea anArea

The area within the intermediate buffer for which the number of available bytes is to be fetched. This can be either the read area or the write area, as indicated by the ERead and EWrite bits. Only one of these can be set, otherwise the function raises a STORE-Stream 17 panic.

Return value

TInt

The number of bytes available.


DoReadL(TAny *,TInt)

protected: IMPORT_C virtual TInt DoReadL(TAny *aPtr, TInt aMaxLength);

Description

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

The function calls the virtual function UnderfLowL() to give concrete implementations the chance to refill the intermediate buffer, and satisfy the caller's requirements.

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

Parameters

TAny *aPtr

A pointer to the target memory location for the data read from the intermediate buffer.

TInt aMaxLength

The maximum number of bytes to be read.

Return value

TInt

The number of bytes read. This may be less than the amount requested.

See also:


DoReadL(MStreamInput &,TStreamTransfer)

protected: IMPORT_C virtual TStreamTransfer DoReadL(MStreamInput &anInput, TStreamTransfer aTransfer);

Description

Reads data from the intermediate buffer and, if necessary, any remaining data from the stream to the specified target stream input object.

It is called by MStreamBuf::ReadL(MStreamInput &,TStreamTransfer).

The intermediate buffer is emptied first by calling the target stream input's MStreamBuf::PushL() function, which performs the read from intermediate buffer operation. Any remaining data is then read from the stream by calling the target stream object's ReadFromL() function, which performs the read from stream operation.

This implementation is called for streams that have buffering capabilities and are derived from this class.

Parameters

MStreamInput &anInput

The target stream input object.

TStreamTransfer aTransfer

A stream transfer object defining the amount of data available to be written.

Return value

TStreamTransfer

The amount of data that was not consumed.

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:


DoWriteL(MStreamOutput &,TStreamTransfer)

protected: IMPORT_C virtual TStreamTransfer DoWriteL(MStreamOutput &anOutput, TStreamTransfer aTransfer);

Description

Parameters

MStreamOutput &anOutput

TStreamTransfer aTransfer

Return value

TStreamTransfer


SetBuf(TRead,TUint8 *,TUint8 *)

protected: inline void SetBuf(TRead, TUint8 *aPtr, TUint8 *anEnd);

Description

Sets the start and end points of the read area within the intermediate buffer.

A start point is always within an area; an end point is always the first byte beyond the end of an area.

Parameters

MStreamBuf::TRead

TUint8 *aPtr

The start point.

TUint8 *anEnd

The end point.

See also:


SetBuf(TWrite,TUint8 *,TUint8 *)

protected: inline void SetBuf(TWrite, TUint8 *aPtr, TUint8 *anEnd);

Description

Sets the start and end points of the write area within the intermediate buffer.

A start point is always within an area; an end point is always the first byte beyond the end of an area.

Parameters

MStreamBuf::TWrite

TUint8 *aPtr

The start point.

TUint8 *anEnd

The end point.

See also:


SetPtr(TRead,TUint8 *)

protected: inline void SetPtr(TRead, TUint8 *aPtr);

Description

Sets the start point of the write area within the intermediate buffer.

A start point is always within an area.

Parameters

MStreamBuf::TRead

TUint8 *aPtr

The start point.

See also:


SetPtr(TWrite,TUint8 *)

protected: inline void SetPtr(TWrite, TUint8 *aPtr);

Description

Sets the start point of the write area within the intermediate buffer.

A start point is always within an area.

Parameters

MStreamBuf::TWrite

TUint8 *aPtr

The start point.

See also:


SetEnd(TRead,TUint8 *)

protected: inline void SetEnd(TRead, TUint8 *anEnd);

Description

Parameters

MStreamBuf::TRead

TUint8 *anEnd


SetEnd(TWrite,TUint8 *)

protected: inline void SetEnd(TWrite, TUint8 *anEnd);

Description

Parameters

MStreamBuf::TWrite

TUint8 *anEnd


Ptr(TRead)const

protected: inline TUint8* Ptr(TRead) const;

Description

Gets the current start point of the read area within the intermediate buffer.

Parameters

MStreamBuf::TRead

Return value

TUint8 *

The start point.

See also:


Ptr(TWrite)const

protected: inline TUint8* Ptr(TWrite) const;

Description

Gets the current start point of the write area within the intermediate buffer.

Parameters

MStreamBuf::TWrite

Return value

TUint8 *

The start point.

See also:


End(TRead)const

protected: inline TUint8* End(TRead) const;

Description

Gets the current end point of the read area within the intermediate buffer.

An end point is always the first byte beyond the end of an area.

Parameters

MStreamBuf::TRead

Return value

TUint8 *

The end point.

See also:


End(TWrite)const

protected: inline TUint8* End(TWrite) const;

Description

Gets the current end point of the write area within the intermediate buffer.

An end point is always the first byte beyond the end of an area.

Parameters

MStreamBuf::TWrite

Return value

TUint8 *

The end point.

See also:


Avail(TRead)const

protected: inline TInt Avail(TRead) const;

Description

Gets the number of bytes available in the read area within the intermediate buffer.

Parameters

MStreamBuf::TRead

Return value

TInt

The number of bytes available.

See also:


Avail(TWrite)const

protected: inline TInt Avail(TWrite) const;

Description

Gets the number of bytes available in the write area within the intermediate buffer.

Parameters

MStreamBuf::TWrite

Return value

TInt

The number of bytes available.

See also:


UnderflowL(TInt)

private: virtual TInt UnderflowL(TInt aMaxLength)=0;

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

private: virtual void OverflowL()=0;

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.

[Top]


Member type definitions


Typedef TArea

protected: typedef TInt TStreamBuf::TArea;

Description

Used to identify the type of area within an intermediate buffer.

The type is used by functions of this class that set or get pointers into the intermediate buffer.

The type uses the ERead and EWrite enumeration values, as bit flags, to identify the read and write areas respectively.

ERead is an MStreamBuf::TRead enumerator. EWrite is an MStreamBuf::EWrite enumerator.

See also: