os/persistentdata/persistentstorage/store/INC/S32SHARE.INL
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/store/INC/S32SHARE.INL	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,305 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +// Class TStreamMark
    1.20 +inline TStreamMark::TStreamMark()
    1.21 +	: iPos(KStreamBeginning-1)
    1.22 +/** Constructs a default shared stream mark object.
    1.23 +
    1.24 +The position for the mark is uninitialised.
    1.25 +
    1.26 +An uninitialised mark means that a call to IsEmpty() returns true.
    1.27 +
    1.28 +@see IsEmpty() */
    1.29 +	{}
    1.30 +inline TStreamMark::TStreamMark(TStreamPos aPos)
    1.31 +	: iPos(aPos)
    1.32 +/** Constructs the shared stream mark object, setting the mark to the specified 
    1.33 +stream position.
    1.34 +
    1.35 +An initialised mark means that a call to IsEmpty() returns false.
    1.36 +
    1.37 +@param aPos The stream position
    1.38 +@see IsEmpty() */
    1.39 +	{
    1.40 +#if defined (_DEBUG)
    1.41 +	__DbgChkPos(aPos);
    1.42 +#endif
    1.43 +	}
    1.44 +inline TStreamMark& TStreamMark::operator=(TStreamPos aPos)
    1.45 +/** Assigns the specified stream position value to this shared stream mark object.
    1.46 +
    1.47 +@param aPos The stream position value to be assigned.
    1.48 +@return A reference to this shared stream mark object. */
    1.49 +	{
    1.50 +#if defined (_DEBUG)
    1.51 +	__DbgChkPos(aPos);
    1.52 +#endif
    1.53 +	iPos=aPos;
    1.54 +	return *this;
    1.55 +	}
    1.56 +inline TStreamMark::operator TStreamMark*()
    1.57 +	{return this;}
    1.58 +inline TStreamMark::operator const TStreamMark*() const
    1.59 +	{return this;}
    1.60 +inline TBool TStreamMark::operator==(const TStreamMark& aMark) const
    1.61 +/** Tests whether this object and the specified referenced shared stream mark object 
    1.62 +are the same object.
    1.63 +
    1.64 +@param aMark A reference to a shared stream mark object.
    1.65 +@return True, if the two objects are the same object; false, otherwise. */
    1.66 +	{return this==&aMark;}
    1.67 +inline TBool TStreamMark::operator==(const TStreamMark* aPtr) const
    1.68 +	{return this==aPtr;}
    1.69 +inline TBool TStreamMark::operator!=(const TStreamMark& aMark) const
    1.70 +/** Tests whether this object and the specified shared stream mark object are different 
    1.71 +objects.
    1.72 +
    1.73 +@param aMark A pointer to a shared stream mark object.
    1.74 +@return True, if the two objects are different objects; false, otherwise. */
    1.75 +	{return this!=&aMark;}
    1.76 +inline TBool TStreamMark::operator!=(const TStreamMark* aPtr) const
    1.77 +	{return this!=aPtr;}
    1.78 +inline TBool TStreamMark::IsEmpty() const
    1.79 +/** Tests whether this mark object is uninitialised.
    1.80 +
    1.81 +@return True, if this mark object is uninitialised; false, otherwise. */
    1.82 +	{return iPos<KStreamBeginning;}
    1.83 +inline void TStreamMark::Clear()
    1.84 +/** Resets the mark object to its default state.
    1.85 +
    1.86 +On return from this function, the mark is uninitialised and a call to IsEmpty() 
    1.87 +returns true.
    1.88 +
    1.89 +Empties the object/makes it empty so that IsEmpty() returns false */
    1.90 +	{iPos=KStreamBeginning-1;}
    1.91 +inline TStreamPos TStreamMark::Position() const
    1.92 +/** Gets the position of the mark.
    1.93 +
    1.94 +@return The stream position. */
    1.95 +	{
    1.96 +#if defined (_DEBUG)
    1.97 +	__DbgChkPos(iPos);
    1.98 +#endif
    1.99 +	return iPos;
   1.100 +	}
   1.101 +inline TBool TStreamMark::IsWith(TStreamExchange& aHost) const
   1.102 +/** Tests whether the specified shared streaming manager currently refers to this 
   1.103 +mark object.
   1.104 +
   1.105 +@param aHost The object that manages shared streaming.
   1.106 +@return True, if the shared stream manager refers to this mark; false, otherwise. */
   1.107 +	{return aHost.RefersTo(*this);}
   1.108 +inline TBool TStreamMark::RelatesTo(TStreamExchange& aHost) const
   1.109 +/** Tests whether the specified shared streaming manager currently refers to this 
   1.110 +mark object OR whether this mark object is initialised.
   1.111 +
   1.112 +@param aHost The object that manages shared streaming.
   1.113 +@return True, if the shared stream manager refers to this mark OR if this mark 
   1.114 +object is initialised; false, otherwise.
   1.115 +@see IsWith()
   1.116 +@see TStreamExchange::IsActive() */
   1.117 +	{return iPos>=KStreamBeginning||aHost.RefersTo(*this);}
   1.118 +inline void TStreamMark::Withdraw(TStreamExchange& aHost)
   1.119 +/** Instructs the shared streaming manager to remove any reference it has to this 
   1.120 +mark object.
   1.121 +
   1.122 +@param aHost The object that manages shared streaming. */
   1.123 +	{aHost.Drop(*this);}
   1.124 +inline void TStreamMark::ExtractL(TStreamExchange& aHost)
   1.125 +/** Refreshes this mark from the mark in the host stream buffer and tells the shared 
   1.126 +streaming manager to drop any reference it has to to this mark object.
   1.127 +
   1.128 +@param aHost The object that manages shared streaming. */
   1.129 +	{aHost.GetL(*this);}
   1.130 +inline TInt TStreamMark::ReadL(TStreamExchange& aHost,TAny* aPtr,TInt aMaxLength)
   1.131 +/** Reads data from the shared stream into the specified memory location.
   1.132 +
   1.133 +@param aHost The object that manages shared streaming.
   1.134 +@param aPtr A pointer to the target memory location for the data read from 
   1.135 +the shared stream.
   1.136 +@param aMaxLength The maximum number of bytes to be read.
   1.137 +@return The number of bytes read. */
   1.138 +	{return aHost.DoReadL(aPtr,aMaxLength,*this);}
   1.139 +inline TInt TStreamMark::ReadL(TStreamExchange& aHost,TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
   1.140 +/** Reads data, asynchronously, from the shared stream into the specified descriptor.
   1.141 +
   1.142 +If the function leaves, then no read request will have been initiated.
   1.143 +
   1.144 +@param aHost The object that manages shared streaming.
   1.145 +@param aDes The target descriptor for the data read from the shared stream.
   1.146 +@param aMaxLength The maximum number of bytes to be read.
   1.147 +@param aStatus The request status that indicates the completion status of this 
   1.148 +asynchronous request.
   1.149 +@return The maximum number of bytes to be read, as used in this request. This 
   1.150 +can be different to the value supplied in aMaxLength; this is dependent on 
   1.151 +the implementation of the underlying stream. */
   1.152 +	{return aHost.DoReadL(aDes,aMaxLength,aStatus,*this);}
   1.153 +inline TStreamTransfer TStreamMark::ReadL(TStreamExchange& aHost,MStreamInput& anInput,TStreamTransfer aTransfer)
   1.154 +/** Reads data from the shared stream into the specified data sink.
   1.155 +
   1.156 +@param aHost The object that manages shared streaming.
   1.157 +@param anInput The sink which is the target for the read operation.
   1.158 +@param aTransfer Defines the amount of data available to be read from the shared 
   1.159 +stream.
   1.160 +@return The amount of data that was not consumed. */
   1.161 +	{return aHost.DoReadL(anInput,aTransfer,*this);}
   1.162 +inline TInt TStreamMark::ReadL(TStreamExchange& aHost,MStreamInput& anInput,TInt aMaxLength)
   1.163 +/** Reads data from the shared stream into the specified data sink.
   1.164 +
   1.165 +@param aHost The object that manages shared streaming.
   1.166 +@param anInput The sink which is the target for the read operation.
   1.167 +@param aMaxLength The maximum amount of data available to be read from the 
   1.168 +shared stream.
   1.169 +@return The amount of data that was not consumed. */
   1.170 +	{return aMaxLength-aHost.DoReadL(anInput,TStreamTransfer(aMaxLength),*this).Left();}
   1.171 +inline void TStreamMark::ReadL(TStreamExchange& aHost,MStreamInput& anInput)
   1.172 +/** Reads data from the shared stream into the specified data sink.
   1.173 +
   1.174 +No explicit limit is placed on the amount of data that can be read.
   1.175 +
   1.176 +@param aHost The object that manages shared streaming.
   1.177 +@param anInput The sink which is the target for the read operation. */
   1.178 +	{aHost.DoReadL(anInput,KStreamUnlimited,*this);}
   1.179 +inline void TStreamMark::WriteL(TStreamExchange& aHost,const TAny* aPtr,TInt aLength)
   1.180 +/** Writes data from the specified memory location into the shared stream.
   1.181 +
   1.182 +@param aHost The object that manages shared streaming.
   1.183 +@param aPtr A pointer to the memory location from which data is to be written 
   1.184 +to the shared stream.
   1.185 +@param aLength The number of bytes to be written. */
   1.186 +	{aHost.DoWriteL(aPtr,aLength,*this);}
   1.187 +inline TInt TStreamMark::WriteL(TStreamExchange& aHost,const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
   1.188 +/** Writes data, asynchronously, from the specified descriptor into the shared 
   1.189 +stream.
   1.190 +
   1.191 +If the function leaves, then no write request will have been initiated.
   1.192 +
   1.193 +@param aHost The object that manages shared streaming.
   1.194 +@param aDes The source descriptor for the data to be written into the shared 
   1.195 +stream.
   1.196 +@param aMaxLength The maximum number of bytes to be written.
   1.197 +@param aStatus The request status that indicates the completion status of this 
   1.198 +asynchronous request.
   1.199 +@return The maximum number of bytes to be written, as used in this request. 
   1.200 +This can be different to the value supplied in aMaxLength; this is dependent 
   1.201 +on the implementation. */
   1.202 +	{return aHost.DoWriteL(aDes,aMaxLength,aStatus,*this);}
   1.203 +inline TStreamTransfer TStreamMark::WriteL(TStreamExchange& aHost,MStreamOutput& anOutput,TStreamTransfer aTransfer)
   1.204 +/** Writes data into the shared stream from the specified data source.
   1.205 +
   1.206 +@param aHost The object that manages shared streaming.
   1.207 +@param anOutput The data source for the write operation.
   1.208 +@param aTransfer Defines the amount of data to be pulled from the output stream 
   1.209 +object.
   1.210 +@return A stream transfer object defining the amount of data that was not consumed. */
   1.211 +	{return aHost.DoWriteL(anOutput,aTransfer,*this);}
   1.212 +inline TInt TStreamMark::WriteL(TStreamExchange& aHost,MStreamOutput& anOutput,TInt aMaxLength)
   1.213 +/** Writes data into the shared stream from the specified data source
   1.214 +
   1.215 +@param aHost The object that manages shared streaming.
   1.216 +@param anOutput The data source for the write operation.
   1.217 +@param aMaxLength The maximum amount of data available to be written.
   1.218 +@return The amount of data that was not consumed. */
   1.219 +	{return aMaxLength-aHost.DoWriteL(anOutput,TStreamTransfer(aMaxLength),*this).Left();}
   1.220 +inline void TStreamMark::WriteL(TStreamExchange& aHost,MStreamOutput& anOutput)
   1.221 +/** Writes data into the shared stream from the specified data source.
   1.222 +
   1.223 +No explicit limit is placed on the amount of data that can be written.
   1.224 +
   1.225 +@param aHost The object that manages shared streaming.
   1.226 +@param anOutput The data source for the write operation. */
   1.227 +	{aHost.DoWriteL(anOutput,KStreamUnlimited,*this);}
   1.228 +inline void TStreamMark::SeekL(TStreamExchange& aHost,TStreamPos aPos)
   1.229 +	{aHost.DoSeekL(*this,EStreamBeginning,aPos.Offset());}
   1.230 +inline TStreamPos TStreamMark::SeekL(TStreamExchange& aHost,TStreamLocation aLocation,TInt anOffset)
   1.231 +/** Moves the position of the mark in the host stream.
   1.232 +
   1.233 +The new position is calculated by adding the specified offset to one of:
   1.234 +
   1.235 +the position of the beginning of the host stream
   1.236 +
   1.237 +the position of the end of the host stream
   1.238 +
   1.239 +the position of the current mark.
   1.240 +
   1.241 +@param aHost The object that manages shared streaming.
   1.242 +@param aLocation The location in the host stream on which the calculation of 
   1.243 +the new position is based.
   1.244 +@param anOffset The offset value.
   1.245 +@return The new position of the mark. */
   1.246 +	{return aHost.DoSeekL(*this,aLocation,anOffset);}
   1.247 +inline TStreamPos TStreamMark::SeekL(TStreamExchange& aHost,TInt anOffset)
   1.248 +/** Moves the position of the mark in the host stream.
   1.249 +
   1.250 +@param aHost The object that manages shared streaming.
   1.251 +@param anOffset The amount by which the position of the mark is to be moved 
   1.252 +relative to the existing position of the mark.
   1.253 +@return The new position of the mark. */
   1.254 +	{return aHost.DoSeekL(*this,EStreamMark,anOffset);}
   1.255 +inline TStreamPos TStreamMark::TellL(TStreamExchange& aHost) const
   1.256 +/** Gets the position of the mark within the host stream.
   1.257 +
   1.258 +@param aHost The object that manages shared streaming.
   1.259 +@return The stream position. */
   1.260 +	{return aHost.DoSeekL(CONST_CAST(TStreamMark&,*this),EStreamMark,0);}
   1.261 +
   1.262 +// Class TStreamExchange
   1.263 +inline TStreamExchange::TStreamExchange()
   1.264 +	: iHost(NULL),iRMrk(NULL),iWMrk(NULL)
   1.265 +/** Constructs an empty object.
   1.266 +
   1.267 +Call Share() to prepare for access to a shared stream buffer. */
   1.268 +	{}
   1.269 +inline TStreamExchange::TStreamExchange(MStreamBuf* aHost)
   1.270 +	: iHost(aHost),iRMrk(NULL),iWMrk(NULL)
   1.271 +/** Constructs the object, specifying the stream buffer that will act as the shared 
   1.272 +host.
   1.273 +
   1.274 +@param aHost A pointer to a stream buffer that will act as the shared host. */
   1.275 +	{}
   1.276 +inline void TStreamExchange::Share(MStreamBuf* aHost)
   1.277 +/** Tells the object to use the specified stream buffer that will act as the shared 
   1.278 +host.
   1.279 +
   1.280 +@param aHost A pointer to a stream buffer that will act as the shared host. */
   1.281 +	{iHost=aHost;}
   1.282 +inline TBool TStreamExchange::IsActive() const
   1.283 +/** Tests whether this object is using a stream buffer that is acting as shared 
   1.284 +host.
   1.285 +
   1.286 +@return True, if this object is using a shared host ; false, otherwise. */
   1.287 +	{return iHost!=NULL;}
   1.288 +	
   1.289 +// Class RShareBuf
   1.290 +inline void RShareBuf::Open(TStreamExchange& aHost,TInt aMode)
   1.291 +/** Prepares the shared stream buffer for streaming.
   1.292 +
   1.293 +The function sets the read mark and/or the write mark to the beginning of 
   1.294 +the host stream.
   1.295 +
   1.296 +@param aHost The object that manages shared streaming.
   1.297 +@param aMode The streaming mode. This can be read and/or write, as indicated 
   1.298 +by the ERead and EWrite bits.
   1.299 +@see MStreamBuf::TRead
   1.300 +@see MStreamBuf::TWrite
   1.301 +@see KStreamBeginning */
   1.302 +	{Open(aHost,KStreamBeginning,aMode);}
   1.303 +
   1.304 +// Class RShareWriteStream
   1.305 +inline RShareWriteStream::RShareWriteStream(const MExternalizer<TStreamRef>& anExter)
   1.306 +	: RWriteStream(anExter)
   1.307 +	{}
   1.308 +