williamr@2: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: // Class TStreamId williamr@2: inline TStreamId::TStreamId(TUint32 aValue) williamr@2: : iVal(aValue) williamr@2: /** Constructs the object with the specified stream ID value. williamr@2: williamr@2: Users of stores do not normally use this function. williamr@2: williamr@2: In debug mode, the function checks that the supplied stream ID value is not williamr@2: greater than the maximum permitted value, and raises a STORE-Store 2 panic williamr@2: if it is. In release mode, no checking on the supplied value is done. williamr@2: williamr@2: The checking of the supplied value is done by a private function implemented williamr@2: in estor. dll. This means that in debug mode, a call is made into estor.dll, williamr@2: but in release mode it is not. williamr@2: williamr@2: @param aValue The stream ID value. */ williamr@2: { williamr@2: #if defined (_DEBUG) williamr@2: __DbgChkRange(aValue); williamr@2: #endif williamr@2: } williamr@2: inline TBool TStreamId::operator==(TStreamId anId) const williamr@2: /** Equality comparison operator. Use this operator to determine whether this stream williamr@2: id is equal to the specified stream id. williamr@2: williamr@2: @param anId The stream id to be compared with this stream id. williamr@2: @return True, if the stream ids are equal; false otherwise */ williamr@2: {return iVal==anId.iVal;} williamr@2: inline TBool TStreamId::operator!=(TStreamId anId) const williamr@2: /** Inequality comparison operator. Use this operator to determine whether this williamr@2: stream id is unequal to the specified stream id. williamr@2: williamr@2: @param anId The stream id to be compared with this stream id. williamr@2: @return True, if the two stream ids are unequal, false otherwise. */ williamr@2: {return iVal!=anId.iVal;} williamr@2: inline void TStreamId::ExternalizeL(RWriteStream& aStream) const williamr@2: /** Externalises an object of this class to a write stream. williamr@2: williamr@2: The presence of this function means that the standard templated operator<<() williamr@2: can be used to externalise objects of this class. williamr@2: williamr@2: @param aStream Stream to which the object should be externalised. */ williamr@2: { williamr@2: #if defined (_DEBUG) williamr@2: __DbgChkRange(iVal); williamr@2: #endif williamr@2: aStream<& anExter) williamr@2: : RWriteStream(anExter) williamr@2: /** Constructs an object with an externaliser. The store map CStoreMap is an example williamr@2: of an externalizer. williamr@2: williamr@2: @param anExter Specifies an externaliser */ williamr@2: {} williamr@2: williamr@2: // Class TSwizzleCBase williamr@2: inline TSwizzleCBase::TSwizzleCBase(TStreamRef aRef) williamr@2: : iPtr(aRef.Ptr()) williamr@2: { williamr@2: #if defined (_DEBUG) williamr@2: __DbgChkRef(aRef); williamr@2: #endif williamr@2: } williamr@2: inline TBool TSwizzleCBase::operator==(const TSwizzleCBase& aSwizzle) const williamr@2: /** Compares for equality with another swizzle. williamr@2: williamr@2: Use this operator to determine whether this swizzle represents the same object williamr@2: as that represented by the specified swizzle. williamr@2: williamr@2: Both this swizzle and the specified swizzle must maintain the representation williamr@2: of their respective objects as either pointers or stream ids. williamr@2: williamr@2: If one swizzle maintains the representation of its object as a pointer while williamr@2: the other swizzle maintains the representation of its object as a stream id, williamr@2: the comparison is meaningless and always returns false. williamr@2: williamr@2: @param aSwizzle A reference to the swizzle to be compared with this swizzle. williamr@2: @return True, if the represented objects are the same; False, otherwise. */ williamr@2: {return iPtr==aSwizzle.iPtr;} williamr@2: inline TBool TSwizzleCBase::operator==(const TAny* aPtr) const williamr@2: /** Compares for equality with an in-memory object. williamr@2: williamr@2: Use this operator to determine whether this swizzle represents the same in-memory williamr@2: object as that represented by the specified pointer. williamr@2: williamr@2: This swizzle must maintain the representation of its object as a pointer. williamr@2: If it maintains the representation of its object as a swizzle, the comparison williamr@2: is meaningless and always returns false. williamr@2: williamr@2: @param aPtr A pointer to the object to be compared with this swizzle. williamr@2: @return True, if the represented objects are the same; False, otherwise. */ williamr@2: {return iPtr==aPtr;} williamr@2: inline TBool TSwizzleCBase::operator!=(const TSwizzleCBase& aSwizzle) const williamr@2: /** Compares for inequality with another swizzle. williamr@2: williamr@2: Use this operator to determine whether this swizzle represents a different williamr@2: object to that represented by the specified swizzle. williamr@2: williamr@2: Both this swizzle and the specified swizzle must maintain the representation williamr@2: of their respective objects as either pointers or stream ids. williamr@2: williamr@2: If one swizzle maintains the representation of its object as a pointer while williamr@2: the other swizzle maintains the representation of its object as a stream id, williamr@2: the comparison is meaningless and always returns true. williamr@2: williamr@2: @param aSwizzle A reference to the swizzle to be compared with this swizzle. williamr@2: @return True, if the represented objects are not the same; False, otherwise */ williamr@2: {return iPtr!=aSwizzle.iPtr;} williamr@2: inline TBool TSwizzleCBase::operator!=(const TAny* aPtr) const williamr@2: /** Compares for inequality with an in-memory object. williamr@2: williamr@2: Use this operator to determine whether this swizzle represents a different williamr@2: in-memory object to that represented by the specified pointer. williamr@2: williamr@2: This swizzle must maintain the representation of its object as a pointer. williamr@2: If it maintains the representation of its object as a swizzle, the comparison williamr@2: is meaningless and always returns true. williamr@2: williamr@2: @param aPtr A pointer to the object to be compared with this swizzle. williamr@2: @return True, if the represented objects are not the same; False, otherwise */ williamr@2: {return iPtr!=aPtr;} williamr@2: inline TBool TSwizzleCBase::IsPtr() const williamr@2: /** Tests whether this swizzle currently represents an object as a pointer. williamr@2: williamr@2: @return True, if this swizzle currently maintains the object representation williamr@2: as a pointer; False, otherwise. Note that if the swizzle is uninitialised, williamr@2: the value returned by this function is not defined. */ williamr@2: {return IsPtrRep(iPtr);} williamr@2: inline TBool TSwizzleCBase::IsId() const williamr@2: /** Tests whether this swizzle currently represents an object as a stream id. williamr@2: williamr@2: @return True, if this swizzle currently maintains the representation of the williamr@2: object as a stream id; False, otherwise. Note that if the swizzle is uninitialised, williamr@2: the value returned by this function is not defined. */ williamr@2: {return IsIdRep(iPtr);} williamr@2: inline TSwizzleCBase::TSwizzleCBase(const TAny* aPtr) williamr@2: : iPtr(aPtr) williamr@2: { williamr@2: #if defined (_DEBUG) williamr@2: __DbgChkPtr(aPtr); williamr@2: #endif williamr@2: } williamr@2: inline const TAny* TSwizzleCBase::Ptr() const williamr@2: { williamr@2: #if defined (_DEBUG) williamr@2: __DbgChkPtr(iPtr); williamr@2: #endif williamr@2: return iPtr; williamr@2: } williamr@2: inline TBool operator==(const TAny* aPtr,const TSwizzleCBase& aSwizzle) williamr@2: {return aSwizzle==aPtr;} williamr@2: inline TBool operator!=(const TAny* aPtr,const TSwizzleCBase& aSwizzle) williamr@2: {return aSwizzle!=aPtr;} williamr@2: williamr@2: // Class TSwizzleBase williamr@2: inline TSwizzleBase::TSwizzleBase(TAny* aPtr) williamr@2: : TSwizzleCBase(aPtr) williamr@2: {} williamr@2: inline TSwizzleBase::TSwizzleBase(TStreamId anId) williamr@2: : TSwizzleCBase(anId) williamr@2: {} williamr@2: inline TAny* TSwizzleBase::Ptr() const williamr@2: {return (TAny*)TSwizzleCBase::Ptr();} williamr@2: williamr@2: // Template class TSwizzle williamr@2: template williamr@2: inline TSwizzle::TSwizzle(T* aPtr) williamr@2: : TSwizzleBase(aPtr) williamr@2: /** Constructs a swizzle for a class T type object, represented by a pointer. williamr@2: williamr@2: @param aPtr A pointer to a class T type object. */ williamr@2: {} williamr@2: template williamr@2: inline TSwizzle::TSwizzle(TStreamId anId) williamr@2: : TSwizzleBase(anId) williamr@2: /** Constructs a swizzle for a class T type object, represented as a stream id. williamr@2: williamr@2: @param anId The id of a stream containing the external representation of a williamr@2: class T type object. */ williamr@2: {} williamr@2: template williamr@2: inline TSwizzle& TSwizzle::operator=(T* aPtr) williamr@2: /** Sets this swizzle to represent the in-memory type T object, pointed to by the williamr@2: specified T* pointer. williamr@2: williamr@2: @param aPtr A pointer to an object of type T which the swizzle is to represent. williamr@2: @return A reference to this swizzle representing the object of type T. */ williamr@2: {return *this=TSwizzle(aPtr);} williamr@2: template williamr@2: inline T* TSwizzle::AsPtr() const williamr@2: /** Returns a pointer to the object which this swizzle represents. williamr@2: williamr@2: Note that the indirect component selector operator->() can be used to access williamr@2: members of the represented object. williamr@2: williamr@2: @return A pointer to the class T type object represented by this swizzle. */ williamr@2: {return (T*)Ptr();} williamr@2: template williamr@2: inline TSwizzle::operator T*() const williamr@2: {return AsPtr();} williamr@2: template williamr@2: inline T& TSwizzle::operator*() const williamr@2: /** Returns a reference to the type T object which this swizzle represents. williamr@2: williamr@2: @return A reference to the type T object represented by this swizzle. */ williamr@2: {return *AsPtr();} williamr@2: template williamr@2: inline T* TSwizzle::operator->() const williamr@2: /** Gives access to members of the type T object which this swizzle represents. williamr@2: williamr@2: Note, use the AsPtr() member function to return a pointer to the object itself. williamr@2: williamr@2: @return A pointer to the T type object; not explicitly accessible. */ williamr@2: {return AsPtr();} williamr@2: template williamr@2: inline void TSwizzle::ExternalizeL(RWriteStream& aStream) const williamr@2: /** Externalises the stream id of the stream associated with this swizzle. williamr@2: williamr@2: This function presupposes that: williamr@2: williamr@2: a store map, i.e. an object of type CStoreMap, has been constructed williamr@2: williamr@2: the id of the stream containing the external representation of the represented williamr@2: type T object has been bound to this swizzle and added to the store map. williamr@2: williamr@2: the concrete stream referenced by aStream has been constructed, specifying williamr@2: the store map as an externaliser. williamr@2: williamr@2: The presence of this function means that the standard templated operator<<() williamr@2: can be used. williamr@2: williamr@2: @param aStream Stream to which the stream id should be externalised. williamr@2: @see CStoreMap */ williamr@2: {TSwizzleBase::DoExternalizeL(aStream,TExternalizer::Function());} williamr@2: inline TSwizzle::TSwizzle(TAny* aPtr) williamr@2: : TSwizzleBase(aPtr) williamr@2: /** Constructs the swizzle representing the specified untyped object as a pointer. williamr@2: williamr@2: @param aPtr A pointer to an untyped object which this swizzle is to represent. */ williamr@2: {} williamr@2: inline TSwizzle::TSwizzle(TStreamId anId) williamr@2: : TSwizzleBase(anId) williamr@2: /** Constructs the swizzle for an untyped object, represented as a stream id. williamr@2: williamr@2: @param anId The id of a stream containing the external representation of the williamr@2: untyped object which this swizzle is to represent. */ williamr@2: {} williamr@2: inline TSwizzle::TSwizzle(const TSwizzleBase& aSwizzle) williamr@2: : TSwizzleBase(aSwizzle) williamr@2: /** Constructs the swizzle to represent the untyped object currently represented williamr@2: by the specified swizzle. williamr@2: williamr@2: @param aSwizzle A reference to a swizzle whose representation of an object williamr@2: is to be copied to this swizzle */ williamr@2: {} williamr@2: inline TSwizzle& TSwizzle::operator=(TAny* aPtr) williamr@2: /** Sets this swizzle to represent the in-memory object, pointed to by the specified williamr@2: pointer. williamr@2: williamr@2: @param aPtr A pointer to the untyped object which the swizzle is to represent. williamr@2: @return A reference to this swizzle. */ williamr@2: {return *this=TSwizzle(aPtr);} williamr@2: inline TSwizzle& TSwizzle::operator=(const TSwizzleBase& aSwizzle) williamr@2: /** Sets the swizzle to represent the untyped object currently represented by the williamr@2: specified swizzle. williamr@2: williamr@2: @param aSwizzle The swizzle whose representation of an object is to be copied williamr@2: to this swizzle. williamr@2: @return A reference to this swizzle. */ williamr@2: {return *this=TSwizzle(aSwizzle);} williamr@2: inline TAny* TSwizzle::AsPtr() const williamr@2: /** Returns a pointer to the untyped object that this swizzle represents. williamr@2: williamr@2: @return A pointer to the untyped object represented by this swizzle. */ williamr@2: {return Ptr();} williamr@2: inline TSwizzle::operator TAny*() const williamr@2: {return AsPtr();} williamr@2: williamr@2: // Template class TSwizzleC williamr@2: template williamr@2: inline TSwizzleC::TSwizzleC(const T* aPtr) williamr@2: : TSwizzleCBase(aPtr) williamr@2: /** Constructs a swizzle for a class T type object and represents the object by williamr@2: pointer. williamr@2: williamr@2: @param aPtr A pointer to a class T type object. */ williamr@2: {} williamr@2: template williamr@2: inline TSwizzleC::TSwizzleC(TStreamId anId) williamr@2: : TSwizzleCBase(anId) williamr@2: /** Constructs a swizzle for a class T type object and represents the object as williamr@2: a stream id. williamr@2: williamr@2: @param anId The stream id of a stream containing the external representation williamr@2: of an object of type class T. */ williamr@2: {} williamr@2: template williamr@2: inline TSwizzleC::TSwizzleC(TSwizzle aSwizzle) williamr@2: : TSwizzleCBase(aSwizzle) williamr@2: /** Constructs a swizzle for a class T type object that is currently represented williamr@2: by another swizzle. williamr@2: williamr@2: The representation of the class T type object is the same as its representation williamr@2: by the specified swizzle, i.e. if the specified swizzle represents the object williamr@2: as a pointer, then this newly constructed swizzle also represents the object williamr@2: as a pointer. williamr@2: williamr@2: @param aSwizzle The swizzle whose representation of the class T type object williamr@2: is to be copied to this swizzle. */ williamr@2: {} williamr@2: template williamr@2: inline TSwizzleC& TSwizzleC::operator=(const T* aPtr) williamr@2: /** Sets this swizzle to represent the in-memory type T object, pointed to by the williamr@2: specified T* pointer. williamr@2: williamr@2: @param aPtr A pointer to an object of type T which the swizzle is to represent. williamr@2: @return A reference to this swizzle representing the object of type T. williamr@2: @see TSwizzle::operator=() */ williamr@2: {return *this=TSwizzleC(aPtr);} williamr@2: template williamr@2: inline const T* TSwizzleC::AsPtr() const williamr@2: /** Returns a constant pointer to the object which this swizzle represents. williamr@2: williamr@2: Note: williamr@2: williamr@2: The in memory object cannot be changed through this swizzle. williamr@2: williamr@2: To access members of the object, the indirect component selector operator->() williamr@2: can be used. williamr@2: williamr@2: @return A const pointer to the class T type object represented by this swizzle. */ williamr@2: {return (const T*)Ptr();} williamr@2: template williamr@2: inline TSwizzleC::operator const T*() const williamr@2: {return AsPtr();} williamr@2: template williamr@2: inline const T& TSwizzleC::operator*() const williamr@2: /** Returns a const reference to the type T object which this swizzle represents. williamr@2: williamr@2: @return A const reference to the type T object represented by this swizzle. williamr@2: @see TSwizzle::operator*() */ williamr@2: {return *AsPtr();} williamr@2: template williamr@2: inline const T* TSwizzleC::operator->() const williamr@2: /** Gives access to members of the type T object which this swizzle represents. williamr@2: williamr@2: Note: williamr@2: williamr@2: use the AsPtr() member function to return a pointer to the object itself. williamr@2: williamr@2: the type T object cannot be changed through this operator. williamr@2: williamr@2: @return A const pointer to the T type object; not explicitly accessible. williamr@2: @see TSwizzle::operator->() */ williamr@2: {return AsPtr();} williamr@2: template williamr@2: inline void TSwizzleC::ExternalizeL(RWriteStream& aStream) const williamr@2: /** Externalises the stream id of the stream associated with this swizzle. williamr@2: williamr@2: This function presupposes that: williamr@2: williamr@2: a store map, i.e. an object of type CStoreMap, has been constructed williamr@2: williamr@2: the id of the stream containing the external representation of the williamr@2: object has been bound to this swizzle and added to the store map. williamr@2: williamr@2: the concrete stream referenced by aStream has been constructed, specifying williamr@2: the store map as an externalizer. williamr@2: williamr@2: The presence of this function means that the standard templated operator<<() williamr@2: can be used. williamr@2: williamr@2: @param aStream Stream to which the stream id should be externalised williamr@2: @see CStoreMap */ williamr@2: {TSwizzleCBase::DoExternalizeL(aStream,TExternalizer::Function());} williamr@2: inline TSwizzleC::TSwizzleC(const TAny* aPtr) williamr@2: : TSwizzleCBase(aPtr) williamr@2: /** Constructs the swizzle representing the specified untyped object as a pointer. williamr@2: williamr@2: @param aPtr A pointer to an untyped object which this swizzle is to represent. */ williamr@2: {} williamr@2: inline TSwizzleC::TSwizzleC(TStreamId anId) williamr@2: : TSwizzleCBase(anId) williamr@2: /** Constructs the swizzle for an untyped object, represented as a stream id. williamr@2: williamr@2: @param anId The id of a stream containing the external representation of the williamr@2: untyped object which this swizzle is to represent. */ williamr@2: {} williamr@2: inline TSwizzleC::TSwizzleC(const TSwizzleCBase& aSwizzle) williamr@2: : TSwizzleCBase(aSwizzle) williamr@2: /** Constructs the swizzle to represent the untyped object currently represented williamr@2: by the specified swizzle. williamr@2: williamr@2: @param aSwizzle The swizzle whose representation of an object is to be copied williamr@2: to this swizzle. */ williamr@2: {} williamr@2: inline TSwizzleC::TSwizzleC(TStreamRef aRef) williamr@2: : TSwizzleCBase(aRef) williamr@2: /** Constructs the swizzle from a stream reference. williamr@2: williamr@2: @param aRef The stream reference. */ williamr@2: {} williamr@2: inline TSwizzleC& TSwizzleC::operator=(const TAny* aPtr) williamr@2: /** Sets this swizzle to represent the specified in-memory untyped object. williamr@2: williamr@2: @param aPtr A pointer to the untyped object that the swizzle is to represent. williamr@2: @return A reference to this swizzle representing the untyped object. */ williamr@2: {return *this=TSwizzleC(aPtr);} williamr@2: inline TSwizzleC& TSwizzleC::operator=(const TSwizzleCBase& aSwizzle) williamr@2: /** Sets this swizzle to represent the untyped object currently represented by the williamr@2: specific swizzle. williamr@2: williamr@2: @param aSwizzle A pointer to the untyped object that the swizzle is to represent. williamr@2: @return A reference to a swizzle whose representation of an object is to be williamr@2: copied to this swizzle. */ williamr@2: {return *this=TSwizzleC(aSwizzle);} williamr@2: inline const TAny* TSwizzleC::AsPtr() const williamr@2: /** Gets a constant pointer to the untyped object that this swizzle represents. williamr@2: williamr@2: @return A const pointer to the untyped object represented by this swizzle. */ williamr@2: {return Ptr();} williamr@2: inline TSwizzleC::operator const TAny*() const williamr@2: {return AsPtr();}