class MStreamBuf |
A stream buffer that provides a generic I/O interface for streamed data.
A stream buffer:
may be buffered or unbuffered
may provide read-only, write-only or read/write capability
may be seekable, or unseekable.
A seekable stream buffer maintains independent read and write pointers, which can be manipulated separately. This is unlike the RFile interface which maintains a single current position in the file. For example, file streams and memory streams are seekable streams, but socket, serial-comms, and filtered streams are not.
Objects of this type are used by the stream interface classes derived from RReadStream and RWriteStream.
The class has no member data.
Derive from this class, if the stream has no intermediate buffering capabilities, otherwise derive from TStreamBuf.
Get a reference to the stream buffer used by a read stream by calling RReadStream::Source(). Get a reference to the stream buffer used by a write stream by calling RWriteStream::Sink()
Protected Member Functions | |
---|---|
MStreamBuf() |
Private Member Functions | |
---|---|
MStreamBuf(const MStreamBuf &) | |
IMPORT_C TInt | DoReadL(TAny *, TInt) |
IMPORT_C TInt | DoReadL(TDes8 &, TInt, TRequestStatus &) |
IMPORT_C TStreamTransfer | DoReadL(MStreamInput &, TStreamTransfer) |
IMPORT_C void | DoRelease() |
IMPORT_C TStreamPos | DoSeekL(TMark, TStreamLocation, TInt) |
IMPORT_C void | DoSynchL() |
IMPORT_C void | DoWriteL(const TAny *, TInt) |
IMPORT_C TInt | DoWriteL(const TDesC8 &, TInt, TRequestStatus &) |
IMPORT_C TStreamTransfer | DoWriteL(MStreamOutput &, TStreamTransfer) |
MStreamBuf & | operator=(const MStreamBuf &) |
Public Member Enumerations | |
---|---|
enum | TRead { ERead = 0x01 } |
enum | TWrite { EWrite = 0x02 } |
Public Member Type Definitions | |
---|---|
typedef | TInt TMark |
IMPORT_C TInt | DoReadL | ( | TDes8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) | [private, virtual] |
TDes8 & aDes | |
TInt aMaxLength | |
TRequestStatus & aStatus |
IMPORT_C TStreamTransfer | DoReadL | ( | MStreamInput & | anInput, |
TStreamTransfer | aTransfer | |||
) | [private, virtual] |
MStreamInput & anInput | |
TStreamTransfer aTransfer |
IMPORT_C TStreamPos | DoSeekL | ( | TMark | aMark, |
TStreamLocation | aLocation, | |||
TInt | anOffset | |||
) | [private, virtual] |
TMark aMark | |
TStreamLocation aLocation | |
TInt anOffset |
IMPORT_C void | DoWriteL | ( | const TAny * | aPtr, |
TInt | aLength | |||
) | [private, virtual] |
IMPORT_C TInt | DoWriteL | ( | const TDesC8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) | [private, virtual] |
const TDesC8 & aDes | |
TInt aMaxLength | |
TRequestStatus & aStatus |
IMPORT_C TStreamTransfer | DoWriteL | ( | MStreamOutput & | anOutput, |
TStreamTransfer | aTransfer | |||
) | [private, virtual] |
MStreamOutput & anOutput | |
TStreamTransfer aTransfer |
IMPORT_C TInt | Read | ( | TDes8 & | aDes, |
TRequestStatus & | aStatus | |||
) |
TDes8 & aDes | |
TRequestStatus & aStatus |
IMPORT_C TInt | Read | ( | TDes8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) |
TDes8 & aDes | |
TInt aMaxLength | |
TRequestStatus & aStatus |
TInt | ReadL | ( | TAny * | aPtr, |
TInt | aMaxLength | |||
) | [inline] |
Reads data from the stream buffer into the specified memory location.
The function calls the virtual function DoReadL(TAny*,TInt) to implement this behaviour.
The number of bytes read.
IMPORT_C TInt | ReadL | ( | TDes8 & | aDes, |
TRequestStatus & | aStatus | |||
) |
TDes8 & aDes | |
TRequestStatus & aStatus |
TInt | ReadL | ( | TDes8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) | [inline] |
Reads data, asynchronously, from the stream buffer into the specified descriptor.
The function calls the virtual function DoReadL(TDes8&,TInt,TRequestStatus&) to implement this behaviour.
If the function leaves, then no read request will have been initiated.
The maximum number of bytes to be read, as used in this request. This can be different to the value supplied in aMaxLength; this is dependent on the implementation.
TDes8 & aDes | The target descriptor for the data read from the stream buffer. |
TInt aMaxLength | The maximum number of bytes to be read. |
TRequestStatus & aStatus | The request status that indicates the completion status of this asynchronous request. |
TStreamTransfer | ReadL | ( | MStreamInput & | anInput, |
TStreamTransfer | aTransfer | |||
) | [inline] |
Reads data from the stream buffer into the specified data sink.
The function calls the virtual function DoReadL(MStreamInput&,TStreamTransfer) to implement this behaviour.
The amount of data that was not consumed.
MStreamInput & anInput | The data sink that is the target for the read operation. |
TStreamTransfer aTransfer | Defines the amount of data available to be read. |
IMPORT_C TInt | ReadL | ( | MStreamInput & | anInput, |
TInt | aMaxLength | |||
) |
MStreamInput & anInput | |
TInt aMaxLength |
void | ReadL | ( | MStreamInput & | anInput | ) | [inline] |
Reads data from the stream buffer into the specified data sink.
The function uses the virtual function DoReadL(MStreamInput&,TStreamTransfer) to implement this behaviour.
No explicit limit is placed on the amount of data that can be read.
MStreamInput & anInput | The data sink that is the target for the read operation. |
void | Release | ( | ) | [inline] |
Frees resources before abandoning the stream buffer.
The function calls the virtual function DoRelease() to implement this behaviour.
Release() is called by both RReadStream::Release() and RWriteStream::Release().
void | SeekL | ( | TMark | aMark, |
TStreamPos | aPos | |||
) | [inline] |
Moves the position of the read or write mark in the stream.
The new position is calculated by adding the specified value to the position of the beginning of the stream.
The function calls virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour. Notes: As there are two current positions, one for the read mark and one for the write mark, it is not valid, in general, to use a single call to SeekL() to move both the read and write marks. Not all streams are seekable.
TMark aMark | The type of mark, i.e. read or write. |
TStreamPos aPos |
TStreamPos | SeekL | ( | TMark | aMark, |
TStreamLocation | aLocation, | |||
TInt | anOffset = 0 | |||
) | [inline] |
Moves the position of the read mark or the write mark in the stream.
The new position is calculated by adding the specified offset to one of:
the position of the beginning of the stream
the position of the end of the stream
the position of the current read mark or write mark.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
As there are two current positions, one for the read mark and one for the write mark, it is not valid, in general, to use a single call to SeekL() to move both the read and write marks.
Not all streams are seekable.
The new stream position of the read or write mark.
TMark aMark | The type of mark, i.e read or write. |
TStreamLocation aLocation | The location in the stream on which the calculation of the new position is based. |
TInt anOffset = 0 | The offset value. |
TStreamPos | SeekL | ( | TRead | , |
TStreamLocation | aLocation, | |||
TInt | anOffset = 0 | |||
) | [inline] |
Moves the position of the read mark in the stream.
The new position is calculated by adding the specified offset to one of:
the position of the beginning of the stream
the position of the end of the stream
the position of the current read mark.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
Not all streams are seekable.
The new stream position of the read mark.
TRead | |
TStreamLocation aLocation | The location in the stream on which the calculation of the new position is based. |
TInt anOffset = 0 | The offset value. |
TStreamPos | SeekL | ( | TWrite | , |
TStreamLocation | aLocation, | |||
TInt | anOffset = 0 | |||
) | [inline] |
Moves the position of the write mark in the stream.
The new position is calculated by adding the specified offset to one of:
the position of the beginning of the stream
the position of the end of the stream
the position of the current write mark.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
Not all streams are seekable.
The new stream position of the write mark.
TWrite | |
TStreamLocation aLocation | The location in the stream on which the calculation of the new position is based. |
TInt anOffset = 0 | The offset value. |
TStreamPos | SeekL | ( | TRead | , |
TInt | anOffset | |||
) | [inline] |
Moves the position of the read mark in the stream by the specified offset.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
Not all streams are seekable.
The new stream position of the read mark.
TStreamPos | SeekL | ( | TWrite | , |
TInt | anOffset | |||
) | [inline] |
Moves the position of the write mark in the stream by the specified offset.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
Not all streams are seekable.
The new stream position of the write mark.
void | SynchL | ( | ) | [inline] |
Synchronises the stream buffer with the stream, leaving if any error occurs.
In effect, this ensures that buffered data is delivered to the stream.
The function calls the virtual function DoSynchL() to implement this behaviour.
TStreamPos | TellL | ( | TRead | ) | const [inline] |
Gets the position of the read mark within the stream.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
The stream position.
TRead |
TStreamPos | TellL | ( | TWrite | ) | const [inline] |
Gets the position of the write mark within the stream.
The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
The stream position.
TWrite |
IMPORT_C TInt | Write | ( | const TDesC8 & | aDes, |
TRequestStatus & | aStatus | |||
) |
const TDesC8 & aDes | |
TRequestStatus & aStatus |
IMPORT_C TInt | Write | ( | const TDesC8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) |
const TDesC8 & aDes | |
TInt aMaxLength | |
TRequestStatus & aStatus |
void | WriteL | ( | const TAny * | aPtr, |
TInt | aLength | |||
) | [inline] |
Writes data from the specified memory location into the stream buffer.
The function calls the virtual function DoWriteL(TAny*,TInt) to implement this behaviour.
IMPORT_C TInt | WriteL | ( | const TDesC8 & | aDes, |
TRequestStatus & | aStatus | |||
) |
const TDesC8 & aDes | |
TRequestStatus & aStatus |
TInt | WriteL | ( | const TDesC8 & | aDes, |
TInt | aMaxLength, | |||
TRequestStatus & | aStatus | |||
) | [inline] |
Writes data, asynchronously, from the specified descriptor into the stream buffer.
The function calls the virtual function DoWriteL(const TDesC8&,TInt,TRequestStatus&) to implement this behaviour.
If the function leaves, then no write request will have been initiated.
The maximum number of bytes to be written, as used in this request. This can be different to the value supplied in aMaxLength; this is dependent on the implementation.
const TDesC8 & aDes | The source descriptor for the data to be written into the stream buffer. |
TInt aMaxLength | The maximum number of bytes to be written. |
TRequestStatus & aStatus | The request status that indicates the completion status of this asynchronous request. |
TStreamTransfer | WriteL | ( | MStreamOutput & | anOutput, |
TStreamTransfer | aTransfer | |||
) | [inline] |
Writes data into the stream buffer from the specified data source.
The function calls the virtual function DoWriteL(MStreamOutput&,TStreamTransfer) to implement this behaviour.
A stream transfer object defining the amount of data that was not consumed.
MStreamOutput & anOutput | The data source for the write operation. |
TStreamTransfer aTransfer | Defines the amount of data to be pulled from the output stream object. |
IMPORT_C TInt | WriteL | ( | MStreamOutput & | anOutput, |
TInt | aMaxLength | |||
) |
MStreamOutput & anOutput | |
TInt aMaxLength |
void | WriteL | ( | MStreamOutput & | anOutput | ) | [inline] |
Writes data into the stream buffer from the specified data source.
The function calls the virtual function DoWriteL(MStreamOutput&,TStreamTransfer) to implement this behaviour.
No explicit limit is placed on the amount of data that can be written.
MStreamOutput & anOutput | The data source for the write operation. |
MStreamBuf & | operator= | ( | const MStreamBuf & | ) | [private] |
const MStreamBuf & |
Indicates that an operation applies to the read mark in a stream or to the read area in an stream buffer.
ERead = 0x01 |
Indicates that an operation applies to the write mark in a stream or to the write area in an stream buffer.
EWrite = 0x02 |
typedef TInt | TMark |
Used to identify the type of mark in a stream.
The type is used by functions of this class and derived classes that perform seek operations to marks within a stream.
The type uses the ERead and EWrite enumeration values, as bit flags, to identify the read and write marks respectively.
ERead is an MStreamBuf::TRead enumerator. EWrite is an MStreamBuf::EWrite enumerator.