| 
sl@0
 | 
     1  | 
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
  | 
| 
sl@0
 | 
     2  | 
// All rights reserved.
  | 
| 
sl@0
 | 
     3  | 
// This component and the accompanying materials are made available
  | 
| 
sl@0
 | 
     4  | 
// under the terms of "Eclipse Public License v1.0"
  | 
| 
sl@0
 | 
     5  | 
// which accompanies this distribution, and is available
  | 
| 
sl@0
 | 
     6  | 
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
  | 
| 
sl@0
 | 
     7  | 
//
  | 
| 
sl@0
 | 
     8  | 
// Initial Contributors:
  | 
| 
sl@0
 | 
     9  | 
// Nokia Corporation - initial contribution.
  | 
| 
sl@0
 | 
    10  | 
//
  | 
| 
sl@0
 | 
    11  | 
// Contributors:
  | 
| 
sl@0
 | 
    12  | 
//
  | 
| 
sl@0
 | 
    13  | 
// Description:
  | 
| 
sl@0
 | 
    14  | 
// Written by DavidW, October 1996
  | 
| 
sl@0
 | 
    15  | 
// Descriptor arrays
  | 
| 
sl@0
 | 
    16  | 
// 
  | 
| 
sl@0
 | 
    17  | 
//
  | 
| 
sl@0
 | 
    18  | 
  | 
| 
sl@0
 | 
    19  | 
#include <badesca.h>
  | 
| 
sl@0
 | 
    20  | 
  | 
| 
sl@0
 | 
    21  | 
  | 
| 
sl@0
 | 
    22  | 
// Class to provide an interface for Sort function - two variants
  | 
| 
sl@0
 | 
    23  | 
// for 8 and 16-bit descriptors.  (should this be templated? -PNJ)
  | 
| 
sl@0
 | 
    24  | 
  | 
| 
sl@0
 | 
    25  | 
  | 
| 
sl@0
 | 
    26  | 
NONSHARABLE_CLASS(TKeyDesC8Array) : public TKeyArrayFix
  | 
| 
sl@0
 | 
    27  | 
	{
 | 
| 
sl@0
 | 
    28  | 
public:
  | 
| 
sl@0
 | 
    29  | 
	TKeyDesC8Array(TKeyCmpText aType);
  | 
| 
sl@0
 | 
    30  | 
private: // from TKey
  | 
| 
sl@0
 | 
    31  | 
	TInt Compare(TInt aLeft,TInt aRight) const;
  | 
| 
sl@0
 | 
    32  | 
	};
  | 
| 
sl@0
 | 
    33  | 
  | 
| 
sl@0
 | 
    34  | 
TKeyDesC8Array::TKeyDesC8Array(TKeyCmpText aType)
  | 
| 
sl@0
 | 
    35  | 
	: TKeyArrayFix(0,aType,0)
  | 
| 
sl@0
 | 
    36  | 
	{
 | 
| 
sl@0
 | 
    37  | 
	}
  | 
| 
sl@0
 | 
    38  | 
  | 
| 
sl@0
 | 
    39  | 
TInt TKeyDesC8Array::Compare(TInt aLeft,TInt aRight) const
  | 
| 
sl@0
 | 
    40  | 
	{
 | 
| 
sl@0
 | 
    41  | 
	TDesC8* left=(*(TDesC8**)At(aLeft));
  | 
| 
sl@0
 | 
    42  | 
	TDesC8* right=(*(TDesC8**)At(aRight));
  | 
| 
sl@0
 | 
    43  | 
	switch (iCmpType)
  | 
| 
sl@0
 | 
    44  | 
		{
 | 
| 
sl@0
 | 
    45  | 
	case ECmpFolded:
  | 
| 
sl@0
 | 
    46  | 
		return(left->CompareF(*right));
  | 
| 
sl@0
 | 
    47  | 
	case ECmpCollated:
  | 
| 
sl@0
 | 
    48  | 
		return(left->CompareC(*right));
  | 
| 
sl@0
 | 
    49  | 
	default:
  | 
| 
sl@0
 | 
    50  | 
		break;
  | 
| 
sl@0
 | 
    51  | 
		}
  | 
| 
sl@0
 | 
    52  | 
	return(left->Compare(*right));
  | 
| 
sl@0
 | 
    53  | 
	}
  | 
| 
sl@0
 | 
    54  | 
  | 
| 
sl@0
 | 
    55  | 
  | 
| 
sl@0
 | 
    56  | 
NONSHARABLE_CLASS(TKeyDesC16Array) : public TKeyArrayFix
  | 
| 
sl@0
 | 
    57  | 
	{
 | 
| 
sl@0
 | 
    58  | 
public:
  | 
| 
sl@0
 | 
    59  | 
	TKeyDesC16Array(TKeyCmpText aType);
  | 
| 
sl@0
 | 
    60  | 
private: // from TKey
  | 
| 
sl@0
 | 
    61  | 
	TInt Compare(TInt aLeft,TInt aRight) const;
  | 
| 
sl@0
 | 
    62  | 
	};
  | 
| 
sl@0
 | 
    63  | 
  | 
| 
sl@0
 | 
    64  | 
TKeyDesC16Array::TKeyDesC16Array(TKeyCmpText aType)
  | 
| 
sl@0
 | 
    65  | 
	: TKeyArrayFix(0,aType,0)
  | 
| 
sl@0
 | 
    66  | 
	{
 | 
| 
sl@0
 | 
    67  | 
	}
  | 
| 
sl@0
 | 
    68  | 
  | 
| 
sl@0
 | 
    69  | 
TInt TKeyDesC16Array::Compare(TInt aLeft,TInt aRight) const
  | 
| 
sl@0
 | 
    70  | 
	{
 | 
| 
sl@0
 | 
    71  | 
	TDesC16* left=(*(TDesC16**)At(aLeft));
  | 
| 
sl@0
 | 
    72  | 
	TDesC16* right=(*(TDesC16**)At(aRight));
  | 
| 
sl@0
 | 
    73  | 
	switch (iCmpType)
  | 
| 
sl@0
 | 
    74  | 
		{
 | 
| 
sl@0
 | 
    75  | 
	case ECmpFolded:
  | 
| 
sl@0
 | 
    76  | 
		return(left->CompareF(*right));
  | 
| 
sl@0
 | 
    77  | 
	case ECmpCollated:
  | 
| 
sl@0
 | 
    78  | 
		return(left->CompareC(*right));
  | 
| 
sl@0
 | 
    79  | 
	default:
  | 
| 
sl@0
 | 
    80  | 
		break;
  | 
| 
sl@0
 | 
    81  | 
		}
  | 
| 
sl@0
 | 
    82  | 
	return(left->Compare(*right));
  | 
| 
sl@0
 | 
    83  | 
	}
  | 
| 
sl@0
 | 
    84  | 
  | 
| 
sl@0
 | 
    85  | 
  | 
| 
sl@0
 | 
    86  | 
  | 
| 
sl@0
 | 
    87  | 
// CDesCxArray implementation...
  | 
| 
sl@0
 | 
    88  | 
  | 
| 
sl@0
 | 
    89  | 
  | 
| 
sl@0
 | 
    90  | 
EXPORT_C CDesC8Array::CDesC8Array(TBufRep aRep,TInt aGranularity)
  | 
| 
sl@0
 | 
    91  | 
    : CArrayFixBase(aRep,sizeof(HBufC8*),aGranularity)
  | 
| 
sl@0
 | 
    92  | 
    {
 | 
| 
sl@0
 | 
    93  | 
    }
  | 
| 
sl@0
 | 
    94  | 
  | 
| 
sl@0
 | 
    95  | 
EXPORT_C CDesC8Array::~CDesC8Array()
  | 
| 
sl@0
 | 
    96  | 
/** Frees all resources owned by the object, prior to its destruction. In particular, 
  | 
| 
sl@0
 | 
    97  | 
it deletes all descriptors from the array and frees the memory allocated to 
  | 
| 
sl@0
 | 
    98  | 
the array buffer. */
  | 
| 
sl@0
 | 
    99  | 
    {
 | 
| 
sl@0
 | 
   100  | 
	Reset();
  | 
| 
sl@0
 | 
   101  | 
    }
  | 
| 
sl@0
 | 
   102  | 
  | 
| 
sl@0
 | 
   103  | 
EXPORT_C void CDesC8Array::Reset()
  | 
| 
sl@0
 | 
   104  | 
/** Deletes all descriptors from the array and frees the memory allocated to the 
  | 
| 
sl@0
 | 
   105  | 
array buffer.
  | 
| 
sl@0
 | 
   106  | 
  | 
| 
sl@0
 | 
   107  | 
@see CDesC8Array::Delete() */
  | 
| 
sl@0
 | 
   108  | 
	{
 | 
| 
sl@0
 | 
   109  | 
	Delete(0,Count());
  | 
| 
sl@0
 | 
   110  | 
	}
  | 
| 
sl@0
 | 
   111  | 
  | 
| 
sl@0
 | 
   112  | 
