os/persistentdata/persistentstorage/store/INC/S32STRM.INL
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/store/INC/S32STRM.INL	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,411 @@
     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 RReadStream
    1.20 +inline RReadStream::RReadStream()
    1.21 +	: iSrc(NULL)
    1.22 +/** Sets the stream buffer source to NULL, which implies that it is safe to close
    1.23 +
    1.24 +@see RReadStream::Source() */
    1.25 +	{}
    1.26 +inline RReadStream::RReadStream(MStreamBuf* aSource)
    1.27 +	: iSrc(aSource)
    1.28 +/** Constructs a read stream over the supplied stream buffer.
    1.29 +
    1.30 +@param aSource The stream buffer used to read from the read stream.
    1.31 +@see RReadStream::Source() */
    1.32 +	{}
    1.33 +inline MStreamBuf* RReadStream::Source()
    1.34 +/** Gets the underlying stream buffer for the read stream. This provides access 
    1.35 +to the stream-buffer implementation used by the read stream.
    1.36 +
    1.37 +Note:
    1.38 +
    1.39 +If the stream buffer supports seeking, this allows the RReadStream client 
    1.40 +to have random access to the stream data.
    1.41 +
    1.42 +@return The underlying stream buffer for the read stream.
    1.43 +@see RReadStream::Attach()
    1.44 +@see RReadStream::Detach() */
    1.45 +	{return iSrc;}
    1.46 +inline void RReadStream::Close()
    1.47 +/** Frees resources used by the stream.
    1.48 +
    1.49 +@see RReadStream::Release() */
    1.50 +	{Release();}
    1.51 +inline void RReadStream::ReadL(RWriteStream& aStream)
    1.52 +/**	Writes the content of this stream to the specified write stream.
    1.53 +
    1.54 +@param aStream A reference to the write stream to which this stream is to be written.*/
    1.55 +	{aStream.WriteL(*this);}
    1.56 +inline void RReadStream::ReadL(RWriteStream& aStream,TInt aLength)
    1.57 +/**	Writes the content of this stream to the specified write stream.
    1.58 +
    1.59 +@param aStream A reference to the write stream to which this stream is to be written.
    1.60 +@param aLength The length of data from this stream to be written to aStream.*/
    1.61 +	{aStream.WriteL(*this,aLength);}
    1.62 +inline void RReadStream::Pop()
    1.63 +/** Removes the cleanup item for this read stream object from the cleanup stack. */
    1.64 +	{CleanupStack::Pop();}
    1.65 +inline void RReadStream::Attach(MStreamBuf* aSource)
    1.66 +/** Sets the stream buffer source for this read stream. The existing source (if 
    1.67 +there is one) will be discarded.
    1.68 +
    1.69 +This is useful for derived classes, enabling them to set the source following 
    1.70 +construction.
    1.71 +
    1.72 +Note:
    1.73 +
    1.74 +Release() is not called on any discarded stream buffer.
    1.75 +
    1.76 +@param aSource The new source stream buffer for this read stream.
    1.77 +@see RReadStream::Source()
    1.78 +@see RReadStream::Detach() */
    1.79 +	{iSrc=aSource;}
    1.80 +inline void RReadStream::Detach()
    1.81 +/** Sets the stream buffer source for this read stream to NULL. The existing source, 
    1.82 +if there is one, will be discarded.
    1.83 +
    1.84 +Note that Release() is not called on any discarded stream buffer.
    1.85 +
    1.86 +@see RReadStream::Source()
    1.87 +@see RReadStream::Attach() */
    1.88 +	{iSrc=NULL;}
    1.89 +
    1.90 +// Class RWriteStream
    1.91 +inline RWriteStream::RWriteStream()
    1.92 +	: iSnk(NULL),iExterL(NULL)
    1.93 +/** The stream buffer sink, as returned by Sink(), is set to NULL, and the stream 
    1.94 +has no associated Store map. */
    1.95 +	{}
    1.96 +inline RWriteStream::RWriteStream(const MExternalizer<TStreamRef>& anExter)
    1.97 +	: iSnk(NULL),iExterL(&anExter)
    1.98 +/** Constructs a write stream with an associated store map. The stream buffer sink 
    1.99 +is set to NULL. 
   1.100 +
   1.101 +@param anExter Specifies an externaliser. For example, CStoreMap implements 
   1.102 +MExternalizer<TStreamRef>. */
   1.103 +	{}
   1.104 +inline RWriteStream::RWriteStream(MStreamBuf* aSink)
   1.105 +	: iSnk(aSink),iExterL(NULL)
   1.106 +/** Constructs a write stream over the supplied stream buffer. The stream has no 
   1.107 +associated Store map.
   1.108 +
   1.109 +@param aSink The stream buffer used to write to the write stream. */
   1.110 +	{}
   1.111 +inline MStreamBuf* RWriteStream::Sink()
   1.112 +/** Gets the underlying stream buffer for the write stream. This provides access 
   1.113 +to the stream-buffer implementation used by the write stream.
   1.114 +
   1.115 +@return The underlying stream buffer for the write stream. */
   1.116 +	{return iSnk;}
   1.117 +inline void RWriteStream::Pop()
   1.118 +/** Removes the cleanup item for this write stream object from the cleanup stack. */
   1.119 +	{CleanupStack::Pop();}
   1.120 +inline void RWriteStream::Attach(MStreamBuf* aSink)
   1.121 +/** Sets the stream buffer sink for this write stream. The existing sink, if there 
   1.122 +is one, will be discarded.
   1.123 +
   1.124 +This is useful for derived classes, enabling them to set the sink following 
   1.125 +construction.
   1.126 +
   1.127 +Note:
   1.128 +
   1.129 +Release() is not called for discarded sinks.
   1.130 +
   1.131 +@param aSink The stream buffer sink for this write stream. */
   1.132 +	{iSnk=aSink;}
   1.133 +inline void RWriteStream::Detach()
   1.134 +/** Sets the stream buffer sink for this write stream to NULL. The existing sink, 
   1.135 +if there is one, will be discarded.
   1.136 +
   1.137 +Note:
   1.138 +
   1.139 +Release() is not called for discarded sinks. */
   1.140 +	{iSnk=NULL;}
   1.141 +
   1.142 +// Class TCardinality
   1.143 +inline TCardinality::TCardinality(TInt aCount)
   1.144 +	:iCount(aCount)
   1.145 +/** Constructs the object with the specified value.
   1.146 +
   1.147 +@param aCount The value for this object. */
   1.148 +	{
   1.149 +#if defined (_DEBUG)
   1.150 +	__DbgChkRange(aCount);
   1.151 +#endif
   1.152 +	}
   1.153 +inline TCardinality::operator TInt() const
   1.154 +	{
   1.155 +#if defined (_DEBUG)
   1.156 +	__DbgChkRange(iCount);
   1.157 +#endif
   1.158 +	return iCount;
   1.159 +	}
   1.160 +
   1.161 +// Template class TExternalizer
   1.162 +template <class T>
   1.163 +inline void TExternalizer<T>::operator()(const T& anObject,RWriteStream& aStream) const
   1.164 +	{aStream<<anObject;}
   1.165 +template <class T>
   1.166 +inline TExternalizeFunction TExternalizer<T>::Function()
   1.167 +/** Gets a pointer to the function to be used to perform externalisation.
   1.168 +
   1.169 +The implementation is the private, static member of this class, ExternalizeAsL().
   1.170 +
   1.171 +@return The externalisation function. */
   1.172 +	{return &ExternalizeAsL;}
   1.173 +template <class T>
   1.174 +void TExternalizer<T>::ExternalizeAsL(const TAny* aPtr,RWriteStream& aStream)
   1.175 +	{aStream<<*((const T*)aPtr);}
   1.176 +inline TExternalizer<TAny>::TExternalizer(TExternalizeFunction aFunction)
   1.177 +	: iFunc(aFunction)
   1.178 +	{}
   1.179 +inline void TExternalizer<TAny>::operator()(const TAny* aPtr,RWriteStream& aStream) const
   1.180 +	{(*iFunc)(aPtr,aStream);}
   1.181 +inline TExternalizeFunction TExternalizer<TAny>::Function() const
   1.182 +	{return iFunc;}
   1.183 +
   1.184 +// Template class TInternalizer
   1.185 +template <class T>
   1.186 +inline void TInternalizer<T>::operator()(T& anObject,RReadStream& aStream) const
   1.187 +	{aStream>>anObject;}
   1.188 +template <class T>
   1.189 +inline TInternalizeFunction TInternalizer<T>::Function()
   1.190 +/** Gets a pointer to the function to be used to perform internalisation.
   1.191 +
   1.192 +The implementation is the private, static member of this class, InternalizeAsL().
   1.193 +
   1.194 +@return The internalisation function. */
   1.195 +	{return &InternalizeAsL;}
   1.196 +template <class T>
   1.197 +void TInternalizer<T>::InternalizeAsL(TAny* aPtr,RReadStream& aStream)
   1.198 +	{aStream>>*((T*)aPtr);}
   1.199 +inline TInternalizer<TAny>::TInternalizer(TInternalizeFunction aFunction)
   1.200 +	: iFunc(aFunction)
   1.201 +	{}
   1.202 +inline void TInternalizer<TAny>::operator()(TAny* aPtr,RReadStream& aStream) const
   1.203 +	{(*iFunc)(aPtr,aStream);}
   1.204 +inline TInternalizeFunction TInternalizer<TAny>::Function() const
   1.205 +	{return iFunc;}
   1.206 +
   1.207 +// Template class MExternalizer
   1.208 +template <class T>
   1.209 +inline void MExternalizer<T>::operator()(const T& anObject,RWriteStream& aStream) const
   1.210 +	{ExternalizeL(anObject,aStream);}
   1.211 +
   1.212 +// Template class MInternalizer
   1.213 +template <class T>
   1.214 +inline void MInternalizer<T>::operator()(T& anObject,RReadStream& aStream) const
   1.215 +	{InternalizeL(anObject,aStream);}
   1.216 +
   1.217 +// Class TStreamRef
   1.218 +inline TStreamRef::TStreamRef(const TAny* aPtr,TExternalizeFunction aFunction)
   1.219 +	: iPtr(aPtr),iFunc(aFunction)
   1.220 +/** Constructor.
   1.221 +
   1.222 +@param aPtr A pointer to the object for which externalisation is being done.
   1.223 +@param aFunction The externalisation function. */
   1.224 +	{}
   1.225 +inline const TAny* TStreamRef::Ptr() const
   1.226 +/** Gets the pointer to the object to be externalised.
   1.227 +
   1.228 +@return The object to be externalised. */
   1.229 +	{return iPtr;}
   1.230 +inline TExternalizeFunction TStreamRef::Function() const
   1.231 +/** Gets a pointer to the externalisation function.
   1.232 +
   1.233 +@return The externalisation function. */
   1.234 +	{return iFunc;}
   1.235 +inline void TStreamRef::ExternalizeL(RWriteStream& aStream) const
   1.236 +/** Externalises the object to the specified write stream.
   1.237 +
   1.238 +@param aStream The write stream. */
   1.239 +	{aStream.WriteRefL(*this);}
   1.240 +
   1.241 +// Externalization and internalization functions
   1.242 +IMPORT_C void ExternalizeL(TInt64 anInt64,RWriteStream& aStream);
   1.243 +IMPORT_C void InternalizeL(TInt64& anInt64,RReadStream& aStream);
   1.244 +
   1.245 +IMPORT_C void ExternalizeL(const TDesC8& aDes8,RWriteStream& aStream);
   1.246 +IMPORT_C void ExternalizeL(const TDesC16& aDes16,RWriteStream& aStream);
   1.247 +IMPORT_C void InternalizeL(TDes8& aDes8,RReadStream& aStream);
   1.248 +IMPORT_C void InternalizeL(TDes16& aDes16,RReadStream& aStream);
   1.249 +
   1.250 +IMPORT_C void ExternalizeL(const TCheckedUid& aUid,RWriteStream& aStream);
   1.251 +IMPORT_C void InternalizeL(TCheckedUid& aUid,RReadStream& aStream);
   1.252 +
   1.253 +IMPORT_C void ExternalizeL(TPoint aPoint,RWriteStream& aStream);
   1.254 +IMPORT_C void ExternalizeL(TSize aSize,RWriteStream& aStream);
   1.255 +IMPORT_C void ExternalizeL(const TRect& aRect,RWriteStream& aStream);
   1.256 +IMPORT_C void InternalizeL(TPoint& aPoint,RReadStream& aStream);
   1.257 +IMPORT_C void InternalizeL(TSize& aSize,RReadStream& aStream);
   1.258 +IMPORT_C void InternalizeL(TRect& aRect,RReadStream& aStream);
   1.259 +
   1.260 +IMPORT_C void ExternalizeL(const CBufBase& aBuf,RWriteStream& aStream);
   1.261 +IMPORT_C void InternalizeL(CBufBase& aBuf,RReadStream& aStream);
   1.262 +
   1.263 +IMPORT_C void ArrayExternalizeCountL(TInt aCount,RWriteStream& aStream);
   1.264 +IMPORT_C void DoExternalizeAllL(const CArrayFixBase& anArray,RWriteStream& aStream,TExternalizer<TAny> anExter);
   1.265 +IMPORT_C TInt ArrayInternalizeCountL(RReadStream& aStream);
   1.266 +IMPORT_C void DoInternalizeAllL(CArrayFixBase& anArray,RReadStream& aStream,TInternalizer<TAny> anInter);
   1.267 +
   1.268 +template <class T>
   1.269 +inline void ExternalizeCountL(const CArrayFix<T>& anArray,RWriteStream& aStream)
   1.270 +	{ArrayExternalizeCountL(anArray.Count(),aStream);}
   1.271 +template <class T>
   1.272 +inline void ExternalizeAllL(const CArrayFix<T>& anArray,RWriteStream& aStream)
   1.273 +	{DoExternalizeAllL(anArray,aStream,TExternalizer<T>::Function());}
   1.274 +template <class T>
   1.275 +void InternalizeCountL(CArrayFix<T>& anArray,RReadStream& aStream)
   1.276 +	{
   1.277 +	TInt n=ArrayInternalizeCountL(aStream);
   1.278 +	anArray.ResizeL(n);
   1.279 +	}
   1.280 +template <class T>
   1.281 +inline void InternalizeAllL(CArrayFix<T>& anArray,RReadStream& aStream)
   1.282 +	{DoInternalizeAllL(anArray,aStream,TInternalizer<T>::Function());}
   1.283 +
   1.284 +template <class T>
   1.285 +void ExternalizeL(const CArrayFix<T>& anArray,RWriteStream& aStream)
   1.286 +	{
   1.287 +	ExternalizeCountL(anArray,aStream);
   1.288 +	ExternalizeAllL(anArray,aStream);
   1.289 +	}
   1.290 +template <class T>
   1.291 +void InternalizeL(CArrayFix<T>& anArray,RReadStream& aStream)
   1.292 +	{
   1.293 +	InternalizeCountL(anArray,aStream);
   1.294 +	InternalizeAllL(anArray,aStream);
   1.295 +	}
   1.296 +
   1.297 +template <class T>
   1.298 +inline void ExternalizeL(const T* aPtr,RWriteStream& aStream)
   1.299 +	{aStream<<TStreamRef(aPtr,TExternalizer<T>::Function());}
   1.300 +
   1.301 +template <class T>
   1.302 +inline void DoExternalizeL(const T& anObject,RWriteStream& aStream,Externalize::Member)
   1.303 +	{anObject.ExternalizeL(aStream);}
   1.304 +template <class T>
   1.305 +inline void DoInternalizeL(T& anObject,RReadStream& aStream,Internalize::Member)
   1.306 +	{anObject.InternalizeL(aStream);}
   1.307 +
   1.308 +template <class T>
   1.309 +inline void DoExternalizeL(const T& anObject,RWriteStream& aStream,Externalize::Function)
   1.310 +	{ExternalizeL(anObject,aStream);}
   1.311 +template <class T>
   1.312 +inline void DoInternalizeL(T& anObject,RReadStream& aStream,Internalize::Function)
   1.313 +	{InternalizeL(anObject,aStream);}
   1.314 +
   1.315 +// Externalization and internalization selectors
   1.316 +inline Externalize::Member Externalization(const TAny*)
   1.317 +	{return Externalize::Member();}
   1.318 +inline Internalize::Member Internalization(TAny*)
   1.319 +	{return Internalize::Member();}
   1.320 +
   1.321 +inline Externalize::Function Externalization(const TDesC8*)
   1.322 +	{return Externalize::Function();}
   1.323 +inline Externalize::Function Externalization(const TDesC16*)
   1.324 +	{return Externalize::Function();}
   1.325 +inline Internalize::Function Internalization(TDes8*)
   1.326 +	{return Internalize::Function();}
   1.327 +inline Internalize::Function Internalization(TDes16*)
   1.328 +	{return Internalize::Function();}
   1.329 +
   1.330 +inline Externalize::Function Externalization(const CBufBase*)
   1.331 +	{return Externalize::Function();}
   1.332 +inline Externalize::Function Externalization(const CArrayFixBase*)
   1.333 +	{return Externalize::Function();}
   1.334 +inline Internalize::Function Internalization(CBufBase*)
   1.335 +	{return Internalize::Function();}
   1.336 +inline Internalize::Function Internalization(CArrayFixBase*)
   1.337 +	{return Internalize::Function();}
   1.338 +
   1.339 +template <class T>
   1.340 +inline Externalize::Function Externalization(T*const*)
   1.341 +	{return Externalize::Function();}
   1.342 +
   1.343 +// Input and output operators
   1.344 +template <class T>
   1.345 +inline RWriteStream& operator<<(RWriteStream& aStream,const T& anObject)
   1.346 +	{DoExternalizeL(anObject,aStream,Externalization(&anObject));return aStream;}
   1.347 +template <class T>
   1.348 +inline RReadStream& operator>>(RReadStream& aStream,T& anObject)
   1.349 +	{DoInternalizeL(anObject,aStream,Internalization(&anObject));return aStream;}
   1.350 +
   1.351 +inline RWriteStream& operator<<(RWriteStream& aStream,const TInt8& anInt8)
   1.352 +	{aStream.WriteInt8L(anInt8);return aStream;}
   1.353 +inline RWriteStream& operator<<(RWriteStream& aStream,const TInt16& anInt16)
   1.354 +	{aStream.WriteInt16L(anInt16);return aStream;}
   1.355 +inline RWriteStream& operator<<(RWriteStream& aStream,const TInt32& anInt32)
   1.356 +	{aStream.WriteInt32L(anInt32);return aStream;}
   1.357 +inline RWriteStream& operator<<(RWriteStream& aStream,const TUint8& aUint8)
   1.358 +	{aStream.WriteUint8L(aUint8);return aStream;}
   1.359 +inline RWriteStream& operator<<(RWriteStream& aStream,const TUint16& aUint16)
   1.360 +	{aStream.WriteUint16L(aUint16);return aStream;}
   1.361 +inline RWriteStream& operator<<(RWriteStream& aStream,const TUint32& aUint32)
   1.362 +	{aStream.WriteUint32L(aUint32);return aStream;}
   1.363 +inline RWriteStream& operator<<(RWriteStream& aStream,const TReal32& aReal32)
   1.364 +	{aStream.WriteReal32L(aReal32);return aStream;}
   1.365 +inline RWriteStream& operator<<(RWriteStream& aStream,const TReal64& aReal64)
   1.366 +	{aStream.WriteReal64L(aReal64);return aStream;}
   1.367 +
   1.368 +inline RReadStream& operator>>(RReadStream& aStream,TInt8& anInt8)
   1.369 +	{anInt8=aStream.ReadInt8L();return aStream;}
   1.370 +inline RReadStream& operator>>(RReadStream& aStream,TInt16& anInt16)
   1.371 +	{anInt16=aStream.ReadInt16L();return aStream;}
   1.372 +inline RReadStream& operator>>(RReadStream& aStream,TInt32& anInt32)
   1.373 +	{anInt32=aStream.ReadInt32L();return aStream;}
   1.374 +inline RReadStream& operator>>(RReadStream& aStream,TUint8& aUint8)
   1.375 +	{aUint8=aStream.ReadUint8L();return aStream;}
   1.376 +inline RReadStream& operator>>(RReadStream& aStream,TUint16& aUint16)
   1.377 +	{aUint16=aStream.ReadUint16L();return aStream;}
   1.378 +inline RReadStream& operator>>(RReadStream& aStream,TUint32& aUint32)
   1.379 +	{aUint32=aStream.ReadUint32L();return aStream;}
   1.380 +inline RReadStream& operator>>(RReadStream& aStream,TReal32& aReal32)
   1.381 +	{aReal32=aStream.ReadReal32L();return aStream;}
   1.382 +inline RReadStream& operator>>(RReadStream& aStream,TReal64& aReal64)
   1.383 +	{aReal64=aStream.ReadReal64L();return aStream;}
   1.384 +
   1.385 +inline RWriteStream& operator<<(RWriteStream& aStream,const TInt64& anInt64)
   1.386 +	{ExternalizeL(anInt64,aStream);return aStream;}
   1.387 +inline RReadStream& operator>>(RReadStream& aStream,TInt64& anInt64)
   1.388 +	{InternalizeL(anInt64,aStream);return aStream;}
   1.389 +
   1.390 +inline RWriteStream& operator<<(RWriteStream& aStream,const TUid& aUid)
   1.391 +	{return aStream<<aUid.iUid;}
   1.392 +inline RWriteStream& operator<<(RWriteStream& aStream,const TCheckedUid& aUid)
   1.393 +	{ExternalizeL(aUid,aStream);return aStream;}
   1.394 +inline RReadStream& operator>>(RReadStream& aStream,TUid& aUid)
   1.395 +	{return aStream>>aUid.iUid;}
   1.396 +inline RReadStream& operator>>(RReadStream& aStream,TCheckedUid& aUid)
   1.397 +	{InternalizeL(aUid,aStream);return aStream;}
   1.398 +
   1.399 +inline RWriteStream& operator<<(RWriteStream& aStream,const TPoint& aPoint)
   1.400 +	{ExternalizeL(aPoint,aStream);return aStream;}
   1.401 +inline RWriteStream& operator<<(RWriteStream& aStream,const TSize& aSize)
   1.402 +	{ExternalizeL(aSize,aStream);return aStream;}
   1.403 +inline RWriteStream& operator<<(RWriteStream& aStream,const TRect& aRect)
   1.404 +	{ExternalizeL(aRect,aStream);return aStream;}
   1.405 +inline RReadStream& operator>>(RReadStream& aStream,TPoint& aPoint)
   1.406 +	{InternalizeL(aPoint,aStream);return aStream;}
   1.407 +inline RReadStream& operator>>(RReadStream& aStream,TSize& aSize)
   1.408 +	{InternalizeL(aSize,aStream);return aStream;}
   1.409 +inline RReadStream& operator>>(RReadStream& aStream,TRect& aRect)
   1.410 +	{InternalizeL(aRect,aStream);return aStream;}
   1.411 +
   1.412 +inline RWriteStream& operator<<(RWriteStream& aStream,const TStreamRef& aRef)
   1.413 +	{aRef.ExternalizeL(aStream);return aStream;}
   1.414 +