os/persistentdata/persistentstorage/store/INC/S32STRM.INL
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 // Class RReadStream
    17 inline RReadStream::RReadStream()
    18 	: iSrc(NULL)
    19 /** Sets the stream buffer source to NULL, which implies that it is safe to close
    20 
    21 @see RReadStream::Source() */
    22 	{}
    23 inline RReadStream::RReadStream(MStreamBuf* aSource)
    24 	: iSrc(aSource)
    25 /** Constructs a read stream over the supplied stream buffer.
    26 
    27 @param aSource The stream buffer used to read from the read stream.
    28 @see RReadStream::Source() */
    29 	{}
    30 inline MStreamBuf* RReadStream::Source()
    31 /** Gets the underlying stream buffer for the read stream. This provides access 
    32 to the stream-buffer implementation used by the read stream.
    33 
    34 Note:
    35 
    36 If the stream buffer supports seeking, this allows the RReadStream client 
    37 to have random access to the stream data.
    38 
    39 @return The underlying stream buffer for the read stream.
    40 @see RReadStream::Attach()
    41 @see RReadStream::Detach() */
    42 	{return iSrc;}
    43 inline void RReadStream::Close()
    44 /** Frees resources used by the stream.
    45 
    46 @see RReadStream::Release() */
    47 	{Release();}
    48 inline void RReadStream::ReadL(RWriteStream& aStream)
    49 /**	Writes the content of this stream to the specified write stream.
    50 
    51 @param aStream A reference to the write stream to which this stream is to be written.*/
    52 	{aStream.WriteL(*this);}
    53 inline void RReadStream::ReadL(RWriteStream& aStream,TInt aLength)
    54 /**	Writes the content of this stream to the specified write stream.
    55 
    56 @param aStream A reference to the write stream to which this stream is to be written.
    57 @param aLength The length of data from this stream to be written to aStream.*/
    58 	{aStream.WriteL(*this,aLength);}
    59 inline void RReadStream::Pop()
    60 /** Removes the cleanup item for this read stream object from the cleanup stack. */
    61 	{CleanupStack::Pop();}
    62 inline void RReadStream::Attach(MStreamBuf* aSource)
    63 /** Sets the stream buffer source for this read stream. The existing source (if 
    64 there is one) will be discarded.
    65 
    66 This is useful for derived classes, enabling them to set the source following 
    67 construction.
    68 
    69 Note:
    70 
    71 Release() is not called on any discarded stream buffer.
    72 
    73 @param aSource The new source stream buffer for this read stream.
    74 @see RReadStream::Source()
    75 @see RReadStream::Detach() */
    76 	{iSrc=aSource;}
    77 inline void RReadStream::Detach()
    78 /** Sets the stream buffer source for this read stream to NULL. The existing source, 
    79 if there is one, will be discarded.
    80 
    81 Note that Release() is not called on any discarded stream buffer.
    82 
    83 @see RReadStream::Source()
    84 @see RReadStream::Attach() */
    85 	{iSrc=NULL;}
    86 
    87 // Class RWriteStream
    88 inline RWriteStream::RWriteStream()
    89 	: iSnk(NULL),iExterL(NULL)
    90 /** The stream buffer sink, as returned by Sink(), is set to NULL, and the stream 
    91 has no associated Store map. */
    92 	{}
    93 inline RWriteStream::RWriteStream(const MExternalizer<TStreamRef>& anExter)
    94 	: iSnk(NULL),iExterL(&anExter)
    95 /** Constructs a write stream with an associated store map. The stream buffer sink 
    96 is set to NULL. 
    97 
    98 @param anExter Specifies an externaliser. For example, CStoreMap implements 
    99 MExternalizer<TStreamRef>. */
   100 	{}
   101 inline RWriteStream::RWriteStream(MStreamBuf* aSink)
   102 	: iSnk(aSink),iExterL(NULL)
   103 /** Constructs a write stream over the supplied stream buffer. The stream has no 
   104 associated Store map.
   105 
   106 @param aSink The stream buffer used to write to the write stream. */
   107 	{}
   108 inline MStreamBuf* RWriteStream::Sink()
   109 /** Gets the underlying stream buffer for the write stream. This provides access 
   110 to the stream-buffer implementation used by the write stream.
   111 
   112 @return The underlying stream buffer for the write stream. */
   113 	{return iSnk;}
   114 inline void RWriteStream::Pop()
   115 /** Removes the cleanup item for this write stream object from the cleanup stack. */
   116 	{CleanupStack::Pop();}
   117 inline void RWriteStream::Attach(MStreamBuf* aSink)
   118 /** Sets the stream buffer sink for this write stream. The existing sink, if there 
   119 is one, will be discarded.
   120 
   121 This is useful for derived classes, enabling them to set the sink following 
   122 construction.
   123 
   124 Note:
   125 
   126 Release() is not called for discarded sinks.
   127 
   128 @param aSink The stream buffer sink for this write stream. */
   129 	{iSnk=aSink;}
   130 inline void RWriteStream::Detach()
   131 /** Sets the stream buffer sink for this write stream to NULL. The existing sink, 
   132 if there is one, will be discarded.
   133 
   134 Note:
   135 
   136 Release() is not called for discarded sinks. */
   137 	{iSnk=NULL;}
   138 
   139 // Class TCardinality
   140 inline TCardinality::TCardinality(TInt aCount)
   141 	:iCount(aCount)
   142 /** Constructs the object with the specified value.
   143 
   144 @param aCount The value for this object. */
   145 	{
   146 #if defined (_DEBUG)
   147 	__DbgChkRange(aCount);
   148 #endif
   149 	}
   150 inline TCardinality::operator TInt() const
   151 	{
   152 #if defined (_DEBUG)
   153 	__DbgChkRange(iCount);
   154 #endif
   155 	return iCount;
   156 	}
   157 
   158 // Template class TExternalizer
   159 template <class T>
   160 inline void TExternalizer<T>::operator()(const T& anObject,RWriteStream& aStream) const
   161 	{aStream<<anObject;}
   162 template <class T>
   163 inline TExternalizeFunction TExternalizer<T>::Function()
   164 /** Gets a pointer to the function to be used to perform externalisation.
   165 
   166 The implementation is the private, static member of this class, ExternalizeAsL().
   167 
   168 @return The externalisation function. */
   169 	{return &ExternalizeAsL;}
   170 template <class T>
   171 void TExternalizer<T>::ExternalizeAsL(const TAny* aPtr,RWriteStream& aStream)
   172 	{aStream<<*((const T*)aPtr);}
   173 inline TExternalizer<TAny>::TExternalizer(TExternalizeFunction aFunction)
   174 	: iFunc(aFunction)
   175 	{}
   176 inline void TExternalizer<TAny>::operator()(const TAny* aPtr,RWriteStream& aStream) const
   177 	{(*iFunc)(aPtr,aStream);}
   178 inline TExternalizeFunction TExternalizer<TAny>::Function() const
   179 	{return iFunc;}
   180 
   181 // Template class TInternalizer
   182 template <class T>
   183 inline void TInternalizer<T>::operator()(T& anObject,RReadStream& aStream) const
   184 	{aStream>>anObject;}
   185 template <class T>
   186 inline TInternalizeFunction TInternalizer<T>::Function()
   187 /** Gets a pointer to the function to be used to perform internalisation.
   188 
   189 The implementation is the private, static member of this class, InternalizeAsL().
   190 
   191 @return The internalisation function. */
   192 	{return &InternalizeAsL;}
   193 template <class T>
   194 void TInternalizer<T>::InternalizeAsL(TAny* aPtr,RReadStream& aStream)
   195 	{aStream>>*((T*)aPtr);}
   196 inline TInternalizer<TAny>::TInternalizer(TInternalizeFunction aFunction)
   197 	: iFunc(aFunction)
   198 	{}
   199 inline void TInternalizer<TAny>::operator()(TAny* aPtr,RReadStream& aStream) const
   200 	{(*iFunc)(aPtr,aStream);}
   201 inline TInternalizeFunction TInternalizer<TAny>::Function() const
   202 	{return iFunc;}
   203 
   204 // Template class MExternalizer
   205 template <class T>
   206 inline void MExternalizer<T>::operator()(const T& anObject,RWriteStream& aStream) const
   207 	{ExternalizeL(anObject,aStream);}
   208 
   209 // Template class MInternalizer
   210 template <class T>
   211 inline void MInternalizer<T>::operator()(T& anObject,RReadStream& aStream) const
   212 	{InternalizeL(anObject,aStream);}
   213 
   214 // Class TStreamRef
   215 inline TStreamRef::TStreamRef(const TAny* aPtr,TExternalizeFunction aFunction)
   216 	: iPtr(aPtr),iFunc(aFunction)
   217 /** Constructor.
   218 
   219 @param aPtr A pointer to the object for which externalisation is being done.
   220 @param aFunction The externalisation function. */
   221 	{}
   222 inline const TAny* TStreamRef::Ptr() const
   223 /** Gets the pointer to the object to be externalised.
   224 
   225 @return The object to be externalised. */
   226 	{return iPtr;}
   227 inline TExternalizeFunction TStreamRef::Function() const
   228 /** Gets a pointer to the externalisation function.
   229 
   230 @return The externalisation function. */
   231 	{return iFunc;}
   232 inline void TStreamRef::ExternalizeL(RWriteStream& aStream) const
   233 /** Externalises the object to the specified write stream.
   234 
   235 @param aStream The write stream. */
   236 	{aStream.WriteRefL(*this);}
   237 
   238 // Externalization and internalization functions
   239 IMPORT_C void ExternalizeL(TInt64 anInt64,RWriteStream& aStream);
   240 IMPORT_C void InternalizeL(TInt64& anInt64,RReadStream& aStream);
   241 
   242 IMPORT_C void ExternalizeL(const TDesC8& aDes8,RWriteStream& aStream);
   243 IMPORT_C void ExternalizeL(const TDesC16& aDes16,RWriteStream& aStream);
   244 IMPORT_C void InternalizeL(TDes8& aDes8,RReadStream& aStream);
   245 IMPORT_C void InternalizeL(TDes16& aDes16,RReadStream& aStream);
   246 
   247 IMPORT_C void ExternalizeL(const TCheckedUid& aUid,RWriteStream& aStream);
   248 IMPORT_C void InternalizeL(TCheckedUid& aUid,RReadStream& aStream);
   249 
   250 IMPORT_C void ExternalizeL(TPoint aPoint,RWriteStream& aStream);
   251 IMPORT_C void ExternalizeL(TSize aSize,RWriteStream& aStream);
   252 IMPORT_C void ExternalizeL(const TRect& aRect,RWriteStream& aStream);
   253 IMPORT_C void InternalizeL(TPoint& aPoint,RReadStream& aStream);
   254 IMPORT_C void InternalizeL(TSize& aSize,RReadStream& aStream);
   255 IMPORT_C void InternalizeL(TRect& aRect,RReadStream& aStream);
   256 
   257 IMPORT_C void ExternalizeL(const CBufBase& aBuf,RWriteStream& aStream);
   258 IMPORT_C void InternalizeL(CBufBase& aBuf,RReadStream& aStream);
   259 
   260 IMPORT_C void ArrayExternalizeCountL(TInt aCount,RWriteStream& aStream);
   261 IMPORT_C void DoExternalizeAllL(const CArrayFixBase& anArray,RWriteStream& aStream,TExternalizer<TAny> anExter);
   262 IMPORT_C TInt ArrayInternalizeCountL(RReadStream& aStream);
   263 IMPORT_C void DoInternalizeAllL(CArrayFixBase& anArray,RReadStream& aStream,TInternalizer<TAny> anInter);
   264 
   265 template <class T>
   266 inline void ExternalizeCountL(const CArrayFix<T>& anArray,RWriteStream& aStream)
   267 	{ArrayExternalizeCountL(anArray.Count(),aStream);}
   268 template <class T>
   269 inline void ExternalizeAllL(const CArrayFix<T>& anArray,RWriteStream& aStream)
   270 	{DoExternalizeAllL(anArray,aStream,TExternalizer<T>::Function());}
   271 template <class T>
   272 void InternalizeCountL(CArrayFix<T>& anArray,RReadStream& aStream)
   273 	{
   274 	TInt n=ArrayInternalizeCountL(aStream);
   275 	anArray.ResizeL(n);
   276 	}
   277 template <class T>
   278 inline void InternalizeAllL(CArrayFix<T>& anArray,RReadStream& aStream)
   279 	{DoInternalizeAllL(anArray,aStream,TInternalizer<T>::Function());}
   280 
   281 template <class T>
   282 void ExternalizeL(const CArrayFix<T>& anArray,RWriteStream& aStream)
   283 	{
   284 	ExternalizeCountL(anArray,aStream);
   285 	ExternalizeAllL(anArray,aStream);
   286 	}
   287 template <class T>
   288 void InternalizeL(CArrayFix<T>& anArray,RReadStream& aStream)
   289 	{
   290 	InternalizeCountL(anArray,aStream);
   291 	InternalizeAllL(anArray,aStream);
   292 	}
   293 
   294 template <class T>
   295 inline void ExternalizeL(const T* aPtr,RWriteStream& aStream)
   296 	{aStream<<TStreamRef(aPtr,TExternalizer<T>::Function());}
   297 
   298 template <class T>
   299 inline void DoExternalizeL(const T& anObject,RWriteStream& aStream,Externalize::Member)
   300 	{anObject.ExternalizeL(aStream);}
   301 template <class T>
   302 inline void DoInternalizeL(T& anObject,RReadStream& aStream,Internalize::Member)
   303 	{anObject.InternalizeL(aStream);}
   304 
   305 template <class T>
   306 inline void DoExternalizeL(const T& anObject,RWriteStream& aStream,Externalize::Function)
   307 	{ExternalizeL(anObject,aStream);}
   308 template <class T>
   309 inline void DoInternalizeL(T& anObject,RReadStream& aStream,Internalize::Function)
   310 	{InternalizeL(anObject,aStream);}
   311 
   312 // Externalization and internalization selectors
   313 inline Externalize::Member Externalization(const TAny*)
   314 	{return Externalize::Member();}
   315 inline Internalize::Member Internalization(TAny*)
   316 	{return Internalize::Member();}
   317 
   318 inline Externalize::Function Externalization(const TDesC8*)
   319 	{return Externalize::Function();}
   320 inline Externalize::Function Externalization(const TDesC16*)
   321 	{return Externalize::Function();}
   322 inline Internalize::Function Internalization(TDes8*)
   323 	{return Internalize::Function();}
   324 inline Internalize::Function Internalization(TDes16*)
   325 	{return Internalize::Function();}
   326 
   327 inline Externalize::Function Externalization(const CBufBase*)
   328 	{return Externalize::Function();}
   329 inline Externalize::Function Externalization(const CArrayFixBase*)
   330 	{return Externalize::Function();}
   331 inline Internalize::Function Internalization(CBufBase*)
   332 	{return Internalize::Function();}
   333 inline Internalize::Function Internalization(CArrayFixBase*)
   334 	{return Internalize::Function();}
   335 
   336 template <class T>
   337 inline Externalize::Function Externalization(T*const*)
   338 	{return Externalize::Function();}
   339 
   340 // Input and output operators
   341 template <class T>
   342 inline RWriteStream& operator<<(RWriteStream& aStream,const T& anObject)
   343 	{DoExternalizeL(anObject,aStream,Externalization(&anObject));return aStream;}
   344 template <class T>
   345 inline RReadStream& operator>>(RReadStream& aStream,T& anObject)
   346 	{DoInternalizeL(anObject,aStream,Internalization(&anObject));return aStream;}
   347 
   348 inline RWriteStream& operator<<(RWriteStream& aStream,const TInt8& anInt8)
   349 	{aStream.WriteInt8L(anInt8);return aStream;}
   350 inline RWriteStream& operator<<(RWriteStream& aStream,const TInt16& anInt16)
   351 	{aStream.WriteInt16L(anInt16);return aStream;}
   352 inline RWriteStream& operator<<(RWriteStream& aStream,const TInt32& anInt32)
   353 	{aStream.WriteInt32L(anInt32);return aStream;}
   354 inline RWriteStream& operator<<(RWriteStream& aStream,const TUint8& aUint8)
   355 	{aStream.WriteUint8L(aUint8);return aStream;}
   356 inline RWriteStream& operator<<(RWriteStream& aStream,const TUint16& aUint16)
   357 	{aStream.WriteUint16L(aUint16);return aStream;}
   358 inline RWriteStream& operator<<(RWriteStream& aStream,const TUint32& aUint32)
   359 	{aStream.WriteUint32L(aUint32);return aStream;}
   360 inline RWriteStream& operator<<(RWriteStream& aStream,const TReal32& aReal32)
   361 	{aStream.WriteReal32L(aReal32);return aStream;}
   362 inline RWriteStream& operator<<(RWriteStream& aStream,const TReal64& aReal64)
   363 	{aStream.WriteReal64L(aReal64);return aStream;}
   364 
   365 inline RReadStream& operator>>(RReadStream& aStream,TInt8& anInt8)
   366 	{anInt8=aStream.ReadInt8L();return aStream;}
   367 inline RReadStream& operator>>(RReadStream& aStream,TInt16& anInt16)
   368 	{anInt16=aStream.ReadInt16L();return aStream;}
   369 inline RReadStream& operator>>(RReadStream& aStream,TInt32& anInt32)
   370 	{anInt32=aStream.ReadInt32L();return aStream;}
   371 inline RReadStream& operator>>(RReadStream& aStream,TUint8& aUint8)
   372 	{aUint8=aStream.ReadUint8L();return aStream;}
   373 inline RReadStream& operator>>(RReadStream& aStream,TUint16& aUint16)
   374 	{aUint16=aStream.ReadUint16L();return aStream;}
   375 inline RReadStream& operator>>(RReadStream& aStream,TUint32& aUint32)
   376 	{aUint32=aStream.ReadUint32L();return aStream;}
   377 inline RReadStream& operator>>(RReadStream& aStream,TReal32& aReal32)
   378 	{aReal32=aStream.ReadReal32L();return aStream;}
   379 inline RReadStream& operator>>(RReadStream& aStream,TReal64& aReal64)
   380 	{aReal64=aStream.ReadReal64L();return aStream;}
   381 
   382 inline RWriteStream& operator<<(RWriteStream& aStream,const TInt64& anInt64)
   383 	{ExternalizeL(anInt64,aStream);return aStream;}
   384 inline RReadStream& operator>>(RReadStream& aStream,TInt64& anInt64)
   385 	{InternalizeL(anInt64,aStream);return aStream;}
   386 
   387 inline RWriteStream& operator<<(RWriteStream& aStream,const TUid& aUid)
   388 	{return aStream<<aUid.iUid;}
   389 inline RWriteStream& operator<<(RWriteStream& aStream,const TCheckedUid& aUid)
   390 	{ExternalizeL(aUid,aStream);return aStream;}
   391 inline RReadStream& operator>>(RReadStream& aStream,TUid& aUid)
   392 	{return aStream>>aUid.iUid;}
   393 inline RReadStream& operator>>(RReadStream& aStream,TCheckedUid& aUid)
   394 	{InternalizeL(aUid,aStream);return aStream;}
   395 
   396 inline RWriteStream& operator<<(RWriteStream& aStream,const TPoint& aPoint)
   397 	{ExternalizeL(aPoint,aStream);return aStream;}
   398 inline RWriteStream& operator<<(RWriteStream& aStream,const TSize& aSize)
   399 	{ExternalizeL(aSize,aStream);return aStream;}
   400 inline RWriteStream& operator<<(RWriteStream& aStream,const TRect& aRect)
   401 	{ExternalizeL(aRect,aStream);return aStream;}
   402 inline RReadStream& operator>>(RReadStream& aStream,TPoint& aPoint)
   403 	{InternalizeL(aPoint,aStream);return aStream;}
   404 inline RReadStream& operator>>(RReadStream& aStream,TSize& aSize)
   405 	{InternalizeL(aSize,aStream);return aStream;}
   406 inline RReadStream& operator>>(RReadStream& aStream,TRect& aRect)
   407 	{InternalizeL(aRect,aStream);return aStream;}
   408 
   409 inline RWriteStream& operator<<(RWriteStream& aStream,const TStreamRef& aRef)
   410 	{aRef.ExternalizeL(aStream);return aStream;}
   411