EXPORT_C void CDesC8Array::Delete(TInt aIndex)
  | 
| 
sl@0
 | 
   113  | 
	{
 | 
| 
sl@0
 | 
   114  | 
	Delete(aIndex,1);
  | 
| 
sl@0
 | 
   115  | 
	}
  | 
| 
sl@0
 | 
   116  | 
  | 
| 
sl@0
 | 
   117  | 
/**
  | 
| 
sl@0
 | 
   118  | 
 *
  | 
| 
sl@0
 | 
   119  | 
 * Deletes one or more logically contiguous descriptor elements from the
  | 
| 
sl@0
 | 
   120  | 
 * array.
  | 
| 
sl@0
 | 
   121  | 
 *
  | 
| 
sl@0
 | 
   122  | 
 * The deletion starts at the specified position.Deleting descriptor
  | 
| 
sl@0
 | 
   123  | 
 * elements from the array frees the memory occupied by the associated
  | 
| 
sl@0
 | 
   124  | 
 * heap descriptors and removes their pointers from the array buffer but
  | 
| 
sl@0
 | 
   125  | 
 * does not cause the array buffer to be automatically compressed. Call
  | 
| 
sl@0
 | 
   126  | 
 * the Compress() function to return excess space in the array buffer to
  | 
| 
sl@0
 | 
   127  | 
 * the heap.
  | 
| 
sl@0
 | 
   128  | 
 *
  | 
| 
sl@0
 | 
   129  | 
 * @param     " TInt aPos "
  | 
| 
sl@0
 | 
   130  | 
 *            The starting position in the array from which
  | 
| 
sl@0
 | 
   131  | 
 *            descriptor elements are to be deleted. The position is
  | 
| 
sl@0
 | 
   132  | 
 *            relative to zero, i.e. zero implies the first
  | 
| 
sl@0
 | 
   133  | 
 *            descriptor element. This value must not be negative
  | 
| 
sl@0
 | 
   134  | 
 *            and must not be greater than the number of descriptor
  | 
| 
sl@0
 | 
   135  | 
 *            elements currently in the array, otherwise the
  | 
| 
sl@0
 | 
   136  | 
 *            functions raise an E32USER-CBase 21 panic.
  | 
| 
sl@0
 | 
   137  | 
 * @param     " TInt aCount "
  | 
| 
sl@0
 | 
   138  | 
 *            If specified, the number of contiguous descriptor
  | 
| 
sl@0
 | 
   139  | 
 *            elements to be deleted from the array. This value must
  | 
| 
sl@0
 | 
   140  | 
 *            not be negative otherwise the function raises an
  | 
| 
sl@0
 | 
   141  | 
 *            E32USER-CBase 22 panic. This value plus the value of
  | 
| 
sl@0
 | 
   142  | 
 *            the starting position must not be greater than the
  | 
| 
sl@0
 | 
   143  | 
 *            number of descriptor elements in the array, otherwise
  | 
| 
sl@0
 | 
   144  | 
 *            the function raises an E32USER-CBase 29 panic. This
  | 
| 
sl@0
 | 
   145  | 
 *            value must not be negative otherwise the function
  | 
| 
sl@0
 | 
   146  | 
 *            raises an E32USER-CBase 22 panic. This value plus the
  | 
| 
sl@0
 | 
   147  | 
 *            value of the starting position must not be greater
  | 
| 
sl@0
 | 
   148  | 
 *            than the number of descriptor elements in the array,
  | 
| 
sl@0
 | 
   149  | 
 *            otherwise the function raises an E32USER-CBase 29
  | 
| 
sl@0
 | 
   150  | 
 *            panic. If not specified, one element is assumed.
  | 
| 
sl@0
 | 
   151  | 
 */
  | 
| 
sl@0
 | 
   152  | 
EXPORT_C void CDesC8Array::Delete(TInt aIndex,TInt aCount)
  | 
| 
sl@0
 | 
   153  | 
	{
 | 
| 
sl@0
 | 
   154  | 
	TInt count=aCount;
  | 
| 
sl@0
 | 
   155  | 
	for (TInt ii=aIndex; count--; ii++)
  | 
| 
sl@0
 | 
   156  | 
		User::Free(*(HBufC8**)At(ii));
  | 
| 
sl@0
 | 
   157  | 
	CArrayFixBase::Delete(aIndex,aCount);
  | 
| 
sl@0
 | 
   158  | 
	}
  | 
| 
sl@0
 | 
   159  | 
  | 
| 
sl@0
 | 
   160  | 
EXPORT_C TInt CDesC8Array::MdcaCount() const
  | 
| 
sl@0
 | 
   161  | 
/** Returns the number of descriptor elements in the array. The function implements 
  | 
| 
sl@0
 | 
   162  | 
the interface MDesC8Array::MdcaCount().
  | 
| 
sl@0
 | 
   163  | 
  | 
| 
sl@0
 | 
   164  | 
@return The number of descriptor elements. */
  | 
| 
sl@0
 | 
   165  | 
    {
 | 
| 
sl@0
 | 
   166  | 
    return Count();
  | 
| 
sl@0
 | 
   167  | 
    }
  | 
| 
sl@0
 | 
   168  | 
  | 
| 
sl@0
 | 
   169  | 
EXPORT_C TPtrC8 CDesC8Array::MdcaPoint(TInt anIndex) const
  | 
| 
sl@0
 | 
   170  | 
/** Indexes into a descriptor array. The function implements the interface 
  | 
| 
sl@0
 | 
   171  | 
MDesC8Array::MdcaPoint().
  | 
| 
sl@0
 | 
   172  | 
	
  | 
| 
sl@0
 | 
   173  | 
@param aIndex The position of the descriptor element within the array. The 
  | 
| 
sl@0
 | 
   174  | 
position is relative to zero; i.e. zero implies the first descriptor element 
  | 
| 
sl@0
 | 
   175  | 
in the array. This value must be non-negative and less than the number of 
  | 
| 
sl@0
 | 
   176  | 
descriptors currently within the array otherwise the operator panics with 
  | 
| 
sl@0
 | 
   177  | 
EArrayIndexOutOfRange. 
  | 
| 
sl@0
 | 
   178  | 
@return A non-modifiable pointer descriptor representing the descriptor element 
  | 
| 
sl@0
 | 
   179  | 
located at position aIndex within the array. */
  | 
| 
sl@0
 | 
   180  | 
	{
 | 
| 
sl@0
 | 
   181  | 
	HBufC8* temp=(*(HBufC8**)At(anIndex));
  | 
| 
sl@0
 | 
   182  | 
	return (TPtrC8)(*temp);
  | 
| 
sl@0
 | 
   183  | 
	}
  | 
| 
sl@0
 | 
   184  | 
  | 
| 
sl@0
 | 
   185  | 
EXPORT_C void CDesC8Array::AppendL(const TDesC8& aPtr)
  | 
| 
sl@0
 | 
   186  | 
/** Appends a descriptor onto the end of any existing descriptor elements in the 
  | 
| 
sl@0
 | 
   187  | 
array.
  | 
| 
sl@0
 | 
   188  | 
  | 
| 
sl@0
 | 
   189  | 
@param aPtr A reference to the descriptor to be appended to the array. 
  | 
| 
sl@0
 | 
   190  | 
@leave KErrNoMemory There is insufficient memory available. If the function 
  | 
| 
sl@0
 | 
   191  | 
leaves, the array is left in the state it was in before the call. */
  | 
| 
sl@0
 | 
   192  | 
	{
 | 
| 
sl@0
 | 
   193  | 
	InsertL(Count(),aPtr);
  | 
| 
sl@0
 | 
   194  | 
	}
  | 
| 
sl@0
 | 
   195  | 
  | 
| 
sl@0
 | 
   196  | 
EXPORT_C void CDesC8Array::InsertL(TInt aPos,const TDesC8& aPtr)
  | 
| 
sl@0
 | 
   197  | 
/** Inserts a descriptor into the array at the specified position. 
  | 
| 
sl@0
 | 
   198  | 
  | 
| 
sl@0
 | 
   199  | 
If the specified position is the same as the current number of descriptor 
  | 
| 
sl@0
 | 
   200  | 
elements in the array, this has the effect of appending the element.
  | 
| 
sl@0
 | 
   201  | 
  | 
| 
sl@0
 | 
   202  | 
@param aPos The position within the array where the descriptor element is 
  | 
| 
sl@0
 | 
   203  | 
to be inserted. The position is relative to zero, i.e. zero implies the first 
  | 
| 
sl@0
 | 
   204  | 
descriptor element. This value must not be negative and must not be greater 
  | 
| 
sl@0
 | 
   205  | 
than the number of descriptor elements currently in the array, otherwise the 
  | 
| 
sl@0
 | 
   206  | 
function rasises an E32USER-CBase 21 panic. 
  | 
| 
sl@0
 | 
   207  | 
@param aPtr The descriptor to be inserted into the array. 
  | 
| 
sl@0
 | 
   208  | 
@leave KErrNoMemory There is insufficient memory available. If the function 
  | 
| 
sl@0
 | 
   209  | 
leaves, the array is left in the state it was in before the call. */
  | 
