sl@0: // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\e32base.inl sl@0: // sl@0: // sl@0: sl@0: // Class CBase sl@0: inline TAny* CBase::operator new(TUint aSize, TAny* aBase) __NO_THROW sl@0: /** sl@0: Initialises the object to binary zeroes. sl@0: sl@0: @param aSize The size of the derived class. This parameter is specified sl@0: implicitly by C++ in all circumstances in which a derived sl@0: class is allocated. sl@0: @param aBase Indicates a base address which is returned as the object's sl@0: address. sl@0: sl@0: @return A pointer to the base address. sl@0: */ sl@0: { Mem::FillZ(aBase, aSize); return aBase; } sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny* CBase::operator new(TUint aSize) __NO_THROW sl@0: /** sl@0: Allocates the object from the heap and then initialises its contents sl@0: to binary zeroes. sl@0: sl@0: @param aSize The size of the derived class. This parameter is specified sl@0: implicitly by C++ in all circumstances in which a derived class sl@0: is allocated. sl@0: sl@0: @return A pointer to the allocated object; NULL if memory could not sl@0: be allocated. sl@0: */ sl@0: { return User::AllocZ(aSize); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny* CBase::operator new(TUint aSize, TLeave) sl@0: /** sl@0: Allocates the object from the heap and then initialises its contents sl@0: to binary zeroes. sl@0: sl@0: @param aSize The size of the derived class. This parameter is specified sl@0: implicitly by C++ in all circumstances in which a derived class sl@0: is allocated. sl@0: sl@0: @return A pointer to the allocated object; the TLeave parameter indicates sl@0: that the operation leaves if allocation fails with out-of-memory. sl@0: */ sl@0: { return User::AllocZL(aSize); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny* CBase::operator new(TUint aSize, TUint aExtraSize) __NO_THROW sl@0: /** sl@0: Allocates the object from the heap and then initialises its contents sl@0: to binary zeroes. sl@0: sl@0: Use of this overload is rare. sl@0: sl@0: @param aSize The size of the derived class. This parameter is specified sl@0: implicitly by C++ in all circumstances in which a derived class sl@0: is allocated. sl@0: sl@0: @param aExtraSize Indicates additional size beyond the end of the base class. sl@0: sl@0: @return A pointer to the allocated object; NULL if memory could not sl@0: be allocated. sl@0: */ sl@0: { return User::AllocZ(aSize + aExtraSize); } sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny* CBase::operator new(TUint aSize, TLeave, TUint aExtraSize) sl@0: /** sl@0: Allocates the object from the heap and then initialises its contents sl@0: to binary zeroes. sl@0: sl@0: Use of this overload is rare. sl@0: sl@0: @param aSize The size of the derived class. This parameter is specified sl@0: implicitly by C++ in all circumstances in which a derived class sl@0: is allocated. sl@0: sl@0: @param aExtraSize Indicates additional size beyond the end of the base class. sl@0: sl@0: @return A pointer to the allocated object; the TLeave parameter indicates sl@0: that the operation leaves if allocation fails with out-of-memory. sl@0: */ sl@0: { return User::AllocZL(aSize + aExtraSize); } sl@0: sl@0: sl@0: sl@0: sl@0: // Class CBufBase sl@0: inline TInt CBufBase::Size() const sl@0: /** sl@0: Gets the number of data bytes in the buffer. sl@0: sl@0: Note that the number of heap bytes used by the buffer may be greater than its sl@0: size, because there is typically extra room to allow for expansion. Use the sl@0: Compress() function to reduce the extra allocation as much as possible. sl@0: sl@0: @return The number of data bytes in the buffer. sl@0: */ sl@0: {return(iSize);} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CBufFlat sl@0: inline TInt CBufFlat::Capacity() const sl@0: /** sl@0: Gets the size to which the buffer may expand without re-allocation. sl@0: sl@0: @return The size of the allocated cell associated with the buffer. This is sl@0: the maximum size the buffer may be expanded to without re-allocation. sl@0: */ sl@0: {return(iMaxSize);} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CArrayFixBase sl@0: inline TInt CArrayFixBase::Count() const sl@0: /** sl@0: Gets the number of elements held in the array. sl@0: sl@0: @return The number of array elements sl@0: */ sl@0: {return(iCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt CArrayFixBase::Length() const sl@0: /** sl@0: Gets the length of an element. sl@0: sl@0: @return The length of an element of type class T. sl@0: */ sl@0: {return(iLength);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayFix sl@0: template sl@0: inline CArrayFix::CArrayFix(TBufRep aRep,TInt aGranularity) sl@0: : CArrayFixBase(aRep,sizeof(T),aGranularity) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &CArrayFix::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a const reference to the element located at the specified position sl@0: within the array. sl@0: sl@0: Note that if a pointer to the returned referenced class T object is taken, sl@0: be aware that the pointer value becomes invalid once elements have been added sl@0: to, or removed from the array. Always refresh the pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A const reference to the required element. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)CArrayFixBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayFix::operator[](TInt anIndex) sl@0: /** sl@0: Gets a non-const reference to the element located at the specified position sl@0: within the array. sl@0: sl@0: Note that if a pointer to the returned referenced class T object is taken, sl@0: be aware that the pointer value becomes invalid once elements have been added sl@0: to, or removed from the array. Always refresh the pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A non-const reference to the required element. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((T *)CArrayFixBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &CArrayFix::At(TInt anIndex) const sl@0: /** sl@0: Gets a const reference to the element located at the specified position sl@0: within the array. sl@0: sl@0: Note that if a pointer to the returned referenced class T object is taken, sl@0: be aware that the pointer value becomes invalid once elements have been added sl@0: to, or removed from the array. Always refresh the pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A const reference to the required element. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)CArrayFixBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T *CArrayFix::End(TInt anIndex) const sl@0: /** sl@0: Gets a pointer to the (const) first byte following the end of the sl@0: contiguous region containing the element at the specified position within sl@0: the array. sl@0: sl@0: For arrays implemented using flat buffers, the pointer always points to the sl@0: first byte following the end of the buffer. sl@0: sl@0: For arrays implemented using segmented buffers, the pointer always points sl@0: to the first byte following the end of the segment which contains the element. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element sl@0: in the array. sl@0: sl@0: @return A pointer to the constant byte following the end of the contiguous sl@0: region. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return((const T *)CArrayFixBase::End(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T *CArrayFix::Back(TInt anIndex) const sl@0: /** sl@0: Gets a pointer to the (const) beginning of a contiguous region. sl@0: sl@0: For arrays implemented using flat buffers, the function always returns a sl@0: pointer to the beginning of the buffer. sl@0: sl@0: For arrays implemented using segmented buffers, the function returns a pointer sl@0: to the beginning of the segment for all elements in that segment except the sl@0: first. If the element at position anIndex is the first in a segment, then sl@0: the function returns a pointer the beginning of the previous segment. sl@0: sl@0: For the first element in the array, the function returns a NULL pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element sl@0: in the array. sl@0: sl@0: @return A pointer to the (const) beginning of the contiguous region. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return((const T *)CArrayFixBase::Back(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayFix::At(TInt anIndex) sl@0: /** sl@0: Gets a non-const reference to the element located at the specified position sl@0: within the array. sl@0: sl@0: Note that if a pointer to the returned referenced class T object is taken, sl@0: be aware that the pointer value becomes invalid once elements have been added sl@0: to, or removed from the array. Always refresh the pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A non-const reference to the required element. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((T *)CArrayFixBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T *CArrayFix::End(TInt anIndex) sl@0: /** sl@0: Gets a pointer to the first byte following the end of the contiguous region sl@0: containing the element at the specified position within the array. sl@0: sl@0: For arrays implemented using flat buffers, the pointer always points to the sl@0: first byte following the end of the buffer. sl@0: sl@0: For arrays implemented using segmented buffers, the pointer always points sl@0: to the first byte following the end of the segment which contains the element. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element sl@0: in the array. sl@0: sl@0: @return A pointer to the byte following the end of the contiguous region. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(((T *)CArrayFixBase::End(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T *CArrayFix::Back(TInt anIndex) sl@0: /** sl@0: Gets a pointer to the beginning of a contiguous region. sl@0: sl@0: For arrays implemented using flat buffers, the function always returns a pointer sl@0: to the beginning of the buffer. sl@0: sl@0: For arrays implemented using segmented buffers, the function returns a pointer sl@0: to the beginning of the segment for all elements in that segment except the sl@0: first. If the element at position anIndex is the first in a segment, then sl@0: the function returns a pointer the beginning of the previous segment. sl@0: sl@0: For the first element in the array, the function returns a NULL pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element sl@0: in the array. sl@0: sl@0: @return A pointer to the beginning of the contiguous region. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(((T *)CArrayFixBase::Back(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::AppendL(const T &aRef) sl@0: /** sl@0: Appends a single element onto the end of the array. sl@0: sl@0: @param aRef A reference to the class T element to be appended. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: */ sl@0: {CArrayFixBase::InsertL(Count(),&aRef);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::AppendL(const T *aPtr,TInt aCount) sl@0: /** sl@0: Appends one or more elements onto the end of the array. sl@0: sl@0: @param aPtr A pointer to a contiguous set of type objects to be sl@0: appended. sl@0: @param aCount The number of contiguous objects of type located at sl@0: aPtr to be appended. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 23, if aCount is negative. sl@0: */ sl@0: {CArrayFixBase::InsertL(Count(),aPtr,aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::AppendL(const T &aRef,TInt aReplicas) sl@0: /** sl@0: Appends replicated copies of an element onto the end of the array. sl@0: sl@0: @param aRef A reference to the object to be replicated and appended. sl@0: @param aReplicas The number of copies of the aRef element to be appended. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 28 if aReplicas is negative. sl@0: */ sl@0: {CArrayFixBase::InsertRepL(Count(),&aRef,aReplicas);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayFix::ExpandL(TInt anIndex) sl@0: /** sl@0: Expands the array by one element at the specified position. sl@0: sl@0: It: sl@0: sl@0: 1. expands the array by one element at the specified position sl@0: sl@0: 2. constructs a new element at that position sl@0: sl@0: 3. returns a reference to the new element. sl@0: sl@0: All existing elements from position anIndex to the end of the array are moved sl@0: up, so that the element originally at position anIndex is now at position sl@0: anIndex + 1 etc. sl@0: sl@0: The new element of type class T is constructed at position anIndex, using sl@0: the default constructor of that class. sl@0: sl@0: @param anIndex The position within the array where the array is to be expanded sl@0: and the new class T object is to be constructed. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @return A reference to the newly constructed class T object at position sl@0: anIndex within the array. sl@0: sl@0: @panic E32USER-CBase 21 if anIndex is negative or greater than the number sl@0: of elements currently in the array. sl@0: */ sl@0: {return(*new(CArrayFixBase::ExpandL(anIndex)) T);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayFix::ExtendL() sl@0: /** sl@0: Expands the array by one element at the end of the array. sl@0: sl@0: It: sl@0: sl@0: 1. expands the array by one element at the end of the array, i.e. at position sl@0: CArrayFixBase::Count() sl@0: sl@0: 2. constructs a new element at that position sl@0: sl@0: 3. returns a reference to the new element. sl@0: sl@0: The new element of type class T is constructed at the end of the array, sl@0: using the default constructor of that class. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @return A reference to the newly constructed class T object at the end of sl@0: the array. sl@0: sl@0: @see CArrayFixBase::Count sl@0: */ sl@0: {return(*new(CArrayFixBase::ExpandL(Count())) T);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayFix::Find(const T &aRef,TKeyArrayFix &aKey,TInt &anIndex) const sl@0: /** sl@0: Finds the position of an element within the array, based on the matching of sl@0: keys, using a sequential search. sl@0: sl@0: The array is searched sequentially for an element whose key matches the key of the sl@0: supplied class T object. The search starts with the first element in the array. sl@0: sl@0: Note that where an array has elements with duplicate keys, the function only sl@0: supplies the position of the first element in the array with that key. sl@0: sl@0: @param aRef A reference to an object of type class T whose key is used sl@0: for comparison. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: @param anIndex A reference to a TInt supplied by the caller. On return, if the sl@0: element is found, the reference is set to the position of that sl@0: element within the array. The position is relative to zero, sl@0: (i.e. the first element in the array is at position 0). sl@0: If the element is not found and the array is not empty, then sl@0: the value of the reference is set to the number of elements in sl@0: the array. sl@0: If the element is not found and the array is empty, then the sl@0: reference is set to zero. sl@0: sl@0: @return Zero, if the element with the specified key is found. sl@0: Non-zero, if the element with the specified key is not found. sl@0: */ sl@0: {return(CArrayFixBase::Find(&aRef,aKey,anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayFix::FindIsq(const T &aRef,TKeyArrayFix &aKey,TInt &anIndex) const sl@0: /** sl@0: Finds the position of an element within the array, based on the matching of sl@0: keys, using a binary search technique. sl@0: sl@0: The array is searched, using a binary search technique, for an element whose sl@0: key matches the key of the supplied class T object. sl@0: sl@0: The array must be in key order. sl@0: sl@0: Note that where an array has elements with duplicate keys, the function cannot sl@0: guarantee which element, with the given key value, it will return, except that sl@0: it will find one of them. sl@0: sl@0: @param aRef A reference to an object of type class T whose key is used sl@0: for comparison. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: @param anIndex A reference to a TInt supplied by the caller. On return, if the sl@0: element is found, the reference is set to the position of that sl@0: element within the array. The position is relative to zero, sl@0: (i.e. the first element in the array is at position 0). sl@0: If the element is not found and the array is not empty, then the sl@0: reference is set to the position of the first element in the sl@0: array with a key which is greater than the key of the sl@0: object aRef. sl@0: If the element is not found and the array is empty, then the sl@0: reference is set to zero. sl@0: sl@0: @return Zero, if the element with the specified key is found. sl@0: Non-zero, if the element with the specified key is not found. sl@0: */ sl@0: {return(CArrayFixBase::FindIsq(&aRef,aKey,anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::InsertL(TInt anIndex,const T &aRef) sl@0: /** sl@0: Inserts an element into the array at the specified position. sl@0: sl@0: Note that passing a value of anIndex which is the same as the current number sl@0: of elements in the array, has the effect of appending the element. sl@0: sl@0: @param anIndex The position within the array where the element is to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that elements are inserted at the beginning of the array. sl@0: sl@0: @param aRef A reference to the class T object to be inserted into the array sl@0: at position anIndex. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21 if anIndex is negative, or is greater than the number sl@0: of elements currently in the array. sl@0: */ sl@0: {CArrayFixBase::InsertL(anIndex,&aRef);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::InsertL(TInt anIndex,const T *aPtr,TInt aCount) sl@0: /** sl@0: Inserts one or more elements into the array at the specified position. sl@0: sl@0: The objects to be added must all be contiguous. sl@0: sl@0: Note that passing a value of anIndex which is the same as the current number sl@0: of elements in the array, has the effect of appending the element. sl@0: sl@0: @param anIndex The position within the array where the elements are to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that elements are inserted at the beginning of the array. sl@0: sl@0: @param aPtr A pointer to the first of the contiguous elements of type sl@0: class T to be inserted into the array at position anIndex. sl@0: sl@0: @param aCount The number of contiguous elements of type class T located at sl@0: aPtr to be inserted into the array. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21 if anIndex is negative or is greater than the number sl@0: of elements currently in the array. sl@0: @panic E32USER-CBase 23 if aCount is negative. sl@0: */ sl@0: {CArrayFixBase::InsertL(anIndex,aPtr,aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::InsertL(TInt anIndex,const T &aRef,TInt aReplicas) sl@0: /** sl@0: Inserts replicated copies of an element into the array at the specified sl@0: position. sl@0: sl@0: Note that passing a value of anIndex which is the same as the current number sl@0: of elements in the array, has the effect of appending the element. sl@0: sl@0: sl@0: @param anIndex The position within the array where elements are to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that elements are inserted at the beginning of the array. sl@0: sl@0: @param aRef A reference to the class T object to be replicated and sl@0: inserted into the array at position anIndex. sl@0: sl@0: @param aReplicas The number of copies of the aRef element to be inserted into sl@0: the array. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or is greater than the number sl@0: of elements currently in the array. sl@0: @panic E32USER-CBase 28, if aReplicas is negative. sl@0: */ sl@0: {CArrayFixBase::InsertRepL(anIndex,&aRef,aReplicas);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayFix::InsertIsqL(const T &aRef,TKeyArrayFix &aKey) sl@0: /** sl@0: Inserts a single element into the array at a position determined by a key. sl@0: sl@0: The array MUST already be in key sequence (as defined by the key), otherwise sl@0: the position of the new element is unpredictable, or duplicates may occur. sl@0: sl@0: Elements with duplicate keys are not permitted. sl@0: sl@0: @param aRef A reference to the element of type to be inserted into sl@0: the array. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: sl@0: @return The position within the array of the newly inserted element. sl@0: sl@0: @leave KErrAlreadyExists An element with the same key already exists within sl@0: the array. NB the array MUST already be in key sequence, otherwise sl@0: the function may insert a duplicate and fail to leave with sl@0: this value. sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: */ sl@0: {return(CArrayFixBase::InsertIsqL(&aRef,aKey));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayFix::InsertIsqAllowDuplicatesL(const T &aRef,TKeyArrayFix &aKey) sl@0: /** sl@0: Inserts a single element into the array at a position determined by a key, sl@0: allowing duplicates. sl@0: sl@0: The array MUST already be in key sequence (as defined by the key), otherwise sl@0: the position of the new element is unpredictable. sl@0: sl@0: If the new element's key is a duplicate of an existing element's key, then sl@0: the new element is positioned after the existing element. sl@0: sl@0: @param aRef A reference to the element of type to be inserted into sl@0: the array. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: sl@0: @return The position within the array of the newly inserted element. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: */ sl@0: {return(CArrayFixBase::InsertIsqAllowDuplicatesL(&aRef,aKey));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::ResizeL(TInt aCount) sl@0: /** sl@0: Changes the size of the array so that it contains the specified number sl@0: of elements. sl@0: sl@0: The following describes the effects of calling this function: sl@0: sl@0: 1. If aCount is less than the current number of elements in the array, then the sl@0: array is shrunk. The elements at positions aCount and above are discarded. sl@0: The array buffer is not compressed. sl@0: sl@0: 2. If aCount is greater than the current number of elements in the array, then sl@0: the array is extended. sl@0: sl@0: 3. New elements are replicated copies of an object of type , sl@0: constructed using the default constructor of that class. sl@0: sl@0: The new elements are positioned after the existing elements in the array. sl@0: sl@0: The function may attempt to expand the array buffer. If there is insufficient sl@0: memory available, the function leaves. The leave code is one of the system sl@0: wide error codes. If the function leaves, the array is left in the state it sl@0: was in before the call. sl@0: sl@0: @param aCount The number of elements the array is to contain after the resizing sl@0: operation. sl@0: sl@0: @panic E32USER-CBase 24, if aCount is negative. sl@0: */ sl@0: {TUint8 b[sizeof(T)]; new(&b[0]) T; CArrayFixBase::ResizeL(aCount,&b[0]);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFix::ResizeL(TInt aCount,const T &aRef) sl@0: /** sl@0: Changes the size of the array so that it contains the specified number sl@0: of elements. sl@0: sl@0: The following describes the effects of calling this function: sl@0: sl@0: 1. If aCount is less than the current number of elements in the array, then the sl@0: array is shrunk. The elements at positions aCount and above are discarded. sl@0: The array buffer is not compressed. sl@0: sl@0: 2. If aCount is greater than the current number of elements in the array, then sl@0: the array is extended. sl@0: sl@0: 3. New elements are replicated copies of aRef. sl@0: sl@0: The new elements are positioned after the existing elements in the array. sl@0: sl@0: The function may attempt to expand the array buffer. If there is insufficient sl@0: memory available, the function leaves. The leave code is one of the system sl@0: wide error codes. If the function leaves, the array is left in the state it sl@0: was in before the call. sl@0: sl@0: @param aCount The number of elements the array is to contain after the resizing sl@0: operation. sl@0: sl@0: @param aRef A reference to an object of type , copies of which are sl@0: used as the new elements of the array, if the array is extended. sl@0: sl@0: @panic E32USER-CBase 24, if aCount is negative. sl@0: */ sl@0: {CArrayFixBase::ResizeL(aCount,&aRef);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const TArray CArrayFix::Array() const sl@0: /** sl@0: Constructs and returns a TArray object. sl@0: sl@0: @return A TArray object representing this array. sl@0: */ sl@0: {return(TArray(CountR,AtR,this));} sl@0: sl@0: sl@0: sl@0: sl@0: inline CArrayFix::CArrayFix(TBufRep aRep,TInt aRecordLength,TInt aGranularity) sl@0: : CArrayFixBase(aRep,aRecordLength,aGranularity) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TAny *CArrayFix::At(TInt anIndex) const sl@0: /** sl@0: Gets a pointer to the untyped element located at the specified position sl@0: within the array. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in the sl@0: array. sl@0: sl@0: @return A pointer to the untyped element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32User-CBase 21, if anIndex is negative or is greater than or equal sl@0: to the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayFixBase::At(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TAny *CArrayFix::End(TInt anIndex) const sl@0: /** sl@0: Gets a pointer to the first byte following the end of the contiguous region sl@0: containing the element at the specfied position within the array. sl@0: sl@0: For flat buffers, the pointer always points to the first byte following the sl@0: end of the buffer. sl@0: sl@0: For segmented buffers, the pointer always points to the first byte following sl@0: the end of the segment which contains the element. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A pointer to the byte following the end of the contiguous region. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayFixBase::End(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TAny *CArrayFix::Back(TInt anIndex) const sl@0: /** sl@0: Gets a pointer to the beginning of a contiguous region. sl@0: sl@0: For flat buffers, the function always returns a pointer to the beginning of sl@0: the buffer. sl@0: sl@0: For segmented buffers, the function returns a pointer to the beginning of sl@0: the segment for all elements in that segment except the first. If the element sl@0: at the specified position is the first in a segment, then the function returns sl@0: a pointer the beginning of the previous segment. sl@0: sl@0: For the first element in the array, the function returns a NULL pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in the array. sl@0: sl@0: @return A pointer to the beginning of the contiguous region. sl@0: sl@0: @panic E32User-CBase 21, if anIndex is negative or is greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayFixBase::Back(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayFix::At(TInt anIndex) sl@0: /** sl@0: Gets a pointer to the untyped element located at the specified position sl@0: within the array. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in the sl@0: array. sl@0: sl@0: @return A pointer to the untyped element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32User-CBase 21, if anIndex is negative or is greater than or equal sl@0: to the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayFixBase::At(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayFix::End(TInt anIndex) sl@0: /** sl@0: Gets a pointer to the first byte following the end of the contiguous region sl@0: containing the element at the specfied position within the array. sl@0: sl@0: For flat buffers, the pointer always points to the first byte following the sl@0: end of the buffer. sl@0: sl@0: For segmented buffers, the pointer always points to the first byte following sl@0: the end of the segment which contains the element. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A pointer to the byte following the end of the contiguous region. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayFixBase::End(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayFix::Back(TInt anIndex) sl@0: /** sl@0: Gets a pointer to the beginning of a contiguous region. sl@0: sl@0: For flat buffers, the function always returns a pointer to the beginning of sl@0: the buffer. sl@0: sl@0: For segmented buffers, the function returns a pointer to the beginning of sl@0: the segment for all elements in that segment except the first. If the element sl@0: at the specified position is the first in a segment, then the function returns sl@0: a pointer the beginning of the previous segment. sl@0: sl@0: For the first element in the array, the function returns a NULL pointer. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in the array. sl@0: sl@0: @return A pointer to the beginning of the contiguous region. sl@0: sl@0: @panic E32User-CBase 21, if anIndex is negative or is greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayFixBase::Back(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayFix::AppendL(const TAny *aPtr) sl@0: /** sl@0: Appends the specified untyped element onto the end of the array. sl@0: sl@0: @param aPtr A pointer to an untyped element to be appended. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: */ sl@0: {CArrayFixBase::InsertL(Count(),aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayFix::AppendL(const TAny *aPtr,TInt aCount) sl@0: /** sl@0: Appends one or more untyped elements onto the end of the array. sl@0: sl@0: @param aPtr A pointer to the first of the contiguous untyped elements to be sl@0: appended. sl@0: @param aCount The number of contiguous elements located at aPtr to be appended. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: @panic E32USER-CBase 23, if aCount is negative. sl@0: */ sl@0: {CArrayFixBase::InsertL(Count(),aPtr,aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayFix::ExtendL() sl@0: /** sl@0: Expands the array by the length of one element at the end of the array and sl@0: returns a pointer to this new location. sl@0: sl@0: As elements are untyped, no construction is possible and the content of the sl@0: new location remains undefined. sl@0: sl@0: @return A pointer to the new element location at the end of the array. sl@0: sl@0: @leave KErrNoMemory The function may attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case the array is left in the state it was in before the call. sl@0: */ sl@0: {return(CArrayFixBase::ExpandL(Count()));} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayFixFlat sl@0: template sl@0: inline CArrayFixFlat::CArrayFixFlat(TInt aGranularity) sl@0: : CArrayFix((TBufRep)CBufFlat::NewL,aGranularity) sl@0: /** sl@0: Constructs a flat array of fixed length objects with the specified granularity. sl@0: sl@0: The length of all array elements is the length of the class passed as the sl@0: template parameter. The length must be non-zero. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 17, if the length of the class implied by the template parameter is zero. sl@0: sl@0: @panic E32USER-CBase 18, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayFixFlat::SetReserveL(TInt aCount) sl@0: /** sl@0: Reserves space in the array buffer. sl@0: sl@0: If necessary, the array buffer is allocated or re-allocated so that it can sl@0: accommodate the specified number of elements. sl@0: sl@0: After a successful call to this function, elements can be added to the array sl@0: and the process is guaranteed not to fail for lack of memory - provided the sl@0: total number of elements does not exceed the number specified in this function. sl@0: sl@0: This function does not increase the number of elements in the array; i.e. sl@0: the member function CArrayFixBase::Count() returns the same value both before sl@0: and after a call to CArrayFixFlat::SetReserveL(). sl@0: sl@0: @param aCount The total number of elements for which space is to be reserved. sl@0: sl@0: @panic E32USER-CBase 27, if aCount is less than the current number of elements sl@0: in the array. sl@0: */ sl@0: {this->SetReserveFlatL(aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline CArrayFixFlat::CArrayFixFlat(TInt aRecordLength,TInt aGranularity) sl@0: : CArrayFix((TBufRep)CBufFlat::NewL,aRecordLength,aGranularity) sl@0: /** sl@0: Constructs a flat array of fixed length objects with the specified granularity sl@0: to contain elements of the specified length. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aRecordLength The length of the elements of this fixed length array. sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 17, if aRecordLength is not positive. sl@0: @panic E32USER-CBase 18, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayFixFlat::SetReserveL(TInt aCount) sl@0: /** sl@0: Reserves space in the array buffer. sl@0: sl@0: If necessary, the array buffer is allocated or re-allocated so that it can sl@0: accommodate the specified number of elements. sl@0: sl@0: After a successful call to this function, elements can be added to the array sl@0: and the process is guaranteed not to fail for lack of memory - provided the sl@0: total number of elements does not exceed the specified number. sl@0: sl@0: This function does not increase the number of elements in the array; i.e. sl@0: the member function CArrayFixBase::Count() returns the same value both before sl@0: and after a call to this function. sl@0: sl@0: @param aCount The total number of elements for which space is to be reserved. sl@0: sl@0: @panic E32USER-CBase 27, if aCount is less than the current number of elements sl@0: in the array. sl@0: */ sl@0: {SetReserveFlatL(aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayFixFlat::SetReserveL(TInt aCount) sl@0: /** sl@0: Reserves space in the array buffer. sl@0: sl@0: If necessary, the array buffer is allocated or re-allocated so that it can sl@0: accommodate the specified number of TInt elements. sl@0: sl@0: After a successful call to this function, elements can be added to the array sl@0: and the process is guaranteed not to fail for lack of memory - provided the sl@0: total number of elements does not exceed the specified number. sl@0: sl@0: This function does not increase the number of elements in the array; i.e. sl@0: the member function CArrayFixBase::Count() returns the same value both before sl@0: and after a call to this function. sl@0: sl@0: @param aCount The total number of elements for which space is to be reserved. sl@0: sl@0: @panic E32USER-CBase 27, if aCount is less than the current number of elements sl@0: in the array. sl@0: */ sl@0: {SetReserveFlatL(aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayFixFlat::SetReserveL(TInt aCount) sl@0: /** sl@0: Reserves space in the array buffer. sl@0: sl@0: If necessary, the array buffer is allocated or re-allocated so that it can sl@0: accommodate the specified number of TUid elements. sl@0: sl@0: After a successful call to this function, elements can be added to the array sl@0: and the process is guaranteed not to fail for lack of memory - provided the sl@0: total number of elements does not exceed the specified number. sl@0: sl@0: This function does not increase the number of elements in the array; i.e. sl@0: the member function CArrayFixBase::Count() returns the same value both before sl@0: and after a call to this function. sl@0: sl@0: @param aCount The total number of elements for which space is to be reserved. sl@0: sl@0: @panic E32USER-CBase 27, if aCount is less than the current number of elements sl@0: in the array. sl@0: */ sl@0: {SetReserveFlatL(aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayFixSeg sl@0: template sl@0: inline CArrayFixSeg::CArrayFixSeg(TInt aGranularity) sl@0: : CArrayFix((TBufRep)CBufSeg::NewL,aGranularity) sl@0: /** sl@0: Constructs a segmented array of fixed length objects with the specified sl@0: granularity. sl@0: sl@0: The length of all array elements is the length of the class passed as the sl@0: template parameter. The length must be non-zero. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 17, if the length of the class implied by the template sl@0: parameter is zero. sl@0: @panic E32USER-CBase 18, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline CArrayFixSeg::CArrayFixSeg(TInt aRecordLength,TInt aGranularity) sl@0: : CArrayFix((TBufRep)CBufSeg::NewL,aRecordLength,aGranularity) sl@0: /** sl@0: Constructs a segmented array of fixed length objects with the specified sl@0: granularity to contain elements of the specified length. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aRecordLength The length of the elements of this array. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 17, if aRecordLength is not positive. sl@0: @panic E32USER-CBase 18, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayPtr sl@0: template sl@0: inline CArrayPtr::CArrayPtr(TBufRep aRep,TInt aGranularity) sl@0: : CArrayFix(aRep,aGranularity) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: void CArrayPtr::ResetAndDestroy() sl@0: /** sl@0: Destroys all objects whose pointers form the elements of the array, before sl@0: resetting the array. sl@0: sl@0: The destructor of each class T object is called before the objects themselves sl@0: are destroyed. sl@0: sl@0: If the array is not empty, this member function must be called before the sl@0: array is deleted to prevent the CBase derived objects from being orphaned sl@0: on the heap. sl@0: sl@0: Note that each call to this function results in a small, but non-trivial, sl@0: amount of code being generated. sl@0: */ sl@0: { sl@0: for (TInt i=0;iCount();++i) sl@0: delete this->At(i); sl@0: this->Reset(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayPtrFlat sl@0: template sl@0: inline CArrayPtrFlat::CArrayPtrFlat(TInt aGranularity) sl@0: : CArrayPtr((TBufRep)CBufFlat::NewL,aGranularity) sl@0: /** sl@0: Constructs a flat array of pointers with specified granularity. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 18, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayPtrFlat::SetReserveL(TInt aCount) sl@0: /** sl@0: Reserves space in the array buffer. sl@0: sl@0: If necessary, the array buffer is allocated or re-allocated so that it can sl@0: accommodate the specified number of elements. sl@0: sl@0: After a successful call to this function, elements can be added to the array sl@0: and the process is guaranteed not to fail for lack of memory - provided the sl@0: total number of elements does not exceed the specified number. sl@0: sl@0: This function does not increase the number of elements in the array; i.e. sl@0: the member function CArrayFixBase::Count() returns the same value both before sl@0: and after a call to this function. sl@0: sl@0: @param aCount The total number of elements for which space is to be reserved. sl@0: sl@0: @panic E32USER-CBase 27, if aCount is less than the current number of elements sl@0: in the array. sl@0: */ sl@0: {this->SetReserveFlatL(aCount);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayPtrSeg sl@0: template sl@0: inline CArrayPtrSeg::CArrayPtrSeg(TInt aGranularity) sl@0: : CArrayPtr((TBufRep)CBufSeg::NewL,aGranularity) sl@0: /** sl@0: Constructs a segmented array of pointers with specified granularity. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 18, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CArrayVarBase sl@0: inline TInt CArrayVarBase::Count() const sl@0: /** sl@0: Gets the number of elements held in the array. sl@0: sl@0: @return The number of array elements. sl@0: */ sl@0: {return(iCount);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayVar sl@0: template sl@0: inline CArrayVar::CArrayVar(TBufRep aRep,TInt aGranularity) sl@0: : CArrayVarBase(aRep,aGranularity) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &CArrayVar::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the const element located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant of the function if the returned reference is sl@0: used in an expression where it cannot be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A const reference to the element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)CArrayVarBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayVar::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to the element located at the specified position within sl@0: the array. sl@0: sl@0: The compiler uses this variant of the function if the returned reference is sl@0: used in an expression where it can be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: sl@0: @return A reference to the non-const element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((T *)CArrayVarBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &CArrayVar::At(TInt anIndex) const sl@0: /** sl@0: Gets a reference to the const element located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant of the function if the returned reference is sl@0: used in an expression where it cannot be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A const reference to the element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)CArrayVarBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayVar::At(TInt anIndex) sl@0: /** sl@0: Gets a reference to the element located at the specified position within sl@0: the array. sl@0: sl@0: The compiler uses this variant of the function if the returned reference is sl@0: used in an expression where it can be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A reference to the non-const element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((T *)CArrayVarBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayVar::AppendL(const T &aRef,TInt aLength) sl@0: /** sl@0: Appends an element of a specified length onto the array. sl@0: sl@0: @param aRef A reference to the element to be appended. sl@0: @param aLength The length of the element to be appended. sl@0: sl@0: @leave KErrNoMemory The function always attempts to allocate a cell to sl@0: contain the new element and may also attempt to expand the array buffer. sl@0: If there is insufficient memory available, the function leaves, in which sl@0: case, the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {CArrayVarBase::InsertL(Count(),&aRef,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayVar::ExpandL(TInt anIndex,TInt aLength) sl@0: /** sl@0: Expands the array by one element of specified length at the specified position. sl@0: sl@0: It: sl@0: sl@0: 1. expands the array by one element position anIndex sl@0: sl@0: 2. constructs a new element of specified length at that position sl@0: sl@0: 3. returns a reference to the new element. sl@0: sl@0: All existing elements from position anIndex to the end of the array are moved sl@0: up, so that the element originally at position anIndex is now at position sl@0: anIndex + 1 etc. sl@0: sl@0: The new element of type and length aLength is constructed at position sl@0: anIndex, using the default constructor of that class. sl@0: sl@0: @param anIndex The position within the array where the array is to be expanded sl@0: and the new object is to be constructed. sl@0: sl@0: @param aLength The length of the new element. sl@0: sl@0: @return A reference to the newly constructed object at position sl@0: anIndex within the array. sl@0: sl@0: @leave KErrNoMemory The function always attempts to allocate a cell to contain sl@0: the new element and may also attempt to expand the array buffer. If there sl@0: is insufficient memory available, the function leaves, in which case, the sl@0: array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or is greater than the number sl@0: of elements currently in the array. sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {return(*new(CArrayVarBase::ExpandL(anIndex,aLength)) T);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayVar::ExtendL(TInt aLength) sl@0: /** sl@0: Expands the array by one element of specified length at the end of the array. sl@0: sl@0: It: sl@0: sl@0: 1. expands the array by one element at the end of the array, i.e. at position sl@0: CArrayVarBase::Count() sl@0: sl@0: 2. constructs a new element of specified length at that position. sl@0: sl@0: 3. returns a reference to the new element. sl@0: sl@0: The new element of type is constructed at the end of the array, sl@0: using the default constructor of that class. sl@0: sl@0: @param aLength The length of the new element. sl@0: sl@0: @return A reference to the newly constructed object at the end of sl@0: the array. sl@0: sl@0: @leave KErrNoMemory The function always attempts to allocate a cell to contain sl@0: the new element and may also attempt to expand the array buffer. If there sl@0: is insufficient memory available, the function leaves, in which case, the sl@0: array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {return(*new(CArrayVarBase::ExpandL(Count(),aLength)) T);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayVar::Find(const T &aRef,TKeyArrayVar &aKey,TInt &anIndex) const sl@0: /** sl@0: Finds the position of an element within the array, based on the matching of sl@0: keys, using a sequential search. sl@0: sl@0: The array is searched sequentially for an element whose key matches the key sl@0: of the supplied object. The search starts with the first element in the array. sl@0: sl@0: Note that where an array has elements with duplicate keys, the function only sl@0: supplies the position of the first element in the array with that key. sl@0: sl@0: @param aRef A reference to an object of type whose key is used sl@0: for comparison. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: @param anIndex A TInt supplied by the caller. On return, if the element is sl@0: found, this is set to the position of that element sl@0: within the array. The position is relative to zero, (i.e. sl@0: the first element in the array is at position 0). sl@0: If the element is not found or the array is empty, then sl@0: this is undefined. sl@0: sl@0: @return Zero, if the element with the specified key is found. Non-zero, if sl@0: the element with the specified key is not found. sl@0: */ sl@0: {return(CArrayVarBase::Find(&aRef,aKey,anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayVar::FindIsq(const T &aRef,TKeyArrayVar &aKey,TInt &anIndex) const sl@0: /** sl@0: Finds the position of an element within the array, based on the matching of sl@0: keys, using a binary search technique. sl@0: sl@0: The array is searched, using a binary search technique, for an element whose sl@0: key matches the key of the supplied object. sl@0: sl@0: The array must be in key order. sl@0: sl@0: Note that where an array has elements with duplicate keys, the function cannot sl@0: guarantee which element, with the given key value, it will return, except that sl@0: it will find one of them. sl@0: sl@0: @param aRef A reference to an object of type whose key is used sl@0: for comparison. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: @param anIndex A TInt supplied by the caller. On return, if the element is sl@0: found, this is set to the position of that element within sl@0: the array. The position is relative to zero, (i.e. sl@0: the first element in the array is at position zero). sl@0: If the element is not found and the array is not empty, then sl@0: this is set to the position of the first element in the array sl@0: with a key which is greater than the key of the object aRef. sl@0: If the element is not found and the array is empty, then sl@0: this is undefined. sl@0: sl@0: @return Zero, if the element with the specified key is found or the array is sl@0: empty. Non-zero, if the element with the specified key is not found. sl@0: */ sl@0: {return(CArrayVarBase::FindIsq(&aRef,aKey,anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayVar::InsertL(TInt anIndex,const T &aRef,TInt aLength) sl@0: /** sl@0: Inserts an element of a specified length into the array at the specified sl@0: position. sl@0: sl@0: Note that passing a value of anIndex which is the same as the current number sl@0: of elements in the array, has the effect of appending that element. sl@0: sl@0: @param anIndex The position within the array where the element is to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that elements are inserted at the beginning of the array. sl@0: @param aRef A reference to the object to be inserted into sl@0: the array. sl@0: @param aLength The length of the element to be inserted into the array. sl@0: sl@0: @leave KErrNoMemory The function always attempts to allocate a cell to contain sl@0: the new element and may also attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case, the array is left in the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or is greater than the number sl@0: of objects currently in the array. sl@0: @panic E32USER-CBase 30, if aLength is is negative. sl@0: */ sl@0: {CArrayVarBase::InsertL(anIndex,&aRef,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayVar::InsertIsqL(const T &aRef,TInt aLength,TKeyArrayVar &aKey) sl@0: /** sl@0: Inserts a single element of a specified length into the array at a position sl@0: determined by a key. sl@0: sl@0: The array MUST already be in key sequence (as defined by the key), otherwise sl@0: the position of the new element is unpredictable, or duplicates may occur. sl@0: sl@0: Elements with duplicate keys are not permitted. sl@0: sl@0: @param aRef A reference to the element of type to be inserted into sl@0: the array. sl@0: @param aLength The length of the new element of type to be inserted sl@0: into the array. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: sl@0: @return The position within the array of the newly inserted element. sl@0: sl@0: @leave KErrAlreadyExists An element with the same key already exists within sl@0: the array. NB the array MUST already be in key sequence, otherwise sl@0: the function may insert a duplicate and fail to leave with sl@0: this value. sl@0: @leave KErrNoMemory The function always attempts to allocate a cell to contain sl@0: the new element and may also attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case, the array is left in the state it was in before the call. sl@0: */ sl@0: {return(CArrayVarBase::InsertIsqL(&aRef,aLength,aKey));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayVar::InsertIsqAllowDuplicatesL(const T &aRef,TInt aLength,TKeyArrayVar &aKey) sl@0: /** sl@0: Inserts a single element of a specified length into the array at a position sl@0: determined by a key, allowing duplicates. sl@0: sl@0: The array MUST already be in key sequence, otherwise the position of the sl@0: new element is unpredictable. sl@0: sl@0: Elements with duplicate keys are permitted. If the new element's key is a sl@0: duplicate of an existing element's key, then the new element is positioned sl@0: after the existing element. sl@0: sl@0: @param aRef A reference to the element of type to be inserted sl@0: into the array. sl@0: @param aLength The length of the new element to be inserted into the array. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: sl@0: @return The position within the array of the newly inserted element. sl@0: sl@0: @leave KErrNoMemory The function always attempts to allocate a cell to contain sl@0: the new element and may also attempt to expand the array buffer. If sl@0: there is insufficient memory available, the function leaves, in which sl@0: case, the array is left in the state it was in before the call. sl@0: */ sl@0: {return(CArrayVarBase::InsertIsqAllowDuplicatesL(&aRef,aLength,aKey));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const TArray CArrayVar::Array() const sl@0: /** sl@0: Constructs and returns a TArray object. sl@0: sl@0: @return A TArray object for this array. sl@0: */ sl@0: {return(TArray(CountR,AtR,this));} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TAny *CArrayVar::At(TInt anIndex) const sl@0: /** sl@0: Returns a pointer to the untyped element located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant of the function if the returned pointer is sl@0: used in an expression where it cannot be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A pointer to the const element located at position anIndex within the sl@0: array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(CArrayVarBase::At(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline CArrayVar::CArrayVar(TBufRep aRep,TInt aGranularity) sl@0: : CArrayVarBase(aRep,aGranularity) sl@0: /** sl@0: Constructs a variable array with the specified granularity and buffer sl@0: organization. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aRep A pointer to a function used to expand the array buffer. sl@0: The organisation of the array buffer is implied by the sl@0: choice of this function. sl@0: For a flat array buffer, pass (TBufRep)CBufFlat::NewL. sl@0: For a segmented array buffer, pass (TBufRep)CBufSeg::NewL. sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 19, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayVar::At(TInt anIndex) sl@0: /** sl@0: Returns a pointer to the untyped element located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant of the function if the returned pointer is sl@0: used in an expression where it can be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A pointer to the non-const element located at position anIndex within the sl@0: array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(CArrayVarBase::At(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayVar::AppendL(const TAny *aPtr,TInt aLength) sl@0: /** sl@0: Appends an untyped element of specified length onto the end of the array. sl@0: sl@0: @param aPtr A pointer to an untyped element to be appended. sl@0: @param aLength The length of the untyped element. sl@0: */ sl@0: {CArrayVarBase::InsertL(Count(),aPtr,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayVar::ExtendL(TInt aLength) sl@0: /** sl@0: Extends the array by one element of specified length at the end of the array, sl@0: i.e. at position CArrayVarBase::Count(), and returns a pointer to the new sl@0: element location. sl@0: sl@0: As elements are untyped, no construction is possible and the content of the sl@0: new location remains undefined. sl@0: sl@0: Note that the function always attempts to allocate a cell to contain the new sl@0: element and may also attempt to expand the array buffer. If there is sl@0: insufficient memory available, the function leaves. sl@0: The leave code is one of the system wide error codes. sl@0: If the function leaves, the array is left in the state it was in before sl@0: the call. sl@0: sl@0: @param aLength The length of the new element. sl@0: sl@0: @return A pointer to the new element location at the end of the array. sl@0: */ sl@0: {return(CArrayVarBase::ExpandL(Count(),aLength));} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayVarFlat sl@0: template sl@0: inline CArrayVarFlat::CArrayVarFlat(TInt aGranularity) sl@0: : CArrayVar((TBufRep)CBufFlat::NewL,aGranularity) sl@0: /** sl@0: Constructs a variable flat array with specified granularity. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 19, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayVarSeg sl@0: template sl@0: inline CArrayVarSeg::CArrayVarSeg(TInt aGranularity) sl@0: : CArrayVar((TBufRep)CBufSeg::NewL,aGranularity) sl@0: /** sl@0: Constructs a variable segmented array with specified granularity. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 19, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CArrayPakBase sl@0: inline TInt CArrayPakBase::Count() const sl@0: /** sl@0: Gets the number of elements held in the array. sl@0: sl@0: @return The number of array elements. sl@0: */ sl@0: {return(iCount);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayPak sl@0: template sl@0: inline CArrayPak::CArrayPak(TBufRep aRep,TInt aGranularity) sl@0: : CArrayPakBase(aRep,aGranularity) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &CArrayPak::operator[](TInt anIndex) const sl@0: /** sl@0: Gets a reference to the element located at the specified position within the sl@0: array. sl@0: sl@0: The compiler uses this variant of the function when the returned reference sl@0: is used in an expression where it cannot be modified. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A const reference to the element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)CArrayPakBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayPak::operator[](TInt anIndex) sl@0: /** sl@0: Gets a reference to the element located at the specified position within the sl@0: array. sl@0: sl@0: The compiler uses this variant of the function when the returned reference sl@0: is used in an expression where it can be modified. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A non-const reference to the element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((T *)CArrayPakBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const T &CArrayPak::At(TInt anIndex) const sl@0: /** sl@0: Gets a reference to the element located at the specified position within the sl@0: array. sl@0: sl@0: The compiler uses this variant of the function when the returned reference sl@0: is used in an expression where it cannot be modified. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A const reference to the element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((const T *)CArrayPakBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayPak::At(TInt anIndex) sl@0: /** sl@0: Gets a reference to the element located at the specified position within the sl@0: array. sl@0: sl@0: The compiler uses this variant of the function when the returned reference sl@0: is used in an expression where it can be modified. sl@0: sl@0: @param anIndex The position of the element within the array. The position sl@0: is relative to zero; i.e. zero implies the first element in sl@0: the array. sl@0: sl@0: @return A non-const reference to the element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: number of objects currently within the array. sl@0: */ sl@0: {return(*((T *)CArrayPakBase::At(anIndex)));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayPak::AppendL(const T &aRef,TInt aLength) sl@0: /** sl@0: Appends an element of a specified length onto the array. sl@0: sl@0: @param aRef A reference to the class T element to be appended. sl@0: @param aLength The length of the element to be appended. sl@0: sl@0: @leave KErrNoMemory The function attempted to allocate from the heap and there sl@0: is insufficient memory available. In this case, the array is left in sl@0: the state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {CArrayPakBase::InsertL(Count(),&aRef,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayPak::ExpandL(TInt anIndex,TInt aLength) sl@0: /** sl@0: Expands the array by one element of specified length at the specified position. sl@0: sl@0: It: sl@0: sl@0: 1. expands the array by one element at the specified position. sl@0: sl@0: 2. constructs a new element of specified length at that position. sl@0: sl@0: 3. returns a reference to the new element. sl@0: sl@0: All existing elements from position anIndex to the end of the array are moved sl@0: up, so that the element originally at position anIndex is now at position sl@0: anIndex + 1 etc. sl@0: sl@0: The new element of type and length aLength is constructed at position sl@0: anIndex, using the default constructor of that class. sl@0: sl@0: @param anIndex The position within the array where the array is to be expanded sl@0: and the new object is to be constructed. sl@0: @param aLength The length of the new element. sl@0: sl@0: @return A reference to the newly constructed object at position sl@0: anIndex within the array. sl@0: sl@0: @leave KErrNoMemory The function attempted to allocate from the heap and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than the number of sl@0: elements currently in the array. sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {return(*new(CArrayPakBase::ExpandL(anIndex,aLength)) T);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline T &CArrayPak::ExtendL(TInt aLength) sl@0: /** sl@0: Expands the array by one element of specified length at the end of the array. sl@0: sl@0: It: sl@0: sl@0: 1. expands the array by one element at the end of the array, i.e. at position sl@0: CArrayPakbase::Count(). sl@0: sl@0: 2. constructs a new element of length aLength at that position. sl@0: sl@0: 3. returns a reference to the new element. sl@0: sl@0: The new element of type is constructed at the end of the array, sl@0: using the default constructor of that class. sl@0: sl@0: @param aLength The length of the new element. sl@0: sl@0: @return A reference to the newly constructed object at the end of sl@0: the array. sl@0: sl@0: @leave KErrNoMemory The function attempted to allocate from the heap and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {return(*new(CArrayPakBase::ExpandL(Count(),aLength)) T);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayPak::Find(const T &aRef,TKeyArrayPak &aKey,TInt &anIndex) const sl@0: /** sl@0: Finds the position of an element within the array, based on the matching of sl@0: keys, using a sequential search. sl@0: sl@0: The array is searched sequentially for an element whose key matches the key sl@0: of the supplied object. The search starts with the first element sl@0: in the array. sl@0: sl@0: Note that where an array has elements with duplicate keys, the function only sl@0: supplies the position of the first element in the array with that key. sl@0: sl@0: @param aRef A reference to an object of type whose key is used sl@0: for comparison. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: @param anIndex A reference to a TInt supplied by the caller. On return, if the sl@0: element is found, this is set to the position sl@0: of that element within the array. The position is relative to zero, (i.e. sl@0: the first element in the array is at position 0). sl@0: If the element is not found or the array is empty, then this is undefined. sl@0: sl@0: @return Zero, if the element with the specified key is found. Non-zero, if sl@0: the element with the specified key is not found. sl@0: */ sl@0: {return(CArrayPakBase::Find(&aRef,aKey,anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayPak::FindIsq(const T &aRef,TKeyArrayPak &aKey,TInt &anIndex) const sl@0: /** sl@0: Finds the position of an element within the array, based on the matching of sl@0: keys, using a binary search technique. sl@0: sl@0: The array is searched, using a binary search technique, for an element whose sl@0: key matches the key of the supplied object. sl@0: sl@0: The array must be in key order. sl@0: sl@0: Note that where an array has elements with duplicate keys, the function cannot sl@0: guarantee which element, with the given key value, it will return, except that it sl@0: will find one of them. sl@0: sl@0: @param aRef A reference to an object of type whose key is used sl@0: for comparison. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: @param anIndex A reference to a TInt supplied by the caller. On return, if the sl@0: element is found, this is set to the position of that element sl@0: within the array. The position is relative to zero, (i.e. sl@0: the first element in the array is at position 0). sl@0: If the element is not found and the array is not empty, then sl@0: this is set to the position of the first element in the array sl@0: with a key which is greater than the key of the object aRef. sl@0: If the element is not found and the array is empty, then this sl@0: is undefined. sl@0: sl@0: @return Zero, if the element with the specified key is found or the array is sl@0: empty. sl@0: Non-zero, if the element with the specified key is not found. sl@0: */ sl@0: {return(CArrayPakBase::FindIsq(&aRef,aKey,anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void CArrayPak::InsertL(TInt anIndex,const T &aRef,TInt aLength) sl@0: /** sl@0: Inserts an element of a specified length into the array at the specified sl@0: position. sl@0: sl@0: @param anIndex The position within the array where the element is to be sl@0: inserted. The position is relative to zero, i.e. zero implies sl@0: that elements are inserted at the beginning of the array. sl@0: @param aRef A reference to the class T object to be inserted into sl@0: the array. sl@0: @param aLength The length of the element to be inserted into the array. sl@0: sl@0: @leave KErrNoMemory The function attempted to expand the array buffer and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than the number of sl@0: objects currently in the array. sl@0: @panic E32USER-CBase 30, if aLength is negative. sl@0: */ sl@0: {CArrayPakBase::InsertL(anIndex,&aRef,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayPak::InsertIsqL(const T &aRef,TInt aLength,TKeyArrayPak &aKey) sl@0: /** sl@0: Inserts a single element of a specified length into the array at a position sl@0: determined by a key. sl@0: sl@0: The array MUST already be in key sequence (as defined by the key), otherwise sl@0: the position of the new element is unpredictable, or duplicates may occur. sl@0: sl@0: Elements with duplicate keys are not permitted. sl@0: sl@0: @param aRef A reference to the element of type to be inserted into sl@0: the array. sl@0: @param aLength The length of the new element of type to be inserted sl@0: into the array. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: sl@0: @return The position within the array of the newly inserted element. sl@0: sl@0: @leave KErrAlreadyExists An element with the same key already exists within sl@0: the array. NB the array MUST already be in key sequence, otherwise sl@0: the function may insert a duplicate and fail to leave with sl@0: this value. sl@0: @leave KErrNoMemory The function attempted to expand the array buffer and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: */ sl@0: {return(CArrayPakBase::InsertIsqL(&aRef,aLength,aKey));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CArrayPak::InsertIsqAllowDuplicatesL(const T &aRef,TInt aLength,TKeyArrayPak &aKey) sl@0: /** sl@0: Inserts a single element of a specified length into the array at a position sl@0: determined by a key, allowing duplicates. sl@0: sl@0: The array MUST already be in key sequence, otherwise the position of the sl@0: new element is unpredictable. sl@0: sl@0: Elements with duplicate keys are permitted. If the new element's key is a sl@0: duplicate of an existing element's key, then the new element is positioned sl@0: after the existing element. sl@0: sl@0: @param aRef A reference to the element of type to be inserted into sl@0: the array. sl@0: @param aLength The length of the new element to be inserted into the array. sl@0: @param aKey A reference to a key object defining the properties of the key. sl@0: sl@0: @return The position within the array of the newly inserted element. sl@0: sl@0: @leave KErrNoMemory The function attempted to expand the array buffer and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: */ sl@0: {return(CArrayPakBase::InsertIsqAllowDuplicatesL(&aRef,aLength,aKey));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline const TArray CArrayPak::Array() const sl@0: /** sl@0: Constructs and returns a TArray object. sl@0: sl@0: @return A Tarray object for this array. sl@0: */ sl@0: {return(TArray(CountR,AtR,this));} sl@0: sl@0: sl@0: sl@0: sl@0: inline CArrayPak::CArrayPak(TBufRep aRep,TInt aGranularity) sl@0: : CArrayPakBase(aRep,aGranularity) sl@0: /** sl@0: Constructs a variable array with the specified granularity and sl@0: buffer organisation. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aRep A pointer to a function used to expand the array buffer. sl@0: The organisation of the array buffer is implied by the sl@0: choice of this function. sl@0: For a flat array buffer, pass (TBufRep)CBufFlat::NewL. sl@0: For a segmented array buffer, pass (TBufRep)CBufSeg::NewL. sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 19, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline const TAny *CArrayPak::At(TInt anIndex) const sl@0: /** sl@0: Gets a pointer to the untyped element located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant of the function if the returned reference is sl@0: used in an expression where that reference cannot be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A pointer to the const element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayPakBase::At(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayPak::At(TInt anIndex) sl@0: /** sl@0: Gets a pointer to the untyped element located at the specified position sl@0: within the array. sl@0: sl@0: The compiler uses this variant of the function if the returned reference is sl@0: used in an expression where that reference can be modified. sl@0: sl@0: @param anIndex The position of the element within the array, relative to zero; sl@0: i.e. zero implies the first element. sl@0: sl@0: @return A pointer to the non-const element located at position anIndex within sl@0: the array. sl@0: sl@0: @panic E32USER-CBase 21, if anIndex is negative or greater than or equal to sl@0: the number of objects currently within the array. sl@0: */ sl@0: {return(CArrayPakBase::At(anIndex));} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CArrayPak::AppendL(const TAny *aPtr,TInt aLength) sl@0: /** sl@0: Appends the untyped element of the specified length onto the end of the array. sl@0: sl@0: @param aPtr A pointer to an untyped element to be appended. sl@0: @param aLength The length of the untyped element. sl@0: sl@0: @leave KErrNoMemory The function attempted to expand the array buffer and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: */ sl@0: {CArrayPakBase::InsertL(Count(),aPtr,aLength);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TAny *CArrayPak::ExtendL(TInt aLength) sl@0: /** sl@0: Expands the array by one element of the specified length at the end of sl@0: the array, and returns a pointer to this new location. sl@0: sl@0: As elements are untyped, no construction is possible and the content of sl@0: the new location remains undefined. sl@0: sl@0: @param aLength The length of the new element. sl@0: sl@0: @return A pointer to the new element location at the end of the array. sl@0: sl@0: @leave KErrNoMemory The function attempted to expand the array buffer and there sl@0: is insufficient memory available. In this case, the array is left in the sl@0: state it was in before the call. sl@0: */ sl@0: {return(CArrayPakBase::ExpandL(Count(),aLength));} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CArrayPakFlat sl@0: template sl@0: inline CArrayPakFlat::CArrayPakFlat(TInt aGranularity) sl@0: : CArrayPak((TBufRep)CBufFlat::NewL,aGranularity) sl@0: /** sl@0: Constructs a packed flat array with specified granularity. sl@0: sl@0: Note that no memory is allocated to the array buffer by this constructor. sl@0: sl@0: @param aGranularity The granularity of the array. sl@0: sl@0: @panic E32USER-CBase 20, if aGranularity is not positive. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CObject sl@0: inline TInt CObject::UniqueID() const sl@0: /** sl@0: Gets this reference counting object's unique ID. sl@0: sl@0: The unique ID is an integer which is a property of the object container. It sl@0: forms part of the identity of all reference counting objects and is the same sl@0: value for all reference counting objects held within the same object container. sl@0: sl@0: @return This reference counting object's unique ID. sl@0: sl@0: @see CObjectCon sl@0: */ sl@0: {return(iContainer->UniqueID());} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt CObject::AccessCount() const sl@0: /** sl@0: Gets the number of open references to this reference counting object. sl@0: sl@0: @return The number of open references. sl@0: */ sl@0: {return(iAccessCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CObject::Inc() sl@0: /** sl@0: Adds one to the reference count. sl@0: sl@0: This function is called by the default implementation of the Open() member sl@0: function of this class. sl@0: sl@0: @see CObject::Open sl@0: */ sl@0: {iAccessCount++;} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CObject::Dec() sl@0: /** sl@0: Subtracts one from the reference count. sl@0: sl@0: This function is called by the default implementation of the Close() member sl@0: function of this class. sl@0: sl@0: @see CObject::Close sl@0: */ sl@0: {iAccessCount--;} sl@0: sl@0: sl@0: sl@0: sl@0: inline CObject * CObject::Owner() const sl@0: /** sl@0: Gets a pointer to the reference counting object which owns this sl@0: reference counting object. sl@0: sl@0: @return A pointer to the owning reference counting object. This is NULL, if sl@0: there is no owner. sl@0: */ sl@0: {return(iOwner);} sl@0: sl@0: sl@0: sl@0: sl@0: inline void CObject::SetOwner(CObject *anOwner) sl@0: /** sl@0: Sets the owner of this reference counting object. sl@0: sl@0: If this reference counting object already has an owner, then all knowledge sl@0: of that owner is lost. sl@0: sl@0: @param anOwner A pointer to the reference counting object which is to be the sl@0: new owner of this reference counting object. sl@0: */ sl@0: {iOwner=anOwner;} sl@0: sl@0: sl@0: sl@0: sl@0: // class CObjectIx sl@0: inline TInt CObjectIx::Count() const sl@0: /** sl@0: Gets the number greater then the last slot number used to hold valid CObject pointer. sl@0: The input argument of CObject* CObjectIx::operator[]() must be less then the number returned by this method. sl@0: sl@0: @return The number greater then the last used slot. sl@0: sl@0: @see CObjectIx::ActiveCount sl@0: @see CObjectIx::operator[] sl@0: */ sl@0: {return iHighWaterMark;} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt CObjectIx::ActiveCount() const sl@0: /** sl@0: Gets the current number of reference counting objects held by this sl@0: object index. sl@0: sl@0: @return The current number. sl@0: */ sl@0: {return iNumEntries;} sl@0: sl@0: sl@0: sl@0: // class CObjectCon sl@0: inline TInt CObjectCon::UniqueID() const sl@0: /** sl@0: Gets this object container's unique ID. sl@0: sl@0: @return The unique ID value. sl@0: */ sl@0: {return iUniqueID;} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt CObjectCon::Count() const sl@0: /** sl@0: Gets the number of reference counting objects in this object container. sl@0: sl@0: @return The number of objects. sl@0: */ sl@0: {return iCount;} sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: // class CCirBufBase sl@0: inline TInt CCirBufBase::Count() const sl@0: /** sl@0: Gets the current number of objects in this circular buffer. sl@0: sl@0: @return The number of objects in this circular buffer. sl@0: This value can never be greater than the maximum capacity. sl@0: */ sl@0: {return(iCount);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt CCirBufBase::Length() const sl@0: /** sl@0: Gets the maximum capacity of this circular buffer. sl@0: sl@0: The capacity is the maximum number of elements that the buffer can hold. sl@0: sl@0: Use SetLengthL() to change the capacity of the circular buffer. sl@0: sl@0: @return The maximum capacity of this circular buffer. sl@0: sl@0: @see CCirBufBase::SetLengthL sl@0: */ sl@0: {return(iLength);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CCirBuf sl@0: template sl@0: inline CCirBuf::CCirBuf() sl@0: : CCirBufBase(sizeof(T)) sl@0: /** sl@0: Default C++ constructor. sl@0: sl@0: The size of each object in the buffer is fixed and is the length of the class sl@0: passed as the template parameter. sl@0: sl@0: @panic E32USER-CBase 72, if the length of the template class is zero. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CCirBuf::Add(const T *aPtr) sl@0: /** sl@0: Adds a single object to the circular buffer. sl@0: sl@0: The object is of type class T and is only added if there is space available. sl@0: sl@0: @param aPtr A pointer to the object of type class T to be added to the circular sl@0: buffer. sl@0: sl@0: @return 1 if the object is successfully added. 0 if the object cannot be added sl@0: because the circular buffer is full. sl@0: sl@0: @panic E32USER-CBase 74, if a call to CCirBufBase::SetLengthL() has not been sl@0: made before calling this function. sl@0: sl@0: @see CCirBufBase::SetLengthL sl@0: */ sl@0: {return(DoAdd((const TUint8 *)aPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CCirBuf::Add(const T *aPtr,TInt aCount) sl@0: /** sl@0: Adds multiple objects to the circular buffer. sl@0: sl@0: The function attempts to add aCount objects of type class T. The objects are sl@0: only added if there is space available. sl@0: sl@0: @param aPtr A pointer to a set of contiguous objects of type class T to be sl@0: added to the circular buffer. sl@0: sl@0: @param aCount The number of objects to be added to the circular buffer. sl@0: sl@0: @return The number of objects successfully added to the buffer. This value sl@0: may be less than the number requested and can range from 0 to aCount. sl@0: sl@0: @panic E32USER-CBase 74, if a call to CCirBufBase::SetLengthL() has not been sl@0: made before calling this function. sl@0: @panic E32USER-CBase 75, if aCount is not a positive value. sl@0: sl@0: @see CCirBufBase::SetLengthL sl@0: */ sl@0: {return(DoAdd((const TUint8 *)aPtr,aCount));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CCirBuf::Remove(T *aPtr) sl@0: /** sl@0: Removes a single object from the circular buffer. sl@0: sl@0: An object can only be removed if there are objects in the buffer. sl@0: sl@0: A binary copy of the object is made to aPtr. sl@0: sl@0: @param aPtr A pointer to an object of type class T supplied by the caller. sl@0: sl@0: @return 1 if an object is successfully removed. 0 if an object cannot be removed sl@0: because the circular buffer is empty. sl@0: */ sl@0: {return(DoRemove((TUint8 *)aPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline TInt CCirBuf::Remove(T *aPtr,TInt aCount) sl@0: /** sl@0: Removes multiple objects from the circular buffer. sl@0: sl@0: The function attempts to remove aCount objects of type class T. sl@0: Objects can only be removed if there are objects in the buffer sl@0: sl@0: A binary copy of the objects is made to aPtr. sl@0: sl@0: @param aPtr A pointer to contiguous memory able to hold aCount class T objects, sl@0: supplied by the caller. sl@0: sl@0: @param aCount The number of objects to be removed from the circular buffer. sl@0: sl@0: @return The number of objects successfully removed from the buffer. This value sl@0: may be less than the number requested, and can range from 0 to aCount. sl@0: sl@0: @panic E32USER-CBase 76, if aCount is not a positive value. sl@0: */ sl@0: {return(DoRemove((TUint8 *)aPtr,aCount));} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CActive sl@0: inline TBool CActive::IsActive() const sl@0: /** sl@0: Determines whether the active object has a request outstanding. sl@0: sl@0: A request is outstanding when: sl@0: sl@0: 1. it has been issued sl@0: sl@0: 2. it has not been cancelled sl@0: sl@0: 3. it servicing has not yet begun. sl@0: sl@0: @return True, if a request is outstanding; false, otherwise. sl@0: */ sl@0: {return(iStatus.iFlags&TRequestStatus::EActive);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TBool CActive::IsAdded() const sl@0: /** sl@0: Determines whether the active object has been added to the active scheduler's sl@0: list of active objects. sl@0: sl@0: If the active object has not been added to a scheduler, it cannot handle the sl@0: completion of any request. No request should be issued until the active object sl@0: has been added to a scheduler because completion of that request generates sl@0: what appears to be a stray signal. sl@0: sl@0: Use the active object function Deque() to remove the active object from the sl@0: scheduler. sl@0: sl@0: @return True, if the active object has been added to an active scheduler; sl@0: false, otherwise. sl@0: sl@0: @see CActive::Deque sl@0: */ sl@0: {return(iLink.iNext!=NULL);} sl@0: sl@0: sl@0: sl@0: sl@0: inline TInt CActive::Priority() const sl@0: /** sl@0: Gets the priority of the active object. sl@0: sl@0: @return The active object's priority value. sl@0: */ sl@0: {return iLink.iPriority;} sl@0: sl@0: sl@0: sl@0: sl@0: // class CDeltaTimer sl@0: inline TDeltaTimerEntry::TDeltaTimerEntry(const TCallBack& aCallback) sl@0: /** sl@0: Constructor specifying a general callback. sl@0: sl@0: @param aCallback The callback to be called when this timed event entry expires. sl@0: */ sl@0: {iCallBack=aCallback;} sl@0: sl@0: sl@0: sl@0: sl@0: inline TDeltaTimerEntry::TDeltaTimerEntry() sl@0: /** sl@0: Default constructor. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline void TDeltaTimerEntry::Set(TCallBack& aCallback) sl@0: /** sl@0: Sets the specified callback. sl@0: sl@0: @param aCallback The callback to be called when this timed event entry expires. sl@0: */ sl@0: {iCallBack=aCallback;} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets a reference to the server's current message. sl@0: sl@0: @return The current message that contains the client request details. sl@0: */ sl@0: inline const RMessage2 &CServer2::Message() const sl@0: {return iMessage;} sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Gets the server active object that handles messages for this session. sl@0: sl@0: This is the instance of the CServer2 derived class that created sl@0: this session object. sl@0: sl@0: @return The server active object. sl@0: */ sl@0: inline const CServer2 *CSession2::Server() const sl@0: {return iServer;} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CAsyncOneShot sl@0: inline RThread& CAsyncOneShot::Thread() sl@0: /** sl@0: Gets a handle to the current thread. sl@0: sl@0: @return The handle to the current thread. sl@0: */ sl@0: { return iThread; } sl@0: sl@0: sl@0: sl@0: sl@0: // Class CActiveScheduler sl@0: inline TInt CActiveScheduler::Level() const sl@0: /** sl@0: @deprecated Use the StackDepth() function instead. sl@0: sl@0: Gets the scheduler's level of nestedness. sl@0: sl@0: @return The level of nestedness. sl@0: sl@0: @see StackDepth() sl@0: */ sl@0: {return StackDepth();} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CActiveSchedulerWait sl@0: inline TBool CActiveSchedulerWait::IsStarted() const sl@0: /** sl@0: Reports whether this CActiveSchedulerWait object is currently started. sl@0: sl@0: Note: a CActiveSchedulerWait object itself becomes "stopped" as sl@0: soon as AsyncStop() is called, and can be started again immediately if sl@0: required (but this would start a new nested level of the scheduler). sl@0: sl@0: @return True if the scheduling loop is active; false, otherwise. sl@0: sl@0: @see CActiveSchedulerWait::Start sl@0: @see CActiveSchedulerWait::AsyncStop sl@0: */ sl@0: {return iLoop != NULL;} sl@0: sl@0: sl@0: sl@0: sl@0: // Class CleanupStack sl@0: #ifdef _DEBUG sl@0: inline void CleanupStack::Pop(TAny* aExpectedItem) sl@0: /** sl@0: Pops an object from the top of the cleanup stack. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function checks that the specified item is at the top sl@0: of the cleanup stack before attempting to pop it; an E32USER-CBase 90 panic sl@0: is raised if the check fails. sl@0: sl@0: 2 In a release build, the function just pops the object which is at the top sl@0: of the cleanup stack; no checking is done. sl@0: sl@0: @param aExpectedItem A pointer to the item expected to be at the top of the sl@0: cleanup stack. In a release build, this parameter sl@0: is not used. sl@0: */ sl@0: { CleanupStack::Check(aExpectedItem); CleanupStack::Pop(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void CleanupStack::Pop(TInt aCount, TAny* aLastExpectedItem) sl@0: /** sl@0: Pops the specified number of objects from the top of the cleanup stack. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function pops (aCount-1) items from the cleanup stack, sl@0: and then checks that the specified item is the next one on the cleanup stack sl@0: before attempting to pop it; an E32USER-CBase 90 panic is raised if the sl@0: check fails. sl@0: sl@0: 2. In a release build, the function just pops aCount items from the cleanup stack; sl@0: no checking is done. sl@0: sl@0: @param aCount The number of items top be popped from sl@0: the cleanup stack. sl@0: @param aLastExpectedItem A pointer to the item expected to be at the top of sl@0: the cleanup stack, after (aCount-1) items have been sl@0: popped. In a release build, this parameter is sl@0: not used. sl@0: */ sl@0: { sl@0: if (--aCount) sl@0: CleanupStack::Pop(aCount); sl@0: CleanupStack::Check(aLastExpectedItem); sl@0: CleanupStack::Pop(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: inline void CleanupStack::PopAndDestroy(TAny* aExpectedItem) sl@0: /** sl@0: Pops an object from the top of the cleanup stack, and cleans it up. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function checks that the specified item is at the top sl@0: of the cleanup stack before attempting to pop and clean it up; sl@0: an E32USER-CBase 90 panic is raised if the check fails. sl@0: sl@0: 2. In a release build, the function just pops and cleans up the object at sl@0: the top of the cleanup stack; no checking is done. sl@0: sl@0: @param aExpectedItem A pointer to the item expected to be at the top of the sl@0: cleanup stack. In a release build, this parameter is sl@0: not used. sl@0: */ sl@0: { CleanupStack::Check(aExpectedItem); CleanupStack::PopAndDestroy(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void CleanupStack::PopAndDestroy(TInt aCount, TAny* aLastExpectedItem) sl@0: /** sl@0: Pops the specified number of objects from the top of the cleanup stack, and sl@0: cleans them up. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function pops and cleans up (aCount-1) items from the sl@0: cleanup stack, and then checks that the specified item is the next one on sl@0: the cleanup stack before attempting to pop it and clean it up; sl@0: an E32USER-CBase 90 panic is raised if the check fails. sl@0: sl@0: 2. In a release build, the function just pops and cleans up aCount items from sl@0: the cleanup stack; no checking is done. sl@0: sl@0: @param aCount The number of items top be popped from the sl@0: cleanup stack, and cleaned up. sl@0: @param aLastExpectedItem A pointer to the item expected to be at the top of sl@0: the cleanup stack, after (aCount-1) items have been sl@0: popped and cleaned up. In a release build, this sl@0: parameter is not used. sl@0: */ sl@0: { sl@0: if (--aCount) sl@0: CleanupStack::PopAndDestroy(aCount); sl@0: CleanupStack::Check(aLastExpectedItem); sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: #else sl@0: inline void CleanupStack::Pop(TAny*) sl@0: /** sl@0: Pops an object from the top of the cleanup stack. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function checks that the specified item is at the top sl@0: of the cleanup stack before attempting to pop it; an E32USER-CBase 90 panic sl@0: is raised if the check fails. sl@0: sl@0: 2 In a release build, the function just pops the object which is at the top sl@0: of the cleanup stack; no checking is done. sl@0: sl@0: @param aExpectedItem A pointer to the item expected to be at the top of the sl@0: cleanup stack. In a release build, this parameter sl@0: is not used. sl@0: */ sl@0: { CleanupStack::Pop(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void CleanupStack::Pop(TInt aCount, TAny*) sl@0: /** sl@0: Pops the specified number of objects from the top of the cleanup stack. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function pops (aCount-1) items from the cleanup stack, sl@0: and then checks that the specified item is the next one on the cleanup stack sl@0: before attempting to pop it; an E32USER-CBase 90 panic is raised if the sl@0: check fails. sl@0: sl@0: 2. In a release build, the function just pops aCount items from the cleanup stack; sl@0: no checking is done. sl@0: sl@0: @param aCount The number of items top be popped from sl@0: the cleanup stack. sl@0: @param aLastExpectedItem A pointer to the item expected to be at the top of sl@0: the cleanup stack, after (aCount-1) items have been sl@0: popped. In a release build, this parameter is sl@0: not used. sl@0: */ sl@0: { CleanupStack::Pop(aCount); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void CleanupStack::PopAndDestroy(TAny*) sl@0: /** sl@0: Pops an object from the top of the cleanup stack, and cleans it up. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function checks that the specified item is at the top sl@0: of the cleanup stack before attempting to pop and clean it up; sl@0: an E32USER-CBase 90 panic is raised if the check fails. sl@0: sl@0: 2. In a release build, the function just pops and cleans up the object at sl@0: the top of the cleanup stack; no checking is done. sl@0: sl@0: @param aExpectedItem A pointer to the item expected to be at the top of the sl@0: cleanup stack. In a release build, this parameter is sl@0: not used. sl@0: */ sl@0: { CleanupStack::PopAndDestroy(); } sl@0: sl@0: sl@0: sl@0: sl@0: inline void CleanupStack::PopAndDestroy(TInt aCount, TAny*) sl@0: /** sl@0: Pops the specified number of objects from the top of the cleanup stack, and sl@0: cleans them up. sl@0: sl@0: The function has two modes of operation, depending on whether it is part of sl@0: a debug build or a release build. sl@0: sl@0: 1. In a debug build, the function pops and cleans up (aCount-1) items from the sl@0: cleanup stack, and then checks that the specified item is the next one on sl@0: the cleanup stack before attempting to pop it and clean it up; sl@0: an E32USER-CBase 90 panic is raised if the check fails. sl@0: sl@0: 2. In a release build, the function just pops and cleans up aCount items from sl@0: the cleanup stack; no checking is done. sl@0: sl@0: @param aCount The number of items top be popped from the sl@0: cleanup stack, and cleaned up. sl@0: @param aLastExpectedItem A pointer to the item expected to be at the top of sl@0: the cleanup stack, after (aCount-1) items have been sl@0: popped and cleaned up. In a release build, this sl@0: parameter is not used. sl@0: */ sl@0: { CleanupStack::PopAndDestroy(aCount); } sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: // Class TCleanupItem sl@0: inline TCleanupItem::TCleanupItem(TCleanupOperation anOperation) sl@0: : iOperation(anOperation) sl@0: /** sl@0: Constructs the object with a cleanup operation. sl@0: sl@0: @param anOperation A cleanup operation which will be invoked by the pop and sl@0: destroy action resulting from a subsequent call to sl@0: CleanupStack::PopAndDestroy(). sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: inline TCleanupItem::TCleanupItem(TCleanupOperation anOperation,TAny *aPtr) sl@0: : iOperation(anOperation), iPtr(aPtr) sl@0: /** sl@0: Constructs the object with a cleanup operation and a pointer to the object sl@0: to be cleaned up. sl@0: sl@0: @param anOperation A cleanup operation which will be invoked by the pop sl@0: and destroy action resulting from a subsequent call to sl@0: CleanupStack::PopAndDestroy(). sl@0: sl@0: @param aPtr A pointer to an object which is the target of the sl@0: cleanup operation. sl@0: */ sl@0: {} sl@0: sl@0: sl@0: sl@0: sl@0: // Class TCleanupTrapHandler sl@0: inline CCleanup &TCleanupTrapHandler::Cleanup() sl@0: {return(*iCleanup);} sl@0: sl@0: // Class TAutoClose sl@0: template sl@0: inline TAutoClose::~TAutoClose() sl@0: /** sl@0: Destructor. sl@0: sl@0: The implementation calls Close() on iObj, the instance of the template class. sl@0: */ sl@0: #ifdef __LEAVE_EQUALS_THROW__ sl@0: {if (!std::uncaught_exception()) iObj.Close();} sl@0: #else sl@0: {iObj.Close();} sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void TAutoClose::PushL() sl@0: /** sl@0: Pushes a cleanup item onto the cleanup stack, so that Close() is called on the sl@0: templated class object, iObj, if a leave occurs. sl@0: */ sl@0: {CleanupStack::PushL(TCleanupItem(Close, (TAny *)&iObj));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: inline void TAutoClose::Pop() sl@0: /** sl@0: Pops a single cleanup item from the cleanup stack. sl@0: */ sl@0: {CleanupStack::Pop();} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: void TAutoClose::Close(TAny *aObj) sl@0: {((T *)aObj)->Close();} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CleanupDelete sl@0: template sl@0: inline void CleanupDelete::PushL(T* aPtr) sl@0: /** sl@0: Creates a TCleanupItem for the specified object. sl@0: sl@0: The cleanup operation is the private static function Delete() of this class, which sl@0: deletes the specified object. sl@0: sl@0: @param aPtr The object for which a TCleanupItem is to be constructed. sl@0: */ sl@0: {CleanupStack::PushL(TCleanupItem(&Delete,aPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: void CleanupDelete::Delete(TAny *aPtr) sl@0: /** sl@0: The cleanup operation to be performed. sl@0: sl@0: @param aPtr A pointer to the object for which clean up is to be performed. sl@0: The implementation deletes this object. sl@0: */ sl@0: {delete STATIC_CAST(T*,aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // See header file e32base.h for in-source comment. sl@0: template sl@0: inline void CleanupDeletePushL(T* aPtr) sl@0: {CleanupDelete::PushL(aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CleanupArrayDelete sl@0: template sl@0: inline void CleanupArrayDelete::PushL(T* aPtr) sl@0: /** sl@0: Creates a TCleanupItem for the specified array. sl@0: sl@0: The cleanup operation is the private static function ArrayDelete() of sl@0: this class, which deletes the specified array. sl@0: sl@0: @param aPtr The array of class T type objects for which a TCleanupItem is sl@0: to be constructed. sl@0: */ sl@0: {CleanupStack::PushL(TCleanupItem(&ArrayDelete,aPtr));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: void CleanupArrayDelete::ArrayDelete(TAny *aPtr) sl@0: /** sl@0: The cleanup operation to be performed. sl@0: sl@0: @param aPtr A pointer to the array for which clean up is to be performed. sl@0: The implementation deletes this array. sl@0: */ sl@0: {delete [] STATIC_CAST(T*,aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // See header file e32base.h for in-source comment. sl@0: template sl@0: inline void CleanupArrayDeletePushL(T* aPtr) sl@0: {CleanupArrayDelete::PushL(aPtr);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CleanupClose sl@0: template sl@0: inline void CleanupClose::PushL(T& aRef) sl@0: /** sl@0: Creates a TCleanupItem for the specified object. sl@0: sl@0: The cleanup operation is the private static function Close() of this class. sl@0: sl@0: @param aRef The object for which a TCleanupItem is to be constructed. sl@0: */ sl@0: {CleanupStack::PushL(TCleanupItem(&Close,&aRef));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: void CleanupClose::Close(TAny *aPtr) sl@0: /** sl@0: The cleanup operation to be performed. sl@0: sl@0: @param aPtr A pointer to the object for which clean up is to be performed. sl@0: The implementation calls Close() on this object. sl@0: */ sl@0: {(STATIC_CAST(T*,aPtr))->Close();} sl@0: sl@0: sl@0: sl@0: sl@0: // See header file e32base.h for in-source comment. sl@0: template sl@0: inline void CleanupClosePushL(T& aRef) sl@0: {CleanupClose::PushL(aRef);} sl@0: sl@0: sl@0: sl@0: sl@0: // Template class CleanupRelease sl@0: template sl@0: inline void CleanupRelease::PushL(T& aRef) sl@0: /** sl@0: Creates a TCleanupItem for the specified object. sl@0: sl@0: The cleanup operation is the private static function Release() of this class. sl@0: sl@0: @param aRef The object for which a TCleanupItem is to be constructed. sl@0: */ sl@0: {CleanupStack::PushL(TCleanupItem(&Release,&aRef));} sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: void CleanupRelease::Release(TAny *aPtr) sl@0: /** sl@0: The cleanup operation to be performed. sl@0: sl@0: @param aPtr A pointer to the object for which clean up is to be performed. sl@0: The implementation calls Release() on this object. sl@0: */ sl@0: {(STATIC_CAST(T*,aPtr))->Release();} sl@0: sl@0: sl@0: sl@0: sl@0: // See header file e32base.h for in-source comment. sl@0: template sl@0: inline void CleanupReleasePushL(T& aRef) sl@0: {CleanupRelease::PushL(aRef);} sl@0: sl@0: sl@0: