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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 inline TStreamId::TStreamId(TUint32 aValue)
19 /** Constructs the object with the specified stream ID value.
21 Users of stores do not normally use this function.
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.
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.
31 @param aValue The stream ID value. */
34 __DbgChkRange(aValue);
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.
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.
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.
54 The presence of this function means that the standard templated operator<<()
55 can be used to externalise objects of this class.
57 @param aStream Stream to which the object should be externalised. */
64 inline TUint32 TStreamId::Value() const
65 /** Gets the stream ID value encapsulated by this object.
67 @return The stream ID value. */
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
81 @param anExter Specifies an externaliser */
84 // Class TSwizzleCBase
85 inline TSwizzleCBase::TSwizzleCBase(TStreamRef aRef)
92 inline TBool TSwizzleCBase::operator==(const TSwizzleCBase& aSwizzle) const
93 /** Compares for equality with another swizzle.
95 Use this operator to determine whether this swizzle represents the same object
96 as that represented by the specified swizzle.
98 Both this swizzle and the specified swizzle must maintain the representation
99 of their respective objects as either pointers or stream ids.
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.
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.
111 Use this operator to determine whether this swizzle represents the same in-memory
112 object as that represented by the specified pointer.
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.
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. */
121 inline TBool TSwizzleCBase::operator!=(const TSwizzleCBase& aSwizzle) const
122 /** Compares for inequality with another swizzle.
124 Use this operator to determine whether this swizzle represents a different
125 object to that represented by the specified swizzle.
127 Both this swizzle and the specified swizzle must maintain the representation
128 of their respective objects as either pointers or stream ids.
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.
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.
140 Use this operator to determine whether this swizzle represents a different
141 in-memory object to that represented by the specified pointer.
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.
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 */
150 inline TBool TSwizzleCBase::IsPtr() const
151 /** Tests whether this swizzle currently represents an object as a pointer.
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.
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)
171 inline const TAny* TSwizzleCBase::Ptr() const
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;}
183 // Class TSwizzleBase
184 inline TSwizzleBase::TSwizzleBase(TAny* aPtr)
185 : TSwizzleCBase(aPtr)
187 inline TSwizzleBase::TSwizzleBase(TStreamId anId)
188 : TSwizzleCBase(anId)
190 inline TAny* TSwizzleBase::Ptr() const
191 {return (TAny*)TSwizzleCBase::Ptr();}
193 // Template class TSwizzle
195 inline TSwizzle<T>::TSwizzle(T* aPtr)
197 /** Constructs a swizzle for a class T type object, represented by a pointer.
199 @param aPtr A pointer to a class T type object. */
202 inline TSwizzle<T>::TSwizzle(TStreamId anId)
204 /** Constructs a swizzle for a class T type object, represented as a stream id.
206 @param anId The id of a stream containing the external representation of a
207 class T type object. */
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.
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);}
218 inline T* TSwizzle<T>::AsPtr() const
219 /** Returns a pointer to the object which this swizzle represents.
221 Note that the indirect component selector operator->() can be used to access
222 members of the represented object.
224 @return A pointer to the class T type object represented by this swizzle. */
227 inline TSwizzle<T>::operator T*() const
230 inline T& TSwizzle<T>::operator*() const
231 /** Returns a reference to the type T object which this swizzle represents.
233 @return A reference to the type T object represented by this swizzle. */
236 inline T* TSwizzle<T>::operator->() const
237 /** Gives access to members of the type T object which this swizzle represents.
239 Note, use the AsPtr() member function to return a pointer to the object itself.
241 @return A pointer to the T type object; not explicitly accessible. */
244 inline void TSwizzle<T>::ExternalizeL(RWriteStream& aStream) const
245 /** Externalises the stream id of the stream associated with this swizzle.
247 This function presupposes that:
249 a store map, i.e. an object of type CStoreMap, has been constructed
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.
254 the concrete stream referenced by aStream has been constructed, specifying
255 the store map as an externaliser.
257 The presence of this function means that the standard templated operator<<()
260 @param aStream Stream to which the stream id should be externalised.
262 {TSwizzleBase::DoExternalizeL(aStream,TExternalizer<T>::Function());}
263 inline TSwizzle<TAny>::TSwizzle(TAny* aPtr)
265 /** Constructs the swizzle representing the specified untyped object as a pointer.
267 @param aPtr A pointer to an untyped object which this swizzle is to represent. */
269 inline TSwizzle<TAny>::TSwizzle(TStreamId anId)
271 /** Constructs the swizzle for an untyped object, represented as a stream id.
273 @param anId The id of a stream containing the external representation of the
274 untyped object which this swizzle is to represent. */
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.
281 @param aSwizzle A reference to a swizzle whose representation of an object
282 is to be copied to this swizzle */
284 inline TSwizzle<TAny>& TSwizzle<TAny>::operator=(TAny* aPtr)
285 /** Sets this swizzle to represent the in-memory object, pointed to by the specified
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
295 @param aSwizzle The swizzle whose representation of an object is to be copied
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.
302 @return A pointer to the untyped object represented by this swizzle. */
304 inline TSwizzle<TAny>::operator TAny*() const
307 // Template class TSwizzleC
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
314 @param aPtr A pointer to a class T type object. */
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
322 @param anId The stream id of a stream containing the external representation
323 of an object of type 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
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
336 @param aSwizzle The swizzle whose representation of the class T type object
337 is to be copied to this swizzle. */
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.
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);}
349 inline const T* TSwizzleC<T>::AsPtr() const
350 /** Returns a constant pointer to the object which this swizzle represents.
354 The in memory object cannot be changed through this swizzle.
356 To access members of the object, the indirect component selector operator->()
359 @return A const pointer to the class T type object represented by this swizzle. */
360 {return (const T*)Ptr();}
362 inline TSwizzleC<T>::operator const T*() const
365 inline const T& TSwizzleC<T>::operator*() const
366 /** Returns a const reference to the type T object which this swizzle represents.
368 @return A const reference to the type T object represented by this swizzle.
369 @see TSwizzle::operator*() */
372 inline const T* TSwizzleC<T>::operator->() const
373 /** Gives access to members of the type T object which this swizzle represents.
377 use the AsPtr() member function to return a pointer to the object itself.
379 the type T object cannot be changed through this operator.
381 @return A const pointer to the T type object; not explicitly accessible.
382 @see TSwizzle::operator->() */
385 inline void TSwizzleC<T>::ExternalizeL(RWriteStream& aStream) const
386 /** Externalises the stream id of the stream associated with this swizzle.
388 This function presupposes that:
390 a store map, i.e. an object of type CStoreMap, has been constructed
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.
395 the concrete stream referenced by aStream has been constructed, specifying
396 the store map as an externalizer.
398 The presence of this function means that the standard templated operator<<()
401 @param aStream Stream to which the stream id should be externalised
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.
408 @param aPtr A pointer to an untyped object which this swizzle is to represent. */
410 inline TSwizzleC<TAny>::TSwizzleC(TStreamId anId)
411 : TSwizzleCBase(anId)
412 /** Constructs the swizzle for an untyped object, represented as a stream id.
414 @param anId The id of a stream containing the external representation of the
415 untyped object which this swizzle is to represent. */
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.
422 @param aSwizzle The swizzle whose representation of an object is to be copied
425 inline TSwizzleC<TAny>::TSwizzleC(TStreamRef aRef)
426 : TSwizzleCBase(aRef)
427 /** Constructs the swizzle from a stream reference.
429 @param aRef The stream reference. */
431 inline TSwizzleC<TAny>& TSwizzleC<TAny>::operator=(const TAny* aPtr)
432 /** Sets this swizzle to represent the specified in-memory untyped object.
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
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.
448 @return A const pointer to the untyped object represented by this swizzle. */
450 inline TSwizzleC<TAny>::operator const TAny*() const