| 
sl@0
 | 
   210  | 
	{
 | 
| 
sl@0
 | 
   211  | 
	HBufC8* bufPtr=aPtr.AllocLC();
  | 
| 
sl@0
 | 
   212  | 
   	CArrayFixBase::InsertL(aPos,&bufPtr);
  | 
| 
sl@0
 | 
   213  | 
	CleanupStack::Pop();
  | 
| 
sl@0
 | 
   214  | 
	}
  | 
| 
sl@0
 | 
   215  | 
  | 
| 
sl@0
 | 
   216  | 
EXPORT_C TInt CDesC8Array::InsertIsqL(const TDesC8& aPtr,TKeyCmpText aTextComparisonType)
  | 
| 
sl@0
 | 
   217  | 
/** Inserts a descriptor into the array at a position which maintains the 
  | 
| 
sl@0
 | 
   218  | 
sequence of the descriptors.
  | 
| 
sl@0
 | 
   219  | 
  | 
| 
sl@0
 | 
   220  | 
The sequence is determined by comparing descriptors using one of the TDesC 
  | 
| 
sl@0
 | 
   221  | 
comparison functions. The enumeration aTextComparisonType governs how the 
  | 
| 
sl@0
 | 
   222  | 
descriptors are to be compared.
  | 
| 
sl@0
 | 
   223  | 
  | 
| 
sl@0
 | 
   224  | 
The array should already be in sequence, otherwise the position of the new 
  | 
| 
sl@0
 | 
   225  | 
descriptor element is unpredictable. Descriptor elements which are the same 
  | 
| 
sl@0
 | 
   226  | 
are not permitted.
  | 
| 
sl@0
 | 
   227  | 
  | 
| 
sl@0
 | 
   228  | 
@param aPtr A reference to the descriptor to be inserted into the array. 
  | 
| 
sl@0
 | 
   229  | 
@param aTextComparisonType An enumeration which determines the type of 
  | 
| 
sl@0
 | 
   230  | 
comparison to be made between descriptors for the purpose of choosing the 
  | 
| 
sl@0
 | 
   231  | 
insertion position.  If no parameter is explicitly passed, ECmpFolded is used 
  | 
| 
sl@0
 | 
   232  | 
by default.
  | 
| 
sl@0
 | 
   233  | 
@leave KErrAlreadyExists A descriptor with the same data (i.e. the same length 
  | 
| 
sl@0
 | 
   234  | 
and the same content) already exists within the array.
  | 
| 
sl@0
 | 
   235  | 
@leave KErrNoMemory There is insufficient memory available. If the function 
  | 
| 
sl@0
 | 
   236  | 
leaves, the array is left in the state it was in before the call.
  | 
| 
sl@0
 | 
   237  | 
@return The position within the array of the inserted descriptor. */
  | 
| 
sl@0
 | 
   238  | 
	{
 | 
| 
sl@0
 | 
   239  | 
	HBufC8* bufPtr=aPtr.AllocLC();
  | 
| 
sl@0
 | 
   240  | 
	TKeyDesC8Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   241  | 
   	TInt found=CArrayFixBase::InsertIsqL(&bufPtr,key);
  | 
| 
sl@0
 | 
   242  | 
	CleanupStack::Pop();
  | 
| 
sl@0
 | 
   243  | 
	return(found);
  | 
| 
sl@0
 | 
   244  | 
	}
  | 
| 
sl@0
 | 
   245  | 
  | 
| 
sl@0
 | 
   246  | 
EXPORT_C TInt CDesC8Array::InsertIsqAllowDuplicatesL(const TDesC8& aPtr,TKeyCmpText aTextComparisonType)
  | 
| 
sl@0
 | 
   247  | 
/** Inserts a descriptor into the array at a position which maintains the 
  | 
| 
sl@0
 | 
   248  | 
sequence of the descriptors - allows duplicates.
  | 
| 
sl@0
 | 
   249  | 
  | 
| 
sl@0
 | 
   250  | 
The sequence is determined by comparing descriptors using one of the TDesC 
  | 
| 
sl@0
 | 
   251  | 
comparison functions. The enumeration aTextComparisonType governs how the 
  | 
| 
sl@0
 | 
   252  | 
descriptors are to be compared.
  | 
| 
sl@0
 | 
   253  | 
  | 
| 
sl@0
 | 
   254  | 
The array should already be in sequence, otherwise the position of the new 
  | 
| 
sl@0
 | 
   255  | 
descriptor element is unpredictable. Descriptor elements which are the same 
  | 
| 
sl@0
 | 
   256  | 
are permitted; if the descriptor aPtr is a duplicate of an existing descriptor 
  | 
| 
sl@0
 | 
   257  | 
within the array, then the new descriptor element is positioned after the 
  | 
| 
sl@0
 | 
   258  | 
existing descriptor element.
  | 
| 
sl@0
 | 
   259  | 
  | 
| 
sl@0
 | 
   260  | 
@param aPtr A reference to the descriptor to be inserted into the array. 
  | 
| 
sl@0
 | 
   261  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   262  | 
to be made between descriptors for the purpose of choosing the insertion position. 
  | 
| 
sl@0
 | 
   263  | 
If no parameter is explicitly passed, ECmpFolded is used by default.
  | 
| 
sl@0
 | 
   264  | 
@leave KErrNoMemory There is insufficient memory available. If the function 
  | 
| 
sl@0
 | 
   265  | 
leaves, the array is left in the state it was in before the call. 
  | 
| 
sl@0
 | 
   266  | 
@return The position within the array of the inserted descriptor. */
  | 
| 
sl@0
 | 
   267  | 
	{
 | 
| 
sl@0
 | 
   268  | 
	HBufC8* bufPtr=aPtr.AllocLC();
  | 
| 
sl@0
 | 
   269  | 
	TKeyDesC8Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   270  | 
   	TInt found=CArrayFixBase::InsertIsqAllowDuplicatesL(&bufPtr,key);
  | 
| 
sl@0
 | 
   271  | 
	CleanupStack::Pop();
  | 
| 
sl@0
 | 
   272  | 
	return(found);
  | 
| 
sl@0
 | 
   273  | 
	}
  | 
| 
sl@0
 | 
   274  | 
  | 
| 
sl@0
 | 
   275  | 
EXPORT_C void CDesC8Array::Sort(TKeyCmpText aTextComparisonType)
  | 
| 
sl@0
 | 
   276  | 
/** Sorts the descriptor elements into sequence.
  | 
| 
sl@0
 | 
   277  | 
  | 
| 
sl@0
 | 
   278  | 
The sequence is determined by comparing descriptors using one of the member 
  | 
| 
sl@0
 | 
   279  | 
functions of the descriptor base class TDesC.
  | 
| 
sl@0
 | 
   280  | 
  | 
| 
sl@0
 | 
   281  | 
@param aTextComparisonType An enumeration which defines the type of comparison 
  | 
| 
sl@0
 | 
   282  | 
to be made between descriptors. By default the comparison type is ECmpFolded. */
  | 
| 
sl@0
 | 
   283  | 
	{
 | 
| 
sl@0
 | 
   284  | 
	TKeyDesC8Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   285  | 
	CArrayFixBase::Sort(key);
  | 
| 
sl@0
 | 
   286  | 
	}
  | 
| 
sl@0
 | 
   287  | 
  | 
| 
sl@0
 | 
   288  | 
EXPORT_C TInt CDesC8Array::Find(const TDesC8& aPtr,TInt& aPos,TKeyCmpText aTextComparisonType) const
  | 
| 
sl@0
 | 
   289  | 
/** Finds the position of a descriptor element within the array which matches the 
  | 
| 
sl@0
 | 
   290  | 
specified descriptor using a sequential search.
  | 
| 
sl@0
 | 
   291  | 
  | 
| 
sl@0
 | 
   292  | 
The array is searched sequentially for a matching descriptor element, starting 
  | 
| 
sl@0
 | 
   293  | 
with the first descriptor element in the array. Descriptors are compared using 
  | 
| 
sl@0
 | 
   294  | 
one of the TDesC comparison functions. The enumeration aTextComparisonType 
  | 
| 
sl@0
 | 
   295  | 
governs how the descriptors are to be compared.
  | 
| 
sl@0
 | 
   296  | 
  | 
| 
sl@0
 | 
   297  | 
Where an array has duplicate descriptor elements, the function only supplies 
  | 
| 
sl@0
 | 
   298  | 
the position of the first descriptor element.
  | 
| 
sl@0
 | 
   299  | 
  | 
| 
sl@0
 | 
   300  | 
@param aPtr A reference to a descriptor to be used for comparison. 
  | 
| 
sl@0
 | 
   301  | 
@param aPos If the descriptor element is found, this reference is set to the 
  | 
| 
sl@0
 | 
   302  | 
position of that descriptor element within the array. The position is relative 
  | 
| 
sl@0
 | 
   303  | 
to zero, (i.e. the first descriptor element in the array is at position 0). 
  | 
| 
sl@0
 | 
   304  | 
If the descriptor element is not found and the array is not empty, then the 
  | 
| 
sl@0
 | 
   305  | 
value of the reference is set to the number of descriptor elements in the 
  | 
| 
sl@0
 | 
   306  | 
array. If the descriptor element is not found and the array is empty, then 
  | 
| 
sl@0
 | 
   307  | 
the reference is set to zero. 
  | 
| 
sl@0
 | 
   308  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   309  | 
to be made between descriptors. If no parameter is explicitly passed, ECmpFolded 
  | 
| 
sl@0
 | 
   310  | 
is used by default. 
  | 
| 
sl@0
 | 
   311  | 
@return Zero, if a matching descriptor element is found. Non-zero, if no matching 
  | 
| 
sl@0
 | 
   312  | 
descriptor element can be found. */
  | 
