sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: // Class TStreamPos
sl@0: inline TStreamPos::TStreamPos(TInt anOffset)
sl@0: 	: iOff(anOffset)
sl@0: /** Constructs the stream position object from the specified value.
sl@0: 
sl@0: @param anOffset The position value. */
sl@0: 	{}
sl@0: inline TBool TStreamPos::operator==(TStreamPos aPos) const
sl@0: /** Tests whether the stream position is equal to the specified stream position.
sl@0: 
sl@0: @param aPos The stream position to be compared.
sl@0: @return True, if this object's stream position value is equal to the specified 
sl@0: stream position's value; false, otherwise. */
sl@0: 	{return iOff==aPos.iOff;}
sl@0: inline TBool TStreamPos::operator!=(TStreamPos aPos) const
sl@0: /** Tests whether the stream position is not equal to the specified stream position.
sl@0: 
sl@0: @param aPos The stream position to be compared.
sl@0: @return True, if this object's stream position value is not equal to the specified 
sl@0: stream position's value; false, otherwise. */
sl@0: 	{return iOff!=aPos.iOff;}
sl@0: inline TBool TStreamPos::operator<(TStreamPos aPos) const
sl@0: /** Tests whether the stream position is less than the specified stream position.
sl@0: 
sl@0: @param aPos The stream position to be compared.
sl@0: @return True, if this object's stream position value is less than the specified 
sl@0: stream position's value; false, otherwise. */
sl@0: 	{return iOff<aPos.iOff;}
sl@0: inline TBool TStreamPos::operator<=(TStreamPos aPos) const
sl@0: /** Tests whether the stream position is less than or equal to the specified stream 
sl@0: position.
sl@0: 
sl@0: @param aPos The stream position to be compared.
sl@0: @return True, if this object's stream position value is less than or equal 
sl@0: to the specified stream position's value; false, otherwise. */
sl@0: 	{return iOff<=aPos.iOff;}
sl@0: inline TBool TStreamPos::operator>(TStreamPos aPos) const
sl@0: /** Tests whether the stream position is greater than the specified stream position.
sl@0: 
sl@0: @param aPos The stream position to be compared.
sl@0: @return True, if this object's stream position value is greater than the specified 
sl@0: stream position's value; false, otherwise. */
sl@0: 	{return iOff>aPos.iOff;}
sl@0: inline TBool TStreamPos::operator>=(TStreamPos aPos) const
sl@0: /** Tests whether the stream position is greater than or equal to the specified 
sl@0: stream position.
sl@0: 
sl@0: @param aPos The stream position to be compared.
sl@0: @return True, if this object's stream position value is greater than or equal 
sl@0: to the specified stream position's value; false, otherwise. */
sl@0: 	{return iOff>=aPos.iOff;}
sl@0: inline TInt TStreamPos::operator-(TStreamPos aPos) const
sl@0: /** Gets the result of subtracting the specified stream position value from this 
sl@0: object's stream position value.
sl@0: 
sl@0: @param aPos The stream position whose value is to be subtracted.
sl@0: @return The result of the calculation. */
sl@0: 	{return iOff-aPos.iOff;}
sl@0: inline TStreamPos TStreamPos::operator+(TInt anOffset) const
sl@0: /** Gets a stream position object that holds the result of adding the specified 
sl@0: value to this object's stream position value.
sl@0: 
sl@0: @param anOffset The value to be added.
sl@0: @return The stream position object holding the result of the calculation. */
sl@0: 	{return TStreamPos(iOff+anOffset);}
sl@0: inline TStreamPos TStreamPos::operator-(TInt anOffset) const
sl@0: /** Gets a stream position object that holds the result of subtracting the specified 
sl@0: value from this object's stream position value.
sl@0: 
sl@0: @param anOffset The value to be subtracted.
sl@0: @return The stream position object holding the result of the calculation. */
sl@0: 	{return TStreamPos(iOff-anOffset);}
sl@0: inline TStreamPos& TStreamPos::operator+=(TInt anOffset)
sl@0: /** Adds the specified value to this stream position object.
sl@0: 
sl@0: @param anOffset The value to be added.
sl@0: @return A reference to this stream position object. */
sl@0: 	{iOff+=anOffset;return *this;}
sl@0: inline TStreamPos& TStreamPos::operator-=(TInt anOffset)
sl@0: /** Subtracts the specified value from this stream position object.
sl@0: 
sl@0: @param anOffset The value to be subtracted.
sl@0: @return A reference to this stream position object. */
sl@0: 	{iOff-=anOffset;return *this;}
sl@0: inline TInt TStreamPos::Offset() const
sl@0: /** Gets the stream position value.
sl@0: 
sl@0: @return The stream position value. */
sl@0: 	{return iOff;}
sl@0: inline TStreamPos operator+(TInt anOffset,TStreamPos aPos)
sl@0: 	{return aPos+anOffset;}
sl@0: 
sl@0: // Class TStreamTransfer
sl@0: inline TStreamTransfer::TStreamTransfer(TInt aMaxLength)
sl@0: 	: iVal(aMaxLength)
sl@0: /** Constructs a stream transfer object specifying a length value.
sl@0: 
sl@0: This value represents the maximum amount of data that can be transferred between 
sl@0: streams.
sl@0: 
sl@0: @param aMaxLength The maximum length of data that can be transferred. In debug 
sl@0: mode, the function raises a STORE-Stream 13 panic, if this value is negative. */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkNonNegative(aMaxLength);
sl@0: #endif
sl@0: 	}
sl@0: inline TStreamTransfer::TStreamTransfer(TUnlimited)
sl@0: 	: iVal(-1)
sl@0: /** Constructs a stream transfer object specifying that there is no explicit limit 
sl@0: to the amount of data that can be transferred between streams.
sl@0: 
sl@0: The amount of data to be transferred is only limited by the streams themselves.
sl@0: 
sl@0: The arithmetical operators do not change the state of an unlimited stream 
sl@0: transfer object.
sl@0: 
sl@0: @param (The enumerator value is not used). */
sl@0: 	{}
sl@0: inline TBool TStreamTransfer::operator==(TInt aLength) const
sl@0: /** Tests whether the stream transfer value is equal to the specified value.
sl@0: 
sl@0: @param aLength The length to compared. In debug mode, the function raises 
sl@0: a STORE-Stream 13 panic, if this value is negative.
sl@0: @return True, if the stream transfer value is equal to the specified value; 
sl@0: false, otherwise. */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkNonNegative(aLength);
sl@0: #endif
sl@0: 	return iVal==aLength;
sl@0: 	}
sl@0: inline TBool TStreamTransfer::operator>(TInt aLength) const
sl@0: /** Tests whether the stream transfer value is greater than the specified value.
sl@0: 
sl@0: @param aLength The length to compared. In debug mode, the function raises 
sl@0: a STORE-Stream 13 panic, if this value is negative.
sl@0: @return True, if the stream transfer value is greater than the specified value; 
sl@0: false, otherwise. */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkNonNegative(aLength);
sl@0: #endif
sl@0: 	return TUint(iVal)>TUint(aLength);
sl@0: 	}
sl@0: inline TStreamTransfer TStreamTransfer::operator-(TInt aLength) const
sl@0: /** Subtracts the specified value from the stream transfer value.
sl@0: 
sl@0: If this stream transfer object was originally constructed as an unlimited 
sl@0: type, i.e. using the TStreamTransfer(TUnlimited) constructor, then this operator 
sl@0: does not change the state of the object, and it remains an unlimited type.
sl@0: 
sl@0: @param aLength The length to be subtracted. In debug mode, the function raises 
sl@0: a STORE-Stream 13 panic, if this value is negative.
sl@0: @return A stream transfer object containing the result of the subtraction. */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkNonNegative(aLength);
sl@0: #endif
sl@0: 	return iVal<0?*this:TStreamTransfer(iVal-aLength);
sl@0: 	}
sl@0: inline TInt TStreamTransfer::operator[](TInt aMaxLength) const
sl@0: 	{return *this>aMaxLength?aMaxLength:iVal;}
sl@0: inline TStreamTransfer& TStreamTransfer::operator-=(TInt aLength)
sl@0: /** Subtracts the specified value from the stream transfer value, updating this 
sl@0: stream transfer object.
sl@0: 
sl@0: If this stream transfer object was originally constructed as an unlimited 
sl@0: type, i.e. using the TStreamTransfer(TUnlimited) constructor, then this operator 
sl@0: does not change the state of the object, and it remains an unlimited type.
sl@0: 
sl@0: If this stream transfer object was not an unlimited type, then, in debug mode, 
sl@0: the function raises a STORE-Stream 13 panic, if the result of the calculation 
sl@0: is negative.
sl@0: 
sl@0: @param aLength The length to be subtracted. In debug mode, the function raises 
sl@0: a STORE-Stream 13 panic, if this value is negative.
sl@0: @return A reference to this stream transfer object. */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkNonNegative(aLength);
sl@0: #endif
sl@0: 	if (iVal>=0)
sl@0: 		{
sl@0: 		iVal-=aLength;
sl@0: #if defined (_DEBUG)
sl@0: 		__DbgChkNonNegative(iVal);
sl@0: #endif
sl@0: 		}
sl@0: 	return *this;
sl@0: 	}
sl@0: inline TInt TStreamTransfer::Left() const
sl@0: /** Gets the stream transfer value.
sl@0: 
sl@0: @return The current stream transfer value. */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkNonNegative(iVal);
sl@0: #endif
sl@0: 	return iVal;
sl@0: 	}
sl@0: inline TBool operator==(TInt aLength,TStreamTransfer aTransfer)
sl@0: 	{return aTransfer==aLength;}
sl@0: inline TBool operator<(TInt aLength,TStreamTransfer aTransfer)
sl@0: 	{return aTransfer>aLength;}
sl@0: 
sl@0: // Class MStreamBuf
sl@0: inline void MStreamBuf::Release()
sl@0: /** Frees resources before abandoning the stream buffer.
sl@0: 
sl@0: The function calls the virtual function DoRelease() to implement this behaviour.
sl@0: 
sl@0: Release() is called by both RReadStream::Release() and RWriteStream::Release().
sl@0: 
sl@0: @see MStreamBuf::DoRelease()
sl@0: @see RReadStream::Release()
sl@0: @see RWriteStream::Release() */
sl@0: 	{DoRelease();}
sl@0: inline void MStreamBuf::SynchL()
sl@0: /** Synchronises the stream buffer with the stream, leaving if any error occurs.
sl@0: 
sl@0: In effect, this ensures that buffered data is delivered to the stream.
sl@0: 
sl@0: The function calls the virtual function DoSynchL() to implement this behaviour.
sl@0: 
sl@0: @see MStreamBuf::DoSynchL() */
sl@0: 	{DoSynchL();}
sl@0: inline TInt MStreamBuf::ReadL(TAny* aPtr,TInt aMaxLength)
sl@0: /** Reads data from the stream buffer into the specified memory location.
sl@0: 
sl@0: The function calls the virtual function DoReadL(TAny*,TInt) to implement this 
sl@0: behaviour.
sl@0: 
sl@0: @param aPtr A pointer to the target memory location for the data read from 
sl@0: the stream buffer.
sl@0: @param aMaxLength The maximum number of bytes to be read.
sl@0: @return The number of bytes read.
sl@0: @see MStreamBuf::DoReadL() */
sl@0: 	{return DoReadL(aPtr,aMaxLength);}
sl@0: inline TInt MStreamBuf::ReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
sl@0: /** Reads data, asynchronously, from the stream buffer into the specified descriptor.
sl@0: 
sl@0: The function calls the virtual function DoReadL(TDes8&,TInt,TRequestStatus&) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: If the function leaves, then no read request will have been initiated.
sl@0: 
sl@0: @param aDes The target descriptor for the data read from the stream buffer.
sl@0: @param aMaxLength The maximum number of bytes to be read.
sl@0: @param aStatus The request status that indicates the completion status of this 
sl@0: asynchronous request.
sl@0: @return The maximum number of bytes to be read, as used in this request. This 
sl@0: can be different to the value supplied in aMaxLength; this is dependent on 
sl@0: the implementation.
sl@0: @see MStreamBuf::DoReadL() */
sl@0: 	{return DoReadL(aDes,aMaxLength,aStatus);}
sl@0: inline TStreamTransfer MStreamBuf::ReadL(MStreamInput& anInput,TStreamTransfer aTransfer)
sl@0: /** Reads data from the stream buffer into the specified data sink.
sl@0: 
sl@0: The function calls the virtual function DoReadL(MStreamInput&,TStreamTransfer) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: @param anInput The data sink that is the target for the read operation.
sl@0: @param aTransfer Defines the amount of data available to be read.
sl@0: @return The amount of data that was not consumed. */
sl@0: 	{return DoReadL(anInput,aTransfer);}
sl@0: inline void MStreamBuf::ReadL(MStreamInput& anInput)
sl@0: /** Reads data from the stream buffer into the specified data sink.
sl@0: 
sl@0: The function uses the virtual function DoReadL(MStreamInput&,TStreamTransfer) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: No explicit limit is placed on the amount of data that can be read.
sl@0: 
sl@0: @param anInput The data sink that is the target for the read operation. */
sl@0: 	{DoReadL(anInput,KStreamUnlimited);}
sl@0: inline void MStreamBuf::WriteL(const TAny* aPtr,TInt aLength)
sl@0: /** Writes data from the specified memory location into the stream buffer.
sl@0: 
sl@0: The function calls the virtual function DoWriteL(TAny*,TInt) to implement 
sl@0: this behaviour.
sl@0: 
sl@0: @param aPtr A pointer to the memory location from which data is to be written 
sl@0: to the stream buffer.
sl@0: @param aLength The number of bytes to be written.
sl@0: @see MStreamBuf::DoWriteL() */
sl@0: 	{DoWriteL(aPtr,aLength);}
sl@0: inline TInt MStreamBuf::WriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
sl@0: /** Writes data, asynchronously, from the specified descriptor into the stream buffer.
sl@0: 
sl@0: The function calls the virtual function DoWriteL(const TDesC8&,TInt,TRequestStatus&) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: If the function leaves, then no write request will have been initiated.
sl@0: 
sl@0: @param aDes The source descriptor for the data to be written into the stream 
sl@0: buffer.
sl@0: @param aMaxLength The maximum number of bytes to be written.
sl@0: @param aStatus The request status that indicates the completion status of this 
sl@0: asynchronous request.
sl@0: @return The maximum number of bytes to be written, as used in this request. 
sl@0: This can be different to the value supplied in aMaxLength; this is dependent 
sl@0: on the implementation.
sl@0: @see MStreamBuf::DoWriteL() */
sl@0: 	{return DoWriteL(aDes,aMaxLength,aStatus);}
sl@0: inline TStreamTransfer MStreamBuf::WriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer)
sl@0: /** Writes data into the stream buffer from the specified data source.
sl@0: 
sl@0: The function calls the virtual function DoWriteL(MStreamOutput&,TStreamTransfer) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: @param anOutput The data source for the write operation.
sl@0: @param aTransfer Defines the amount of data to be pulled from the output stream 
sl@0: object.
sl@0: @return A stream transfer object defining the amount of data that was not consumed. */
sl@0: 	{return DoWriteL(anOutput,aTransfer);}
sl@0: inline void MStreamBuf::WriteL(MStreamOutput& anOutput)
sl@0: /**Writes data into the stream buffer from the specified data source.
sl@0: 
sl@0: The function calls the virtual function DoWriteL(MStreamOutput&,TStreamTransfer) to implement this behaviour.
sl@0: 
sl@0: No explicit limit is placed on the amount of data that can be written.
sl@0: 
sl@0: @param anOutput The data source for the write operation.
sl@0: @param aMaxLength The maximum amount of data available to be written.
sl@0: */
sl@0: 	{DoWriteL(anOutput,KStreamUnlimited);}
sl@0: inline void MStreamBuf::SeekL(TMark aMark,TStreamPos aPos)
sl@0: /**Moves the position of the read or write mark in the stream.
sl@0: 
sl@0: The new position is calculated by adding the specified value to the position of the beginning of the stream.
sl@0: 
sl@0: The function calls virtual function DoSeekL(TMark,TStreamLocation,TInt) to implement this behaviour.
sl@0: Notes:
sl@0: 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. 
sl@0: Not all streams are seekable. 
sl@0: 
sl@0: @param aMark The type of mark, i.e. read or write.
sl@0: @param aLocation A stream position value on which the calculation of the new position is based.
sl@0: */
sl@0: 	{DoSeekL(aMark,EStreamBeginning,aPos.Offset());}
sl@0: inline TStreamPos MStreamBuf::SeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset)
sl@0: /** Moves the position of the read mark or the write mark in the stream.
sl@0: 
sl@0: The new position is calculated by adding the specified offset to one of:
sl@0: 
sl@0: the position of the beginning of the stream
sl@0: 
sl@0: the position of the end of the stream
sl@0: 
sl@0: the position of the current read mark or write mark.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: As there are two current positions, one for the read mark and one for the 
sl@0: write mark, it is not valid, in general, to use a single call to SeekL() to 
sl@0: move both the read and write marks.
sl@0: 
sl@0: Not all streams are seekable.
sl@0: 
sl@0: @param aMark The type of mark, i.e read or write.
sl@0: @param aLocation The location in the stream on which the calculation of the 
sl@0: new position is based.
sl@0: @param anOffset The offset value.
sl@0: @return The new stream position of the read or write mark. */
sl@0: 	{return DoSeekL(aMark,aLocation,anOffset);}
sl@0: inline TStreamPos MStreamBuf::SeekL(TRead,TStreamLocation aLocation,TInt anOffset)
sl@0: /** Moves the position of the read mark in the stream.
sl@0: 
sl@0: The new position is calculated by adding the specified offset to one of:
sl@0: 
sl@0: the position of the beginning of the stream
sl@0: 
sl@0: the position of the end of the stream
sl@0: 
sl@0: the position of the current read mark.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: Not all streams are seekable.
sl@0: 
sl@0: @param (The enumerator value is not used)
sl@0: @param aLocation The location in the stream on which the calculation of the 
sl@0: new position is based.
sl@0: @param anOffset The offset value.
sl@0: @return The new stream position of the read mark. */
sl@0: 	{return DoSeekL(ERead,aLocation,anOffset);}
sl@0: inline TStreamPos MStreamBuf::SeekL(TWrite,TStreamLocation aLocation,TInt anOffset)
sl@0: /** Moves the position of the write mark in the stream.
sl@0: 
sl@0: The new position is calculated by adding the specified offset to one of:
sl@0: 
sl@0: the position of the beginning of the stream
sl@0: 
sl@0: the position of the end of the stream
sl@0: 
sl@0: the position of the current write mark.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: Not all streams are seekable.
sl@0: 
sl@0: @param (The enumerator value is not used)
sl@0: @param aLocation The location in the stream on which the calculation of the 
sl@0: new position is based.
sl@0: @param anOffset The offset value.
sl@0: @return The new stream position of the write mark. */
sl@0: 	{return DoSeekL(EWrite,aLocation,anOffset);}
sl@0: inline TStreamPos MStreamBuf::SeekL(TRead,TInt anOffset)
sl@0: /** Moves the position of the read mark in the stream by the specified offset.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: Not all streams are seekable.
sl@0: 
sl@0: @param (The enumerator value is not used)
sl@0: @param anOffset The amount by which the position of the read mark is to be 
sl@0: moved relative to the existing position of the read mark.
sl@0: @return The new stream position of the read mark. */
sl@0: 	{return DoSeekL(ERead,EStreamMark,anOffset);}
sl@0: inline TStreamPos MStreamBuf::SeekL(TWrite,TInt anOffset)
sl@0: /** Moves the position of the write mark in the stream by the specified offset.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: Not all streams are seekable.
sl@0: 
sl@0: @param (The enumerator value is not used)
sl@0: @param anOffset The amount by which the position of the write mark is to be 
sl@0: moved relative to the existing position of the write mark.
sl@0: @return The new stream position of the write mark. */
sl@0: 	{return DoSeekL(EWrite,EStreamMark,anOffset);}
sl@0: inline TStreamPos MStreamBuf::TellL(TRead) const
sl@0: /** Gets the position of the read mark within the stream.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: @param (The enumerator value is not used).
sl@0: @return The stream position. */
sl@0: 	{return CONST_CAST(MStreamBuf*,this)->DoSeekL(ERead,EStreamMark,0);}
sl@0: inline TStreamPos MStreamBuf::TellL(TWrite) const
sl@0: /** Gets the position of the write mark within the stream.
sl@0: 
sl@0: The function calls the virtual function DoSeekL(TMark,TStreamLocation,TInt) 
sl@0: to implement this behaviour.
sl@0: 
sl@0: @param (The enumerator value is not used).
sl@0: @return The stream position. */
sl@0: 	{return CONST_CAST(MStreamBuf*,this)->DoSeekL(EWrite,EStreamMark,0);}
sl@0: inline TInt MStreamBuf::SizeL() const
sl@0: /** Gets the size of the stream.
sl@0: 
sl@0: @return The size of the stream, in bytes. */
sl@0: 	{return CONST_CAST(MStreamBuf*,this)->DoSeekL(0,EStreamEnd,0).Offset();}
sl@0: 
sl@0: // Class TStreamBuf
sl@0: inline void TStreamBuf::SetBuf(TRead,TUint8* aPtr,TUint8* anEnd)
sl@0: /** Sets the start and end points of the read area within the intermediate buffer.
sl@0: 
sl@0: A start point is always within an area; an end point is always the first byte 
sl@0: beyond the end of an area.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @param aPtr The start point.
sl@0: @param anEnd The end point.
sl@0: @see MStreamBuf::TRead */
sl@0: 	{iRPtr=aPtr;iREnd=anEnd;}
sl@0: inline void TStreamBuf::SetBuf(TWrite,TUint8* aPtr,TUint8* anEnd)
sl@0: /** Sets the start and end points of the write area within the intermediate buffer.
sl@0: 
sl@0: A start point is always within an area; an end point is always the first byte 
sl@0: beyond the end of an area.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @param aPtr The start point.
sl@0: @param anEnd The end point.
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{iWPtr=aPtr;iWEnd=anEnd;}
sl@0: inline void TStreamBuf::SetPtr(TRead,TUint8* aPtr)
sl@0: /** Sets the start point of the write area within the intermediate buffer.
sl@0: 
sl@0: A start point is always within an area.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @param aPtr The start point.
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{iRPtr=aPtr;}
sl@0: inline void TStreamBuf::SetPtr(TWrite,TUint8* aPtr)
sl@0: /** Sets the start point of the write area within the intermediate buffer.
sl@0: 
sl@0: A start point is always within an area.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @param aPtr The start point.
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{iWPtr=aPtr;}
sl@0: inline void TStreamBuf::SetEnd(TRead,TUint8* anEnd)
sl@0: 	{iREnd=anEnd;}
sl@0: inline void TStreamBuf::SetEnd(TWrite,TUint8* anEnd)
sl@0: 	{iWEnd=anEnd;}
sl@0: inline TUint8* TStreamBuf::Ptr(TRead) const
sl@0: /** Gets the current start point of the read area within the intermediate buffer.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @return The start point.
sl@0: @see MStreamBuf::TRead */
sl@0: 	{return iRPtr;}
sl@0: inline TUint8* TStreamBuf::Ptr(TWrite) const
sl@0: /** Gets the current start point of the write area within the intermediate buffer.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @return The start point.
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{return iWPtr;}
sl@0: inline TUint8* TStreamBuf::End(TRead) const
sl@0: /** Gets the current end point of the read area within the intermediate buffer.
sl@0: 
sl@0: An end point is always the first byte beyond the end of an area.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @return The end point.
sl@0: @see MStreamBuf::TRead */
sl@0: 	{return iREnd;}
sl@0: inline TUint8* TStreamBuf::End(TWrite) const
sl@0: /** Gets the current end point of the write area within the intermediate buffer.
sl@0: 
sl@0: An end point is always the first byte beyond the end of an area.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @return The end point.
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{return iWEnd;}
sl@0: inline TInt TStreamBuf::Avail(TRead) const
sl@0: /** Gets the number of bytes available in the read area within the intermediate 
sl@0: buffer.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @return The number of bytes available.
sl@0: @see MStreamBuf::TRead */
sl@0: 	{return iREnd-iRPtr;}
sl@0: inline TInt TStreamBuf::Avail(TWrite) const
sl@0: /** Gets the number of bytes available in the write area within the intermediate 
sl@0: buffer.
sl@0: 
sl@0: @param (The enumerator is not used).
sl@0: @return The number of bytes available.
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{return iWEnd-iWPtr;}
sl@0: 
sl@0: // Class TStreamFilter
sl@0: inline void TStreamFilter::Set(MStreamBuf* aHost,TInt aMode)
sl@0: /** Sets up the filter to use the specified host for streamed data.
sl@0: 
sl@0: Taking ownership of the host stream buffer means that calls to SynchL() propagate 
sl@0: to the host buffer after the filter has flushed its data, and that when the 
sl@0: filter is released it also releases the host buffer. 
sl@0: 
sl@0: @param aHost The host for the streamed data - a stream buffer.
sl@0: @param aMode The mode in which the stream buffer is to be used. It can be used 
sl@0: in either read or write modes, represented by ERead and EWrite, but not both 
sl@0: at the same time. In debug mode, setting both raises a STORE-Stream 18 panic. 
sl@0: In addition, specify EAttached to indicate that the filter should take ownership 
sl@0: of the host stream buffer.
sl@0: @see MStreamBuf::TRead
sl@0: @see MStreamBuf::TWrite */
sl@0: 	{
sl@0: #if defined (_DEBUG)
sl@0: 	__DbgChkMode(aMode);
sl@0: #endif
sl@0: 	iHost=aHost;iMode=aMode;
sl@0: 	}
sl@0: inline void TStreamFilter::Committed()
sl@0: /** Flags the streamed data as committed. */
sl@0: 	{iMode&=~EWrite;}
sl@0: inline TBool TStreamFilter::IsCommitted() const
sl@0: /** Tests whether the streamed data is committed.
sl@0: 
sl@0: @return True, if streamed data is committed; false, otherwise. */
sl@0: 	{return iHost==NULL||!(iMode&EWrite);}
sl@0: