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