| 
sl@0
 | 
   313  | 
	{
 | 
| 
sl@0
 | 
   314  | 
	TKeyDesC8Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   315  | 
	const TDesC8* tmp=(&aPtr);
  | 
| 
sl@0
 | 
   316  | 
	return(CArrayFixBase::Find(&tmp,key,aPos));
  | 
| 
sl@0
 | 
   317  | 
	}
  | 
| 
sl@0
 | 
   318  | 
  | 
| 
sl@0
 | 
   319  | 
EXPORT_C TInt CDesC8Array::FindIsq(const TDesC8& aPtr,TInt& aPos,TKeyCmpText aTextComparisonType) const
  | 
| 
sl@0
 | 
   320  | 
/** Finds the position of a descriptor element within the array which matches 
  | 
| 
sl@0
 | 
   321  | 
the specified descriptor using a binary search technique. The array must 
  | 
| 
sl@0
 | 
   322  | 
be in sequence, otherwise the outcome is unpredictable.
  | 
| 
sl@0
 | 
   323  | 
  | 
| 
sl@0
 | 
   324  | 
Descriptors are compared using one of the TDesC comparison functions. The 
  | 
| 
sl@0
 | 
   325  | 
enumeration aTextComparisonType governs how the descriptors are to be compared.
  | 
| 
sl@0
 | 
   326  | 
  | 
| 
sl@0
 | 
   327  | 
Where an array has duplicate descriptor elements, the function cannot guarantee 
  | 
| 
sl@0
 | 
   328  | 
which matching descriptor element it will return; except that it will find 
  | 
| 
sl@0
 | 
   329  | 
one of them.
  | 
| 
sl@0
 | 
   330  | 
  | 
| 
sl@0
 | 
   331  | 
@param aPtr A reference to a descriptor to be used for comparison. 
  | 
| 
sl@0
 | 
   332  | 
@param aPos If the descriptor element is found, the reference is set to the 
  | 
| 
sl@0
 | 
   333  | 
position of that descriptor element within the array. The position is relative 
  | 
| 
sl@0
 | 
   334  | 
to zero, (i.e. the first descriptor element in the array is at position 0). 
  | 
| 
sl@0
 | 
   335  | 
If the descriptor element is not found and the array is not empty, then the 
  | 
| 
sl@0
 | 
   336  | 
reference is set to the position of the first descriptor element in the array 
  | 
| 
sl@0
 | 
   337  | 
whose content is greater than the content of aPtr. If the descriptor element 
  | 
| 
sl@0
 | 
   338  | 
is not found and the array is empty, then the reference is set to zero.
  | 
| 
sl@0
 | 
   339  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   340  | 
to be made between descriptors. If no parameter is explicitly passed, ECmpFolded 
  | 
| 
sl@0
 | 
   341  | 
is used by default. 
  | 
| 
sl@0
 | 
   342  | 
@return Zero, if a matching descriptor element is found. Non-zero, if no matching 
  | 
| 
sl@0
 | 
   343  | 
descriptor element can be found. */
  | 
| 
sl@0
 | 
   344  | 
	{
 | 
| 
sl@0
 | 
   345  | 
	TKeyDesC8Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   346  | 
	const TDesC8* tmp=(&aPtr);
  | 
| 
sl@0
 | 
   347  | 
	return(CArrayFixBase::FindIsq(&tmp,key,aPos));
  | 
| 
sl@0
 | 
   348  | 
	}
  | 
| 
sl@0
 | 
   349  | 
  | 
| 
sl@0
 | 
   350  | 
  | 
| 
sl@0
 | 
   351  | 
/**
  | 
| 
sl@0
 | 
   352  | 
 *
  | 
| 
sl@0
 | 
   353  | 
 * Constructs a flat descriptor array with the specified granularity.
  | 
| 
sl@0
 | 
   354  | 
 *
  | 
| 
sl@0
 | 
   355  | 
 * No memory is allocated to the array buffer by this constructor.
  | 
| 
sl@0
 | 
   356  | 
 *
  | 
| 
sl@0
 | 
   357  | 
 * @param     "TInt aGranularity"
  | 
| 
sl@0
 | 
   358  | 
 *            The granularity of the array. This value must be
  | 
| 
sl@0
 | 
   359  | 
 *            positive otherwise the constructor raises an
  | 
| 
sl@0
 | 
   360  | 
 *            E32USER-CBase 18 panic.
  | 
| 
sl@0
 | 
   361  | 
 */
  | 
| 
sl@0
 | 
   362  | 
EXPORT_C CDesC8ArrayFlat::CDesC8ArrayFlat(TInt aGranularity)
  | 
| 
sl@0
 | 
   363  | 
    : CDesC8Array((TBufRep)CBufFlat::NewL,aGranularity)
  | 
| 
sl@0
 | 
   364  | 
    {
 | 
| 
sl@0
 | 
   365  | 
	__DECLARE_NAME(_S("CDesC8ArrayFlat"));
 | 
| 
sl@0
 | 
   366  | 
	}
  | 
| 
sl@0
 | 
   367  | 
  | 
| 
sl@0
 | 
   368  | 
EXPORT_C CDesC8ArrayFlat::~CDesC8ArrayFlat()
  | 
| 
sl@0
 | 
   369  | 
/** Frees all resources owned by the object, prior to its destruction. */
  | 
| 
sl@0
 | 
   370  | 
    {}
 | 
| 
sl@0
 | 
   371  | 
  | 
| 
sl@0
 | 
   372  | 
EXPORT_C CDesC8ArraySeg::CDesC8ArraySeg(TInt aGranularity)
  | 
| 
sl@0
 | 
   373  | 
    : CDesC8Array((TBufRep)CBufSeg::NewL,aGranularity)
  | 
| 
sl@0
 | 
   374  | 
/** Constructs a segmented descriptor array with the specified granularity.
  | 
| 
sl@0
 | 
   375  | 
  | 
| 
sl@0
 | 
   376  | 
No memory is allocated to the array buffer by this constructor.
  | 
| 
sl@0
 | 
   377  | 
  | 
| 
sl@0
 | 
   378  | 
@param aGranularity The granularity of the array. This value must be positive 
  | 
| 
sl@0
 | 
   379  | 
otherwise the constructor raises an E32USER-CBase 18 panic. */
  | 
| 
sl@0
 | 
   380  | 
    {
 | 
| 
sl@0
 | 
   381  | 
	__DECLARE_NAME(_S("CDesC8ArraySeg"));
 | 
| 
sl@0
 | 
   382  | 
    }
  | 
| 
sl@0
 | 
   383  | 
  | 
| 
sl@0
 | 
   384  | 
EXPORT_C CDesC8ArraySeg::~CDesC8ArraySeg()
  | 
| 
sl@0
 | 
   385  | 
/** Frees all resources owned by the object, prior to its destruction. */
  | 
| 
sl@0
 | 
   386  | 
    {}
 | 
| 
sl@0
 | 
   387  | 
  | 
| 
sl@0
 | 
   388  | 
  | 
| 
sl@0
 | 
   389  | 
// 16-bit equivalents to the above.
  | 
| 
sl@0
 | 
   390  | 
  | 
| 
sl@0
 | 
   391  | 
  | 
| 
sl@0
 | 
   392  | 
EXPORT_C CDesC16Array::CDesC16Array(TBufRep aRep,TInt aGranularity)
  | 
| 
sl@0
 | 
   393  | 
    : CArrayFixBase(aRep,sizeof(HBufC16*),aGranularity)
  | 
| 
sl@0
 | 
   394  | 
    {
 | 
| 
sl@0
 | 
   395  | 
    }
  | 
| 
sl@0
 | 
   396  | 
  | 
| 
sl@0
 | 
   397  | 
EXPORT_C CDesC16Array::~CDesC16Array()
  | 
| 
sl@0
 | 
   398  | 
/** Frees all resources owned by the object, prior to its destruction. In particular, 
  | 
| 
sl@0
 | 
   399  | 
it deletes all descriptors from the array and frees the memory allocated to 
  | 
| 
sl@0
 | 
   400  | 
the array buffer. */
  | 
| 
sl@0
 | 
   401  | 
    {
 | 
| 
sl@0
 | 
   402  | 
	Reset();
  | 
| 
sl@0
 | 
   403  | 
    }
  | 
