sl@0: // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\e32cmn.inl sl@0: // sl@0: // sl@0: sl@0: #ifndef __PLACEMENT_NEW_INLINE sl@0: #define __PLACEMENT_NEW_INLINE sl@0: // Global placement operator new sl@0: inline TAny* operator new(TUint /*aSize*/, TAny* aBase) __NO_THROW sl@0: {return aBase;} sl@0: sl@0: // Global placement operator delete sl@0: inline void operator delete(TAny* /*aPtr*/, TAny* /*aBase*/) __NO_THROW sl@0: {} sl@0: #endif //__PLACEMENT_NEW_INLINE sl@0: sl@0: #ifndef __PLACEMENT_VEC_NEW_INLINE sl@0: #define __PLACEMENT_VEC_NEW_INLINE sl@0: // Global placement operator new[] sl@0: inline TAny* operator new[](TUint /*aSize*/, TAny* aBase) __NO_THROW sl@0: {return aBase;} sl@0: sl@0: // Global placement operator delete[] sl@0: inline void operator delete[](TAny* /*aPtr*/, TAny* /*aBase*/) __NO_THROW sl@0: {} sl@0: #endif //__PLACEMENT_VEC_NEW_INLINE sl@0: sl@0: sl@0: // class RAllocator sl@0: inline RAllocator::RAllocator() sl@0: { sl@0: iAccessCount=1; sl@0: iHandleCount=0; sl@0: iHandles=0; sl@0: iFlags=0; sl@0: iCellCount=0; sl@0: iTotalAllocSize=0; sl@0: } sl@0: inline void RAllocator::__DbgMarkCheck(TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum) sl@0: {__DbgMarkCheck(aCountAll, aCount, TPtrC8(aFileName), aLineNum);} sl@0: sl@0: // Class RHeap sl@0: inline RHeap::RHeap() sl@0: {} sl@0: sl@0: /** sl@0: @return The maximum length to which the heap can grow. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: inline TInt RHeap::MaxLength() const sl@0: {return iMaxLength;} sl@0: sl@0: inline void RHeap::operator delete(TAny*, TAny*) sl@0: /** sl@0: Called if constructor issued by operator new(TUint aSize, TAny* aBase) throws exception. sl@0: This is dummy as corresponding new operator does not allocate memory. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: inline TUint8* RHeap::Base() const sl@0: /** sl@0: Gets a pointer to the start of the heap. sl@0: sl@0: Note that because of the small space overhead incurred by all allocated cells, sl@0: no cell will have the same address as that returned by this function. sl@0: sl@0: @return A pointer to the base of the heap. sl@0: */ sl@0: {return iBase;} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RHeap::Size() const sl@0: /** sl@0: Gets the current size of the heap. sl@0: sl@0: This is the total number of bytes committed by the host chunk. sl@0: It is the requested size rounded up by page size minus the size of RHeap object(116 bytes) sl@0: minus the cell alignment overhead as shown: sl@0: sl@0: Size = (Rounded committed size - Size of RHeap - Cell Alignment Overhead). sl@0: sl@0: The cell alignment overhead varies between release builds and debug builds. sl@0: sl@0: Note that this value is always greater than the total space available across all allocated cells. sl@0: sl@0: @return The size of the heap. sl@0: sl@0: @see Rheap::Available( ) sl@0: */ sl@0: {return iTop-iBase;} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RHeap::Align(TInt a) const sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {return _ALIGN_UP(a, iAlign);} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TAny* RHeap::Align(const TAny* a) const sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {return (const TAny*)_ALIGN_UP((TLinAddr)a, iAlign);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool RHeap::IsLastCell(const SCell* aCell) const sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {return (((TUint8*)aCell) + aCell->len) == iTop;} sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline void RHeap::Lock() const sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {((RFastLock&)iLock).Wait();} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RHeap::Unlock() const sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {((RFastLock&)iLock).Signal();} sl@0: sl@0: sl@0: inline TInt RHeap::ChunkHandle() const sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: return iChunkHandle; sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: // Class TRefByValue sl@0: template sl@0: inline TRefByValue::TRefByValue(T &aRef) sl@0: : iRef(aRef) sl@0: /** sl@0: Constructs this value reference for the specified referenced object. sl@0: sl@0: @param aRef The referenced object. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TRefByValue::operator T &() sl@0: /** sl@0: Gets a reference to the object encapsulated inside this value reference. sl@0: */ sl@0: {return(iRef);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Creates the logical channel. sl@0: sl@0: @param aDevice The name of the logical device for which the channel sl@0: is to be constructed. This is the name by which sl@0: the LDD factory object, i.e. the instance of sl@0: the DLogicalDevice derived class, is known. sl@0: @param aVer The required version of the logical device. The driver sl@0: normally checks this against the version of the logical sl@0: channel, returning KErrNotSupported if the logical channel sl@0: is not compatible. sl@0: @param aUnit A unit of the device. This argument only has meaning if sl@0: the flag KDeviceAllowUnit is set in the iParseMask data sl@0: member of the LDD factory object. sl@0: @param aDriver A pointer to a descriptor containing the name of sl@0: a physical device. This is the name by which the PDD sl@0: factory object, i.e. the instance of the DPhysicalDevice sl@0: derived class, is known. sl@0: This is NULL, if no explicit name is to be supplied, or sl@0: the logical device does not require an accompanying physical sl@0: device. sl@0: @param aInfo A pointer to an explicit 8-bit descriptor containing extra sl@0: information for the physical device. This argument only has sl@0: meaning if the KDeviceAllowInfo flag is set in the iParseMask sl@0: data member of the LDD factory object. sl@0: @param aType An enumeration whose enumerators define the ownership of sl@0: this handle. If not explicitly specified, EOwnerProcess is sl@0: taken as default. sl@0: @param aTransferable If false, the channel is created as an object which is sl@0: local/private to the current process. sl@0: If true, the channel is an object which may be shared with sl@0: other processes using the IPC mechanisms for handle passing. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: inline TInt RBusLogicalChannel::DoCreate(const TDesC& aDevice, const TVersion& aVer, TInt aUnit, const TDesC* aDriver, const TDesC8* aInfo, TOwnerType aType, TBool aTransferable) sl@0: { return DoCreate(aDevice, aVer, aUnit, aDriver, aInfo, (TInt)aType | (aTransferable?KCreateProtectedObject:0) ); } sl@0: sl@0: sl@0: sl@0: sl@0: // Class TChar sl@0: inline TChar::TChar() sl@0: /** sl@0: Default constructor. sl@0: sl@0: Constructs this character object with an undefined value. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline TChar::TChar(TUint aChar) sl@0: : iChar(aChar) sl@0: /** sl@0: Constructs this character object and initialises it with the specified value. sl@0: sl@0: @param aChar The initialisation value. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline TChar& TChar::operator-=(TUint aChar) sl@0: /** sl@0: Subtracts an unsigned integer value from this character object. sl@0: sl@0: This character object is changed by the operation. sl@0: sl@0: @param aChar The value to be subtracted. sl@0: sl@0: @return A reference to this character object. sl@0: */ sl@0: {iChar-=aChar;return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TChar& TChar::operator+=(TUint aChar) sl@0: /** sl@0: Adds an unsigned integer value to this character object. sl@0: sl@0: This character object is changed by the operation. sl@0: sl@0: @param aChar The value to be added. sl@0: sl@0: @return A reference to this character object. sl@0: */ sl@0: {iChar+=aChar;return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TChar TChar::operator-(TUint aChar) sl@0: /** sl@0: Gets the result of subtracting an unsigned integer value from this character sl@0: object. sl@0: sl@0: This character object is not changed. sl@0: sl@0: @param aChar The value to be subtracted. sl@0: sl@0: @return A character object whose value is the result of the subtraction sl@0: operation. sl@0: */ sl@0: {return(iChar-aChar);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TChar TChar::operator+(TUint aChar) sl@0: /** sl@0: Gets the result of adding an unsigned integer value to this character object. sl@0: sl@0: This character object is not changed. sl@0: sl@0: @param aChar The value to be added. sl@0: sl@0: @return A character object whose value is the result of the addition operation. sl@0: */ sl@0: {return(iChar+aChar);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TChar::operator TUint() const sl@0: /** sl@0: Gets the value of the character as an unsigned integer. sl@0: sl@0: The operator casts a TChar to a TUint, returning the TUint value wrapped by sl@0: this character object. sl@0: */ sl@0: {return(iChar);} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TDesC8 sl@0: inline TBool TDesC8::operator<(const TDesC8 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is less than the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 8-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if greater than or equal, false otherwise. sl@0: sl@0: @see TDesC8::Compare sl@0: */ sl@0: {return(Compare(aDes)<0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC8::operator<=(const TDesC8 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is less than or equal to the sl@0: specified descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 8-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if less than or equal, false otherwise. sl@0: sl@0: @see TDesC8::Compare sl@0: */ sl@0: {return(Compare(aDes)<=0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC8::operator>(const TDesC8 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is greater than the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 8-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if greater than, false otherwise. sl@0: sl@0: @see TDesC8::Compare sl@0: */ sl@0: {return(Compare(aDes)>0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC8::operator>=(const TDesC8 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is greater than or equal to the sl@0: specified descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 8-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if greater than, false otherwise. sl@0: sl@0: @see TDesC8::Compare sl@0: */ sl@0: {return(Compare(aDes)>=0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC8::operator==(const TDesC8 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is equal to the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 8-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if equal, false otherwise. sl@0: sl@0: @see TDesC8::Compare sl@0: */ sl@0: {return(Compare(aDes)==0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC8::operator!=(const TDesC8 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is not equal to the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 8-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if not equal, false otherwise. sl@0: sl@0: @see TDesC8::Compare sl@0: */ sl@0: {return(Compare(aDes)!=0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TUint8 &TDesC8::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to a single data item within this descriptor's data. sl@0: sl@0: @param anIndex The position of the individual data item within the descriptor's sl@0: data. This is an offset value; a zero value refers to the sl@0: leftmost data position. sl@0: sl@0: @return A reference to the data item. sl@0: sl@0: @panic USER 21, if anIndex is negative or greater than or equal to the current sl@0: length of the descriptor. sl@0: */ sl@0: {return(AtC(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDesC8::Length() const sl@0: /** sl@0: Gets the length of the data. sl@0: sl@0: This is the number of 8-bit values or data items represented by the descriptor. sl@0: sl@0: @return The length of the data represented by the descriptor. sl@0: */ sl@0: {return(iLength&KMaskDesLength8);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDesC8::Size() const sl@0: /** sl@0: Gets the size of the data. sl@0: sl@0: This is the number of bytes occupied by the data represented by the descriptor. sl@0: sl@0: @return The size of the data represented by the descriptor. sl@0: */ sl@0: {return(Length());} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TDesC8::DoSetLength(TInt aLength) sl@0: {iLength=(iLength&(~KMaskDesLength8))|aLength;} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TPtrC8 sl@0: inline void TPtrC8::Set(const TUint8 *aBuf,TInt aLength) sl@0: /** sl@0: Sets the 8-bit non-modifiable pointer descriptor to point to the specified sl@0: location in memory, whether in RAM or ROM. sl@0: sl@0: The length of the descriptor is set to the specified length. sl@0: sl@0: @param aBuf A pointer to the location that the descriptor is to represent. sl@0: @param aLength The length of the descriptor. This value must be non-negative. sl@0: sl@0: @panic USER 29, if aLength is negative. sl@0: */ sl@0: {new(this) TPtrC8(aBuf,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtrC8::Set(const TDesC8 &aDes) sl@0: /** sl@0: Sets the 8-bit non-modifiable pointer descriptor from the specified descriptor. sl@0: sl@0: It is set to point to the same data and is given the same length. sl@0: sl@0: @param aDes A reference to an 8-bit non-modifiable descriptor. sl@0: */ sl@0: {new(this) TPtrC8(aDes);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtrC8::Set(const TPtrC8& aPtr) sl@0: /** sl@0: Sets the 8-bit non-modifiable pointer descriptor from the specified sl@0: non-modifiable pointer descriptor. sl@0: sl@0: It is set to point to the same data and is given the same length. sl@0: sl@0: @param aPtr A reference to an 8-bit non-modifiable pointer descriptor. sl@0: */ sl@0: {new(this) TPtrC8(aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: // class TBufCBase8 sl@0: inline TPtr8 TBufCBase8::DoDes(TInt aMaxLength) sl@0: {return TPtr8(*this,aMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TBufC8 sl@0: template sl@0: inline TBufC8::TBufC8() sl@0: : TBufCBase8() sl@0: /** sl@0: Constructs an empty 8-bit non-modifiable buffer descriptor. sl@0: sl@0: It contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of the buffer descriptor object. sl@0: sl@0: Data can, subsequently, be assigned into this buffer descriptor using the sl@0: assignment operators. sl@0: sl@0: @see TBufC8::operator= sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC8::TBufC8(const TUint8 *aString) sl@0: : TBufCBase8(aString,S) sl@0: /** sl@0: Constructs the 8-bit non-modifiable buffer descriptor from a zero terminated sl@0: string. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer descriptor's sl@0: data area. The length of this buffer descriptor is set to the length of the sl@0: string, excluding the zero terminator. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: sl@0: @panic USER 20, if the length of the string, excluding the zero terminator, is sl@0: greater than the value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC8::TBufC8(const TDesC8 &aDes) sl@0: : TBufCBase8(aDes,S) sl@0: /** sl@0: Constructs the 8-bit non-modifiable buffer descriptor from any sl@0: existing descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: Data is copied from the source descriptor into this buffer descriptor and sl@0: the length of this buffer descriptor is set to the length of the sl@0: source descriptor. sl@0: sl@0: @param aDes The source 8-bit non-modifiable descriptor. sl@0: sl@0: @panic USER 20, if the length of the source descriptor is sl@0: greater than the value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC8 &TBufC8::operator=(const TUint8 *aString) sl@0: /** sl@0: Copies data into this descriptor, replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString,S);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC8 &TBufC8::operator=(const TDesC8 &aDes) sl@0: /** sl@0: Copies data into this descriptor, replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8-bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 23, if the length of the descriptor aDes is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes,S);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TPtr8 TBufC8::Des() sl@0: /** sl@0: Creates and returns an 8-bit modifiable pointer descriptor for the data sl@0: represented by this 8-bit non-modifiable buffer descriptor. sl@0: sl@0: The content of a non-modifiable buffer descriptor normally cannot be altered, sl@0: other than by complete replacement of the data. Creating a modifiable pointer sl@0: descriptor provides a way of changing the data. sl@0: sl@0: The modifiable pointer descriptor is set to point to this non-modifiable buffer sl@0: descriptor's data. sl@0: sl@0: The length of the modifiable pointer descriptor is set to the length of this sl@0: non-modifiable buffer descriptor. sl@0: sl@0: The maximum length of the modifiable pointer descriptor is set to the value sl@0: of the integer template parameter. sl@0: sl@0: When data is modified through this new pointer descriptor, the lengths of sl@0: both it and this constant buffer descriptor are changed. sl@0: sl@0: @return An 8-bit modifiable pointer descriptor representing the data in this sl@0: 8-bit non-modifiable buffer descriptor. sl@0: */ sl@0: {return DoDes(S);} sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: // Class HBufC8 sl@0: inline HBufC8 &HBufC8::operator=(const HBufC8 &aLcb) sl@0: /** sl@0: Copies data into this 8-bit heap descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: Note that the maximum length of this (target) descriptor is the length sl@0: of the descriptor buffer in the allocated host heap cell; this may be greater sl@0: than the maximum length specified when this descriptor was created or sl@0: last re-allocated. sl@0: sl@0: @param aLcb The source 8-bit heap descriptor. sl@0: sl@0: @return A reference to this 8-bit heap descriptor. sl@0: sl@0: @panic USER 23, if the length of the descriptor aLcb is greater than the sl@0: maximum length of this (target) descriptor sl@0: */ sl@0: {return *this=static_cast(aLcb);} sl@0: sl@0: sl@0: sl@0: sl@0: // Class RBuf8 sl@0: inline RBuf8& RBuf8::operator=(const TUint8* aString) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline RBuf8& RBuf8::operator=(const TDesC8& aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8-bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline RBuf8& RBuf8::operator=(const RBuf8& aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 8-bit buffer descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Creates an 8-bit resizable buffer descriptor that has been initialised with sl@0: data from the specified read stream; leaves on failure. sl@0: sl@0: Data is assigned to the new descriptor from the specified stream. sl@0: This variant assumes that the stream contains the length of the data followed sl@0: by the data itself. sl@0: sl@0: The function is implemented by calling the HBufC8::NewL(RReadStream&,TInt) sl@0: variant and then assigning the resulting heap descriptor using sl@0: the RBuf8::Assign(HBufC8*) variant. The comments that describe sl@0: the HBufC8::NewL() variant also apply to this RBuf8::CreateL() function. sl@0: sl@0: The function may leave with one of the system-wide error codes, specifically sl@0: KErrOverflow, if the length of the data as read from the stream is greater than sl@0: the upper limit as specified by the aMaxLength parameter. sl@0: sl@0: @param aStream The stream from which the data length and the data to be sl@0: assigned to the new descriptor, are taken. sl@0: @param aMaxLength The upper limit on the length of data that the descriptor is sl@0: to represent. The value of this parameter must be non-negative sl@0: otherwise the underlying function will panic. sl@0: */ sl@0: inline void RBuf8::CreateL(RReadStream &aStream,TInt aMaxLength) sl@0: { sl@0: Assign(HBufC8::NewL(aStream,aMaxLength)); sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: // Class TDes8 sl@0: inline TDes8 &TDes8::operator=(const TUint8 *aString) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDes8 &TDes8::operator=(const TDesC8 &aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8-bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 23, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDes8 &TDes8::operator=(const TDes8 &aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8-bit modifiable descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 23, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDes8 &TDes8::operator+=(const TDesC8 &aDes) sl@0: /** sl@0: Appends data onto the end of this descriptor's data and returns a reference sl@0: to this descriptor. sl@0: sl@0: The length of this descriptor is incremented to reflect the new content. sl@0: sl@0: @param aDes An-8 bit non-modifiable descriptor whose data is to be appended. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 23, if the resulting length of this descriptor is greater than its sl@0: maximum length. sl@0: */ sl@0: {Append(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TUint8 &TDes8::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a const reference to a single data item within this descriptor's data. sl@0: sl@0: @param anIndex The position of the data item within this descriptor's data. sl@0: This is an offset value; a zero value refers to the leftmost sl@0: data position. sl@0: sl@0: @return A const reference to the data item at the specified position. sl@0: sl@0: @panic USER 21, if anIndex is negative or is greater than or equal to the sl@0: current length of this descriptor. sl@0: */ sl@0: {return(AtC(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TUint8 &TDes8::operator[](TInt anIndex) sl@0: /** sl@0: Gets a non-const reference to a single data item within this descriptor's sl@0: data. sl@0: sl@0: @param anIndex The position of the data item within this descriptor's data. sl@0: This is an offset value; a zero value refers to the leftmost sl@0: data position. sl@0: sl@0: @return A non-const reference to the data item at the specified position. sl@0: sl@0: @panic USER 21, if anIndex is negative or is greater than or equal to the sl@0: current length of this descriptor. sl@0: */ sl@0: {return((TUint8 &)AtC(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDes8::MaxLength() const sl@0: /** sl@0: Gets the maximum length of the descriptor. sl@0: sl@0: This is the upper limit for the number of 8-bit values or data items that sl@0: the descriptor can represent. sl@0: sl@0: @return The maximum length of data that the descriptor can represent. sl@0: */ sl@0: {return(iMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDes8::MaxSize() const sl@0: /** sl@0: Gets the maximum size of the descriptor. sl@0: sl@0: This is the upper limit for the number of bytes which the data represented by sl@0: the descriptor can occupy. sl@0: sl@0: @return The maximum size of the descriptor data. sl@0: */ sl@0: {return(iMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TUint8 * TDes8::WPtr() const sl@0: {return((TUint8 *)Ptr());} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TPtr8 sl@0: inline TPtr8 &TPtr8::operator=(const TUint8 *aString) sl@0: /** sl@0: Copies data into this 8-bit modifiable pointer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this 8-bit modifiable pointer descriptor. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TPtr8 &TPtr8::operator=(const TDesC8 &aDes) sl@0: /** sl@0: Copies data into this 8-bit modifiable pointer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8-bit modifiable pointer descriptor whose data is to be copied sl@0: into this descriptor. sl@0: sl@0: @return A reference to this 8-bit modifiable pointer descriptor. sl@0: sl@0: @panic USER 23, if the length of aDes is greater than the maximum sl@0: length of this descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TPtr8 &TPtr8::operator=(const TPtr8 &aDes) sl@0: /** sl@0: Copies data into this 8-bit modifiable pointer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8-bit modifiable pointer descriptor whose data is to be copied sl@0: into this descriptor. sl@0: sl@0: @return A reference to this 8-bit modifiable pointer descriptor. sl@0: sl@0: @panic USER 23, if the length of aDes is greater than the maximum sl@0: length of this descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtr8::Set(TUint8 *aBuf,TInt aLength,TInt aMaxLength) sl@0: /** sl@0: Sets the 8-bit modifiable pointer descriptor to point to the specified location sl@0: in memory, whether in RAM or ROM. sl@0: sl@0: The length of the descriptor and its maximum length are set to the specified sl@0: values. sl@0: sl@0: @param aBuf A pointer to the location that the descriptor is to represent. sl@0: @param aLength The length of the descriptor. sl@0: @param aMaxLength The maximum length of the descriptor. sl@0: sl@0: @panic USER 20, if aLength is negative or is greater than the maximum length of sl@0: this descriptor. sl@0: @panic USER 30, if aMaxLength is negative. sl@0: */ sl@0: {new(this) TPtr8(aBuf,aLength,aMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtr8::Set(const TPtr8 &aPtr) sl@0: /** sl@0: Sets the 8-bit modifiable pointer descriptor from an existing 8-bit modifiable sl@0: pointer descriptor. sl@0: sl@0: It is set to point to the same data, is given the same length and the same sl@0: maximum length as the source pointer descriptor. sl@0: sl@0: @param aPtr The source 8-bit modifiable pointer descriptor. sl@0: */ sl@0: {new(this) TPtr8(aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TBuf8 sl@0: template sl@0: inline TBuf8::TBuf8() sl@0: : TBufBase8(S) sl@0: /** sl@0: Constructs an empty 8-bit modifiable buffer descriptor. sl@0: sl@0: It contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area that is created sl@0: as part of the object, and defines the descriptor's maximum length. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf8::TBuf8(TInt aLength) sl@0: : TBufBase8(aLength,S) sl@0: /** sl@0: Constructs an empty 8-bit modifiable buffer descriptor and sets the its length sl@0: to the specified value. sl@0: sl@0: No data is assigned to the descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area that is created sl@0: as part of the object, and defines the descriptor's maximum length. sl@0: sl@0: @param aLength The length of this modifiable buffer descriptor. sl@0: sl@0: @panic USER 20, if aLength is negative or is greater than the sl@0: value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf8::TBuf8(const TUint8 *aString) sl@0: : TBufBase8(aString,S) sl@0: /** sl@0: Constructs the 8-bit modifiable buffer descriptor from a sl@0: zero terminated string. sl@0: sl@0: The integer template parameter determines the size of the data area that sl@0: is created as part of the object, and defines the descriptor's maximum length. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer sl@0: descriptor's data area. The length of this buffer descriptor is set to the sl@0: length of the string, excluding the zero terminator. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, sl@0: is greater than the value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf8::TBuf8(const TDesC8 &aDes) sl@0: : TBufBase8(aDes,S) sl@0: /** sl@0: Constructs the 8-bit modifiable buffer descriptor from any existing sl@0: 8-bit descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area created sl@0: as part of this object and defines the descriptor's maximum length. sl@0: sl@0: Data is copied from the source descriptor into this modifiable buffer sl@0: descriptor and the length of this modifiable buffer descriptor is set to sl@0: the length of the source descriptor. sl@0: sl@0: @param aDes The source 8-bit non-modifiable descriptor. sl@0: sl@0: @panic USER 23, if the length of the source descriptor is greater than the sl@0: value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf8 &TBuf8::operator=(const TUint8 *aString) sl@0: /** sl@0: Copies data into this 8-bit modifiable buffer descriptor, replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this 8-bit modifiable buffer descriptor. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, sl@0: is greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf8 &TBuf8::operator=(const TDesC8 &aDes) sl@0: /** sl@0: Copies data into this 8-bit modifiable buffer descriptor, replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8 bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this 8-bit modifiable buffer descriptor. sl@0: sl@0: @panic USER 23, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf8& TBuf8::operator=(const TBuf8& aBuf) sl@0: /** sl@0: Copies data into this 8-bit modifiable buffer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aBuf The source 8-bit modifiable buffer descriptor with the same sl@0: template value. sl@0: sl@0: @return A reference to this 8-bit modifiable buffer descriptor. sl@0: */ sl@0: {Copy(aBuf);return *this;} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TAlignedBuf8 sl@0: template sl@0: inline TAlignedBuf8::TAlignedBuf8() sl@0: : TBufBase8(S) sl@0: /** sl@0: Constructs an empty 8-bit modifiable buffer descriptor. sl@0: sl@0: It contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area that is created sl@0: as part of the object, and defines the descriptor's maximum length. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TAlignedBuf8::TAlignedBuf8(TInt aLength) sl@0: : TBufBase8(aLength,S) sl@0: /** sl@0: Constructs an empty 8-bit modifiable buffer descriptor and sets the its length sl@0: to the specified value. sl@0: sl@0: No data is assigned to the descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area that is created sl@0: as part of the object, and defines the descriptor's maximum length. sl@0: sl@0: @param aLength The length of this modifiable buffer descriptor. sl@0: sl@0: @panic USER 20, if aLength is negative or is greater than the sl@0: value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TAlignedBuf8::TAlignedBuf8(const TUint8 *aString) sl@0: : TBufBase8(aString,S) sl@0: /** sl@0: Constructs the 8-bit modifiable buffer descriptor from a sl@0: zero terminated string. sl@0: sl@0: The integer template parameter determines the size of the data area that sl@0: is created as part of the object, and defines the descriptor's maximum length. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer sl@0: descriptor's data area. The length of this buffer descriptor is set to the sl@0: length of the string, excluding the zero terminator. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, sl@0: is greater than the value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TAlignedBuf8::TAlignedBuf8(const TDesC8 &aDes) sl@0: : TBufBase8(aDes,S) sl@0: /** sl@0: Constructs the 8-bit modifiable buffer descriptor from any existing sl@0: 8-bit descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area created sl@0: as part of this object and defines the descriptor's maximum length. sl@0: sl@0: Data is copied from the source descriptor into this modifiable buffer sl@0: descriptor and the length of this modifiable buffer descriptor is set to sl@0: the length of the source descriptor. sl@0: sl@0: @param aDes The source 8-bit non-modifiable descriptor. sl@0: sl@0: @panic USER 23, if the length of the source descriptor is greater than the sl@0: value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TAlignedBuf8 &TAlignedBuf8::operator=(const TUint8 *aString) sl@0: /** sl@0: Copies data into this 8-bit modifiable buffer descriptor, replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this 8-bit modifiable buffer descriptor. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, sl@0: is greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TAlignedBuf8 &TAlignedBuf8::operator=(const TDesC8 &aDes) sl@0: /** sl@0: Copies data into this 8-bit modifiable buffer descriptor, replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes An 8 bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this 8-bit modifiable buffer descriptor. sl@0: sl@0: @panic USER 23, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TAlignedBuf8& TAlignedBuf8::operator=(const TAlignedBuf8& aBuf) sl@0: /** sl@0: Copies data into this 8-bit modifiable buffer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aBuf The source 8-bit modifiable buffer descriptor with the same sl@0: template value. sl@0: sl@0: @return A reference to this 8-bit modifiable buffer descriptor. sl@0: */ sl@0: {Copy(aBuf);return *this;} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TLitC8 sl@0: template sl@0: inline const TDesC8* TLitC8::operator&() const sl@0: /** sl@0: Returns a const TDesC8 type pointer. sl@0: sl@0: @return A descriptor type pointer to this literal. sl@0: */ sl@0: {return REINTERPRET_CAST(const TDesC8*,this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const TDesC8& TLitC8::operator()() const sl@0: /** sl@0: Returns a const TDesC8 type reference. sl@0: sl@0: @return A descriptor type reference to this literal sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLitC8::operator const TDesC8&() const sl@0: /** sl@0: Invoked by the compiler when a TLitC8 type is passed to a function sl@0: which is prototyped to take a const TDesC8& type. sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLitC8::operator const __TRefDesC8() const sl@0: /** sl@0: Invoked by the compiler when a TLitC8 type is passed to a function sl@0: which is prototyped to take a const TRefByValue type. sl@0: sl@0: @see __TRefDesC8 sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: // Class TDesC16 sl@0: inline TBool TDesC16::operator<(const TDesC16 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is less than the specified descriptor's sl@0: data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 16-bit non-modifable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if less than, false otherwise. sl@0: sl@0: @see TDesC16::Compare sl@0: */ sl@0: {return(Compare(aDes)<0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC16::operator<=(const TDesC16 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is less than or equal sl@0: to the specified descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 16-bit non- modifiable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if less than or equal, false otherwise. sl@0: sl@0: @see TDesC16::Compare sl@0: */ sl@0: {return(Compare(aDes)<=0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC16::operator>(const TDesC16 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is greater than the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 16-bit non-modifiable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if greater than, false otherwise. sl@0: sl@0: @see TDesC16::Compare sl@0: */ sl@0: {return(Compare(aDes)>0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC16::operator>=(const TDesC16 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is greater than or equal to the sl@0: specified descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 16-bit non-modifiable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if greater than or equal, false otherwise. sl@0: sl@0: @see TDesC16::Compare sl@0: */ sl@0: {return(Compare(aDes)>=0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC16::operator==(const TDesC16 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is equal to the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 16-bit non-modifiable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if equal, false otherwise. sl@0: sl@0: @see TDesC16::Compare sl@0: */ sl@0: {return(Compare(aDes)==0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TDesC16::operator!=(const TDesC16 &aDes) const sl@0: /** sl@0: Determines whether this descriptor's data is not equal to the specified sl@0: descriptor's data. sl@0: sl@0: The comparison is implemented using the Compare() member function. sl@0: sl@0: @param aDes The 16-bit non-modifiable descriptor whose data is to be compared sl@0: with this descriptor's data. sl@0: sl@0: @return True if not equal, false otherwise. sl@0: sl@0: @see TDesC16::Compare sl@0: */ sl@0: {return(Compare(aDes)!=0);} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TUint16 &TDesC16::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to a single data item within this descriptor's data. sl@0: sl@0: @param anIndex The position of the individual data item within the descriptor's sl@0: data. This is an offset value; a zero value refers to the sl@0: leftmost data position. sl@0: sl@0: @return A reference to the data item. sl@0: sl@0: @panic USER 9, if anIndex is negative or greater than or equal to the current sl@0: length of the descriptor. sl@0: */ sl@0: {return(AtC(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDesC16::Length() const sl@0: /** sl@0: Gets the length of the data. sl@0: sl@0: This is the number of 16-bit values or data items represented by the descriptor. sl@0: sl@0: @return The length of the data represented by the descriptor. sl@0: */ sl@0: {return(iLength&KMaskDesLength16);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDesC16::Size() const sl@0: /** sl@0: Gets the size of the data. sl@0: sl@0: This is the number of bytes occupied by the data represented by the descriptor. sl@0: sl@0: @return The size of the data represented by the descriptor. This is always sl@0: twice the length. sl@0: */ sl@0: {return(Length()<<1);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TDesC16::DoSetLength(TInt aLength) sl@0: {iLength=(iLength&(~KMaskDesLength16))|aLength;} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TPtrC16 sl@0: inline void TPtrC16::Set(const TUint16 *aBuf,TInt aLength) sl@0: /** sl@0: Sets the 16-bit non-modifiable pointer descriptor to point to the specified sl@0: location in memory, whether in RAM or ROM. sl@0: sl@0: The length of the descriptor is set to the specified length. sl@0: sl@0: @param aBuf A pointer to the location that the descriptor is to represent. sl@0: @param aLength The length of the descriptor. This value must be non-negative sl@0: sl@0: @panic USER 17, if aLength is negative. sl@0: */ sl@0: {new(this) TPtrC16(aBuf,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtrC16::Set(const TDesC16 &aDes) sl@0: /** sl@0: Sets the 16-bit non-modifiable pointer descriptor from the specified descriptor. sl@0: sl@0: It is set to point to the same data and is given the same length. sl@0: sl@0: @param aDes A reference to a 16-bit non-modifiable descriptor sl@0: */ sl@0: {new(this) TPtrC16(aDes);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtrC16::Set(const TPtrC16& aPtr) sl@0: {new(this) TPtrC16(aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // class TBufCBase16 sl@0: inline TPtr16 TBufCBase16::DoDes(TInt aMaxLength) sl@0: {return TPtr16(*this,aMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TBufC16 sl@0: template sl@0: inline TBufC16::TBufC16() sl@0: : TBufCBase16() sl@0: /** sl@0: Constructs an empty 16-bit non-modifiable buffer descriptor. sl@0: sl@0: It contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of the buffer descriptor object. sl@0: sl@0: Data can, subsequently, be assigned into this buffer descriptor using the sl@0: assignment operators. sl@0: sl@0: @see TBufC16::operator= sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC16::TBufC16(const TUint16 *aString) sl@0: : TBufCBase16(aString,S) sl@0: /** sl@0: Constructs the 16-bit non-modifiable buffer descriptor from a zero terminated sl@0: string. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer descriptor's sl@0: data area. The length of this buffer descriptor is set to the length of the sl@0: string, excluding the zero terminator. sl@0: sl@0: @panic USER 8, if the length of the string, excluding the zero terminator, is sl@0: greater than the value of the integer template parameter. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC16::TBufC16(const TDesC16 &aDes) sl@0: : TBufCBase16(aDes,S) sl@0: /** sl@0: Constructs the 16-bit non-modifiable buffer descriptor from any sl@0: existing descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: Data is copied from the source descriptor into this buffer descriptor and sl@0: the length of this buffer descriptor is set to the length of the sl@0: source descriptor. sl@0: sl@0: @param aDes The source 16-bit non-modifiable descriptor. sl@0: sl@0: @panic USER 8, if the length of the source descriptor is sl@0: greater than the value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC16 &TBufC16::operator=(const TUint16 *aString) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString,S);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC16 &TBufC16::operator=(const TDesC16 &aDes) sl@0: /** sl@0: Copies data into this descriptor, replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit non-modifiable descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is sl@0: greater than the maximum length of this (target) descriptor. sl@0: sl@0: @return A reference to this descriptor. sl@0: */ sl@0: {Copy(aDes,S);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TPtr16 TBufC16::Des() sl@0: /** sl@0: Creates and returns a 16-bit modifiable pointer descriptor for the data sl@0: represented by this 16-bit non-modifiable buffer descriptor. sl@0: sl@0: The content of a non-modifiable buffer descriptor normally cannot be altered, sl@0: other than by complete replacement of the data. Creating a modifiable pointer sl@0: descriptor provides a way of changing the data. sl@0: sl@0: The modifiable pointer descriptor is set to point to this non-modifiable buffer sl@0: descriptor's data. sl@0: sl@0: The length of the modifiable pointer descriptor is set to the length of this sl@0: non-modifiable buffer descriptor. sl@0: sl@0: The maximum length of the modifiable pointer descriptor is set to the value sl@0: of the integer template parameter. sl@0: sl@0: When data is modified through this new pointer descriptor, the lengths of sl@0: both it and this constant buffer descriptor are changed. sl@0: sl@0: @return A 16-bit modifiable pointer descriptor representing the data in this sl@0: 16-bit non-modifiable buffer descriptor. sl@0: */ sl@0: {return(DoDes(S));} sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: // Class HBufC16 sl@0: inline HBufC16 &HBufC16::operator=(const HBufC16 &aLcb) sl@0: /** sl@0: Copies data into this 16-bit heap descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: Note that the maximum length of this (target) descriptor is the length sl@0: of the descriptor buffer in the allocated host heap cell; this may be greater sl@0: than the maximum length specified when this descriptor was created or sl@0: last re-allocated. sl@0: sl@0: @param aLcb The source 16-bit heap descriptor. sl@0: sl@0: @return A reference to this 16-bit heap descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aLcb is greater than the sl@0: maximum length of this (target) descriptor sl@0: */ sl@0: {return *this=static_cast(aLcb);} sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: // Class TDes16 sl@0: inline TDes16 &TDes16::operator=(const TUint16 *aString) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDes16 &TDes16::operator=(const TDesC16 &aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDes16 &TDes16::operator=(const TDes16 &aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit modifiable descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDes16 &TDes16::operator+=(const TDesC16 &aDes) sl@0: /** sl@0: Appends data onto the end of this descriptor's data and returns a reference sl@0: to this descriptor. sl@0: sl@0: The length of this descriptor is incremented to reflect the new content. sl@0: sl@0: @param aDes A 16-bit non-modifiable descriptor whose data is to be appended. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 11, if the resulting length of this descriptor is greater than its sl@0: maximum length. sl@0: */ sl@0: {Append(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TUint16 &TDes16::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a const reference to a single data item within this descriptor's data. sl@0: sl@0: @param anIndex The position the data item within this descriptor's data. This sl@0: is an offset value; a zero value refers to the leftmost data position. sl@0: sl@0: @return A const reference to the data item at the specified position. sl@0: sl@0: @panic USER 9, if anIndex is negative or is greater than or equal to the sl@0: current length of this descriptor. sl@0: */ sl@0: {return(AtC(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TUint16 &TDes16::operator[](TInt anIndex) sl@0: /** sl@0: Gets a non-const reference to a single data item within this descriptor's sl@0: data. sl@0: sl@0: @param anIndex The position of the data item within this descriptor's data. sl@0: This is an offset value; a zero value refers to the leftmost sl@0: data position. sl@0: sl@0: @return A non-const reference to the data item at the specified position. sl@0: sl@0: @panic USER 9, if anIndex is negative or is greater than or equal to the sl@0: current length of this descriptor. sl@0: */ sl@0: {return((TUint16 &)AtC(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDes16::MaxLength() const sl@0: /** sl@0: Gets the maximum length of the descriptor. sl@0: sl@0: This is the upper limit for the number of 16-bit values or data items that sl@0: the descriptor can represent. sl@0: sl@0: @return The maximum length of data that the descriptor can represent. sl@0: */ sl@0: {return(iMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TDes16::MaxSize() const sl@0: /** sl@0: Gets the maximum size of the descriptor. sl@0: sl@0: This is the upper limit for the number of bytes which the data represented by sl@0: the descriptor can occupy. sl@0: sl@0: @return The maximum size of the descriptor data. sl@0: */ sl@0: {return(iMaxLength<<1);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TUint16 * TDes16::WPtr() const sl@0: {return((TUint16 *)Ptr());} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TPtr16 sl@0: inline TPtr16 &TPtr16::operator=(const TUint16 *aString) sl@0: /** sl@0: Copies data into this 16-bit modifiable pointer descriptor replacing sl@0: any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this 16-bit modifiable pointer descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TPtr16 &TPtr16::operator=(const TDesC16 &aDes) sl@0: /** sl@0: Copies data into this 16-bit modifiable pointer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit non-modifiable descriptor whose data is to be copied sl@0: into this descriptor. sl@0: sl@0: @return A reference to this 16-bit modifiable pointer descriptor. sl@0: sl@0: @panic USER 11, if the length of aDes is greater than the maximum sl@0: length of this descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TPtr16 &TPtr16::operator=(const TPtr16 &aDes) sl@0: /** sl@0: Copies data into this 16-bit modifiable pointer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit modifiable pointer descriptor whose data is to be copied sl@0: into this descriptor. sl@0: sl@0: @return A reference to this 16-bit modifiable pointer descriptor. sl@0: sl@0: @panic USER 11, if the length of aDes is greater than the maximum sl@0: length of this descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtr16::Set(TUint16 *aBuf,TInt aLength,TInt aMaxLength) sl@0: /** sl@0: Sets the 16-bit modifiable pointer descriptor to point to the specified location sl@0: in memory, whether in RAM or ROM. sl@0: sl@0: The length of the descriptor and its maximum length are set to the specified sl@0: values. sl@0: sl@0: @param aBuf A pointer to the location that the descriptor is to represent. sl@0: @param aLength The length of the descriptor. sl@0: @param aMaxLength The maximum length of the descriptor. sl@0: sl@0: @panic USER 8, if aLength is negative or is greater than the maximum length of sl@0: this descriptor. sl@0: @panic USER 18, if aMaxLength is negative. sl@0: */ sl@0: {new(this) TPtr16(aBuf,aLength,aMaxLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TPtr16::Set(const TPtr16 &aPtr) sl@0: /** sl@0: Sets the 16-bit modifiable pointer descriptor from an existing sl@0: 16-bit modifiable pointer descriptor. sl@0: sl@0: It is set to point to the same data, is given the same length and the same sl@0: maximum length as the source pointer descriptor. sl@0: sl@0: @param aPtr The source 16-bit modifiable pointer descriptor. sl@0: */ sl@0: {new(this) TPtr16(aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TBuf16 sl@0: template sl@0: inline TBuf16::TBuf16() sl@0: : TBufBase16(S) sl@0: /** sl@0: Constructs an empty 16-bit modifiable buffer descriptor. sl@0: sl@0: It contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area created sl@0: as part of the object and defines the descriptor's maximum length. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf16::TBuf16(TInt aLength) sl@0: : TBufBase16(aLength,S) sl@0: /** sl@0: Constructs an empty 16-bit modifiable buffer descriptor and sets the its length sl@0: to the specified value. sl@0: sl@0: No data is assigned to the descriptor. sl@0: sl@0: The integer template parameter defines the size of the data area created as sl@0: part of the object and defines the descriptor's maximum length. sl@0: sl@0: @param aLength The length of this modifiable buffer descriptor. sl@0: sl@0: @panic USER 8, if aLength is negative or is greater than the sl@0: value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf16::TBuf16(const TUint16 *aString) sl@0: : TBufBase16(aString,S) sl@0: /** sl@0: Constructs the 16-bit modifiable buffer descriptor from sl@0: a zero terminated string. sl@0: sl@0: The integer template parameter determines the size of the data area that is sl@0: created as part of this object, and defines the descriptor's maximum length. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer sl@0: descriptor's data area. The length of this buffer descriptor is set to the sl@0: length of the string, excluding the zero terminator. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, sl@0: is greater than the value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf16::TBuf16(const TDesC16 &aDes) sl@0: : TBufBase16(aDes,S) sl@0: /** sl@0: Constructs the 16-bit modifiable buffer descriptor from any existing sl@0: 16-bit descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area created sl@0: as part of this object and defines the descriptor's maximum length. sl@0: sl@0: Data is copied from the source descriptor into this modifiable buffer descriptor sl@0: and the length of this modifiable buffer descriptor is set to the length of sl@0: the source descriptor. sl@0: sl@0: @param aDes The source 16-bit non-modifiable descriptor. sl@0: sl@0: @panic USER 11, if the length of the source descriptor is greater than the sl@0: value of the integer template parameter. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf16 &TBuf16::operator=(const TUint16 *aString) sl@0: /** sl@0: Copies data into this 16-bit modifiable buffer descriptor, replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, sl@0: is greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf16 &TBuf16::operator=(const TDesC16 &aDes) sl@0: /** sl@0: Copies data into this 16-bit modifiable descriptor, replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf16& TBuf16::operator=(const TBuf16& aBuf) sl@0: /** sl@0: Copies data into this 16-bit modifiable buffer descriptor replacing any sl@0: existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aBuf The source 16-bit modifiable buffer descriptor with the same sl@0: template value. sl@0: sl@0: @return A reference to this 16-bit modifiable buffer descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aBuf);return *this;} sl@0: sl@0: sl@0: // Class RBuf16 sl@0: inline RBuf16& RBuf16::operator=(const TUint16* aString) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, is sl@0: greater than the maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aString);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline RBuf16& RBuf16::operator=(const TDesC16& aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit non-modifiable descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: inline RBuf16& RBuf16::operator=(const RBuf16& aDes) sl@0: /** sl@0: Copies data into this descriptor replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A 16-bit buffer descriptor. sl@0: sl@0: @return A reference to this, the target descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor. sl@0: */ sl@0: {Copy(aDes);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Creates a 16-bit resizable buffer descriptor that has been initialised with sl@0: data from the specified read stream; leaves on failure. sl@0: sl@0: Data is assigned to the new descriptor from the specified stream. sl@0: This variant assumes that the stream contains the length of the data followed sl@0: by the data itself. sl@0: sl@0: The function is implemented by calling the HBufC16::NewL(RReadStream&,TInt) sl@0: variant and then assigning the resulting heap descriptor using sl@0: the RBuf16::Assign(HBufC16*) variant. The comments that describe sl@0: the HBufC16::NewL() variant also apply to this RBuf16::CreateL() function. sl@0: sl@0: The function may leave with one of the system-wide error codes, specifically sl@0: KErrOverflow, if the length of the data as read from the stream is greater than sl@0: the upper limit as specified by the aMaxLength parameter. sl@0: sl@0: @param aStream The stream from which the data length and the data to be sl@0: assigned to the new descriptor, are taken. sl@0: @param aMaxLength The upper limit on the length of data that the descriptor is sl@0: to represent. The value of this parameter must be non-negative sl@0: otherwise the underlying function will panic. sl@0: */ sl@0: inline void RBuf16::CreateL(RReadStream &aStream,TInt aMaxLength) sl@0: { sl@0: Assign(HBufC16::NewL(aStream,aMaxLength)); sl@0: } sl@0: sl@0: sl@0: // Template class TLitC16 sl@0: template sl@0: inline const TDesC16* TLitC16::operator&() const sl@0: /** sl@0: Returns a const TDesC16 type pointer. sl@0: sl@0: @return A descriptor type pointer to this literal. sl@0: */ sl@0: {return REINTERPRET_CAST(const TDesC16*,this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const TDesC16& TLitC16::operator()() const sl@0: /** sl@0: Returns a const TDesC16 type reference. sl@0: sl@0: @return A descriptor type reference to this literal sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLitC16::operator const TDesC16&() const sl@0: /** sl@0: Invoked by the compiler when a TLitC16 type is passed to a function sl@0: which is prototyped to take a const TDesC16& type. sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLitC16::operator const __TRefDesC16() const sl@0: /** sl@0: Invoked by the compiler when a TLitC16 type is passed to a function sl@0: which is prototyped to take a const TRefByValue type. sl@0: sl@0: @see __TRefDesC16 sl@0: */ sl@0: {return *operator&();} sl@0: #endif //__KERNEL_MODE__ sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TBufC sl@0: #if defined(_UNICODE) && !defined(__KERNEL_MODE__) sl@0: template sl@0: inline TBufC::TBufC() sl@0: : TBufCBase16() sl@0: /** sl@0: Constructs an empty build independent non-modifiable buffer descriptor. sl@0: sl@0: It contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of the buffer descriptor object. sl@0: sl@0: Data can, subsequently, be assigned into this buffer descriptor using the sl@0: assignment operators. sl@0: sl@0: @see TBufC::operator= sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC::TBufC(const TText *aString) sl@0: : TBufCBase16(aString,S) sl@0: /** sl@0: Constructs a build independent non-modifiable sl@0: buffer descriptor from a zero terminated string. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer descriptor's sl@0: data area. The length of this buffer descriptor is set to the length of the sl@0: string, excluding the zero terminator. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: sl@0: @panic USER 8, if the length of the string, excluding the zero terminator, is sl@0: greater than the value of the integer template parameter for sl@0: the 16-bit build variant. sl@0: sl@0: @panic USER 20, if the length of the string, excluding the zero terminator, is sl@0: greater than the value of the integer template parameter for sl@0: the 8-bit build variant. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC::TBufC(const TDesC &aDes) sl@0: : TBufCBase16(aDes,S) sl@0: /** sl@0: Constructs a build-independent non-modifiable buffer descriptor from any sl@0: existing build independent descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: Data is copied from the source descriptor into this buffer descriptor and sl@0: the length of this buffer descriptor is set to the length of the source descriptor. sl@0: sl@0: The length of the source descriptor must not be greater than the value of sl@0: the integer template parameter, otherwise the constructor raises a USER 20 sl@0: panic for an 8 bit build variant or a USER 8 panic for a 16 bit (Unicode) sl@0: build variant. sl@0: sl@0: @param aDes The source build independent non-modifiable descriptor. sl@0: sl@0: @panic USER 8, if the length of the source descriptor is sl@0: greater than the value of the integer template parameter for sl@0: the 16-bit build variant. sl@0: sl@0: @panic USER 20, if the length of the source descriptor is sl@0: greater than the value of the integer template parameter for sl@0: the 8-bit build variant. sl@0: */ sl@0: {} sl@0: #else sl@0: template sl@0: inline TBufC::TBufC() sl@0: : TBufCBase8() sl@0: {} sl@0: template sl@0: inline TBufC::TBufC(const TText *aString) sl@0: : TBufCBase8(aString,S) sl@0: {} sl@0: template sl@0: inline TBufC::TBufC(const TDesC &aDes) sl@0: : TBufCBase8(aDes,S) sl@0: {} sl@0: #endif sl@0: template sl@0: inline TBufC &TBufC::operator=(const TText *aString) sl@0: /** sl@0: Copies data into this descriptor, replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aString A pointer to a zero-terminated string. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, sl@0: is greater than the maximum length of this (target) descriptor sl@0: for the 16-bit build variant. sl@0: sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, sl@0: is greater than the maximum length of this (target) descriptor sl@0: for the 8-bit build variant. sl@0: */ sl@0: {Copy(aString,S);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBufC &TBufC::operator=(const TDesC &aDes) sl@0: /** sl@0: Copies data into this descriptor, replacing any existing data. sl@0: sl@0: The length of this descriptor is set to reflect the new data. sl@0: sl@0: @param aDes A build independent non-modifiable descriptor. sl@0: sl@0: @return A reference to this descriptor. sl@0: sl@0: @panic USER 11, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor for the 16-bit sl@0: build variant. sl@0: sl@0: @panic USER 23, if the length of the descriptor aDes is greater than the sl@0: maximum length of this (target) descriptor for the 8-bit sl@0: build variant. sl@0: */ sl@0: {Copy(aDes,S);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TPtr TBufC::Des() sl@0: /** sl@0: Creates and returns a build-independent modifiable pointer descriptor for sl@0: the data represented by this build-independent non-modifiable buffer sl@0: descriptor. sl@0: sl@0: The content of a non-modifiable buffer descriptor normally cannot be altered, sl@0: other than by complete replacement of the data. Creating a modifiable pointer sl@0: descriptor provides a way of changing the data. sl@0: sl@0: The modifiable pointer descriptor is set to point to this non-modifiable buffer sl@0: descriptor's data. sl@0: sl@0: The length of the modifiable pointer descriptor is set to the length of this sl@0: non-modifiable buffer descriptor. sl@0: sl@0: The maximum length of the modifiable pointer descriptor is set to the value sl@0: of the integer template parameter. sl@0: sl@0: When data is modified through this new pointer descriptor, the lengths of sl@0: both it and this constant buffer descriptor are changed. sl@0: sl@0: @return A build independent modifiable pointer descriptor representing the sl@0: data in this build independent non-modifiable buffer descriptor. sl@0: */ sl@0: {return(DoDes(S));} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TBuf sl@0: #if defined(_UNICODE) && !defined(__KERNEL_MODE__) sl@0: template sl@0: inline TBuf::TBuf() sl@0: : TBufBase16(S) sl@0: /** sl@0: Creates a build-independent modifiable buffer descriptor which sl@0: contains no data. sl@0: sl@0: The integer template parameter determines the size of the data area that is created sl@0: as part of the object, and defines the descriptor's maximum length. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf::TBuf(TInt aLength) sl@0: : TBufBase16(aLength,S) sl@0: /** sl@0: Constructs an empty build independent modifiable buffer descriptor and sl@0: sets its length to the specified value. sl@0: sl@0: No data is assigned to the descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area created sl@0: as part of the object and defines the descriptor's maximum length. sl@0: sl@0: @param aLength The length of this modifiable buffer descriptor. sl@0: sl@0: @panic USER 8, if aLength is negative and is greater than the value of the sl@0: integer template parameter for a 16-bit build variant. sl@0: sl@0: @panic USER 20, if aLength is negative and is greater than the value of the sl@0: integer template parameter for a 8-bit build variant. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf::TBuf(const TText *aString) sl@0: : TBufBase16(aString,S) sl@0: /** sl@0: Constructs the build-independent modifiable buffer descriptor from sl@0: a zero terminated string. sl@0: sl@0: The integer template parameter determines the size of the data area which sl@0: is created as part of this object. sl@0: sl@0: The string, excluding the zero terminator, is copied into this buffer sl@0: descriptor's data area. The length of this buffer descriptor is set to sl@0: the length of the string, excluding the zero terminator. sl@0: sl@0: @param aString A pointer to a zero terminated string. sl@0: sl@0: @panic USER 11, if the length of the string, excluding the zero terminator, sl@0: is greater than the value of the integer template parameter sl@0: for a 16-bit build variant. sl@0: @panic USER 23, if the length of the string, excluding the zero terminator, sl@0: is greater than the value of the integer template parameter sl@0: for a 8-bit build variant. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBuf::TBuf(const TDesC &aDes) sl@0: : TBufBase16(aDes,S) sl@0: /** sl@0: Constructs the build-independent modifiable buffer descriptor from any sl@0: existing build-independent descriptor. sl@0: sl@0: The integer template parameter determines the size of the data area created sl@0: as part of this object, and defines the descriptor's maximum length. sl@0: sl@0: Data is copied from the source descriptor into this modifiable buffer descriptor sl@0: and the length of this modifiable buffer descriptor is set to the length of sl@0: the source descriptor. sl@0: sl@0: @param aDes The source build independent non-modifiable descriptor. sl@0: sl@0: @panic USER 11, if the length of the source descriptor is greater than the sl@0: value of the integer template parameter for a 16-bit sl@0: build variant. sl@0: @panic USER 23, if the length of the source descriptor is greater than the sl@0: value of the integer template parameter for an 8-bit sl@0: build variant. sl@0: sl@0: */ sl@0: {} sl@0: #else sl@0: template sl@0: inline TBuf::TBuf() sl@0: : TBufBase8(S) sl@0: {} sl@0: template sl@0: inline TBuf::TBuf(TInt aLength) sl@0: : TBufBase8(aLength,S) sl@0: {} sl@0: template sl@0: inline TBuf::TBuf(const TText *aString) sl@0: : TBufBase8(aString,S) sl@0: {} sl@0: template sl@0: inline TBuf::TBuf(const TDesC &aDes) sl@0: : TBufBase8(aDes,S) sl@0: {} sl@0: #endif sl@0: template sl@0: inline TBuf &TBuf::operator=(const TText *aString) sl@0: {Copy(aString);return(*this);} sl@0: template sl@0: inline TBuf &TBuf::operator=(const TDesC &aDes) sl@0: {Copy(aDes);return(*this);} sl@0: template sl@0: inline TBuf &TBuf::operator=(const TBuf &aBuf) sl@0: {Copy(aBuf);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TLitC sl@0: template sl@0: inline const TDesC* TLitC::operator&() const sl@0: /** sl@0: Returns a const TDesC type pointer. sl@0: sl@0: @return A descriptor type pointer to this literal. sl@0: */ sl@0: {return REINTERPRET_CAST(const TDesC*,this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const TDesC& TLitC::operator()() const sl@0: /** sl@0: Returns a const TDesC type reference. sl@0: sl@0: @return A descriptor type reference to this literal sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLitC::operator const TDesC&() const sl@0: /** sl@0: Invoked by the compiler when a TLitC type is passed to a function sl@0: which is prototyped to take a const TDesC& type. sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLitC::operator const __TRefDesC() const sl@0: /** sl@0: Invoked by the compiler when a TLitC type is passed to a function sl@0: which is prototyped to take a const TRefByValue type. sl@0: sl@0: @see __TRefDesC. sl@0: */ sl@0: {return *operator&();} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TPckgC sl@0: template sl@0: inline TPckgC::TPckgC(const T &aRef) sl@0: : TPtrC8((const TUint8 *)&aRef,sizeof(T)) sl@0: /** sl@0: Constructs a packaged non-modifiable pointer descriptor to represent sl@0: the specified object whose type is defined by the template parameter. sl@0: sl@0: @param aRef The object to be represented by this packaged non-modifiable sl@0: pointer descriptor. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &TPckgC::operator()() const sl@0: /** sl@0: Gets a reference to the object represented by this packaged non-modifiable sl@0: pointer descriptor. sl@0: sl@0: @return The packaged object sl@0: */ sl@0: {return(*((const T *)iPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TPckg sl@0: template sl@0: inline TPckg::TPckg(const T &aRef) sl@0: : TPtr8((TUint8 *)&aRef,sizeof(T),sizeof(T)) sl@0: /** sl@0: Constructs a packaged modifiable pointer descriptor to represent the specified sl@0: object whose type is defined by the template parameter. sl@0: sl@0: @param aRef The object to be represented by this packaged modifiable pointer sl@0: descriptor. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &TPckg::operator()() sl@0: /** sl@0: Gets a reference to the object represented by this packaged sl@0: modifiable pointer descriptor. sl@0: sl@0: @return The packaged object. sl@0: */ sl@0: {return(*((T *)iPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class TPckgBuf sl@0: template sl@0: inline TPckgBuf::TPckgBuf() sl@0: : TAlignedBuf8(sizeof(T)) sl@0: /** sl@0: Constructs a packaged modifiable buffer descriptor for an object whose type sl@0: is defined by the template parameter. sl@0: sl@0: The length of the packaged descriptor is set to the length of the templated sl@0: class but no data is assigned into the descriptor. sl@0: */ sl@0: {new(&this->iBuf[0]) T;} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TPckgBuf::TPckgBuf(const T &aRef) sl@0: : TAlignedBuf8(sizeof(T)) sl@0: /** sl@0: Constructs a packaged modifiable buffer descriptor for an object whose type sl@0: is defined by the template parameter and copies the supplied object into the sl@0: descriptor. sl@0: sl@0: The length of the packaged descriptor is set to the length of the templated sl@0: class. sl@0: sl@0: @param aRef The source object to be copied into the packaged modifiable buffer sl@0: descriptor. sl@0: */ sl@0: {new(&this->iBuf[0]) T(aRef);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TPckgBuf &TPckgBuf::operator=(const TPckgBuf &aRef) sl@0: /** sl@0: Copies data from the specified packaged modifiable buffer descriptor into this sl@0: packaged modifiable buffer descriptor, replacing any existing data. sl@0: sl@0: @param aRef The source packaged modifiable buffer descriptor. sl@0: @return A reference to this packaged modifiable descriptor. sl@0: */ sl@0: {this->Copy(aRef);return(*this);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &TPckgBuf::operator=(const T &aRef) sl@0: /** sl@0: Copies data from the specified object into this packaged modifiable buffer sl@0: descriptor, replacing any existing data. sl@0: sl@0: @param aRef The source object. sl@0: @return A reference to the copy of the source object in the packaged modifiable sl@0: buffer descriptor. sl@0: */ sl@0: {this->Copy((TUint8 *)&aRef,sizeof(T));return(*((T *)&this->iBuf[0]));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &TPckgBuf::operator()() sl@0: /** sl@0: Gets a reference to the object contained by this packaged modifiable sl@0: buffer descriptor. sl@0: sl@0: @return The packaged object. sl@0: */ sl@0: {return(*((T *)&this->iBuf[0]));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &TPckgBuf::operator()() const sl@0: /** sl@0: Gets a const reference to the object contained by this packaged modifiable sl@0: buffer descriptor. sl@0: sl@0: @return The (const) packaged object. sl@0: */ sl@0: {return(*((T *)&this->iBuf[0]));} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TRequestStatus sl@0: inline TRequestStatus::TRequestStatus() sl@0: /** sl@0: Default constructor. sl@0: */ sl@0: : iFlags(0) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline TRequestStatus::TRequestStatus(TInt aVal) sl@0: /** sl@0: Constructs an asynchronous request status object and assigns a completion value sl@0: to it. sl@0: sl@0: @param aVal The completion value to be assigned to the constructed request sl@0: status object. sl@0: */ sl@0: : iStatus(aVal), sl@0: iFlags(aVal==KRequestPending ? TRequestStatus::ERequestPending : 0) sl@0: sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt TRequestStatus::operator=(TInt aVal) sl@0: /** sl@0: Assigns the specified completion code to the request status object. sl@0: sl@0: @param aVal The value to be assigned. sl@0: sl@0: @return The value assigned. sl@0: */ sl@0: { sl@0: if(aVal==KRequestPending) sl@0: iFlags|=TRequestStatus::ERequestPending; sl@0: else sl@0: iFlags&=~TRequestStatus::ERequestPending; sl@0: return (iStatus=aVal); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TRequestStatus::operator==(TInt aVal) const sl@0: /** sl@0: Tests whether the request status object's completion code is the same as sl@0: the specified value. sl@0: sl@0: @param aVal The value to be compared. sl@0: sl@0: @return True, if the values are equal; false otherwise. sl@0: */ sl@0: {return(iStatus==aVal);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TRequestStatus::operator!=(TInt aVal) const sl@0: /** sl@0: Tests whether the request status object's completion code is not equal to sl@0: the specified value. sl@0: sl@0: @param aVal The value to be compared. sl@0: sl@0: @return True, if the values are unequal; false otherwise. sl@0: */ sl@0: {return(iStatus!=aVal);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TRequestStatus::operator>=(TInt aVal) const sl@0: /** sl@0: Tests whether the request status object's completion code is greater than sl@0: or equal to the specified value. sl@0: sl@0: @param aVal The value to be compared. sl@0: sl@0: @return True, if the request status object's value is greater than or equal sl@0: to the specified value; false, otherwise. sl@0: */ sl@0: {return(iStatus>=aVal);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TRequestStatus::operator<=(TInt aVal) const sl@0: /** sl@0: Tests whether the request status object's completion code is less than or sl@0: equal to the specified value. sl@0: sl@0: @param aVal The value to be compared. sl@0: sl@0: @return True, if the request status object's value is less than or equal sl@0: to the specified value; false, otherwise. sl@0: */ sl@0: {return(iStatus<=aVal);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TRequestStatus::operator>(TInt aVal) const sl@0: /** sl@0: Tests whether the request status object's completion code is greater than sl@0: the specified value. sl@0: sl@0: @param aVal The value to be compared. sl@0: sl@0: @return True, if the request status object's value is greater than sl@0: the specified value; false, otherwise. sl@0: */ sl@0: {return(iStatus>aVal);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool TRequestStatus::operator<(TInt aVal) const sl@0: /** sl@0: Tests whether the request status object's completion code is less than the sl@0: specified value. sl@0: sl@0: @param aVal The value to be compared. sl@0: sl@0: @return True, if the request status object's value is less than the specified sl@0: value; false, otherwise. sl@0: */ sl@0: {return(iStatus>KFindHandleUniqueIdShift)&KFindHandleUniqueIdMask);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the unique ID of the kernel object itself. sl@0: sl@0: @return The ID of the object. sl@0: */ sl@0: inline TUint64 TFindHandle::ObjectID() const sl@0: {return MAKE_TUINT64(iObjectIdHigh, iObjectIdLow);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets the find handle to refer to a specific object. sl@0: sl@0: @oaram aIndex The current index of the object in its container. sl@0: @param aUniqueId The unique ID of the container object. sl@0: @param aObjectId The unique ID of the object iteself. sl@0: */ sl@0: inline void TFindHandle::Set(TInt aIndex, TInt aUniqueId, TUint64 aObjectId) sl@0: { sl@0: iHandle=(TInt)((aUniqueId<=0) sl@0: { sl@0: iHandle = aHandleOrError; sl@0: return KErrNone; sl@0: } sl@0: iHandle = 0; sl@0: return aHandleOrError; sl@0: #elif defined(_WIN32) sl@0: //Our problem is that win32 handles can be negative sl@0: if (aHandleOrError==NULL) sl@0: { sl@0: //TODO: check GetLastError and return proper error code sl@0: return KErrUnknown; sl@0: } sl@0: //Valid handle sl@0: iHandle = aHandleOrError; sl@0: return KErrNone; sl@0: #else sl@0: #error "Platform not supported" sl@0: #endif sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Class RSemaphore sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TInt RSemaphore::Open(const TFindSemaphore& aFind,TOwnerType aType) sl@0: /** sl@0: Opens a handle to the global semaphore found using a TFindSemaphore object. sl@0: sl@0: A TFindSemaphore object is used to find all global semaphores whose full names sl@0: match a specified pattern. sl@0: sl@0: By default, any thread in the process can use this instance of RSemaphore sl@0: to access the semaphore. However, specifying EOwnerThread as the second parameter sl@0: to this function, means that only the opening thread can use this instance sl@0: of RSemaphore to access the semaphore; any other thread in this process that sl@0: wants to access the semaphore must either duplicate the handle or use OpenGlobal() sl@0: again. sl@0: sl@0: @param aFind A reference to the TFindSemaphore object used to find the semaphore. sl@0: @param aType An enumeration whose enumerators define the ownership of this sl@0: semaphore handle. If not explicitly specified, EOwnerProcess is sl@0: taken as default. sl@0: sl@0: @return KErrNone if successful otherwise another of the system wide error codes. sl@0: */ sl@0: {return(RHandleBase::Open((const TFindHandleBase&)aFind,aType));} sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: // Class RFastLock sl@0: sl@0: sl@0: /** sl@0: Default constructor. sl@0: */ sl@0: inline RFastLock::RFastLock() sl@0: : iCount(0) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Default constructor. sl@0: */ sl@0: inline RReadWriteLock::RReadWriteLock() sl@0: : iValues(0), iPriority(EAlternatePriority), iReaderSem(), iWriterSem() sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Class RMessagePtr2 sl@0: sl@0: sl@0: /** sl@0: Default constructor sl@0: */ sl@0: inline RMessagePtr2::RMessagePtr2() sl@0: : iHandle(0) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Tests whether this message handle is empty. sl@0: sl@0: @return True, if this message handle is empty, false, otherwise. sl@0: */ sl@0: inline TBool RMessagePtr2::IsNull() const sl@0: {return iHandle==0;} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the message handle value. sl@0: sl@0: @return The message handle value. sl@0: */ sl@0: inline TInt RMessagePtr2::Handle() const sl@0: {return iHandle;} sl@0: inline TBool operator==(RMessagePtr2 aLeft,RMessagePtr2 aRight) sl@0: {return aLeft.Handle()==aRight.Handle();} sl@0: inline TBool operator!=(RMessagePtr2 aLeft,RMessagePtr2 aRight) sl@0: {return aLeft.Handle()!=aRight.Handle();} sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: // Class RMessage sl@0: sl@0: sl@0: /** sl@0: Default constructor sl@0: */ sl@0: inline RMessage2::RMessage2() sl@0: :iFunction(0), iSpare1(0), iSessionPtr(NULL), iFlags(0), iSpare3(0) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the the number of the function requested by the client. sl@0: sl@0: @return The function number. sl@0: */ sl@0: inline TInt RMessage2::Function() const sl@0: {return(iFunction);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the first message argument as an integer value. sl@0: sl@0: @return The first message argument. sl@0: */ sl@0: inline TInt RMessage2::Int0() const sl@0: {return(iArgs[0]);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the second message argument as an integer value. sl@0: sl@0: @return The second message argument. sl@0: */ sl@0: inline TInt RMessage2::Int1() const sl@0: {return(iArgs[1]);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the third message argument as an integer value. sl@0: sl@0: @return The third message argument. sl@0: */ sl@0: inline TInt RMessage2::Int2() const sl@0: {return(iArgs[2]);} sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the fourth message argument as an integer value. sl@0: sl@0: @return The fourth message argument. sl@0: */ sl@0: inline TInt RMessage2::Int3() const sl@0: {return(iArgs[3]);} sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the first message argument as a pointer type. sl@0: sl@0: @return The first message argument. sl@0: */ sl@0: inline const TAny *RMessage2::Ptr0() const sl@0: {return((const TAny *)iArgs[0]);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the second message argument as a pointer type. sl@0: sl@0: @return The second message argument. sl@0: */ sl@0: inline const TAny *RMessage2::Ptr1() const sl@0: {return((const TAny *)iArgs[1]);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the third message argument as a pointer type. sl@0: sl@0: @return The third message argument. sl@0: */ sl@0: inline const TAny *RMessage2::Ptr2() const sl@0: {return((const TAny *)iArgs[2]);} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the fourth message argument as a pointer type. sl@0: sl@0: @return The fourth message argument. sl@0: */ sl@0: inline const TAny *RMessage2::Ptr3() const sl@0: {return((const TAny *)iArgs[3]);} sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets a pointer to the session. sl@0: sl@0: @return A pointer to the session object. sl@0: */ sl@0: inline CSession2* RMessage2::Session() const sl@0: {return (CSession2*)iSessionPtr; } sl@0: sl@0: sl@0: sl@0: sl@0: // Class TUid sl@0: inline TUid TUid::Uid(TInt aUid) sl@0: /** sl@0: Constructs the TUid object from a 32-bit integer. sl@0: sl@0: @param aUid The 32-bit integer value from which the TUid object is to be sl@0: constructed. sl@0: sl@0: @return The constructed TUid object. sl@0: */ sl@0: {TUid uid={aUid};return uid;} sl@0: sl@0: sl@0: sl@0: sl@0: inline TUid TUid::Null() sl@0: /** sl@0: Constructs a Null-valued TUid object. sl@0: sl@0: @return The constructed Null-valued TUid object. sl@0: */ sl@0: {TUid uid={KNullUidValue};return uid;} sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: // Template class TArray sl@0: template sl@0: inline TArray::TArray(TInt (*aCount)(const CBase *aPtr),const TAny *(*anAt)(const CBase *aPtr,TInt anIndex),const CBase *aPtr) sl@0: : iPtr(aPtr),iCount(aCount),iAt(anAt) sl@0: /** sl@0: Constructor. sl@0: sl@0: A TArray object is not intended to be instantiated explicitly. An object of sl@0: this type is instantiated as a result of a call to to the Array() member sl@0: function of a concrete array class sl@0: sl@0: @param aCount A pointer to a function which takes a sl@0: @code sl@0: const CBase* sl@0: @endcode sl@0: argument and returns a sl@0: @code sl@0: TInt sl@0: @endcode sl@0: aCount must point to the member function which returns the sl@0: current number of elements of type class T contained in the sl@0: array at aPtr, for which this TArray is being constructed. sl@0: This argument is supplied by the Array() member function of the sl@0: array class. sl@0: @param anAt A pointer to a function which takes a sl@0: @code sl@0: const CBase* sl@0: @endcode sl@0: and a sl@0: @code sl@0: TInt sl@0: @endcode sl@0: argument, and returns a pointer to sl@0: @code sl@0: TAny sl@0: @endcode sl@0: anAt must point to the member function which returns a reference sl@0: to the element located at position anIndex within the array at sl@0: aPtr, for which this TArray is being constructed. sl@0: This argument is supplied by the Array() member function of the sl@0: array class. sl@0: @param aPtr A pointer to the array for which this TArray is being sl@0: constructed. This argument is supplied by the Array() member sl@0: function of the array class. sl@0: sl@0: @see CArrayFixFlat::Array sl@0: @see CArrayFixSeg::Array sl@0: @see CArrayVarFlat::Array sl@0: @see CArrayVarSeg::Array sl@0: @see CArrayPakFlat::Array sl@0: @see RArray::Array sl@0: @see RPointerArray::Array sl@0: @see RArray::Array sl@0: @see RArray::Array sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt TArray::Count() const sl@0: /** sl@0: Gets the number of elements currently held in the array for which this generic sl@0: array has been constructed. sl@0: sl@0: @return The number of array elements. sl@0: */ sl@0: {return((*iCount)(iPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &TArray::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the element located at the specified position. sl@0: sl@0: The returned reference is const and cannot be used to change the element. sl@0: Any member function of the referenced template class T must be declared sl@0: as const if that function is to be accessed through this operator. sl@0: sl@0: @param anIndex The position of the element within the array for which this sl@0: TArray has been constructed. The position is relative to zero; sl@0: i.e. zero implies the first element in the array. sl@0: sl@0: @return A const reference to the element located at position anIndex within sl@0: the array for which this TArray has been constructed. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative, or greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)(*iAt)(iPtr,anIndex)));} sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: // Class TIdentityRelation sl@0: template sl@0: inline TIdentityRelation::TIdentityRelation() sl@0: /** sl@0: Constructs the object to use the equality operator (==) defined for class T sl@0: to determine whether two class T type objects match. sl@0: */ sl@0: {iIdentity=(TGeneralIdentityRelation)&EqualityOperatorCompare;} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TIdentityRelation::TIdentityRelation( TBool (*anIdentity)(const T&, const T&) ) sl@0: /** sl@0: Constructs the object taking the specified function as an argument. sl@0: sl@0: The specified function should implement an algorithm for determining whether sl@0: two class T type objects match. It should return: sl@0: sl@0: 1. true, if the two objects match. sl@0: sl@0: 2. false, if the two objects do not match. sl@0: sl@0: @param anIdentity A pointer to a function that takes constant references to two sl@0: class T objects and returns a TInt value. sl@0: */ sl@0: { iIdentity=(TGeneralIdentityRelation)anIdentity; } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TIdentityRelation::operator TGeneralIdentityRelation() const sl@0: /** sl@0: Operator that gets the function that determines whether two sl@0: objects of a given class type match. sl@0: */ sl@0: { return iIdentity; } sl@0: sl@0: sl@0: sl@0: template sl@0: inline TBool TIdentityRelation::EqualityOperatorCompare(const T& aLeft, const T& aRight) sl@0: /** sl@0: Compares two objects of class T using the equality operator defined for class T. sl@0: */ sl@0: {return aLeft == aRight;} sl@0: sl@0: sl@0: sl@0: // Class TLinearOrder sl@0: template sl@0: inline TLinearOrder::TLinearOrder( TInt(*anOrder)(const T&, const T&) ) sl@0: /** sl@0: Constructs the object taking the specified function as an argument. sl@0: sl@0: The specified function should implement an algorithm that determines the sl@0: order of two class T type objects. It should return: sl@0: sl@0: 1. zero, if the two objects are equal. sl@0: sl@0: 2. a negative value, if the first object is less than the second. sl@0: sl@0: 3. a positive value, if the first object is greater than the second. sl@0: sl@0: @param anOrder A pointer to a function that takes constant references to two sl@0: class T objects and returns a TInt value. sl@0: */ sl@0: { iOrder=(TGeneralLinearOrder)anOrder; } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TLinearOrder::operator TGeneralLinearOrder() const sl@0: /** sl@0: Operator that gets the function that determines the order of two sl@0: objects of a given class type. sl@0: */ sl@0: { return iOrder; } sl@0: sl@0: sl@0: sl@0: sl@0: // Class RPointerArray sl@0: sl@0: /** sl@0: Default C++ constructor. sl@0: sl@0: This constructs an array object for an array of pointers with default sl@0: granularity, which is 8. sl@0: */ sl@0: template sl@0: inline RPointerArray::RPointerArray() sl@0: : RPointerArrayBase() sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with granularity. sl@0: sl@0: This constructs an array object for an array of pointers with the specified sl@0: granularity. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic USER 127, if aGranularity is not positive, or greater than or equal sl@0: to 0x10000000. sl@0: */ sl@0: template sl@0: inline RPointerArray::RPointerArray(TInt aGranularity) sl@0: : RPointerArrayBase(aGranularity) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with minimum growth step and exponential growth factor. sl@0: sl@0: This constructs an array object for an array of pointers with the specified sl@0: minimum growth step and exponential growth factor. sl@0: sl@0: @param aMinGrowBy The minimum growth step of the array. Must be between 1 and sl@0: 65535 inclusive. sl@0: @param aFactor The factor by which the array grows, multiplied by 256. sl@0: For example 512 specifies a factor of 2. Must be between 257 sl@0: and 32767 inclusive. sl@0: sl@0: @panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535. sl@0: @panic USER 193, if aFactor<=257 or aFactor>32767. sl@0: */ sl@0: template sl@0: inline RPointerArray::RPointerArray(TInt aMinGrowBy, TInt aFactor) sl@0: : RPointerArrayBase(aMinGrowBy, aFactor) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::Close() sl@0: /** sl@0: Closes the array and frees all memory allocated to it. sl@0: sl@0: The function must be called before this array object goes out of scope. sl@0: sl@0: Note that the function does not delete the objects whose pointers are contained sl@0: in the array. sl@0: */ sl@0: {RPointerArrayBase::Close();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::Count() const sl@0: /** sl@0: Gets the number of object pointers in the array. sl@0: sl@0: @return The number of object pointers in the array. sl@0: */ sl@0: { return RPointerArrayBase::Count(); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T* const& RPointerArray::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the object pointer located at the specified sl@0: position within the array. sl@0: sl@0: The compiler chooses this option if the returned reference is used in sl@0: an expression where the reference cannot be modified. sl@0: sl@0: @param anIndex The position of the object pointer within the array. The sl@0: position is relative to zero, i.e. zero implies the object sl@0: pointer at the beginning of the array. sl@0: sl@0: @return A const reference to the object pointer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {return (T* const&)At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T*& RPointerArray::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to the object pointer located at the specified sl@0: position within the array. sl@0: sl@0: The compiler chooses this option if the returned reference is used in sl@0: an expression where the reference can be modified. sl@0: sl@0: @param anIndex The position of the object pointer within the array. The sl@0: position is relative to zero, i.e. zero implies the object sl@0: pointer at the beginning of the array. sl@0: sl@0: @return A non-const reference to the object pointer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {return (T*&)At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::Append(const T* anEntry) sl@0: /** sl@0: Appends an object pointer onto the array. sl@0: sl@0: @param anEntry The object pointer to be appended. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::Append(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::Insert(const T* anEntry, TInt aPos) sl@0: /** sl@0: Inserts an object pointer into the array at the specified position. sl@0: sl@0: @param anEntry The object pointer to be inserted. sl@0: @param aPos The position within the array where the object pointer is to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that a pointer is inserted at the beginning of the array. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: sl@0: @panic USER 131, if aPos is negative, or is greater than the number of object sl@0: pointers currently in the array. sl@0: */ sl@0: { return RPointerArrayBase::Insert(anEntry,aPos); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::Remove(TInt anIndex) sl@0: /** sl@0: Removes the object pointer at the specified position from the array. sl@0: sl@0: Note that the function does not delete the object whose pointer is removed. sl@0: sl@0: @param anIndex The position within the array from where the object pointer sl@0: is to be removed. The position is relative to zero, i.e. zero sl@0: implies that a pointer at the beginning of the array is to be sl@0: removed. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {RPointerArrayBase::Remove(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::Compress() sl@0: /** sl@0: Compresses the array down to a minimum. sl@0: sl@0: After a call to this function, the memory allocated to the array is just sl@0: sufficient for its contained object pointers. sl@0: Subsequently adding a new object pointer to the array sl@0: always results in a re-allocation of memory. sl@0: */ sl@0: {RPointerArrayBase::Compress();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::Reset() sl@0: /** sl@0: Empties the array. sl@0: sl@0: It frees all memory allocated to the array and resets the internal state so sl@0: that it is ready to be reused. sl@0: sl@0: This array object can be allowed to go out of scope after a call to this sl@0: function. sl@0: sl@0: Note that the function does not delete the objects whose pointers are contained sl@0: in the array. sl@0: */ sl@0: {RPointerArrayBase::Reset();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::Find(const T* anEntry) const sl@0: /** sl@0: Finds the first object pointer in the array which matches the specified object sl@0: pointer, using a sequential search. sl@0: sl@0: Matching is based on the comparison of pointers. sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @return The index of the first matching object pointer within the array. sl@0: KErrNotFound, if no matching object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::Find(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::Find(const T* anEntry, TIdentityRelation anIdentity) const sl@0: /** sl@0: Finds the first object pointer in the array whose object matches the specified sl@0: object, using a sequential search and a matching algorithm. sl@0: sl@0: The algorithm for determining whether two class T objects match is provided sl@0: by a function supplied by the caller. sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anIdentity A package encapsulating the function which determines whether sl@0: two class T objects match. sl@0: sl@0: @return The index of the first matching object pointer within the array. sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::Find(anEntry,anIdentity); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::FindReverse(const T* anEntry) const sl@0: /** sl@0: Finds the last object pointer in the array which matches the specified object sl@0: pointer, using a sequential search. sl@0: sl@0: Matching is based on the comparison of pointers. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @return The index of the last matching object pointer within the array. sl@0: KErrNotFound, if no matching object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindReverse(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::FindReverse(const T* anEntry, TIdentityRelation anIdentity) const sl@0: /** sl@0: Finds the last object pointer in the array whose object matches the specified sl@0: object, using a sequential search and a matching algorithm. sl@0: sl@0: The algorithm for determining whether two class T objects match is provided sl@0: by a function supplied by the caller. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anIdentity A package encapsulating the function which determines whether sl@0: two class T objects match. sl@0: sl@0: @return The index of the last matching object pointer within the array. sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindReverse(anEntry,anIdentity); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::FindInAddressOrder(const T* anEntry) const sl@0: /** sl@0: Finds the object pointer in the array that matches the specified object sl@0: pointer, using a binary search technique. sl@0: sl@0: The function assumes that object pointers in the array are in address order. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: sl@0: @return The index of the matching object pointer within the array or KErrNotFound sl@0: if no suitable object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::FindInOrder(const T* anEntry, TLinearOrder anOrder) const sl@0: /** sl@0: Finds the object pointer in the array whose object matches the specified sl@0: object, using a binary search technique and an ordering algorithm. sl@0: sl@0: The function assumes that existing object pointers in the array are ordered sl@0: so that the objects themselves are in object order as determined by an algorithm sl@0: supplied by the caller and packaged as a TLinearOrder. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return The index of the matching object pointer within the array or KErrNotFound, sl@0: if no suitable object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindIsq(anEntry,anOrder); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::FindInAddressOrder(const T* anEntry, TInt& anIndex) const sl@0: /** sl@0: Finds the object pointer in the array that matches the specified object sl@0: pointer, using a binary search technique. sl@0: sl@0: The function assumes that object pointers in the array are in address order. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anIndex A TInt supplied by the caller. On return, contains an index sl@0: value: sl@0: If the function returns KErrNone, this is the index of the sl@0: matching object pointer within the array. sl@0: If the function returns KErrNotFound, this is the sl@0: index of the first object pointer within the array which sl@0: logically follows after anEntry. sl@0: sl@0: @return KErrNone, if a matching object pointer is found. sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::FindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder anOrder) const sl@0: /** sl@0: Finds the object pointer in the array whose object matches the specified sl@0: object, using a binary search technique and an ordering algorithm. sl@0: sl@0: The function assumes that existing object pointers in the array are ordered sl@0: so that the objects themselves are in object order as determined by an sl@0: algorithm supplied by the caller and packaged as a TLinearOrder. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anIndex A TInt supplied by the caller. On return, contains an sl@0: index value: sl@0: If the function returns KErrNone, this is the index of the sl@0: matching object pointer within the array. sl@0: If the function returns KErrNotFound, this is the index of sl@0: the first object pointer in the array whose object is larger sl@0: than the entry being searched for - if no objects pointed to in sl@0: the array are larger, then the index value is the same as the sl@0: total number of object pointers in the array. sl@0: sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return KErrNone, if a matching object pointer is found. sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::BinarySearch(anEntry,anIndex,anOrder); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::SpecificFindInAddressOrder(const T* anEntry, TInt aMode) const sl@0: /** sl@0: Finds the object pointer in the array that matches the specified object sl@0: pointer, using a binary search technique. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last sl@0: or any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that object pointers in the array are in address order. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param aMode Specifies whether to find the first match, the last match or sl@0: any match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array sl@0: index of a matching element - what the index refers to depends on the sl@0: value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of sl@0: the array, then the index value is the same as the total number of elements in the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry, aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::SpecificFindInOrder(const T* anEntry, TLinearOrder anOrder, TInt aMode) const sl@0: /** sl@0: Finds the object pointer in the array whose object matches the specified sl@0: object, using a binary search technique and an ordering algorithm. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last sl@0: or any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that existing object pointers in the array are ordered sl@0: so that the objects themselves are in object order as determined by an algorithm sl@0: supplied by the caller and packaged as a TLinearOrder type. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: @param aMode Specifies whether to find the first match, the last match or any match, sl@0: as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array sl@0: index of a matching element - what the index refers to depends on sl@0: the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of the array, sl@0: then the index value is the same as the total number of elements in the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::FindIsq(anEntry,anOrder,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::SpecificFindInAddressOrder(const T* anEntry, TInt& anIndex, TInt aMode) const sl@0: /** sl@0: Finds the object pointer in the array that matches the specified object sl@0: pointer, using a binary search technique. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last sl@0: or any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that object pointers in the array are in address order. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains an sl@0: index value depending on whether a match is found and on the sl@0: value of aMode. sl@0: If there is no matching element in the array, then this is sl@0: the index of the first element in the array that is bigger than sl@0: the element being searched for - if no elements in the array are sl@0: bigger, then the index value is the same as the total number of sl@0: elements in the array. If there is a matching element, then what sl@0: the index refers to depends on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows the sl@0: last matching element - if the last matching element is also the last element of the array, sl@0: then the index value is the same as the total number of elements in the array. sl@0: sl@0: @param aMode Specifies whether to find the first match, the last match or any sl@0: match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNone, if a matching object pointer is found. sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::SpecificFindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder anOrder, TInt aMode) const sl@0: /** sl@0: Finds the object pointer in the array whose object matches the specified sl@0: object, using a binary search technique and an ordering algorithm. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last or any sl@0: matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that existing object pointers in the array are ordered sl@0: so that the objects themselves are in object order as determined by an sl@0: algorithm supplied by the caller and packaged as a TLinearOrder type. sl@0: sl@0: @param anEntry The object pointer to be found. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains an sl@0: index value depending on whether a match is found and on the sl@0: value of aMode. If there is no matching element in the array, sl@0: then this is the index of the first element in the array sl@0: that is bigger than the element being searched for - if sl@0: no elements in the array are bigger, then the index value sl@0: is the same as the total number of elements in the array. sl@0: If there is a matching element, then what the index refers to sl@0: depends on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element sl@0: of the array, then the index value is the same as the total number of elements in the array. sl@0: sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: @param aMode Specifies whether to find the first match, the last match or sl@0: any match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNone, if a matching object pointer is found. sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::BinarySearch(anEntry,anIndex,anOrder,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::InsertInAddressOrder(const T* anEntry) sl@0: /** sl@0: Inserts an object pointer into the array in address order. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: The function assumes that existing object pointers within the array are in sl@0: address order. sl@0: sl@0: @param anEntry The object pointer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,EFalse); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::InsertInOrder(const T* anEntry, TLinearOrder anOrder) sl@0: /** sl@0: Inserts an object pointer into the array so that the object itself is in object sl@0: order. sl@0: sl@0: The algorithm for determining the order of two class T objects is provided sl@0: by a function supplied by the caller. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: The function assumes that the array is ordered so that the referenced objects sl@0: are in object order. sl@0: sl@0: @param anEntry The object pointer to be inserted. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsq(anEntry,anOrder,EFalse); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::InsertInAddressOrderAllowRepeats(const T* anEntry) sl@0: /** sl@0: Inserts an object pointer into the array in address order, allowing duplicates. sl@0: sl@0: If the new object pointer is a duplicate of an existing object pointer in sl@0: the array, then the new pointer is inserted after the existing one. If more sl@0: than one duplicate object pointer already exists in the array, then any new sl@0: duplicate pointer is inserted after the last one. sl@0: sl@0: The function assumes that existing object pointers within the array are in sl@0: address order. sl@0: sl@0: @param anEntry The object pointer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,ETrue); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::InsertInOrderAllowRepeats(const T* anEntry, TLinearOrder anOrder) sl@0: /** sl@0: Inserts an object pointer into the array so that the object itself is in object sl@0: order, allowing duplicates sl@0: sl@0: The algorithm for determining the order of two class T objects is provided sl@0: by a function supplied by the caller. sl@0: sl@0: If the specified object is a duplicate of an existing object, then the new sl@0: pointer is inserted after the pointer to the existing object. If more than sl@0: one duplicate object already exists, then the new pointer is inserted after sl@0: the pointer to the last one. sl@0: sl@0: @param anEntry The object pointer to be inserted. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsq(anEntry,anOrder,ETrue); } sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: template sl@0: inline RPointerArray::RPointerArray(T** aEntries, TInt aCount) sl@0: : RPointerArrayBase((TAny **)aEntries, aCount) sl@0: /** sl@0: C++ constructor with a pointer to the first array entry in a pre-existing sl@0: array, and the number of entries in that array. sl@0: sl@0: This constructor takes a pointer to a pre-existing set of entries of type sl@0: pointer to class T, which is owned by another RPointerArray object. Ownership sl@0: of the set of entries still resides with the original RPointerArray object. sl@0: sl@0: @param aEntries A pointer to the first entry of type pointer to class T in sl@0: the set of entries belonging to the existing array. sl@0: @param aCount The number of entries in the existing array. The granularity of sl@0: this array is set to this value. sl@0: sl@0: @panic USER 156, if aCount is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::GranularCompress() sl@0: /** sl@0: Compresses the array down to a granular boundary. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: for its contained object pointers. Adding new object pointers to the array sl@0: does not result in a re-allocation of memory until the the total number of sl@0: pointers reaches a multiple of the granularity. sl@0: */ sl@0: {RPointerArrayBase::GranularCompress();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RPointerArray::Reserve(TInt aCount) sl@0: /** sl@0: Reserves space for the specified number of elements. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: to hold the number of object pointers specified. Adding new object pointers to the array sl@0: does not result in a re-allocation of memory until the the total number of sl@0: pointers exceeds the specified count. sl@0: sl@0: @param aCount The number of object pointers for which space should be reserved sl@0: @return KErrNone If the operation completed successfully sl@0: @return KErrNoMemory If the requested amount of memory could not be allocated sl@0: */ sl@0: { return RPointerArrayBase::DoReserve(aCount); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::SortIntoAddressOrder() sl@0: /** sl@0: Sorts the object pointers within the array into address order. sl@0: */ sl@0: { HeapSortUnsigned(); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RPointerArray::Sort(TLinearOrder anOrder) sl@0: /** sl@0: Sorts the object pointers within the array. sl@0: sl@0: The sort order of the pointers is based on the order of the referenced objects. sl@0: The referenced object order is determined by an algorithm supplied by the sl@0: caller and packaged as a TLinerOrder. sl@0: sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: */ sl@0: { HeapSort(anOrder); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TArray RPointerArray::Array() const sl@0: /** sl@0: Constructs and returns a generic array. sl@0: sl@0: @return A generic array representing this array. sl@0: sl@0: @see TArray sl@0: */ sl@0: { return TArray(GetCount,GetElementPtr,(const CBase*)this); } sl@0: #endif sl@0: sl@0: sl@0: sl@0: template sl@0: void RPointerArray::ResetAndDestroy() sl@0: /** sl@0: Empties the array and deletes the referenced objects. sl@0: sl@0: It frees all memory allocated to the array and resets the internal state so sl@0: that it is ready to be reused. The function also deletes all of the objects sl@0: whose pointers are contained by the array. sl@0: sl@0: This array object can be allowed to go out of scope after a call to this function. sl@0: */ sl@0: { sl@0: TInt c=Count(); sl@0: T** pE=(T**)Entries(); sl@0: ZeroCount(); sl@0: TInt i; sl@0: for (i=0; i sl@0: sl@0: /** sl@0: Default C++ constructor. sl@0: sl@0: This constructs an array object for an array of TAny pointers with default sl@0: granularity, which is 8. sl@0: */ sl@0: inline RPointerArray::RPointerArray() sl@0: : RPointerArrayBase() sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with granularity. sl@0: sl@0: This constructs an array object for an array of TAny pointers with the specified sl@0: granularity. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic USER 127, if aGranularity is not positive, or greater than or equal sl@0: to 0x10000000. sl@0: */ sl@0: inline RPointerArray::RPointerArray(TInt aGranularity) sl@0: : RPointerArrayBase(aGranularity) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with minimum growth step and exponential growth factor. sl@0: sl@0: This constructs an array object for an array of TAny pointers with the specified sl@0: minimum growth step and exponential growth factor. sl@0: sl@0: @param aMinGrowBy The minimum growth step of the array. Must be between 1 and sl@0: 65535 inclusive. sl@0: @param aFactor The factor by which the array grows, multiplied by 256. sl@0: For example 512 specifies a factor of 2. Must be between 257 sl@0: and 32767 inclusive. sl@0: sl@0: @panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535. sl@0: @panic USER 193, if aFactor<=257 or aFactor>32767. sl@0: */ sl@0: inline RPointerArray::RPointerArray(TInt aMinGrowBy, TInt aFactor) sl@0: : RPointerArrayBase(aMinGrowBy, aFactor) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RPointerArray::Close() sl@0: /** sl@0: Closes the array and frees all memory allocated to it. sl@0: sl@0: The function must be called before this array object goes out of scope. sl@0: sl@0: Note that the function does not delete the objects whose pointers are contained sl@0: in the array. sl@0: */ sl@0: {RPointerArrayBase::Close();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::Count() const sl@0: /** sl@0: Gets the number of pointers in the array. sl@0: sl@0: @return The number of pointers in the array. sl@0: */ sl@0: { return RPointerArrayBase::Count(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny* const& RPointerArray::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the pointer located at the specified sl@0: position within the array. sl@0: sl@0: The compiler chooses this option if the returned reference is used in sl@0: an expression where the reference cannot be modified. sl@0: sl@0: @param anIndex The position of the pointer within the array. The sl@0: position is relative to zero, i.e. zero implies the object sl@0: pointer at the beginning of the array. sl@0: sl@0: @return A const reference to the pointer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {return At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny*& RPointerArray::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to the pointer located at the specified sl@0: position within the array. sl@0: sl@0: The compiler chooses this option if the returned reference is used in sl@0: an expression where the reference can be modified. sl@0: sl@0: @param anIndex The position of the pointer within the array. The sl@0: position is relative to zero, i.e. zero implies the object sl@0: pointer at the beginning of the array. sl@0: sl@0: @return A non-const reference to the pointer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {return At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::Append(const TAny* anEntry) sl@0: /** sl@0: Appends an pointer onto the array. sl@0: sl@0: @param anEntry The pointer to be appended. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::Append(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::Insert(const TAny* anEntry, TInt aPos) sl@0: /** sl@0: Inserts an pointer into the array at the specified position. sl@0: sl@0: @param anEntry The pointer to be inserted. sl@0: @param aPos The position within the array where the pointer is to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that a pointer is inserted at the beginning of the array. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: sl@0: @panic USER 131, if aPos is negative, or is greater than the number of object sl@0: pointers currently in the array. sl@0: */ sl@0: { return RPointerArrayBase::Insert(anEntry,aPos); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void RPointerArray::Remove(TInt anIndex) sl@0: /** sl@0: Removes the pointer at the specified position from the array. sl@0: sl@0: Note that the function does not delete the object whose pointer is removed. sl@0: sl@0: @param anIndex The position within the array from where the pointer sl@0: is to be removed. The position is relative to zero, i.e. zero sl@0: implies that a pointer at the beginning of the array is to be sl@0: removed. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {RPointerArrayBase::Remove(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RPointerArray::Compress() sl@0: /** sl@0: Compresses the array down to a minimum. sl@0: sl@0: After a call to this function, the memory allocated to the array is just sl@0: sufficient for its contained pointers. sl@0: Subsequently adding a new pointer to the array sl@0: always results in a re-allocation of memory. sl@0: */ sl@0: {RPointerArrayBase::Compress();} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RPointerArray::Reset() sl@0: /** sl@0: Empties the array. sl@0: sl@0: It frees all memory allocated to the array and resets the internal state so sl@0: that it is ready to be reused. sl@0: sl@0: This array object can be allowed to go out of scope after a call to this sl@0: function. sl@0: sl@0: Note that the function does not delete the objects whose pointers are contained sl@0: in the array. sl@0: */ sl@0: {RPointerArrayBase::Reset();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::Find(const TAny* anEntry) const sl@0: /** sl@0: Finds the first pointer in the array which matches the specified pointer, using sl@0: a sequential search. sl@0: sl@0: Matching is based on the comparison of pointers. sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry The pointer to be found. sl@0: @return The index of the first matching pointer within the array. sl@0: KErrNotFound, if no matching pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::Find(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::FindReverse(const TAny* anEntry) const sl@0: /** sl@0: Finds the last pointer in the array which matches the specified pointer, using sl@0: a sequential search. sl@0: sl@0: Matching is based on the comparison of pointers. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry The pointer to be found. sl@0: @return The index of the last matching pointer within the array. sl@0: KErrNotFound, if no matching pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindReverse(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::FindInAddressOrder(const TAny* anEntry) const sl@0: /** sl@0: Finds the pointer in the array that matches the specified object sl@0: pointer, using a binary search technique. sl@0: sl@0: The function assumes that pointers in the array are in address order. sl@0: sl@0: @param anEntry The pointer to be found. sl@0: sl@0: @return The index of the matching pointer within the array or KErrNotFound sl@0: if no suitable pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::FindInAddressOrder(const TAny* anEntry, TInt& anIndex) const sl@0: /** sl@0: Finds the pointer in the array that matches the specified object sl@0: pointer, using a binary search technique. sl@0: sl@0: The function assumes that pointers in the array are in address order. sl@0: sl@0: @param anEntry The pointer to be found. sl@0: @param anIndex A TInt supplied by the caller. On return, contains an index sl@0: value: sl@0: If the function returns KErrNone, this is the index of the sl@0: matching pointer within the array. sl@0: If the function returns KErrNotFound, this is the index of the sl@0: last pointer within the array which logically sl@0: precedes anEntry. sl@0: sl@0: @return KErrNone, if a matching pointer is found. sl@0: KErrNotFound, if no suitable pointer can be found. sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::SpecificFindInAddressOrder(const TAny* anEntry, TInt aMode) const sl@0: /** sl@0: Finds the pointer in the array that matches the specified pointer, using a sl@0: binary search technique. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last sl@0: or any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that pointers in the array are in address order. sl@0: sl@0: @param anEntry The pointer to be found. sl@0: @param aMode Specifies whether to find the first match, the last match or sl@0: any match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array sl@0: index of a matching element - what the index refers to depends on the sl@0: value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of sl@0: the array, then the index value is the same as the total number of elements in the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry, aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::SpecificFindInAddressOrder(const TAny* anEntry, TInt& anIndex, TInt aMode) const sl@0: /** sl@0: Finds the pointer in the array that matches the specified pointer, using a sl@0: binary search technique. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last sl@0: or any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that pointers in the array are in address order. sl@0: sl@0: @param anEntry The pointer to be found. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains an sl@0: index value depending on whether a match is found and on the sl@0: value of aMode. sl@0: If there is no matching element in the array, then this is sl@0: the index of the first element in the array that is bigger than sl@0: the element being searched for - if no elements in the array are sl@0: bigger, then the index value is the same as the total number of sl@0: elements in the array. If there is a matching element, then what sl@0: the index refers to depends on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows the sl@0: last matching element - if the last matching element is also the last element of the array, sl@0: then the index value is the same as the total number of elements in the array. sl@0: sl@0: @param aMode Specifies whether to find the first match, the last match or any sl@0: match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNone, if a matching pointer is found. sl@0: KErrNotFound, if no suitable pointer can be found. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::InsertInAddressOrder(const TAny* anEntry) sl@0: /** sl@0: Inserts an pointer into the array in address order. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: The function assumes that existing pointers within the array are in sl@0: address order. sl@0: sl@0: @param anEntry The pointer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,EFalse); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RPointerArray::InsertInAddressOrderAllowRepeats(const TAny* anEntry) sl@0: /** sl@0: Inserts an pointer into the array in address order, allowing duplicates. sl@0: sl@0: If the new pointer is a duplicate of an existing pointer in sl@0: the array, then the new pointer is inserted after the existing one. If more sl@0: than one duplicate pointer already exists in the array, then any new sl@0: duplicate pointer is inserted after the last one. sl@0: sl@0: The function assumes that existing pointers within the array are in sl@0: address order. sl@0: sl@0: @param anEntry The pointer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,ETrue); } sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline RPointerArray::RPointerArray(TAny** aEntries, TInt aCount) sl@0: : RPointerArrayBase((TAny **)aEntries, aCount) sl@0: /** sl@0: C++ constructor with a pointer to the first array entry in a pre-existing sl@0: array, and the number of entries in that array. sl@0: sl@0: This constructor takes a pointer to a pre-existing set of entries of type TAny*, sl@0: which is owned by another RPointerArray object. Ownership of the set of entries sl@0: still resides with the original RPointerArray object. sl@0: sl@0: @param aEntries A pointer to the first entry of type TAny* in the set of entries sl@0: belonging to the existing array. sl@0: @param aCount The number of entries in the existing array. The granularity of sl@0: this array is set to this value. sl@0: sl@0: @panic USER 156, if aCount is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RPointerArray::GranularCompress() sl@0: /** sl@0: Compresses the array down to a granular boundary. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: for its contained pointers. Adding new pointers to the array sl@0: does not result in a re-allocation of memory until the the total number of sl@0: pointers reaches a multiple of the granularity. sl@0: */ sl@0: {RPointerArrayBase::GranularCompress();} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RPointerArray::SortIntoAddressOrder() sl@0: /** sl@0: Sorts the pointers within the array into address order. sl@0: */ sl@0: { HeapSortUnsigned(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TArray RPointerArray::Array() const sl@0: /** sl@0: Constructs and returns a generic array. sl@0: sl@0: @return A generic array representing this array. sl@0: sl@0: @see TArray sl@0: */ sl@0: { return TArray(GetCount,GetElementPtr,(const CBase*)this); } sl@0: #endif sl@0: sl@0: sl@0: sl@0: template sl@0: inline RArray::RArray() sl@0: : RArrayBase(sizeof(T)) sl@0: /** sl@0: Default C++ constructor. sl@0: sl@0: This constructs an array object for an array of type class T objects with sl@0: default granularity and key offset value. The default granularity is 8 and sl@0: the defaul key offset value is zero. sl@0: sl@0: @panic USER 129, if the size of class T is not positive or is not less sl@0: than 640. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline RArray::RArray(TInt aGranularity) sl@0: : RArrayBase(sizeof(T),aGranularity) sl@0: /** sl@0: C++ constructor with granularity. sl@0: sl@0: This constructs an array object for an array of type class T objects with sl@0: a specified granularity and default key offset value. The default key offset sl@0: value is zero. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic USER 129, if the size of class T is not positive or is not less sl@0: than 640. sl@0: @panic USER 127, if aGranularity is not positive or the product of this sl@0: value and the size of class T is not less than 0x10000000. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline RArray::RArray(TInt aGranularity, TInt aKeyOffset) sl@0: : RArrayBase(sizeof(T),aGranularity,aKeyOffset) sl@0: /** sl@0: C++ constructor with granularity and key offset. sl@0: sl@0: This constructs an array object for an array of type class T objects with sl@0: a specified granularity and a specified key offset value. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: @param aKeyOffset The key offset. sl@0: sl@0: @panic USER 129, if the size of class T is not positive or is not less sl@0: than 640. sl@0: @panic USER 127, if aGranularity is not positive or the product of this sl@0: value and the size of class T is not less than 0x10000000. sl@0: @panic USER 128, if aKeyOffset is not positive, or is not less than the sl@0: size of class T, or is not a multiple of 4. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with minimum growth step and exponential growth factor. sl@0: sl@0: This constructs an array object for an array of class T objects with the sl@0: specified minimum growth step and exponential growth factor. sl@0: sl@0: @param aMinGrowBy The minimum growth step of the array. Must be between 1 and sl@0: 65535 inclusive. sl@0: @param aKeyOffset The key offset. sl@0: @param aFactor The factor by which the array grows, multiplied by 256. sl@0: For example 512 specifies a factor of 2. Must be between 257 sl@0: and 32767 inclusive. sl@0: sl@0: @panic USER 129, if the size of class T is not positive or is not less than 640. sl@0: @panic USER 128, if aKeyOffset is negative, or is not less than the sl@0: size of class T, or is not a multiple of 4. sl@0: @panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535. sl@0: @panic USER 193, if aFactor<=257 or aFactor>32767. sl@0: */ sl@0: template sl@0: inline RArray::RArray(TInt aMinGrowBy, TInt aKeyOffset, TInt aFactor) sl@0: : RArrayBase(sizeof(T), aMinGrowBy, aKeyOffset, aFactor) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline RArray::RArray(TInt aEntrySize,T* aEntries, TInt aCount) sl@0: : RArrayBase(aEntrySize,aEntries,aCount) sl@0: /** sl@0: C++ constructor with size of entry, a pointer to the first array entry in a sl@0: pre-existing array, and the number of entries in that array. sl@0: sl@0: This constructor takes a pointer to a pre-existing set of entries of type sl@0: class T objects owned by another RArray object. Ownership of the set of entries sl@0: still resides with the original RArray object. sl@0: sl@0: This array is assigned a default granularity and key offset value. The default sl@0: granularity is 8 and the default key offset value is zero. sl@0: sl@0: The purpose of constructing an array in this way is to allow sorting and sl@0: finding operations to be done without further allocation of memory. sl@0: sl@0: @param aEntrySize The size of an entry in the existing array. sl@0: @param aEntries A pointer to the first entry of type class T in the set of sl@0: entries belonging to the existing array. sl@0: @param aCount The number of entries in the existing array. sl@0: sl@0: @panic USER 129, if aEntrySize is not positive or is not less than 640. sl@0: @panic USER 156, if aCount is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::Close() sl@0: /** sl@0: Closes the array and frees all memory allocated to the array. sl@0: sl@0: The function must be called before this array object is destroyed. sl@0: */ sl@0: {RArrayBase::Close();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::Count() const sl@0: /** sl@0: Gets the number of objects in the array. sl@0: sl@0: @return The number of objects in the array. sl@0: */ sl@0: {return RArrayBase::Count();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T& RArray::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to an object located at a specified position within the array. sl@0: sl@0: The compiler chooses this function if the returned reference is used in an sl@0: expression where the reference cannot be modified. sl@0: sl@0: @param anIndex The position of the object within the array. The position is sl@0: relative to zero, i.e. zero implies the object at the beginning sl@0: of the array. sl@0: sl@0: @return A const reference to the object at position anIndex within the array. sl@0: sl@0: @panic USER 130, if anIndex is negative or is greater than the number of sl@0: objects currently in the array sl@0: */ sl@0: {return *(const T*)At(anIndex); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T& RArray::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to an object located at a specified position within the array. sl@0: sl@0: The compiler chooses this function if the returned reference is used in an sl@0: expression where the reference can be modified. sl@0: sl@0: @param anIndex The position of the object within the array. The position is sl@0: relative to zero, i.e. zero implies the object at the beginning sl@0: of the array. sl@0: sl@0: @return A non-const reference to the object at position anIndex within the array. sl@0: sl@0: @panic USER 130, if anIndex is negative or is greater than the number of sl@0: objects currently in the array sl@0: */ sl@0: {return *(T*)At(anIndex); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::Append(const T& anEntry) sl@0: /** sl@0: Apends an object onto the array. sl@0: sl@0: @param anEntry A reference to the object of type class T to be appended. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: {return RArrayBase::Append(&anEntry);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::Insert(const T& anEntry, TInt aPos) sl@0: /** sl@0: Inserts an object into the array at a specified position. sl@0: sl@0: @param anEntry The class T object to be inserted. sl@0: @param aPos The position within the array where the object is to sl@0: be inserted. The position is relative to zero, i.e. zero sl@0: implies that an object is inserted at the beginning of sl@0: the array. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: sl@0: @panic USER 131, if aPos is negative or is greater than the number of objects sl@0: currently in the array. sl@0: */ sl@0: {return RArrayBase::Insert(&anEntry,aPos);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::Remove(TInt anIndex) sl@0: /** sl@0: Removes the object at a specified position from the array. sl@0: sl@0: @param anIndex The position within the array from where the object is to be sl@0: removed. The position is relative to zero, i.e. zero implies sl@0: that an object at the beginning of the array is to be removed. sl@0: sl@0: @panic USER 130, if anIndex is negative or is greater than the number of sl@0: objects currently in the array. sl@0: */ sl@0: {RArrayBase::Remove(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::Compress() sl@0: /** sl@0: Compresses the array down to a minimum. sl@0: sl@0: After a call to this function, the memory allocated to the array is just sl@0: sufficient for its contained objects. Subsequently adding a new object to the sl@0: array always results in a re-allocation of memory. sl@0: */ sl@0: {RArrayBase::Compress();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::Reset() sl@0: /** sl@0: Empties the array, so that it is ready to be reused. sl@0: sl@0: The function frees all memory allocated to the array and resets the internal sl@0: state so that it is ready to be reused. sl@0: sl@0: This array object can be allowed to go out of scope after a call to this function. sl@0: */ sl@0: {RArrayBase::Reset();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::Find(const T& anEntry) const sl@0: /** sl@0: Finds the first object in the array which matches the specified object using sl@0: a sequential search. sl@0: sl@0: Matching is based on the comparison of a TInt value at the key offset position sl@0: within the objects. sl@0: sl@0: For classes which define their own equality operator (==), the alternative method sl@0: Find(const T& anEntry, TIdentityRelation anIdentity) is recommended. sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: sl@0: @return The index of the first matching object within the array. sl@0: KErrNotFound, if no matching object can be found. sl@0: */ sl@0: {return RArrayBase::Find(&anEntry);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::Find(const T& anEntry, TIdentityRelation anIdentity) const sl@0: /** sl@0: Finds the first object in the array which matches the specified object using sl@0: a sequential search and a matching algorithm. sl@0: sl@0: The algorithm for determining whether two class T type objects match is provided sl@0: by a function supplied by the caller. sl@0: sl@0: Such a function need not be supplied if an equality operator (==) is defined for class T. sl@0: In this case, default construction of anIdentity provides matching, as in the example below: sl@0: sl@0: @code sl@0: //Construct a TPoint and append to an RArray sl@0: TPoint p1(0,0); sl@0: RArray points; sl@0: points.AppendL(p1); sl@0: //Find position of p1 in points using TIdentityRelation default construction sl@0: TInt r = points.Find(p1, TIdentityRelation()); sl@0: @endcode sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used sl@0: for matching. sl@0: @param anIdentity A package encapsulating the function which determines whether sl@0: two class T type objects match. sl@0: sl@0: @return The index of the first matching object within the array. sl@0: KErrNotFound, if no matching object can be found. sl@0: */ sl@0: {return RArrayBase::Find(&anEntry,anIdentity);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindReverse(const T& anEntry) const sl@0: /** sl@0: Finds the last object in the array which matches the specified object using sl@0: a sequential search. sl@0: sl@0: Matching is based on the comparison of a TInt value at the key offset position sl@0: within the objects. sl@0: sl@0: For classes which define their own equality operator (==), the alternative method sl@0: FindReverse(const T& anEntry, TIdentityRelation anIdentity) is recommended. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: sl@0: @return The index of the last matching object within the array. sl@0: KErrNotFound, if no matching object can be found. sl@0: */ sl@0: {return RArrayBase::FindReverse(&anEntry);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindReverse(const T& anEntry, TIdentityRelation anIdentity) const sl@0: /** sl@0: Finds the last object in the array which matches the specified object using sl@0: a sequential search and a matching algorithm. sl@0: sl@0: The algorithm for determining whether two class T type objects match is provided sl@0: by a function supplied by the caller. sl@0: sl@0: Such a function need not be supplied if an equality operator (==) is defined for class T. sl@0: In this case, default construction of anIdentity provides matching. sl@0: sl@0: See Find(const T& anEntry, TIdentityRelation anIdentity) for more details. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of objects in the array. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used sl@0: for matching. sl@0: @param anIdentity A package encapsulating the function which determines whether sl@0: two class T type objects match. sl@0: sl@0: @return The index of the last matching object within the array. sl@0: KErrNotFound, if no matching object can be found. sl@0: */ sl@0: {return RArrayBase::FindReverse(&anEntry,anIdentity);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindInSignedKeyOrder(const T& anEntry) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The function assumes that existing objects within the array are in signed sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: sl@0: @return The index of the matching object within the array, or KErrNotFound sl@0: if no matching object can be found. sl@0: */ sl@0: {return RArrayBase::FindIsqSigned(&anEntry);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindInUnsignedKeyOrder(const T& anEntry) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The function assumes that existing objects within the array are in unsigned sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: sl@0: @return The index of the matching object within the array, or KErrNotFound sl@0: if no matching object can be found. sl@0: */ sl@0: {return RArrayBase::FindIsqUnsigned(&anEntry);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindInOrder(const T& anEntry, TLinearOrder anOrder) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique and an ordering algorithm. sl@0: sl@0: The function assumes that existing objects within the array are in object sl@0: order as determined by an algorithm supplied by the caller and packaged as sl@0: a TLinearOrder. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return The index of the matching object within the array, or KErrNotFound if sl@0: no matching object can be found. sl@0: */ sl@0: {return RArrayBase::FindIsq(&anEntry,anOrder);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindInSignedKeyOrder(const T& anEntry, TInt& anIndex) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The function assumes that existing objects within the array are in signed sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anIndex On return contains an index value. If the function returns KErrNone, sl@0: this is the index of the matching object within the array. sl@0: If the function returns KErrNotFound, this is the index of the sl@0: first element in the array whose key is bigger than the key of the sl@0: element being sought. If there are no elements in the array with sl@0: a bigger key, then the index value is the same as the total sl@0: number of elements in the array. sl@0: @return KErrNone if a matching object is found, or KErrNotFound if no matching sl@0: object can be found. sl@0: */ sl@0: {return RArrayBase::BinarySearchSigned(&anEntry,anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The function assumes that existing objects within the array are in unsigned sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anIndex On return contains an index value. If the function returns sl@0: KErrNone, this is the index of the matching object within the sl@0: array. sl@0: If the function returns KErrNotFound, this is the index of the sl@0: first element in the array whose key is bigger than the key of the sl@0: element being sought. If there are no elements in the array with sl@0: a bigger key, then the index value is the same as the total sl@0: number of elements in the array. sl@0: @return KErrNone if a matching object is found, or KErrNotFound if no matching sl@0: object can be found. sl@0: */ sl@0: {return RArrayBase::BinarySearchUnsigned(&anEntry,anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::FindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder anOrder) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique and an ordering algorithm. sl@0: sl@0: The function assumes that existing objects within the array are in object sl@0: order as determined by an algorithm supplied by the caller and packaged as sl@0: a TLinearOrder. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anIndex On return contains an index value. If the function returns sl@0: KErrNone, this is the index of the matching object within the sl@0: array. sl@0: If the function returns KErrNotFound, this is the index of the sl@0: first element in the array that is bigger than the element being sl@0: searched for - if no elements in the array are bigger, then sl@0: the index value is the same as the total number of elements in sl@0: the array. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return KErrNone if a matching object is found. KErrNotFound if no matching sl@0: object can be found. sl@0: */ sl@0: {return RArrayBase::BinarySearch(&anEntry,anIndex,anOrder);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::SpecificFindInSignedKeyOrder(const T& anEntry, TInt aMode) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The element ordering is determined by a signed 32-bit word sl@0: (the key) embedded in each array element. In the case that there is more than sl@0: one matching element, finds the first, last or any match as specified by sl@0: the value of aMode. sl@0: sl@0: The function assumes that existing objects within the array are in signed sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param aMode Specifies whether to find the first match, the last match or sl@0: any match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array sl@0: index of a matching element - what the index refers to depends on the sl@0: value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of sl@0: the array, then the index value is the same as the total number of elements in the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: {return RArrayBase::FindIsqSigned(&anEntry,aMode);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt aMode) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The element ordering is determined by an unsigned 32-bit word sl@0: (the key) embedded in each array element. Where there is more than sl@0: one matching element, it finds the first, last or any matching element sl@0: as specified by the value of aMode. sl@0: sl@0: The function assumes that existing objects within the array are in unsigned sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param aMode Specifies whether to find the first match, the last match or sl@0: any match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array sl@0: index of a matching element - what the index refers to depends on the sl@0: value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows the sl@0: last matching element - if the last matching element is also the last element of the array, sl@0: then the index value is the same as the total number of elements in the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: {return RArrayBase::FindIsqUnsigned(&anEntry,aMode);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::SpecificFindInOrder(const T& anEntry, TLinearOrder anOrder, TInt aMode) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique and an ordering algorithm. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last sl@0: or any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that existing objects within the array are in object sl@0: order as determined by an algorithm supplied by the caller and packaged as sl@0: a TLinearOrder type. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: @param aMode Specifies whether to find the first match, the last match or any sl@0: match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array index sl@0: of a matching element - what the index refers to depends on the value of sl@0: aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of sl@0: the array, then the index value is the same as the total number of elements in the array. sl@0: */ sl@0: {return RArrayBase::FindIsq(&anEntry,anOrder,aMode);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::SpecificFindInSignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The element ordering is determined by a signed 32-bit word sl@0: (the key) embedded in each array element. Where there is more than sl@0: one matching element, finds the first, last or any matching element as sl@0: specified specified by the value of aMode. sl@0: sl@0: The function assumes that existing objects within the array are in signed sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains sl@0: an index value depending on whether a match is found and on the sl@0: value of aMode. If there is no matching element in the array, sl@0: then this is the index of the first element in the array that sl@0: is bigger than the element being searched for - if no elements sl@0: in the array are bigger, then the index value is the same as the sl@0: total number of elements in the array. If there is a matching sl@0: element, then what the index refers to depends on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of sl@0: the array, then the index value is the same as the total number of elements in the array. sl@0: @param aMode Specifies whether to find the first match, the last match or any match, sl@0: as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNone, if a matching object pointer is found; sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: */ sl@0: {return RArrayBase::BinarySearchSigned(&anEntry,anIndex,aMode);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique. sl@0: sl@0: The element ordering is determined by an unsigned 32-bit word sl@0: (the key) embedded in each array element. Where there is more than sl@0: one matching element, it finds the first, last or any matching element as sl@0: specified by the value of aMode. sl@0: sl@0: The function assumes that existing objects within the array are in unsigned sl@0: key order. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains an index sl@0: value depending on whether a match is found and on the value of aMode. sl@0: If there is no matching element in the array, then this is the index sl@0: of the first element in the array that is bigger than the element sl@0: being searched for - if no elements in the array are bigger, then sl@0: the index value is the same as the total number of elements in the array. sl@0: If there is a matching element, then what the index refers to depends on sl@0: the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows the sl@0: last matching element - if the last matching element is also the last element of the array, sl@0: then the index value is the same as the total number of elements in the array. sl@0: @param aMode Specifies whether to find the first match, the last match or any match, as defined by one sl@0: of the TArrayFindMode enum values. sl@0: @return KErrNone, if a matching object pointer is found; KErrNotFound, if no suitable object pointer can be found. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: {return RArrayBase::BinarySearchUnsigned(&anEntry,anIndex,aMode);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::SpecificFindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder anOrder, TInt aMode) const sl@0: /** sl@0: Finds the object in the array which matches the specified object using a binary sl@0: search technique and a specified ordering algorithm. sl@0: sl@0: Where there is more than one matching element, it finds the first, the last or sl@0: any matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that existing objects within the array are in object sl@0: order as determined by an algorithm supplied by the caller and packaged as sl@0: a TLinearOrder type. sl@0: sl@0: @param anEntry A reference to an object of type class T to be used for matching. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains sl@0: an index value depending on whether a match is found and on the sl@0: value of aMode. If there is no matching element in the array, sl@0: then this is the index of the first element in the array that sl@0: is bigger than the element being searched for - if no elements sl@0: in the array are bigger, then the index value is the same as sl@0: the total number of elements in the array. sl@0: If there is a matching element, then what the index refers to sl@0: depends on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also sl@0: the last element of the array, then the index value is the same as sl@0: the total number of elements in the array. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: @param aMode Specifies whether to find the first match, the last match or any match, sl@0: as defined by one of the TArrayFindMode enum values. sl@0: @return KErrNone, if a matching object pointer is found; sl@0: KErrNotFound, if no suitable object pointer can be found. sl@0: sl@0: */ sl@0: {return RArrayBase::BinarySearch(&anEntry,anIndex,anOrder,aMode);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::InsertInSignedKeyOrder(const T& anEntry) sl@0: /** sl@0: Inserts an object into the array in ascending signed key order. sl@0: sl@0: The order of two class T type objects is based on comparing a TInt value sl@0: located at the key offset position within the class T object. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: @param anEntry A reference to the object of type class T to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: {return RArrayBase::InsertIsqSigned(&anEntry,EFalse);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::InsertInUnsignedKeyOrder(const T& anEntry) sl@0: /** sl@0: Inserts an object into the array in ascending unsigned key order. sl@0: sl@0: The order of two class T type objects is based on comparing a TUint value sl@0: located at the key offset position within the class T object. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: @param anEntry A reference to the object of type class T to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: {return RArrayBase::InsertIsqUnsigned(&anEntry,EFalse);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::InsertInOrder(const T& anEntry, TLinearOrder anOrder) sl@0: /** sl@0: Inserts an object of into the array in object order. sl@0: sl@0: The algorithm for determining the order of two class T type objects is provided sl@0: by a function supplied by the caller. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: The function assumes that existing objects within the array are in object sl@0: order. sl@0: sl@0: @param anEntry A reference to the object of type class T to be inserted. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: {return RArrayBase::InsertIsq(&anEntry,anOrder,EFalse);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::InsertInSignedKeyOrderAllowRepeats(const T& anEntry) sl@0: /** sl@0: Inserts an object into the array in ascending signed key order, sl@0: allowing duplicates. sl@0: sl@0: The order of two class T type objects is based on comparing a TInt value sl@0: located at the key offset position within the class T object. sl@0: sl@0: If anEntry is a duplicate of an existing object in the array, then the new sl@0: object is inserted after the existing object. If more than one duplicate object sl@0: already exists in the array, then any new duplicate object is inserted after sl@0: the last one. sl@0: sl@0: @param anEntry A reference to the object of type class T to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: {return RArrayBase::InsertIsqSigned(&anEntry,ETrue);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::InsertInUnsignedKeyOrderAllowRepeats(const T& anEntry) sl@0: /** sl@0: Inserts an object into the array in ascending unsigned key order, allowing sl@0: duplicates. sl@0: sl@0: The order of two class T type objects is based on comparing a TUint value sl@0: located at the key offset position within the class T object. sl@0: sl@0: If anEntry is a duplicate of an existing object in the array, then the new sl@0: object is inserted after the existing object. If more than one duplicate object sl@0: already exists in the array, then any new duplicate object is inserted after sl@0: the last one. sl@0: sl@0: @param anEntry A reference to the object of type class T to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: {return RArrayBase::InsertIsqUnsigned(&anEntry,ETrue);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::InsertInOrderAllowRepeats(const T& anEntry, TLinearOrder anOrder) sl@0: /** sl@0: Inserts an object into the array in object order, allowing duplicates. sl@0: sl@0: The algorithm for determining the order of two class T type objects is provided sl@0: by a function supplied by the caller. sl@0: sl@0: If anEntry is a duplicate of an existing object in the array, then the new sl@0: object is inserted after the existing object. If more than one duplicate object sl@0: already exists in the array, then anEntry is inserted after the last one. sl@0: sl@0: The function assumes that existing objects within the array are in object sl@0: order. sl@0: sl@0: @param anEntry A reference to the object of type class T to be inserted. sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T objects. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: {return RArrayBase::InsertIsq(&anEntry,anOrder,ETrue);} sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: template sl@0: inline void RArray::GranularCompress() sl@0: /** sl@0: Compresses the array down to a granular boundary. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: for its contained objects. Adding new objects to the array does not result sl@0: in a re-allocation of memory until the the total number of objects reaches sl@0: a multiple of the granularity. sl@0: */ sl@0: {RArrayBase::GranularCompress();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt RArray::Reserve(TInt aCount) sl@0: /** sl@0: Reserves space for the specified number of elements. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: to hold the number of objects specified. Adding new objects to the array sl@0: does not result in a re-allocation of memory until the the total number of sl@0: objects exceeds the specified count. sl@0: sl@0: @param aCount The number of objects for which space should be reserved sl@0: @return KErrNone If the operation completed successfully sl@0: @return KErrNoMemory If the requested amount of memory could not be allocated sl@0: */ sl@0: { return RArrayBase::DoReserve(aCount); } sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::SortSigned() sl@0: /** sl@0: Sorts the objects within the array; the sort order is assumed to be in signed sl@0: integer order. sl@0: */ sl@0: {HeapSortSigned();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::SortUnsigned() sl@0: /** sl@0: Sorts the objects within the array; the sort order is assumed to be in unsigned sl@0: integer order. sl@0: */ sl@0: {HeapSortUnsigned();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void RArray::Sort(TLinearOrder anOrder) sl@0: /** sl@0: Sorts the objects within the array using the specified TLinearOrder. sl@0: sl@0: The sort order is determined by an algorithm supplied by the caller and sl@0: packaged as a TLinerOrder. sl@0: sl@0: @param anOrder A package encapsulating the function which determines the order sl@0: of two class T type objects. sl@0: */ sl@0: {HeapSort(anOrder);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TArray RArray::Array() const sl@0: /** sl@0: Constructs and returns a generic array. sl@0: sl@0: @return A generic array representing this array. sl@0: */ sl@0: { return TArray(GetCount,GetElementPtr,(const CBase*)this); } sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: inline RArray::RArray() sl@0: : RPointerArrayBase() sl@0: /** sl@0: Constructs an array object for an array of signed integers with sl@0: default granularity. sl@0: sl@0: The default granularity is 8. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline RArray::RArray(TInt aGranularity) sl@0: : RPointerArrayBase(aGranularity) sl@0: /** sl@0: Constructs an array object for an array of signed integers with the specified sl@0: granularity. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic USER 127, if aGranularity is not positive or is greater than or sl@0: equal to 0x10000000. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with minimum growth step and exponential growth factor. sl@0: sl@0: This constructs an array object for an array of signed integers with the sl@0: specified minimum growth step and exponential growth factor. sl@0: sl@0: @param aMinGrowBy The minimum growth step of the array. Must be between 1 and sl@0: 65535 inclusive. sl@0: @param aFactor The factor by which the array grows, multiplied by 256. sl@0: For example 512 specifies a factor of 2. Must be between 257 sl@0: and 32767 inclusive. sl@0: sl@0: @panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535. sl@0: @panic USER 193, if aFactor<=257 or aFactor>32767. sl@0: */ sl@0: inline RArray::RArray(TInt aMinGrowBy, TInt aFactor) sl@0: : RPointerArrayBase(aMinGrowBy, aFactor) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Close() sl@0: /** sl@0: Closes the array and frees all memory allocated to the array. sl@0: sl@0: The function must be called before this array object goes out of scope. sl@0: */ sl@0: {RPointerArrayBase::Close();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Count() const sl@0: /** sl@0: Gets the number of signed integers in the array. sl@0: sl@0: @return The number of signed integers in the array. sl@0: */ sl@0: { return RPointerArrayBase::Count(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline const TInt& RArray::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the signed integer located at a specified position within sl@0: the array. sl@0: sl@0: The compiler chooses this function if the returned reference is used in an sl@0: expression where the reference cannot be modified. sl@0: sl@0: @param anIndex The position of the signed integer within the array. The sl@0: position is relative to zero, i.e. zero implies the entry sl@0: at the beginning of the array. sl@0: sl@0: @return A const reference to the signed integer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: entries currently in the array. sl@0: */ sl@0: {return (const TInt&)At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt& RArray::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to the signed integer located at a specified position within sl@0: the array. sl@0: sl@0: The compiler chooses this function if the returned reference is used in an sl@0: expression where the reference can be modified. sl@0: sl@0: @param anIndex The position of the signed integer within the array. The sl@0: position is relative to zero, i.e. zero implies the entry sl@0: at the beginning of the array. sl@0: sl@0: @return A non-const reference to the signed integer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: entries currently in the array. sl@0: */ sl@0: {return (TInt&)At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Append(TInt anEntry) sl@0: /** sl@0: Appends a signed integer onto the array. sl@0: sl@0: @param anEntry The signed integer to be appended. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::Append((const TAny*)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Insert(TInt anEntry, TInt aPos) sl@0: /** sl@0: Inserts a signed integer into the array at the specified position. sl@0: sl@0: @param anEntry The signed integer to be inserted. sl@0: @param aPos The position within the array where the signed integer is to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that an entry is inserted at the beginning of the array. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: sl@0: @panic USER 131, if aPos is negative, or is greater than the number of entries sl@0: currently in the array. sl@0: */ sl@0: { return RPointerArrayBase::Insert((const TAny*)anEntry,aPos); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Remove(TInt anIndex) sl@0: /** sl@0: Removes the signed integer at the specified position from the array. sl@0: sl@0: @param anIndex The position within the array from where the signed integer sl@0: is to be removed. The position is relative to zero, i.e. zero sl@0: implies that an entry at the beginning of the array is to be sl@0: removed. sl@0: sl@0: @panic USER 130, if anIndex is negative or is greater than the number of sl@0: entries currently in the array. sl@0: */ sl@0: {RPointerArrayBase::Remove(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Compress() sl@0: /** sl@0: Compresses the array down to a minimum. sl@0: sl@0: After a call to this function, the memory allocated to the array is just sl@0: sufficient for its entries. Subsequently adding a new signed integer to the sl@0: array always results in a re-allocation of memory. sl@0: */ sl@0: {RPointerArrayBase::Compress();} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Reset() sl@0: /** sl@0: Empties the array. sl@0: sl@0: The function frees all memory allocated to the array and sl@0: resets the internal state so that it is ready to be reused. sl@0: sl@0: This array object can be allowed to go out of scope after a call to this sl@0: function. sl@0: */ sl@0: {RPointerArrayBase::Reset();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Find(TInt anEntry) const sl@0: /** sl@0: Finds the first signed integer in the array which matches the specified signed sl@0: integer using a sequential search. sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of entries in the array. sl@0: sl@0: @param anEntry The signed integer to be found. sl@0: sl@0: @return The index of the first matching signed integer within the array. sl@0: KErrNotFound, if no matching entry can be found. sl@0: */ sl@0: { return RPointerArrayBase::Find((const TAny*)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::FindReverse(TInt anEntry) const sl@0: /** sl@0: Finds the last signed integer in the array which matches the specified signed sl@0: integer using a sequential search. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of entries in the array. sl@0: sl@0: @param anEntry The signed integer to be found. sl@0: sl@0: @return The index of the last matching signed integer within the array. sl@0: KErrNotFound, if no matching entry can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindReverse((const TAny*)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::FindInOrder(TInt anEntry) const sl@0: /** sl@0: Finds the signed integer in the array that matches the specified signed integer sl@0: using a binary search technique. sl@0: sl@0: The function assumes that the array is in signed integer order. sl@0: sl@0: @param anEntry The signed integer to find. sl@0: sl@0: @return The index of the matching signed integer within the array or KErrNotFound, sl@0: if no match can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindIsqSigned(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::FindInOrder(TInt anEntry, TInt& anIndex) const sl@0: /** sl@0: Finds the signed integer in the array that matches the specified signed integer sl@0: using a binary search technique. sl@0: sl@0: The function assumes that the array is in signed integer order. sl@0: sl@0: @param anEntry The signed integer to find. sl@0: @param anIndex A TInt suplied by the caller. On return contains an index value. sl@0: If the function returns KErrNone, this is the index of the sl@0: matching signed integer within the array. sl@0: If the function returns KErrNotFound, this is the index of the sl@0: first signed integer within the array that is bigger than the sl@0: signed integer being searched for - if no signed integers within sl@0: the array are bigger, then the index value is the same as the sl@0: total number of signed integers within the array. sl@0: sl@0: @return KErrNone if a matching signed integer is found. sl@0: KErrNotFound if no match can be found. sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchSigned(anEntry,anIndex); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::SpecificFindInOrder(TInt anEntry, TInt aMode) const sl@0: /** sl@0: Finds the signed integer in the array that matches the specified signed integer sl@0: using a binary search technique. sl@0: sl@0: Where there is more than one matching element, it finds the first, last or any sl@0: matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that the array is in signed integer order. sl@0: sl@0: @param anEntry The signed integer to be found. sl@0: @param aMode Specifies whether to find the first match, the last match or any sl@0: match, as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array sl@0: index of a matching element - what the index refers to depends on the sl@0: value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element sl@0: of the array, then the index value is the same as the total number of elements in sl@0: the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::FindIsqSigned(anEntry,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::SpecificFindInOrder(TInt anEntry, TInt& anIndex, TInt aMode) const sl@0: /** sl@0: Finds the signed integer in the array that matches the specified signed integer sl@0: using a binary search technique. sl@0: sl@0: Where there is more than one matching element, it finds the first, last or any sl@0: matching element as specified by the value of aMode. sl@0: sl@0: The function assumes that the array is in signed integer order. sl@0: sl@0: @param anEntry The signed integer to be found. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains an index sl@0: value depending on whether a match is found and on the value of aMode. sl@0: If there is no matching element in the array, then this is the index of sl@0: the first element in the array that is bigger than the element being sl@0: searched for - if no elements in the array are bigger, then the index sl@0: value is the same as the total number of elements in the array. sl@0: If there is a matching element, then what the index refers to depends sl@0: on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element sl@0: of the array, then the index value is the same as the total number of elements in the array. sl@0: sl@0: @param aMode Specifies whether to find the first match, the last match or any match, sl@0: as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNone, if a matching element is found; sl@0: KErrNotFound, if no suitable element can be found. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchSigned(anEntry,anIndex,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::InsertInOrder(TInt anEntry) sl@0: /** sl@0: Inserts a signed integer into the array in signed integer order. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: The function assumes that existing entries within the array are in signed sl@0: integer order. sl@0: sl@0: @param anEntry The signed integer to be inserted sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqSigned(anEntry,EFalse); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::InsertInOrderAllowRepeats(TInt anEntry) sl@0: /** sl@0: Inserts a signed integer into the array in signed integer order, sl@0: allowing duplicates. sl@0: sl@0: If anEntry is a duplicate of an existing entry in the array, then the new sl@0: signed integer is inserted after the existing one. If more than one duplicate sl@0: entry already exists in the array, then any new duplicate signed integer is sl@0: inserted after the last one. sl@0: sl@0: The function assumes that existing entries within the array are in signed sl@0: integer order. sl@0: sl@0: @param anEntry The signed integer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqSigned(anEntry,ETrue); } sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline RArray::RArray(TInt* aEntries, TInt aCount) sl@0: : RPointerArrayBase((TAny**)aEntries, aCount) sl@0: /** sl@0: C++ constructor with a pointer to the first array entry in a sl@0: pre-existing array, and the number of entries in that array. sl@0: sl@0: This constructor takes a pointer to a pre-existing set of entries of type sl@0: TInt objects. Ownership of the set of entries does not transfer to sl@0: this RArray object. sl@0: sl@0: The purpose of constructing an array in this way is to allow sorting and sl@0: finding operations to be done without further allocation of memory. sl@0: sl@0: @param aEntries A pointer to the first entry of type class TInt in the set of sl@0: entries belonging to the existing array. sl@0: @param aCount The number of entries in the existing array. sl@0: */ sl@0: {} sl@0: sl@0: inline void RArray::GranularCompress() sl@0: /** sl@0: Compresses the array down to a granular boundary. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: for its contained entries. Adding new signed integers to the array does not sl@0: result in a re-allocation of memory until the total number of entries reaches sl@0: a multiple of the granularity. sl@0: */ sl@0: {RPointerArrayBase::GranularCompress();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Reserve(TInt aCount) sl@0: /** sl@0: Reserves space for the specified number of elements. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: to hold the number of integers specified. Adding new integers to the array sl@0: does not result in a re-allocation of memory until the the total number of sl@0: integers exceeds the specified count. sl@0: sl@0: @param aCount The number of integers for which space should be reserved sl@0: @return KErrNone If the operation completed successfully sl@0: @return KErrNoMemory If the requested amount of memory could not be allocated sl@0: */ sl@0: { return RPointerArrayBase::DoReserve(aCount); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Sort() sl@0: /** sl@0: Sorts the array entries into signed integer order. sl@0: */ sl@0: { HeapSortSigned(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TArray RArray::Array() const sl@0: /** sl@0: Constructs and returns a generic array. sl@0: sl@0: @return A generic array representing this array. sl@0: sl@0: @see TArray sl@0: */ sl@0: { return TArray(GetCount,GetElementPtr,(const CBase*)this); } sl@0: #endif sl@0: sl@0: sl@0: sl@0: inline RArray::RArray() sl@0: : RPointerArrayBase() sl@0: /** sl@0: Default C++ constructor. sl@0: sl@0: This constructs an array object for an array of unsigned sl@0: integers with default granularity. sl@0: sl@0: The default granularity of the array is 8. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline RArray::RArray(TInt aGranularity) sl@0: : RPointerArrayBase(aGranularity) sl@0: /** sl@0: Constructs an array object for an array of unsigned integers with the specified sl@0: granularity. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic USER 127, if aGranularity is not positive or is greater than or sl@0: equal to 0x10000000. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: C++ constructor with minimum growth step and exponential growth factor. sl@0: sl@0: This constructs an array object for an array of unsigned integers with the sl@0: specified minimum growth step and exponential growth factor. sl@0: sl@0: @param aMinGrowBy The minimum growth step of the array. Must be between 1 and sl@0: 65535 inclusive. sl@0: @param aFactor The factor by which the array grows, multiplied by 256. sl@0: For example 512 specifies a factor of 2. Must be between 257 sl@0: and 32767 inclusive. sl@0: sl@0: @panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535. sl@0: @panic USER 193, if aFactor<=257 or aFactor>32767. sl@0: */ sl@0: inline RArray::RArray(TInt aMinGrowBy, TInt aFactor) sl@0: : RPointerArrayBase(aMinGrowBy, aFactor) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Close() sl@0: /** sl@0: Closes the array and frees all memory allocated to the array. sl@0: sl@0: The function must be called before this array object goes out of scope. sl@0: */ sl@0: {RPointerArrayBase::Close();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Count() const sl@0: /** sl@0: Gets the number of unsigned integers in the array. sl@0: sl@0: @return The number of unsigned integers in the array. sl@0: */ sl@0: {return RPointerArrayBase::Count(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline const TUint& RArray::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the unsigned integer located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant if the returned reference is used in an sl@0: expression where the reference cannot be modified. sl@0: sl@0: @param anIndex The position of the unsigned integer within the array, relative sl@0: to zero, i.e. zero implies the entry at the beginning of sl@0: the array. sl@0: sl@0: @return A reference to the const unsigned integer at position anIndex within sl@0: the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: entries currently in the array. sl@0: */ sl@0: {return (const TUint&)At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TUint& RArray::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to the unsigned integer located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant if the returned reference is used in an sl@0: expression where the reference can be modified. sl@0: sl@0: @param anIndex The position of the unsigned integer within the array, relative sl@0: to zero, i.e. zero implies the entry at the beginning of sl@0: the array. sl@0: sl@0: @return A reference to the non-const unsigned integer at position anIndex sl@0: within the array. sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: entries currently in the array. sl@0: */ sl@0: {return (TUint&)At(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Append(TUint anEntry) sl@0: /** sl@0: Appends an unsigned integer onto the array. sl@0: sl@0: @param anEntry The unsigned integer to be appended. sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::Append((const TAny*)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Insert(TUint anEntry, TInt aPos) sl@0: /** sl@0: Inserts an unsigned integer into the array at the specified position. sl@0: sl@0: @param anEntry The unsigned integer to be inserted. sl@0: @param aPos The position within the array where the unsigned integer is to sl@0: be inserted. The position is relative to zero, i.e. zero sl@0: implies that an entry is inserted at the beginning of sl@0: the array. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: sl@0: @panic USER 131, if aPos is negative, or is greater than the number of entries sl@0: currently in the array. sl@0: */ sl@0: { return RPointerArrayBase::Insert((const TAny*)anEntry,aPos); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Remove(TInt anIndex) sl@0: /** sl@0: Removes the unsigned integer at the specified position from the array. sl@0: sl@0: @param anIndex The position within the array from where the unsigned integer sl@0: is to be removed. The position is relative to zero, i.e. zero sl@0: implies that an entry at the beginning of the array is to be sl@0: removed. sl@0: sl@0: sl@0: @panic USER 130, if anIndex is negative, or is greater than the number of sl@0: entries currently in the array. sl@0: */ sl@0: {RPointerArrayBase::Remove(anIndex);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Compress() sl@0: /** sl@0: Compresses the array down to a minimum. sl@0: sl@0: After a call to this function, the memory allocated to the array is just sl@0: sufficient for its entries. Subsequently adding a new unsigned integer to the sl@0: array always results in a re-allocation of memory. sl@0: */ sl@0: {RPointerArrayBase::Compress();} sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Reset() sl@0: /** sl@0: Empties the array. sl@0: sl@0: It frees all memory allocated to the array and resets the sl@0: internal state so that it is ready to be reused. sl@0: sl@0: This array object can be allowed to go out of scope after a call to sl@0: this function. sl@0: */ sl@0: {RPointerArrayBase::Reset();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Find(TUint anEntry) const sl@0: /** sl@0: Finds the first unsigned integer in the array which matches the specified sl@0: value, using a sequential search. sl@0: sl@0: The find operation always starts at the low index end of the array. There sl@0: is no assumption about the order of entries in the array. sl@0: sl@0: @param anEntry The unsigned integer to be found. sl@0: sl@0: @return The index of the first matching unsigned integer within the array. sl@0: KErrNotFound, if no matching entry can be found. sl@0: */ sl@0: { return RPointerArrayBase::Find((const TAny*)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::FindReverse(TUint anEntry) const sl@0: /** sl@0: Finds the last unsigned integer in the array which matches the specified sl@0: value, using a sequential search. sl@0: sl@0: The find operation always starts at the high index end of the array. There sl@0: is no assumption about the order of entries in the array. sl@0: sl@0: @param anEntry The unsigned integer to be found. sl@0: sl@0: @return The index of the last matching unsigned integer within the array. sl@0: KErrNotFound, if no matching entry can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindReverse((const TAny*)anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::FindInOrder(TUint anEntry) const sl@0: /** sl@0: Finds the unsigned integer in the array which matches the specified value, sl@0: using a binary search technique. sl@0: sl@0: The functions assume that existing entries within the array are in unsigned sl@0: integer order. sl@0: sl@0: @param anEntry The unsigned integer to be found. sl@0: sl@0: @return This is either: the index of the matching unsigned integer within the sl@0: array; sl@0: KErrNotFound, if no suitable entry can be found. sl@0: */ sl@0: { return RPointerArrayBase::FindIsqUnsigned(anEntry); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::FindInOrder(TUint anEntry, TInt& anIndex) const sl@0: /** sl@0: Finds the unsigned integer in the array which matches the specified value, sl@0: using a binary search technique. sl@0: sl@0: If the index cannot be found, the function returns the index of the last sl@0: unsigned integer within the array which logically precedes anEntry. sl@0: sl@0: The functions assume that existing entries within the array are in unsigned sl@0: integer order. sl@0: sl@0: @param anEntry The unsigned integer to be found. sl@0: @param anIndex A TInt supplied by the caller. On return, contains an index sl@0: value. sl@0: If the function returns KErrNone, this is the index of the sl@0: matching unsigned integer within the array. sl@0: If the function returns KErrNotFound, this is the index of the sl@0: first unsigned integer within the array that is bigger than the sl@0: unsigned integer being searched for - if no unsigned integers within sl@0: the array are bigger, then the index value is the same as the sl@0: total number of unsigned integers within the array. sl@0: @return KErrNone, if a matching unsigned integer is found. sl@0: KErrNotFound, if no suitable entry can be found. sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchUnsigned(anEntry,anIndex); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::SpecificFindInOrder(TUint anEntry, TInt aMode) const sl@0: /** sl@0: Finds the unsigned integer in the array that matches the specified unsigned integer sl@0: using a binary search technique. sl@0: sl@0: In the case that there is more than one matching element, finds the first, last sl@0: or any match as specified by the value of aMode. sl@0: sl@0: The function assumes that the array is in unsigned integer order. sl@0: sl@0: @param anEntry The unsigned integer to be found.. sl@0: @param aMode Specifies whether to find the first match, the last match or any match, sl@0: as defined by one of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNotFound, if there is no matching element, otherwise the array index of sl@0: a matching element - what the index refers to depends on the value of sl@0: aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of sl@0: the array, then the index value is the same as the total number of elements in the array. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::FindIsqUnsigned(anEntry,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::SpecificFindInOrder(TUint anEntry, TInt& anIndex, TInt aMode) const sl@0: /** sl@0: Finds the unsigned integer in the array that matches the specified unsigned integer sl@0: using a binary search technique. sl@0: sl@0: In the case that there is more than one matching element, finds the first, last or any match as specified. sl@0: sl@0: The function assumes that the array is in unsigned integer order. sl@0: sl@0: @param anEntry The unsigned integer to be found. sl@0: @param anIndex A TInt type supplied by the caller. On return, it contains an index sl@0: value depending on whether a match is found and on the value of aMode. sl@0: If there is no matching element in the array, then this is the index sl@0: of the first element in the array that is bigger than the element being sl@0: searched for - if no elements in the array are bigger, then the index sl@0: value is the same as the total number of elements in the array. sl@0: If there is a matching element, then what the index refers to depends sl@0: on the value of aMode: sl@0: if this is EArrayFindMode_First, then the index refers to the first matching element; sl@0: if this is EArrayFindMode_Any, then the index can refer to any of the matching elements; sl@0: if this is EArrayFindMode_Last, then the index refers to first element that follows sl@0: the last matching element - if the last matching element is also the last element of the array, sl@0: then the index value is the same as the total number of elements in the array. sl@0: @param aMode Specifies whether to find the first match, the last match or any match, as defined by one sl@0: of the TArrayFindMode enum values. sl@0: sl@0: @return KErrNone, if a matching entry is found; KErrNotFound, if no matching entry exists. sl@0: sl@0: @see TArrayFindMode sl@0: */ sl@0: { return RPointerArrayBase::BinarySearchUnsigned(anEntry,anIndex,aMode); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::InsertInOrder(TUint anEntry) sl@0: /** sl@0: Inserts an unsigned integer into the array in unsigned integer order. sl@0: sl@0: No duplicate entries are permitted. The array remains unchanged following sl@0: an attempt to insert a duplicate entry. sl@0: sl@0: The function assumes that existing entries within the array are in unsigned sl@0: integer order. sl@0: sl@0: @param anEntry The unsigned integer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful; sl@0: KErrAlreadyExists, if an attempt is being made sl@0: to insert a duplicate entry; otherwise one of the other system wide sl@0: error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqUnsigned(anEntry,EFalse); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::InsertInOrderAllowRepeats(TUint anEntry) sl@0: /** sl@0: Inserts an unsigned integer into the array in unsigned integer order, allowing sl@0: duplicates. sl@0: sl@0: If the new integer is a duplicate of an existing entry in the array, then sl@0: the new unsigned integer is inserted after the existing one. If more than sl@0: one duplicate entry already exists in the array, then any new duplicate sl@0: unsigned integer is inserted after the last one. sl@0: sl@0: The function assumes that existing entries within the array are in unsigned sl@0: integer order. sl@0: sl@0: @param anEntry The unsigned integer to be inserted. sl@0: sl@0: @return KErrNone, if the insertion is successful, otherwise one of the system sl@0: wide error codes. sl@0: */ sl@0: { return RPointerArrayBase::InsertIsqUnsigned(anEntry,ETrue); } sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: inline RArray::RArray(TUint* aEntries, TInt aCount) sl@0: : RPointerArrayBase((TAny**)aEntries, aCount) sl@0: /** sl@0: C++ constructor with a pointer to the first array entry in a sl@0: pre-existing array, and the number of entries in that array. sl@0: sl@0: This constructor takes a pointer to a pre-existing set of entries of type sl@0: TUint objects. Ownership of the set of entries does not transfer to sl@0: this RArray object. sl@0: sl@0: The purpose of constructing an array in this way is to allow sorting and sl@0: finding operations to be done without further allocation of memory. sl@0: sl@0: @param aEntries A pointer to the first entry of type class TUint in the set of sl@0: entries belonging to the existing array. sl@0: @param aCount The number of entries in the existing array. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: inline void RArray::GranularCompress() sl@0: /** sl@0: Compresses the array down to a granular boundary. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: for its contained entries. Adding new unsigned integers to the array does not sl@0: result in a re-allocation of memory until the total number of entries reaches sl@0: a multiple of the granularity. sl@0: */ sl@0: {RPointerArrayBase::GranularCompress();} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt RArray::Reserve(TInt aCount) sl@0: /** sl@0: Reserves space for the specified number of elements. sl@0: sl@0: After a call to this function, the memory allocated to the array is sufficient sl@0: to hold the number of integers specified. Adding new integers to the array sl@0: does not result in a re-allocation of memory until the the total number of sl@0: integers exceeds the specified count. sl@0: sl@0: @param aCount The number of integers for which space should be reserved sl@0: @return KErrNone If the operation completed successfully sl@0: @return KErrNoMemory If the requested amount of memory could not be allocated sl@0: */ sl@0: { return RPointerArrayBase::DoReserve(aCount); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void RArray::Sort() sl@0: /** sl@0: Sorts the array entries into unsigned integer order. sl@0: */ sl@0: { HeapSortUnsigned(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TArray RArray::Array() const sl@0: /** sl@0: Constructs and returns a generic array. sl@0: sl@0: @return A generic array representing this array. sl@0: sl@0: @see TArray sl@0: */ sl@0: { return TArray(GetCount,GetElementPtr,(const CBase*)this); } sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets an argument to default value and type. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt,TNothing) sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets an argument value of TInt type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,TInt aValue) sl@0: { sl@0: iArgs[aIndex] = aValue; sl@0: iFlags |= EUnspecified<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets an argument value of TAny* type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,const TAny* aValue) sl@0: { sl@0: iArgs[aIndex] = (TInt)aValue; sl@0: iFlags |= EUnspecified<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets an argument value of RHandleBase type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,RHandleBase aValue) sl@0: { sl@0: iArgs[aIndex] = (TInt)aValue.Handle(); sl@0: iFlags |= EHandle<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets an argument value TDesC8* type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,const TDesC8* aValue) sl@0: { sl@0: iArgs[aIndex] = (TInt)aValue; sl@0: iFlags |= EDesC8<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: /** sl@0: Sets an argument value of TDesC16* type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,const TDesC16* aValue) sl@0: { sl@0: iArgs[aIndex] = (TInt)aValue; sl@0: iFlags |= EDesC16<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Sets an argument value of TDes8* type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,TDes8* aValue) sl@0: { sl@0: iArgs[aIndex] = (TInt)aValue; sl@0: iFlags |= EDes8<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: /** sl@0: Sets an argument value of TDes16* type. sl@0: sl@0: @param aIndex An index value that identifies the slot in the array of arguments sl@0: into which the argument value is to be placed. sl@0: This must be a value in the range 0 to 3. sl@0: @param aValue The argument value. sl@0: */ sl@0: inline void TIpcArgs::Set(TInt aIndex,TDes16* aValue) sl@0: { sl@0: iArgs[aIndex] = (TInt)aValue; sl@0: iFlags |= EDes16<<(aIndex*KBitsPerType); sl@0: } sl@0: sl@0: #endif sl@0: sl@0: sl@0: /** sl@0: Allows the client to specify whether each argument of the TIpcArgs object will sl@0: be pinned before being sent to the server. sl@0: sl@0: To pin all the arguments in the TIpcArgs object pass no parameters to this sl@0: method. sl@0: sl@0: @return A reference to this TIpcArgs object that can be passed as a parameter to sl@0: one of the overloads the DSession::Send() and DSession::SendReceive() methods. sl@0: */ sl@0: inline TIpcArgs& TIpcArgs::PinArgs(TBool aPinArg0, TBool aPinArg1, TBool aPinArg2, TBool aPinArg3) sl@0: { sl@0: __ASSERT_COMPILE(!((1 << ((KBitsPerType*KMaxMessageArguments)-1)) & KPinMask)); sl@0: if (aPinArg0) sl@0: iFlags |= KPinArg0; sl@0: if (aPinArg1) sl@0: iFlags |= KPinArg1; sl@0: if (aPinArg2) sl@0: iFlags |= KPinArg2; sl@0: if (aPinArg3) sl@0: iFlags |= KPinArg3; sl@0: return *this; sl@0: } sl@0: sl@0: sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(TNothing) sl@0: { return EUnspecified; } sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(TInt) sl@0: { return EUnspecified; } sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(const TAny*) sl@0: { return EUnspecified; } sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(RHandleBase) sl@0: { return EHandle; } sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(const TDesC8*) sl@0: { return EDesC8; } sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(const TDesC16*) sl@0: { return EDesC16; } sl@0: #endif sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(TDes8*) sl@0: { return EDes8; } sl@0: #ifndef __KERNEL_MODE__ sl@0: inline TIpcArgs::TArgType TIpcArgs::Type(TDes16*) sl@0: { return EDes16; } sl@0: #endif sl@0: inline void TIpcArgs::Assign(TInt&,TIpcArgs::TNothing) sl@0: {} sl@0: inline void TIpcArgs::Assign(TInt& aArg,TInt aValue) sl@0: { aArg = aValue; } sl@0: inline void TIpcArgs::Assign(TInt& aArg,const TAny* aValue) sl@0: { aArg = (TInt)aValue; } sl@0: inline void TIpcArgs::Assign(TInt& aArg,RHandleBase aValue) sl@0: { aArg = (TInt)aValue.Handle(); } sl@0: inline void TIpcArgs::Assign(TInt& aArg,const TDesC8* aValue) sl@0: { aArg = (TInt)aValue; } sl@0: #ifndef __KERNEL_MODE__ sl@0: inline void TIpcArgs::Assign(TInt& aArg,const TDesC16* aValue) sl@0: { aArg = (TInt)aValue; } sl@0: #endif sl@0: inline void TIpcArgs::Assign(TInt& aArg,TDes8* aValue) sl@0: { aArg = (TInt)aValue; } sl@0: #ifndef __KERNEL_MODE__ sl@0: inline void TIpcArgs::Assign(TInt& aArg,TDes16* aValue) sl@0: { aArg = (TInt)aValue; } sl@0: #endif sl@0: sl@0: sl@0: sl@0: // Structures for passing 64 bit integers and doubles across GCC/EABI boundaries sl@0: sl@0: inline SInt64::SInt64() sl@0: {} sl@0: sl@0: inline SInt64::SInt64(Int64 a) sl@0: { sl@0: iData[0] = (TUint32)((Uint64)a); sl@0: iData[1] = (TUint32)(((Uint64)a)>>32); sl@0: } sl@0: sl@0: inline SInt64& SInt64::operator=(Int64 a) sl@0: { sl@0: iData[0] = (TUint32)((Uint64)a); sl@0: iData[1] = (TUint32)(((Uint64)a)>>32); sl@0: return *this; sl@0: } sl@0: sl@0: inline SInt64::operator Int64() const sl@0: { sl@0: Int64 x; sl@0: TUint32* px = (TUint32*)&x; sl@0: px[0] = iData[0]; sl@0: px[1] = iData[1]; sl@0: return x; sl@0: } sl@0: sl@0: inline SUint64::SUint64() sl@0: {} sl@0: sl@0: inline SUint64::SUint64(Uint64 a) sl@0: { sl@0: iData[0] = (TUint32)a; sl@0: iData[1] = (TUint32)(a>>32); sl@0: } sl@0: sl@0: inline SUint64& SUint64::operator=(Uint64 a) sl@0: { sl@0: iData[0] = (TUint32)a; sl@0: iData[1] = (TUint32)(a>>32); sl@0: return *this; sl@0: } sl@0: sl@0: inline SUint64::operator Uint64() const sl@0: { sl@0: Uint64 x; sl@0: TUint32* px = (TUint32*)&x; sl@0: px[0] = iData[0]; sl@0: px[1] = iData[1]; sl@0: return x; sl@0: } sl@0: sl@0: inline SDouble::SDouble() sl@0: {} sl@0: sl@0: inline SDouble::SDouble(TReal a) sl@0: { sl@0: const TUint32* pa = (const TUint32*)&a; sl@0: #ifdef __DOUBLE_WORDS_SWAPPED__ sl@0: iData[0] = pa[1]; sl@0: iData[1] = pa[0]; // compiler puts MS word of double first sl@0: #else sl@0: iData[0] = pa[0]; sl@0: iData[1] = pa[1]; // compiler puts MS word of double second sl@0: #endif sl@0: } sl@0: sl@0: inline SDouble& SDouble::operator=(TReal a) sl@0: { sl@0: new (this) SDouble(a); sl@0: return *this; sl@0: } sl@0: sl@0: inline SDouble::operator TReal() const sl@0: { sl@0: TReal x; sl@0: TUint32* px = (TUint32*)&x; sl@0: #ifdef __DOUBLE_WORDS_SWAPPED__ sl@0: px[1] = iData[0]; sl@0: px[0] = iData[1]; // compiler puts MS word of double first sl@0: #else sl@0: px[0] = iData[0]; sl@0: px[1] = iData[1]; // compiler puts MS word of double second sl@0: #endif sl@0: return x; sl@0: } sl@0: sl@0: // sl@0: // TSecureId sl@0: // sl@0: sl@0: /** Default constructor. This leaves the object in an undefined state */ sl@0: inline TSecureId::TSecureId() sl@0: {} sl@0: sl@0: /** Construct 'this' using a TUint32 sl@0: @param aId The value for the ID */ sl@0: inline TSecureId::TSecureId(TUint32 aId) sl@0: : iId(aId) {} sl@0: sl@0: /** Convert 'this' into a TUint32 sl@0: */ sl@0: inline TSecureId::operator TUint32() const sl@0: { return iId; } sl@0: sl@0: /** Construct 'this' using a TUid sl@0: @param aId The value for the ID */ sl@0: inline TSecureId::TSecureId(TUid aId) sl@0: : iId(aId.iUid) {} sl@0: sl@0: /** Convert 'this' into a TUid sl@0: */ sl@0: inline TSecureId::operator TUid() const sl@0: { return (TUid&)iId; } sl@0: sl@0: // sl@0: // SSecureId sl@0: // sl@0: inline const TSecureId* SSecureId::operator&() const sl@0: { return (const TSecureId*)this; } sl@0: inline SSecureId::operator const TSecureId&() const sl@0: { /* coverity[return_local_addr] */ return (const TSecureId&)iId; } sl@0: inline SSecureId::operator TUint32() const sl@0: { return iId; } sl@0: inline SSecureId::operator TUid() const sl@0: { return (TUid&)iId; } sl@0: sl@0: // sl@0: // TVendorId sl@0: // sl@0: sl@0: /** Default constructor which leaves the object in an undefined state */ sl@0: inline TVendorId::TVendorId() sl@0: {} sl@0: sl@0: /** Construct 'this' using a TUint32 sl@0: @param aId The value for the ID */ sl@0: inline TVendorId::TVendorId(TUint32 aId) sl@0: : iId(aId) {} sl@0: sl@0: /** Convert 'this' into a TUint32 sl@0: */ sl@0: inline TVendorId::operator TUint32() const sl@0: { return iId; } sl@0: sl@0: /** Construct 'this' using a TUid sl@0: @param aId The value for the ID */ sl@0: inline TVendorId::TVendorId(TUid aId) sl@0: : iId(aId.iUid) {} sl@0: sl@0: /** Convert 'this' into a TUid sl@0: */ sl@0: inline TVendorId::operator TUid() const sl@0: { return (TUid&)iId; } sl@0: sl@0: // sl@0: // SSecureId sl@0: // sl@0: inline const TVendorId* SVendorId::operator&() const sl@0: { return (const TVendorId*)this; } sl@0: inline SVendorId::operator const TVendorId&() const sl@0: { /* coverity[return_local_addr] */ return (const TVendorId&)iId; } sl@0: inline SVendorId::operator TUint32() const sl@0: { return iId; } sl@0: inline SVendorId::operator TUid() const sl@0: { return (TUid&)iId; } sl@0: sl@0: // sl@0: // TSharedChunkBufConfigBase sl@0: // sl@0: inline TSharedChunkBufConfigBase::TSharedChunkBufConfigBase() sl@0: {memset(this,0,sizeof(TSharedChunkBufConfigBase));} sl@0: sl@0: /** sl@0: Default constructor. This leaves the set in an undefned state. sl@0: */ sl@0: inline TCapabilitySet::TCapabilitySet() sl@0: {} sl@0: sl@0: /** sl@0: Construct a set consisting of a single capability. sl@0: @param aCapability The single capability sl@0: */ sl@0: inline TCapabilitySet::TCapabilitySet(TCapability aCapability) sl@0: { new (this) TCapabilitySet(aCapability, aCapability); } sl@0: sl@0: /** sl@0: Make this set consist of a single capability. sl@0: @param aCapability The single capability. sl@0: */ sl@0: inline void TCapabilitySet::Set(TCapability aCapability) sl@0: { new (this) TCapabilitySet(aCapability, aCapability); } sl@0: sl@0: /** sl@0: Make this set consist of two capabilities. sl@0: @param aCapability1 The first capability. sl@0: @param aCapability2 The second capability. sl@0: */ sl@0: inline void TCapabilitySet::Set(TCapability aCapability1, TCapability aCapability2) sl@0: { new (this) TCapabilitySet(aCapability1, aCapability2); } sl@0: sl@0: sl@0: /** sl@0: Default constructor. This leaves the object in an undefned state. sl@0: */ sl@0: inline TSecurityInfo::TSecurityInfo() sl@0: {} sl@0: sl@0: /** Constructs a TSecurityPolicy that will always fail, irrespective of the sl@0: checked object's attributes. sl@0: */ sl@0: inline TSecurityPolicy::TSecurityPolicy() sl@0: { new (this) TSecurityPolicy(EAlwaysFail); } sl@0: sl@0: /** sl@0: 'Address of' operator which generates a TSecurityPolicy* sl@0: @return A pointer of type TSecurityPolicy which refers to this object sl@0: */ sl@0: inline const TSecurityPolicy* TStaticSecurityPolicy::operator&() const sl@0: { return (const TSecurityPolicy*)this; } sl@0: sl@0: /** sl@0: 'Reference of' operator which generates a TSecurityPolicy& sl@0: @return A reference of type TSecurityPolicy which refers to this object sl@0: */ sl@0: inline TStaticSecurityPolicy::operator const TSecurityPolicy&() const sl@0: { return *(const TSecurityPolicy*)this; } sl@0: sl@0: /** sl@0: A method to explicity generate a TSecurityPolicy reference. sl@0: @return A reference of type TSecurityPolicy which refers to this object sl@0: */ sl@0: inline const TSecurityPolicy& TStaticSecurityPolicy::operator()() const sl@0: { return *(const TSecurityPolicy*)this; } sl@0: sl@0: #ifdef __KERNEL_MODE__ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of aProcess. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The DProcess object to check against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aProcess, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: inline TBool TSecurityPolicy::CheckPolicy(DProcess* aProcess, const char* aDiagnostic) const sl@0: { sl@0: return DoCheckPolicy(aProcess, aDiagnostic); sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of the process sl@0: owning aThread. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aThread The thread whose owning process' platform security attributes sl@0: are to be checked against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security parameters of the owning process of aThread, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: inline TBool TSecurityPolicy::CheckPolicy(DThread* aThread, const char* aDiagnostic) const sl@0: { sl@0: return DoCheckPolicy(aThread, aDiagnostic); sl@0: } sl@0: sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of aProcess. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The DProcess object to check against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aProcess, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: inline TBool TSecurityPolicy::CheckPolicy(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aProcess); sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of the process sl@0: owning aThread. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aThread The thread whose owning process' platform security attributes sl@0: are to be checked against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security parameters of the owning process of aThread, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: inline TBool TSecurityPolicy::CheckPolicy(DThread* aThread, OnlyCreateWithNull /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aThread); sl@0: } sl@0: sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ sl@0: #endif // __KERNEL_MODE__