epoc32/include/s32std.inl
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 s32std.inl
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 // Class TStreamId
       
    17 inline TStreamId::TStreamId(TUint32 aValue)
       
    18 	: iVal(aValue)
       
    19 /** Constructs the object with the specified stream ID value.
       
    20 
       
    21 Users of stores do not normally use this function.
       
    22 
       
    23 In debug mode, the function checks that the supplied stream ID value is not 
       
    24 greater than the maximum permitted value, and raises a STORE-Store 2 panic 
       
    25 if it is. In release mode, no checking on the supplied value is done.
       
    26 
       
    27 The checking of the supplied value is done by a private function implemented 
       
    28 in estor. dll. This means that in debug mode, a call is made into estor.dll, 
       
    29 but in release mode it is not.
       
    30 
       
    31 @param aValue The stream ID value. */
       
    32 	{
       
    33 #if defined (_DEBUG)
       
    34 	__DbgChkRange(aValue);
       
    35 #endif
       
    36 	}
       
    37 inline TBool TStreamId::operator==(TStreamId anId) const
       
    38 /** Equality comparison operator. Use this operator to determine whether this stream 
       
    39 id is equal to the specified stream id.
       
    40 
       
    41 @param anId The stream id to be compared with this stream id.
       
    42 @return True, if the stream ids are equal; false otherwise */
       
    43 	{return iVal==anId.iVal;}
       
    44 inline TBool TStreamId::operator!=(TStreamId anId) const
       
    45 /** Inequality comparison operator. Use this operator to determine whether this 
       
    46 stream id is unequal to the specified stream id.
       
    47 
       
    48 @param anId The stream id to be compared with this stream id.
       
    49 @return True, if the two stream ids are unequal, false otherwise. */
       
    50 	{return iVal!=anId.iVal;}
       
    51 inline void TStreamId::ExternalizeL(RWriteStream& aStream) const
       
    52 /** Externalises an object of this class to a write stream.
       
    53 
       
    54 The presence of this function means that the standard templated operator<<() 
       
    55 can be used to externalise objects of this class.
       
    56 
       
    57 @param aStream Stream to which the object should be externalised. */
       
    58 	{
       
    59 #if defined (_DEBUG)
       
    60 	__DbgChkRange(iVal);
       
    61 #endif
       
    62 	aStream<<iVal;
       
    63 	}
       
    64 inline TUint32 TStreamId::Value() const
       
    65 /** Gets the stream ID value encapsulated by this object.
       
    66 
       
    67 @return The stream ID value. */
       
    68 	{
       
    69 #if defined (_DEBUG)
       
    70 	__DbgChkRange(iVal);
       
    71 #endif
       
    72 	return iVal;
       
    73 	}
       
    74 
       
    75 // Class RStoreWriteStream
       
    76 inline RStoreWriteStream::RStoreWriteStream(const MExternalizer<TStreamRef>& anExter)
       
    77 	: RWriteStream(anExter)
       
    78 /** Constructs an object with an externaliser. The store map CStoreMap is an example 
       
    79 of an externalizer.
       
    80 
       
    81 @param anExter Specifies an externaliser */
       
    82 	{}
       
    83 
       
    84 // Class TSwizzleCBase
       
    85 inline TSwizzleCBase::TSwizzleCBase(TStreamRef aRef)
       
    86 	: iPtr(aRef.Ptr())
       
    87 	{
       
    88 #if defined (_DEBUG)
       
    89 	__DbgChkRef(aRef);
       
    90 #endif
       
    91     }
       
    92 inline TBool TSwizzleCBase::operator==(const TSwizzleCBase& aSwizzle) const
       
    93 /** Compares for equality with another swizzle.
       
    94 
       
    95 Use this operator to determine whether this swizzle represents the same object 
       
    96 as that represented by the specified swizzle.
       
    97 
       
    98 Both this swizzle and the specified swizzle must maintain the representation 
       
    99 of their respective objects as either pointers or stream ids.
       
   100 
       
   101 If one swizzle maintains the representation of its object as a pointer while 
       
   102 the other swizzle maintains the representation of its object as a stream id, 
       
   103 the comparison is meaningless and always returns false.
       
   104 
       
   105 @param aSwizzle A reference to the swizzle to be compared with this swizzle.
       
   106 @return True, if the represented objects are the same; False, otherwise. */
       
   107 	{return iPtr==aSwizzle.iPtr;}
       
   108 inline TBool TSwizzleCBase::operator==(const TAny* aPtr) const
       
   109 /** Compares for equality with an in-memory object.
       
   110 
       
   111 Use this operator to determine whether this swizzle represents the same in-memory 
       
   112 object as that represented by the specified pointer.
       
   113 
       
   114 This swizzle must maintain the representation of its object as a pointer. 
       
   115 If it maintains the representation of its object as a swizzle, the comparison 
       
   116 is meaningless and always returns false.
       
   117 
       
   118 @param aPtr A pointer to the object to be compared with this swizzle.
       
   119 @return True, if the represented objects are the same; False, otherwise. */
       
   120 	{return iPtr==aPtr;}
       
   121 inline TBool TSwizzleCBase::operator!=(const TSwizzleCBase& aSwizzle) const
       
   122 /** Compares for inequality with another swizzle.
       
   123 
       
   124 Use this operator to determine whether this swizzle represents a different 
       
   125 object to that represented by the specified swizzle.
       
   126 
       
   127 Both this swizzle and the specified swizzle must maintain the representation 
       
   128 of their respective objects as either pointers or stream ids.
       
   129 
       
   130 If one swizzle maintains the representation of its object as a pointer while 
       
   131 the other swizzle maintains the representation of its object as a stream id, 
       
   132 the comparison is meaningless and always returns true.
       
   133 
       
   134 @param aSwizzle A reference to the swizzle to be compared with this swizzle.
       
   135 @return True, if the represented objects are not the same; False, otherwise */
       
   136 	{return iPtr!=aSwizzle.iPtr;}
       
   137 inline TBool TSwizzleCBase::operator!=(const TAny* aPtr) const
       
   138 /** Compares for inequality with an in-memory object.
       
   139 
       
   140 Use this operator to determine whether this swizzle represents a different 
       
   141 in-memory object to that represented by the specified pointer.
       
   142 
       
   143 This swizzle must maintain the representation of its object as a pointer. 
       
   144 If it maintains the representation of its object as a swizzle, the comparison 
       
   145 is meaningless and always returns true.
       
   146 
       
   147 @param aPtr A pointer to the object to be compared with this swizzle.
       
   148 @return True, if the represented objects are not the same; False, otherwise */
       
   149 	{return iPtr!=aPtr;}
       
   150 inline TBool TSwizzleCBase::IsPtr() const
       
   151 /** Tests whether this swizzle currently represents an object as a pointer.
       
   152 
       
   153 @return True, if this swizzle currently maintains the object representation 
       
   154 as a pointer; False, otherwise. Note that if the swizzle is uninitialised, 
       
   155 the value returned by this function is not defined. */
       
   156 	{return IsPtrRep(iPtr);}
       
   157 inline TBool TSwizzleCBase::IsId() const
       
   158 /** Tests whether this swizzle currently represents an object as a stream id.
       
   159 
       
   160 @return True, if this swizzle currently maintains the representation of the 
       
   161 object as a stream id; False, otherwise. Note that if the swizzle is uninitialised, 
       
   162 the value returned by this function is not defined. */
       
   163 	{return IsIdRep(iPtr);}
       
   164 inline TSwizzleCBase::TSwizzleCBase(const TAny* aPtr)
       
   165 	: iPtr(aPtr)
       
   166 	{
       
   167 #if defined (_DEBUG)
       
   168 	__DbgChkPtr(aPtr);
       
   169 #endif
       
   170     }
       
   171 inline const TAny* TSwizzleCBase::Ptr() const
       
   172 	{
       
   173 #if defined (_DEBUG)
       
   174 	__DbgChkPtr(iPtr);
       
   175 #endif
       
   176 	return iPtr;
       
   177 	}
       
   178 inline TBool operator==(const TAny* aPtr,const TSwizzleCBase& aSwizzle)
       
   179 	{return aSwizzle==aPtr;}
       
   180 inline TBool operator!=(const TAny* aPtr,const TSwizzleCBase& aSwizzle)
       
   181 	{return aSwizzle!=aPtr;}
       
   182 
       
   183 // Class TSwizzleBase
       
   184 inline TSwizzleBase::TSwizzleBase(TAny* aPtr)
       
   185 	: TSwizzleCBase(aPtr)
       
   186 	{}
       
   187 inline TSwizzleBase::TSwizzleBase(TStreamId anId)
       
   188 	: TSwizzleCBase(anId)
       
   189 	{}
       
   190 inline TAny* TSwizzleBase::Ptr() const
       
   191 	{return (TAny*)TSwizzleCBase::Ptr();}
       
   192 
       
   193 // Template class TSwizzle
       
   194 template <class T>
       
   195 inline TSwizzle<T>::TSwizzle(T* aPtr)
       
   196 	: TSwizzleBase(aPtr)
       
   197 /** Constructs a swizzle for a class T type object, represented by a pointer.
       
   198 
       
   199 @param aPtr A pointer to a class T type object. */
       
   200 	{}
       
   201 template <class T>
       
   202 inline TSwizzle<T>::TSwizzle(TStreamId anId)
       
   203 	: TSwizzleBase(anId)
       
   204 /** Constructs a swizzle for a class T type object, represented as a stream id.
       
   205 
       
   206 @param anId The id of a stream containing the external representation of a 
       
   207 class T type object. */
       
   208 	{}
       
   209 template <class T>
       
   210 inline TSwizzle<T>& TSwizzle<T>::operator=(T* aPtr)
       
   211 /** Sets this swizzle to represent the in-memory type T object, pointed to by the 
       
   212 specified T* pointer.
       
   213 
       
   214 @param aPtr A pointer to an object of type T which the swizzle is to represent.
       
   215 @return A reference to this swizzle representing the object of type T. */
       
   216 	{return *this=TSwizzle<T>(aPtr);}
       
   217 template <class T>
       
   218 inline T* TSwizzle<T>::AsPtr() const
       
   219 /** Returns a pointer to the object which this swizzle represents.
       
   220 
       
   221 Note that the indirect component selector operator->() can be used to access 
       
   222 members of the represented object.
       
   223 
       
   224 @return A pointer to the class T type object represented by this swizzle. */
       
   225 	{return (T*)Ptr();}
       
   226 template <class T>
       
   227 inline TSwizzle<T>::operator T*() const
       
   228 	{return AsPtr();}
       
   229 template <class T>
       
   230 inline T& TSwizzle<T>::operator*() const
       
   231 /** Returns a reference to the type T object which this swizzle represents.
       
   232 
       
   233 @return A reference to the type T object represented by this swizzle. */
       
   234 	{return *AsPtr();}
       
   235 template <class T>
       
   236 inline T* TSwizzle<T>::operator->() const
       
   237 /** Gives access to members of the type T object which this swizzle represents.
       
   238 
       
   239 Note, use the AsPtr() member function to return a pointer to the object itself.
       
   240 
       
   241 @return A pointer to the T type object; not explicitly accessible. */
       
   242 	{return AsPtr();}
       
   243 template <class T>
       
   244 inline void TSwizzle<T>::ExternalizeL(RWriteStream& aStream) const
       
   245 /** Externalises the stream id of the stream associated with this swizzle.
       
   246 
       
   247 This function presupposes that: 
       
   248 
       
   249 a store map, i.e. an object of type CStoreMap, has been constructed
       
   250 
       
   251 the id of the stream containing the external representation of the represented 
       
   252 type T object has been bound to this swizzle and added to the store map.
       
   253 
       
   254 the concrete stream referenced by aStream has been constructed, specifying 
       
   255 the store map as an externaliser.
       
   256 
       
   257 The presence of this function means that the standard templated operator<<() 
       
   258 can be used.
       
   259 
       
   260 @param aStream Stream to which the stream id should be externalised.
       
   261 @see CStoreMap */
       
   262 	{TSwizzleBase::DoExternalizeL(aStream,TExternalizer<T>::Function());}
       
   263 inline TSwizzle<TAny>::TSwizzle(TAny* aPtr)
       
   264 	: TSwizzleBase(aPtr)
       
   265 /** Constructs the swizzle representing the specified untyped object as a pointer.
       
   266 	
       
   267 @param aPtr A pointer to an untyped object which this swizzle is to represent. */
       
   268 	{}
       
   269 inline TSwizzle<TAny>::TSwizzle(TStreamId anId)
       
   270 	: TSwizzleBase(anId)
       
   271 /** Constructs the swizzle for an untyped object, represented as a stream id.
       
   272 	
       
   273 @param anId The id of a stream containing the external representation of the 
       
   274 	untyped object which this swizzle is to represent. */
       
   275 	{}
       
   276 inline TSwizzle<TAny>::TSwizzle(const TSwizzleBase& aSwizzle)
       
   277 	: TSwizzleBase(aSwizzle)
       
   278 /** Constructs the swizzle to represent the untyped object currently represented 
       
   279 	by the specified swizzle.
       
   280 	
       
   281 @param aSwizzle A reference to a swizzle whose representation of an object 
       
   282 	is to be copied to this swizzle */
       
   283 	{}
       
   284 inline TSwizzle<TAny>& TSwizzle<TAny>::operator=(TAny* aPtr)
       
   285 /** Sets this swizzle to represent the in-memory object, pointed to by the specified 
       
   286 	pointer.
       
   287 	
       
   288 @param aPtr A pointer to the untyped object which the swizzle is to represent.
       
   289 @return A reference to this swizzle. */
       
   290 	{return *this=TSwizzle<TAny>(aPtr);}
       
   291 inline TSwizzle<TAny>& TSwizzle<TAny>::operator=(const TSwizzleBase& aSwizzle)
       
   292 	/** Sets the swizzle to represent the untyped object currently represented by the 
       
   293 	specified swizzle.
       
   294 	
       
   295 	@param aSwizzle The swizzle whose representation of an object is to be copied 
       
   296 	to this swizzle.
       
   297 	@return A reference to this swizzle. */
       
   298 	{return *this=TSwizzle<TAny>(aSwizzle);}
       
   299 inline TAny* TSwizzle<TAny>::AsPtr() const
       
   300 /** Returns a pointer to the untyped object that this swizzle represents.
       
   301 	
       
   302 	@return A pointer to the untyped object represented by this swizzle. */
       
   303 	{return Ptr();}
       
   304 inline TSwizzle<TAny>::operator TAny*() const
       
   305 	{return AsPtr();}
       
   306 
       
   307 // Template class TSwizzleC
       
   308 template <class T>
       
   309 inline TSwizzleC<T>::TSwizzleC(const T* aPtr)
       
   310 	: TSwizzleCBase(aPtr)
       
   311 /** Constructs a swizzle for a class T type object and represents the object by 
       
   312 pointer.
       
   313 
       
   314 @param aPtr A pointer to a class T type object. */
       
   315 	{}
       
   316 template <class T>
       
   317 inline TSwizzleC<T>::TSwizzleC(TStreamId anId)
       
   318 	: TSwizzleCBase(anId)
       
   319 /** Constructs a swizzle for a class T type object and represents the object as 
       
   320 a stream id.
       
   321 
       
   322 @param anId The stream id of a stream containing the external representation 
       
   323 of an object of type class T. */
       
   324 	{}
       
   325 template <class T>
       
   326 inline TSwizzleC<T>::TSwizzleC(TSwizzle<T> aSwizzle)
       
   327 	: TSwizzleCBase(aSwizzle)
       
   328 /** Constructs a swizzle for a class T type object that is currently represented 
       
   329 by another swizzle.
       
   330 
       
   331 The representation of the class T type object is the same as its representation 
       
   332 by the specified swizzle, i.e. if the specified swizzle represents the object 
       
   333 as a pointer, then this newly constructed swizzle also represents the object 
       
   334 as a pointer.
       
   335 
       
   336 @param aSwizzle The swizzle whose representation of the class T type object 
       
   337 is to be copied to this swizzle. */
       
   338 	{}
       
   339 template <class T>
       
   340 inline TSwizzleC<T>& TSwizzleC<T>::operator=(const T* aPtr)
       
   341 /** Sets this swizzle to represent the in-memory type T object, pointed to by the 
       
   342 specified T* pointer.
       
   343 
       
   344 @param aPtr A pointer to an object of type T which the swizzle is to represent.
       
   345 @return A reference to this swizzle representing the object of type T.
       
   346 @see TSwizzle::operator=() */
       
   347 	{return *this=TSwizzleC<T>(aPtr);}
       
   348 template <class T>
       
   349 inline const T* TSwizzleC<T>::AsPtr() const
       
   350 /** Returns a constant pointer to the object which this swizzle represents.
       
   351 
       
   352 Note:
       
   353 
       
   354 The in memory object cannot be changed through this swizzle.
       
   355 
       
   356 To access members of the object, the indirect component selector operator->() 
       
   357 can be used.
       
   358 
       
   359 @return A const pointer to the class T type object represented by this swizzle. */
       
   360 	{return (const T*)Ptr();}
       
   361 template <class T>
       
   362 inline TSwizzleC<T>::operator const T*() const
       
   363 	{return AsPtr();}
       
   364 template <class T>
       
   365 inline const T& TSwizzleC<T>::operator*() const
       
   366 /** Returns a const reference to the type T object which this swizzle represents.
       
   367 
       
   368 @return A const reference to the type T object represented by this swizzle.
       
   369 @see TSwizzle::operator*() */
       
   370 	{return *AsPtr();}
       
   371 template <class T>
       
   372 inline const T* TSwizzleC<T>::operator->() const
       
   373 /** Gives access to members of the type T object which this swizzle represents.
       
   374 
       
   375 Note:
       
   376 
       
   377 use the AsPtr() member function to return a pointer to the object itself.
       
   378 
       
   379 the type T object cannot be changed through this operator.
       
   380 
       
   381 @return A const pointer to the T type object; not explicitly accessible.
       
   382 @see TSwizzle::operator->() */
       
   383 	{return AsPtr();}
       
   384 template <class T>
       
   385 inline void TSwizzleC<T>::ExternalizeL(RWriteStream& aStream) const
       
   386 /** Externalises the stream id of the stream associated with this swizzle.
       
   387 
       
   388 This function presupposes that: 
       
   389 
       
   390 a store map, i.e. an object of type CStoreMap, has been constructed
       
   391 
       
   392 the id of the stream containing the external representation of the <class T> 
       
   393 object has been bound to this swizzle and added to the store map.
       
   394 
       
   395 the concrete stream referenced by aStream has been constructed, specifying 
       
   396 the store map as an externalizer.
       
   397 
       
   398 The presence of this function means that the standard templated operator<<() 
       
   399 can be used.
       
   400 
       
   401 @param aStream Stream to which the stream id should be externalised
       
   402 @see CStoreMap */
       
   403 	{TSwizzleCBase::DoExternalizeL(aStream,TExternalizer<T>::Function());}
       
   404 inline TSwizzleC<TAny>::TSwizzleC(const TAny* aPtr)
       
   405 	: TSwizzleCBase(aPtr)
       
   406 /** Constructs the swizzle representing the specified untyped object as a pointer.
       
   407 	
       
   408 @param aPtr A pointer to an untyped object which this swizzle is to represent. */
       
   409 	{}
       
   410 inline TSwizzleC<TAny>::TSwizzleC(TStreamId anId)
       
   411 	: TSwizzleCBase(anId)
       
   412 /** Constructs the swizzle for an untyped object, represented as a stream id.
       
   413 	
       
   414 @param anId The id of a stream containing the external representation of the 
       
   415 	untyped object which this swizzle is to represent. */
       
   416 	{}
       
   417 inline TSwizzleC<TAny>::TSwizzleC(const TSwizzleCBase& aSwizzle)
       
   418 	: TSwizzleCBase(aSwizzle)
       
   419 /** Constructs the swizzle to represent the untyped object currently represented 
       
   420 	by the specified swizzle.
       
   421 	
       
   422 @param aSwizzle The swizzle whose representation of an object is to be copied 
       
   423 	to this swizzle. */
       
   424 	{}
       
   425 inline TSwizzleC<TAny>::TSwizzleC(TStreamRef aRef)
       
   426 	: TSwizzleCBase(aRef)
       
   427 /** Constructs the swizzle from a stream reference.
       
   428 	
       
   429 @param aRef The stream reference. */
       
   430  	{}
       
   431 inline TSwizzleC<TAny>& TSwizzleC<TAny>::operator=(const TAny* aPtr)
       
   432 /** Sets this swizzle to represent the specified in-memory untyped object.
       
   433 	
       
   434 @param aPtr A pointer to the untyped object that the swizzle is to represent.
       
   435 @return A reference to this swizzle representing the untyped object. */
       
   436 	{return *this=TSwizzleC<TAny>(aPtr);}
       
   437 inline TSwizzleC<TAny>& TSwizzleC<TAny>::operator=(const TSwizzleCBase& aSwizzle)
       
   438 /** Sets this swizzle to represent the untyped object currently represented by the 
       
   439 	specific swizzle.
       
   440 	
       
   441 @param aSwizzle A pointer to the untyped object that the swizzle is to represent.
       
   442 @return A reference to a swizzle whose representation of an object is to be 
       
   443 	copied to this swizzle. */
       
   444 	{return *this=TSwizzleC<TAny>(aSwizzle);}
       
   445 inline const TAny* TSwizzleC<TAny>::AsPtr() const
       
   446 /** Gets a constant pointer to the untyped object that this swizzle represents.
       
   447 	
       
   448 @return A const pointer to the untyped object represented by this swizzle. */
       
   449 	{return Ptr();}
       
   450 inline TSwizzleC<TAny>::operator const TAny*() const
       
   451 	{return AsPtr();}