| 
sl@0
 | 
   404  | 
  | 
| 
sl@0
 | 
   405  | 
EXPORT_C void CDesC16Array::Reset()
  | 
| 
sl@0
 | 
   406  | 
/** Deletes all descriptors from the array and frees the memory allocated to the 
  | 
| 
sl@0
 | 
   407  | 
array buffer.
  | 
| 
sl@0
 | 
   408  | 
  | 
| 
sl@0
 | 
   409  | 
@see CDesC16Array::Delete() */
  | 
| 
sl@0
 | 
   410  | 
	{
 | 
| 
sl@0
 | 
   411  | 
	Delete(0,Count());
  | 
| 
sl@0
 | 
   412  | 
	}
  | 
| 
sl@0
 | 
   413  | 
  | 
| 
sl@0
 | 
   414  | 
EXPORT_C void CDesC16Array::Delete(TInt aIndex)
  | 
| 
sl@0
 | 
   415  | 
	{
 | 
| 
sl@0
 | 
   416  | 
	Delete(aIndex,1);
  | 
| 
sl@0
 | 
   417  | 
	}
  | 
| 
sl@0
 | 
   418  | 
  | 
| 
sl@0
 | 
   419  | 
/**
  | 
| 
sl@0
 | 
   420  | 
 *
  | 
| 
sl@0
 | 
   421  | 
 * Deletes one or more logically contiguous descriptor elements from the
  | 
| 
sl@0
 | 
   422  | 
 * array.
  | 
| 
sl@0
 | 
   423  | 
 *
  | 
| 
sl@0
 | 
   424  | 
 * The deletion starts at the specified position.Deleting descriptor
  | 
| 
sl@0
 | 
   425  | 
 * elements from the array frees the memory occupied by the associated
  | 
| 
sl@0
 | 
   426  | 
 * heap descriptors and removes their pointers from the array buffer but
  | 
| 
sl@0
 | 
   427  | 
 * does not cause the array buffer to be automatically compressed. Call
  | 
| 
sl@0
 | 
   428  | 
 * the Compress() function to return excess space in the array buffer to
  | 
| 
sl@0
 | 
   429  | 
 * the heap.
  | 
| 
sl@0
 | 
   430  | 
 *
  | 
| 
sl@0
 | 
   431  | 
 * @param     " TInt aPos "
  | 
| 
sl@0
 | 
   432  | 
 *            The starting position in the array from which
  | 
| 
sl@0
 | 
   433  | 
 *            descriptor elements are to be deleted. The position is
  | 
| 
sl@0
 | 
   434  | 
 *            relative to zero, i.e. zero implies the first
  | 
| 
sl@0
 | 
   435  | 
 *            descriptor element. This value must not be negative
  | 
| 
sl@0
 | 
   436  | 
 *            and must not be greater than the number of descriptor
  | 
| 
sl@0
 | 
   437  | 
 *            elements currently in the array, otherwise the
  | 
| 
sl@0
 | 
   438  | 
 *            functions raise an E32USER-CBase 21 panic.
  | 
| 
sl@0
 | 
   439  | 
 * @param     " TInt aCount "
  | 
| 
sl@0
 | 
   440  | 
 *            If specified, the number of contiguous descriptor
  | 
| 
sl@0
 | 
   441  | 
 *            elements to be deleted from the array. This value must
  | 
| 
sl@0
 | 
   442  | 
 *            not be negative otherwise the function raises an
  | 
| 
sl@0
 | 
   443  | 
 *            E32USER-CBase 22 panic. This value must not be
  | 
| 
sl@0
 | 
   444  | 
 *            negative otherwise the function raises an
  | 
| 
sl@0
 | 
   445  | 
 *            E32USER-CBase 22 panic. This value must not be
  | 
| 
sl@0
 | 
   446  | 
 *            negative otherwise the function raises an
  | 
| 
sl@0
 | 
   447  | 
 *            E32USER-CBase 22 panic. This value plus the value of
  | 
| 
sl@0
 | 
   448  | 
 *            the starting position must not be greater than the
  | 
| 
sl@0
 | 
   449  | 
 *            number of descriptor elements in the array, otherwise
  | 
| 
sl@0
 | 
   450  | 
 *            the function raises an E32USER-CBase 29 panic. If not
  | 
| 
sl@0
 | 
   451  | 
 *            specified, one element is assumed.
  | 
| 
sl@0
 | 
   452  | 
 */
  | 
| 
sl@0
 | 
   453  | 
EXPORT_C void CDesC16Array::Delete(TInt aIndex,TInt aCount)
  | 
| 
sl@0
 | 
   454  | 
	{
 | 
| 
sl@0
 | 
   455  | 
	TInt count=aCount;
  | 
| 
sl@0
 | 
   456  | 
	for (TInt ii=aIndex; count--; ii++)
  | 
| 
sl@0
 | 
   457  | 
		User::Free(*(HBufC16**)At(ii));
  | 
| 
sl@0
 | 
   458  | 
	CArrayFixBase::Delete(aIndex,aCount);
  | 
| 
sl@0
 | 
   459  | 
	}
  | 
| 
sl@0
 | 
   460  | 
  | 
| 
sl@0
 | 
   461  | 
EXPORT_C TInt CDesC16Array::MdcaCount() const
  | 
| 
sl@0
 | 
   462  | 
/** Returns the number of descriptor elements in the array. The function implements 
  | 
| 
sl@0
 | 
   463  | 
the function interface MDesC16Array::MdcaCount().
  | 
| 
sl@0
 | 
   464  | 
  | 
| 
sl@0
 | 
   465  | 
@return The number of descriptor elements. */
  | 
| 
sl@0
 | 
   466  | 
    {
 | 
| 
sl@0
 | 
   467  | 
    return Count();
  | 
| 
sl@0
 | 
   468  | 
    }
  | 
| 
sl@0
 | 
   469  | 
  | 
| 
sl@0
 | 
   470  | 
EXPORT_C TPtrC16 CDesC16Array::MdcaPoint(TInt anIndex) const
  | 
| 
sl@0
 | 
   471  | 
/** Indexes into a descriptor array. The function implements the interface MDesC16Array::MdcaPoint().
  | 
| 
sl@0
 | 
   472  | 
	
  | 
| 
sl@0
 | 
   473  | 
	@param aIndex The position of the descriptor element within the array. The 
  | 
| 
sl@0
 | 
   474  | 
	position is relative to zero; i.e. zero implies the first descriptor element 
  | 
| 
sl@0
 | 
   475  | 
	in the array. This value must be non-negative and less than the number of 
  | 
| 
sl@0
 | 
   476  | 
	descriptors currently within the array otherwise the operator panics with 
  | 
| 
sl@0
 | 
   477  | 
	EArrayIndexOutOfRange. 
  | 
| 
sl@0
 | 
   478  | 
	@return A non-modifiable pointer descriptor representing the descriptor element 
  | 
| 
sl@0
 | 
   479  | 
	located at position aIndex within the array. */	
  | 
| 
sl@0
 | 
   480  | 
	{
 | 
| 
sl@0
 | 
   481  | 
	HBufC16* temp=(*(HBufC16**)At(anIndex));
  | 
| 
sl@0
 | 
   482  | 
	return (TPtrC16)(*temp);
  | 
| 
sl@0
 | 
   483  | 
	}
  | 
| 
sl@0
 | 
   484  | 
  | 
| 
sl@0
 | 
   485  | 
EXPORT_C void CDesC16Array::AppendL(const TDesC16& aPtr)
  | 
| 
sl@0
 | 
   486  | 
/** Appends a descriptor onto the end of any existing descriptor elements in the 
  | 
| 
sl@0
 | 
   487  | 
array.
  | 
| 
sl@0
 | 
   488  | 
  | 
| 
sl@0
 | 
   489  | 
@param aPtr A reference to the descriptor to be appended to the array. */
  | 
| 
sl@0
 | 
   490  | 
	{
 | 
| 
sl@0
 | 
   491  | 
	InsertL(Count(),aPtr);
  | 
| 
sl@0
 | 
   492  | 
	}
  | 
| 
sl@0
 | 
   493  | 
  | 
| 
sl@0
 | 
   494  | 
EXPORT_C void CDesC16Array::InsertL(TInt aPos,const TDesC16& aPtr)
  | 
| 
sl@0
 | 
   495  | 
/** Inserts a descriptor into the array at the specified position. 
  | 
| 
sl@0
 | 
   496  | 
  | 
| 
sl@0
 | 
   497  | 
If the specified position is the same as the current number of descriptor 
  | 
| 
sl@0
 | 
   498  | 
elements in the array, this has the effect of appending the element.
  | 
| 
sl@0
 | 
   499  | 
  | 
| 
sl@0
 | 
   500  | 
@param aPos The position within the array where the descriptor element is 
  | 
| 
sl@0
 | 
   501  | 
to be inserted. The position is relative to zero, i.e. zero implies the first 
  | 
| 
sl@0
 | 
   502  | 
descriptor element. This value must not be negative and must not be greater 
  | 
| 
sl@0
 | 
   503  | 
than the number of descriptor elements currently in the array, otherwise the 
  | 
| 
sl@0
 | 
   504  | 
function raises an E32USER-CBase 21 panic. 
  | 
| 
sl@0
 | 
   505  | 
@param aPtr The descriptor to be inserted into the array. */
  | 
| 
sl@0
 | 
   506  | 
	{
 | 
| 
sl@0
 | 
   507  | 
	HBufC16* bufPtr=aPtr.AllocLC();
  | 
| 
sl@0
 | 
   508  | 
   	CArrayFixBase::InsertL(aPos,&bufPtr);
  | 
| 
sl@0
 | 
   509  | 
	CleanupStack::Pop();
  | 
| 
sl@0
 | 
   510  | 
	}
  | 
| 
sl@0
 | 
   511  | 
  | 
| 
sl@0
 | 
   512  | 
EXPORT_C TInt CDesC16Array::InsertIsqL(const TDesC16& aPtr,TKeyCmpText aTextComparisonType)
  | 
| 
sl@0
 | 
   513  | 
/** Inserts a descriptor into the array at a position which maintains the sequence 
  | 
| 
sl@0
 | 
   514  | 
of the descriptors.
  | 
| 
sl@0
 | 
   515  | 
  | 
| 
sl@0
 | 
   516  | 
The sequence is determined by comparing descriptors using one of the TDesC 
  | 
| 
sl@0
 | 
   517  | 
comparison functions. The enumeration aTextComparisonType governs how the 
  | 
| 
sl@0
 | 
   518  | 
descriptors are to be compared.
  | 
| 
sl@0
 | 
   519  | 
  | 
| 
sl@0
 | 
   520  | 
The array should already be in sequence, otherwise the position of the new 
  | 
| 
sl@0
 | 
   521  | 
descriptor element is unpredictable. Descriptor elements which are the same 
  | 
| 
sl@0
 | 
   522  | 
are not permitted.
  | 
| 
sl@0
 | 
   523  | 
  | 
| 
sl@0
 | 
   524  | 
@param aPtr A reference to the descriptor to be inserted into the array. 
  | 
| 
sl@0
 | 
   525  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   526  | 
to be made between descriptors for the purpose of choosing the insertion position. 
  | 
| 
sl@0
 | 
   527  | 
If no parameter is explicitly passed, ECmpFolded is used by default.
  | 
| 
sl@0
 | 
   528  | 
@return The position within the array of the inserted descriptor. */
  | 
| 
sl@0
 | 
   529  | 
	{
 | 
| 
sl@0
 | 
   530  | 
	HBufC16* bufPtr=aPtr.AllocLC();
  | 
| 
sl@0
 | 
   531  | 
	TKeyDesC16Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   532  | 
   	TInt found=CArrayFixBase::InsertIsqL(&bufPtr,key);
  | 
| 
sl@0
 | 
   533  | 
	CleanupStack::Pop();
  | 
| 
sl@0
 | 
   534  | 
	return(found);
  | 
| 
sl@0
 | 
   535  | 
	}
  | 
| 
sl@0
 | 
   536  | 
  | 
| 
sl@0
 | 
   537  | 
EXPORT_C TInt CDesC16Array::InsertIsqAllowDuplicatesL(const TDesC16& aPtr,TKeyCmpText aTextComparisonType)
  | 
| 
sl@0
 | 
   538  | 
/** Inserts a descriptor into the array at a position which maintains the sequence 
  | 
| 
sl@0
 | 
   539  | 
of the descriptors; allows duplicates.
  | 
| 
sl@0
 | 
   540  | 
  | 
| 
sl@0
 | 
   541  | 
The sequence is determined by comparing descriptors using one of the TDesC 
  | 
| 
sl@0
 | 
   542  | 
comparison functions. The enumeration aTextComparisonType governs how the 
  | 
| 
sl@0
 | 
   543  | 
descriptors are to be compared.
  | 
| 
sl@0
 | 
   544  | 
  | 
| 
sl@0
 | 
   545  | 
The array should already be in sequence, otherwise the position of the new 
  | 
| 
sl@0
 | 
   546  | 
descriptor element is unpredictable. Descriptor elements which are the same 
  | 
| 
sl@0
 | 
   547  | 
are permitted; if the descriptor aPtr is a duplicate of an existing descriptor 
  | 
| 
sl@0
 | 
   548  | 
within the array, then the new descriptor element is positioned after the 
  | 
| 
sl@0
 | 
   549  | 
existing descriptor element.
  | 
| 
sl@0
 | 
   550  | 
  | 
| 
sl@0
 | 
   551  | 
@param aPtr A reference to the descriptor to be inserted into the array. 
  | 
| 
sl@0
 | 
   552  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   553  | 
to be made between descriptors for the purpose of choosing the insertion position. 
  | 
| 
sl@0
 | 
   554  | 
If no parameter is explicitly passed, ECmpFolded is used by default.
  | 
| 
sl@0
 | 
   555  | 
@return The position within the array of the inserted descriptor. */
  | 
| 
sl@0
 | 
   556  | 
	{
 | 
| 
sl@0
 | 
   557  | 
	HBufC16* bufPtr=aPtr.AllocLC();
  | 
| 
sl@0
 | 
   558  | 
	TKeyDesC16Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   559  | 
   	TInt found=CArrayFixBase::InsertIsqAllowDuplicatesL(&bufPtr,key);
  | 
| 
sl@0
 | 
   560  | 
	CleanupStack::Pop();
  | 
| 
sl@0
 | 
   561  | 
	return(found);
  | 
| 
sl@0
 | 
   562  | 
	}
  | 
| 
sl@0
 | 
   563  | 
  | 
| 
sl@0
 | 
   564  | 
EXPORT_C void CDesC16Array::Sort(TKeyCmpText aTextComparisonType)
  | 
| 
sl@0
 | 
   565  | 
/** Sorts the descriptor elements into sequence.
  | 
| 
sl@0
 | 
   566  | 
  | 
| 
sl@0
 | 
   567  | 
The sequence is determined by comparing descriptors using one of the member 
  | 
| 
sl@0
 | 
   568  | 
functions of the descriptor base class TDesC.
  | 
| 
sl@0
 | 
   569  | 
  | 
| 
sl@0
 | 
   570  | 
@param aTextComparisonType An enumeration which defines the type of comparison 
  | 
| 
sl@0
 | 
   571  | 
to be made between descriptors. By default the comparison type is ECmpFolded. */
  | 
| 
sl@0
 | 
   572  | 
	{
 | 
| 
sl@0
 | 
   573  | 
	TKeyDesC16Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   574  | 
	CArrayFixBase::Sort(key);
  | 
| 
sl@0
 | 
   575  | 
	}
  | 
| 
sl@0
 | 
   576  | 
  | 
| 
sl@0
 | 
   577  | 
EXPORT_C TInt CDesC16Array::Find(const TDesC16& aPtr,TInt& aPos,TKeyCmpText aTextComparisonType) const
  | 
| 
sl@0
 | 
   578  | 
/** Finds the position of a descriptor element within the array which matches the 
  | 
| 
sl@0
 | 
   579  | 
specified descriptor, using a sequential search.
  | 
| 
sl@0
 | 
   580  | 
  | 
| 
sl@0
 | 
   581  | 
The array is searched sequentially for a matching descriptor element, starting 
  | 
| 
sl@0
 | 
   582  | 
with the first descriptor element in the array. Descriptors are compared using 
  | 
| 
sl@0
 | 
   583  | 
one of the TDesC comparison functions. The enumeration aTextComparisonType 
  | 
| 
sl@0
 | 
   584  | 
governs how the descriptors are to be compared.
  | 
| 
sl@0
 | 
   585  | 
  | 
| 
sl@0
 | 
   586  | 
Where an array has duplicate descriptor elements, the function only supplies 
  | 
| 
sl@0
 | 
   587  | 
the position of the first descriptor element.
  | 
| 
sl@0
 | 
   588  | 
  | 
| 
sl@0
 | 
   589  | 
@param aPtr A reference to a descriptor to be used for comparison. 
  | 
| 
sl@0
 | 
   590  | 
@param aPos If the descriptor element is found, this reference is set to the 
  | 
| 
sl@0
 | 
   591  | 
position of that descriptor element within the array. The position is relative 
  | 
| 
sl@0
 | 
   592  | 
to zero, (i.e. the first descriptor element in the array is at position 0). 
  | 
| 
sl@0
 | 
   593  | 
If the descriptor element is not found and the array is not empty, then the 
  | 
| 
sl@0
 | 
   594  | 
value of the reference is set to the number of descriptor elements in the 
  | 
| 
sl@0
 | 
   595  | 
array. If the descriptor element is not found and the array is empty, then 
  | 
| 
sl@0
 | 
   596  | 
the reference is set to zero. 
  | 
| 
sl@0
 | 
   597  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   598  | 
to be made between descriptors. If no parameter is explicitly passed,ECmpFolded 
  | 
| 
sl@0
 | 
   599  | 
is used by default. 
  | 
| 
sl@0
 | 
   600  | 
@return Zero, if a matching descriptor element is found. Non-zero, if no matching 
  | 
| 
sl@0
 | 
   601  | 
descriptor element can be found. */
  | 
| 
sl@0
 | 
   602  | 
	{
 | 
| 
sl@0
 | 
   603  | 
	TKeyDesC16Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   604  | 
	const TDesC16* tmp=(&aPtr);
  | 
| 
sl@0
 | 
   605  | 
	return(CArrayFixBase::Find(&tmp,key,aPos));
  | 
| 
sl@0
 | 
   606  | 
	}
  | 
| 
sl@0
 | 
   607  | 
  | 
| 
sl@0
 | 
   608  | 
EXPORT_C TInt CDesC16Array::FindIsq(const TDesC16& aPtr,TInt& aPos,TKeyCmpText aTextComparisonType) const
  | 
| 
sl@0
 | 
   609  | 
/** Finds the position of a descriptor element within the array which matches the 
  | 
| 
sl@0
 | 
   610  | 
specified descriptor, using a binary search technique. The array must 
  | 
| 
sl@0
 | 
   611  | 
be in sequence, otherwise the outcome is unpredictable.
  | 
| 
sl@0
 | 
   612  | 
  | 
| 
sl@0
 | 
   613  | 
Descriptors are compared using one of the TDesC comparison functions. The 
  | 
| 
sl@0
 | 
   614  | 
enumeration aTextComparisonType governs how the descriptors are to be compared.
  | 
| 
sl@0
 | 
   615  | 
  | 
| 
sl@0
 | 
   616  | 
Where an array has duplicate descriptor elements, the function cannot guarantee 
  | 
| 
sl@0
 | 
   617  | 
which matching descriptor element it will return; except that it will find 
  | 
| 
sl@0
 | 
   618  | 
one of them.
  | 
| 
sl@0
 | 
   619  | 
  | 
| 
sl@0
 | 
   620  | 
@param aPtr A reference to a descriptor to be used for comparison. 
  | 
| 
sl@0
 | 
   621  | 
@param aPos If the descriptor element is found, the reference is set to the 
  | 
| 
sl@0
 | 
   622  | 
position of that descriptor element within the array. The position is relative 
  | 
| 
sl@0
 | 
   623  | 
to zero, (i.e. the first descriptor element in the array is at position 0). 
  | 
| 
sl@0
 | 
   624  | 
If the descriptor element is not found and the array is not empty, then the 
  | 
| 
sl@0
 | 
   625  | 
reference is set to the position of the first descriptor element in the array 
  | 
| 
sl@0
 | 
   626  | 
whose content is greater than the content of aPtr. If the descriptor element 
  | 
| 
sl@0
 | 
   627  | 
is not found and the array is empty, then the reference is set to zero.
  | 
| 
sl@0
 | 
   628  | 
@param aTextComparisonType An enumeration which determines the type of comparison 
  | 
| 
sl@0
 | 
   629  | 
to be made between descriptors. If no parameter is explicitly passed, ECmpFolded 
  | 
| 
sl@0
 | 
   630  | 
is used by default. 
  | 
| 
sl@0
 | 
   631  | 
@return Zero, if a matching descriptor element is found. Non-zero, if no matching 
  | 
| 
sl@0
 | 
   632  | 
descriptor element can be found. */
  | 
| 
sl@0
 | 
   633  | 
	{
 | 
| 
sl@0
 | 
   634  | 
	TKeyDesC16Array key(aTextComparisonType);
  | 
| 
sl@0
 | 
   635  | 
	const TDesC16* tmp=(&aPtr);
  | 
| 
sl@0
 | 
   636  | 
	return(CArrayFixBase::FindIsq(&tmp,key,aPos));
  | 
| 
sl@0
 | 
   637  | 
	}
  | 
| 
sl@0
 | 
   638  | 
  | 
| 
sl@0
 | 
   639  | 
/**
  | 
| 
sl@0
 | 
   640  | 
 *
  | 
| 
sl@0
 | 
   641  | 
 * Constructs a flat descriptor array with the specified granularity.
  | 
| 
sl@0
 | 
   642  | 
 *
  | 
| 
sl@0
 | 
   643  | 
 * No memory is allocated to the array buffer by this constructor.
  | 
| 
sl@0
 | 
   644  | 
 *
  | 
| 
sl@0
 | 
   645  | 
 * @param     "TInt aGranularity"
  | 
| 
sl@0
 | 
   646  | 
 *            The granularity of the array. This value must be
  | 
| 
sl@0
 | 
   647  | 
 *            positive otherwise the constructor raises an
  | 
| 
sl@0
 | 
   648  | 
 *            E32USER-CBase 18 panic.
  | 
| 
sl@0
 | 
   649  | 
 */
  | 
| 
sl@0
 | 
   650  | 
EXPORT_C CDesC16ArrayFlat::CDesC16ArrayFlat(TInt aGranularity)
  | 
| 
sl@0
 | 
   651  | 
    : CDesC16Array((TBufRep)CBufFlat::NewL,aGranularity)
  | 
| 
sl@0
 | 
   652  | 
    {
 | 
| 
sl@0
 | 
   653  | 
	__DECLARE_NAME(_S("CDesC16ArrayFlat"));
 | 
| 
sl@0
 | 
   654  | 
    }
  | 
| 
sl@0
 | 
   655  | 
  | 
| 
sl@0
 | 
   656  | 
EXPORT_C CDesC16ArrayFlat::~CDesC16ArrayFlat()
  | 
| 
sl@0
 | 
   657  | 
/** Frees all resources owned by the object, prior to its destruction. */
  | 
| 
sl@0
 | 
   658  | 
    {}
 | 
| 
sl@0
 | 
   659  | 
  | 
| 
sl@0
 | 
   660  | 
EXPORT_C CDesC16ArraySeg::CDesC16ArraySeg(TInt aGranularity)
  | 
| 
sl@0
 | 
   661  | 
    : CDesC16Array((TBufRep)CBufSeg::NewL,aGranularity)
  | 
| 
sl@0
 | 
   662  | 
/** Construct a segmented descriptor array with the specified granularity.
  | 
| 
sl@0
 | 
   663  | 
  | 
| 
sl@0
 | 
   664  | 
No memory is allocated to the array buffer by this C++ constructor.
  | 
| 
sl@0
 | 
   665  | 
  | 
| 
sl@0
 | 
   666  | 
@param aGranularity The granularity of the array. This value must be positive 
  | 
| 
sl@0
 | 
   667  | 
otherwise the constructor raises an E32USER-CBase 18 panic. */
  | 
| 
sl@0
 | 
   668  | 
    {
 | 
| 
sl@0
 | 
   669  | 
	__DECLARE_NAME(_S("CDesC16ArraySeg"));
 | 
| 
sl@0
 | 
   670  | 
    }
  | 
| 
sl@0
 | 
   671  | 
  | 
| 
sl@0
 | 
   672  | 
EXPORT_C CDesC16ArraySeg::~CDesC16ArraySeg()
  | 
| 
sl@0
 | 
   673  | 
/** Frees all resources owned by the object, prior to its destruction. */
  | 
| 
sl@0
 | 
   674  | 
    {}
 | 
| 
sl@0
 | 
   675  | 
  | 
| 
sl@0
 | 
   676  | 
//
  | 
| 
sl@0
 | 
   677  | 
//	class CPtrC8Array
  | 
| 
sl@0
 | 
   678  | 
//
  | 
| 
sl@0
 | 
   679  | 
  | 
| 
sl@0
 | 
   680  | 
EXPORT_C CPtrC8Array::CPtrC8Array(TInt aGranularity)
  | 
| 
sl@0
 | 
   681  | 
	: CArrayFixFlat<TPtrC8>(aGranularity)
  | 
| 
sl@0
 | 
   682  | 
/** Constructs an array of 8 bit non-modifiable descriptors with the specified 
  | 
| 
sl@0
 | 
   683  | 
granularity. The length of all elements in the array buffer is the length 
  | 
| 
sl@0
 | 
   684  | 
of a TPtrC8 object.
  | 
| 
sl@0
 | 
   685  | 
  | 
| 
sl@0
 | 
   686  | 
No memory is allocated to the array buffer by this constructor.
  | 
| 
sl@0
 | 
   687  | 
  | 
| 
sl@0
 | 
   688  | 
@param aGranularity The granularity of the array. This value must be positive 
  | 
| 
sl@0
 | 
   689  | 
otherwise the constructor raises an E32USER-CBase 18 panic. */
  | 
| 
sl@0
 | 
   690  | 
	{
 | 
| 
sl@0
 | 
   691  | 
	__DECLARE_NAME(_S("CPtrC8Array"));
 | 
| 
sl@0
 | 
   692  | 
	}
  | 
| 
sl@0
 | 
   693  | 
  | 
| 
sl@0
 | 
   694  | 
EXPORT_C CPtrC8Array::~CPtrC8Array()
  | 
| 
sl@0
 | 
   695  | 
/** Frees all resources owned by the object, prior to its destruction. */
  | 
| 
sl@0
 | 
   696  | 
	{}
 | 
| 
sl@0
 | 
   697  | 
  | 
| 
sl@0
 | 
   698  | 
EXPORT_C TInt CPtrC8Array::MdcaCount() const
  | 
| 
sl@0
 | 
   699  | 
/** Returns the number of elements in the array. The function implements the pure 
  | 
| 
sl@0
 | 
   700  | 
virtual function MDesC8Array::MdcaCount().
  | 
| 
sl@0
 | 
   701  | 
  | 
| 
sl@0
 | 
   702  | 
@return The number of elements. */
  | 
| 
sl@0
 | 
   703  | 
	{
 | 
| 
sl@0
 | 
   704  | 
	return(Count());
  | 
| 
sl@0
 | 
   705  | 
	}
  | 
| 
sl@0
 | 
   706  | 
  | 
| 
sl@0
 | 
   707  | 
EXPORT_C TPtrC8 CPtrC8Array::MdcaPoint(TInt aIndex) const
  | 
| 
sl@0
 | 
   708  | 
/** Indexes into the descriptor array. The function implements the pure virtual 
  | 
| 
sl@0
 | 
   709  | 
function MDesC8Array::MdcaPoint().
  | 
| 
sl@0
 | 
   710  | 
  | 
| 
sl@0
 | 
   711  | 
@param aIndex The position of the descriptor element within the array. The 
  | 
| 
sl@0
 | 
   712  | 
position is relative to zero; i.e. zero implies the first descriptor element 
  | 
| 
sl@0
 | 
   713  | 
in the array. This value must be non-negative and must be less than the number 
  | 
| 
sl@0
 | 
   714  | 
of elements currently in the array otherwise the operator raises a E32USER-CBase 
  | 
| 
sl@0
 | 
   715  | 
21 panic.
  | 
| 
sl@0
 | 
   716  | 
@return A non-modifiable pointer descriptor for the data represented by the 
  | 
| 
sl@0
 | 
   717  | 
element at position aIndex within the array. */
  | 
| 
sl@0
 | 
   718  | 
	{
 | 
| 
sl@0
 | 
   719  | 
	return(At(aIndex));
  | 
| 
sl@0
 | 
   720  | 
	}
  | 
| 
sl@0
 | 
   721  | 
  | 
| 
sl@0
 | 
   722  | 
EXPORT_C void CPtrC8Array::CopyL(const MDesC8Array& aArray)
  | 
| 
sl@0
 | 
   723  | 
/** Copies a descriptor array into this array, deleting any pre-existing elements.
  | 
| 
sl@0
 | 
   724  | 
  | 
| 
sl@0
 | 
   725  | 
The function constructs TPtrC8 elements for each descriptor element in the 
  | 
| 
sl@0
 | 
   726  | 
specified descriptor array.
  | 
| 
sl@0
 | 
   727  | 
  | 
| 
sl@0
 | 
   728  | 
@param aArray A reference to any descriptor array which satisfies the protocol 
  | 
| 
sl@0
 | 
   729  | 
defined by this mixin class. */
  | 
| 
sl@0
 | 
   730  | 
	{
 | 
| 
sl@0
 | 
   731  | 
	Reset();
  | 
| 
sl@0
 | 
   732  | 
	TInt count=aArray.MdcaCount();
  | 
| 
sl@0
 | 
   733  | 
	for (TInt i=0;i<count;++i)
  | 
| 
sl@0
 | 
   734  | 
		AppendL(aArray.MdcaPoint(i));
  | 
| 
sl@0
 | 
   735  | 
	}
  | 
| 
sl@0
 | 
   736  | 
  | 
| 
sl@0
 | 
   737  | 
//
  | 
| 
sl@0
 | 
   738  | 
//	class CPtrC16Array
  | 
| 
sl@0
 | 
   739  | 
//
  | 
| 
sl@0
 | 
   740  | 
  | 
| 
sl@0
 | 
   741  | 
EXPORT_C CPtrC16Array::CPtrC16Array(TInt aGranularity)
  | 
| 
sl@0
 | 
   742  | 
	: CArrayFixFlat<TPtrC16>(aGranularity)
  | 
| 
sl@0
 | 
   743  | 
/** Constructs an array of 16 bit non-modifiable descriptors with the specified 
  | 
| 
sl@0
 | 
   744  | 
granularity. The length of all elements in the array buffer is the length 
  | 
| 
sl@0
 | 
   745  | 
of a TPtrC16 object.
  | 
| 
sl@0
 | 
   746  | 
  | 
| 
sl@0
 | 
   747  | 
No memory is allocated to the array buffer by constructor.
  | 
| 
sl@0
 | 
   748  | 
  | 
| 
sl@0
 | 
   749  | 
@param aGranularity The granularity of the array. This value must be positive 
  | 
| 
sl@0
 | 
   750  | 
otherwise the constructor raises an E32USER-CBase 18 panic. */
  | 
| 
sl@0
 | 
   751  | 
	{
 | 
| 
sl@0
 | 
   752  | 
	__DECLARE_NAME(_S("CPtrC16Array"));
 | 
| 
sl@0
 | 
   753  | 
	}
  | 
| 
sl@0
 | 
   754  | 
  | 
| 
sl@0
 | 
   755  | 
EXPORT_C CPtrC16Array::~CPtrC16Array()
  | 
| 
sl@0
 | 
   756  | 
/** Frees all resources owned by the object, prior to its destruction. */
  | 
| 
sl@0
 | 
   757  | 
	{}
 | 
| 
sl@0
 | 
   758  | 
  | 
| 
sl@0
 | 
   759  | 
EXPORT_C TInt CPtrC16Array::MdcaCount() const
  | 
| 
sl@0
 | 
   760  | 
/** Returns the number of elements in the array. The function implements the pure 
  | 
| 
sl@0
 | 
   761  | 
virtual function MDesC16Array::MdcaCount().
  | 
| 
sl@0
 | 
   762  | 
  | 
| 
sl@0
 | 
   763  | 
@return The number of elements. */
  | 
| 
sl@0
 | 
   764  | 
	{
 | 
| 
sl@0
 | 
   765  | 
	return(Count());
  | 
| 
sl@0
 | 
   766  | 
	}
  | 
| 
sl@0
 | 
   767  | 
  | 
| 
sl@0
 | 
   768  | 
EXPORT_C TPtrC16 CPtrC16Array::MdcaPoint(TInt aIndex) const
  | 
| 
sl@0
 | 
   769  | 
/** Indexes into the descriptor array. The function implements the pure virtual 
  | 
| 
sl@0
 | 
   770  | 
function MDesC16Array::MdcaPoint().
  | 
| 
sl@0
 | 
   771  | 
  | 
| 
sl@0
 | 
   772  | 
@param aIndex The position of the descriptor element within the array. The 
  | 
| 
sl@0
 | 
   773  | 
position is relative to zero; i.e. zero implies the first descriptor element 
  | 
| 
sl@0
 | 
   774  | 
in the array. This value must be non-negative and must be less than the number 
  | 
| 
sl@0
 | 
   775  | 
of elements currently in the array otherwise the operator raises a E32USER-CBase 
  | 
| 
sl@0
 | 
   776  | 
21 panic.
  | 
| 
sl@0
 | 
   777  | 
@return A non-modifiable pointer descriptor for the data represented by the 
  | 
| 
sl@0
 | 
   778  | 
element at position aIndex within the array. */
  | 
| 
sl@0
 | 
   779  | 
	{
 | 
| 
sl@0
 | 
   780  | 
	return(At(aIndex));
  | 
| 
sl@0
 | 
   781  | 
	}
  | 
| 
sl@0
 | 
   782  | 
  | 
| 
sl@0
 | 
   783  | 
EXPORT_C void CPtrC16Array::CopyL(const MDesC16Array& aArray)
  | 
| 
sl@0
 | 
   784  | 
/** Copies a descriptor array into this array, deleting any pre-existing elements.
  | 
| 
sl@0
 | 
   785  | 
  | 
| 
sl@0
 | 
   786  | 
The function constructs TPtrC16 elements for each descriptor element in the 
  | 
| 
sl@0
 | 
   787  | 
specified descriptor array.
  | 
| 
sl@0
 | 
   788  | 
  | 
| 
sl@0
 | 
   789  | 
@param aArray A reference to any descriptor array which satisfies the protocol 
  | 
| 
sl@0
 | 
   790  | 
defined by this mixin class. */
  | 
| 
sl@0
 | 
   791  | 
	{
 | 
| 
sl@0
 | 
   792  | 
	Reset();
  | 
| 
sl@0
 | 
   793  | 
	TInt count=aArray.MdcaCount();
  | 
| 
sl@0
 | 
   794  | 
	for (TInt i=0;i<count;++i)
  | 
| 
sl@0
 | 
   795  | 
		AppendL(aArray.MdcaPoint(i));
  | 
| 
sl@0
 | 
   796  | 
	}
  |