epoc32/include/e32base.inl
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     4
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
// e32\include\e32base.inl
williamr@2
    15
// 
williamr@2
    16
//
williamr@2
    17
williamr@2
    18
// Class CBase
williamr@2
    19
inline TAny* CBase::operator new(TUint aSize, TAny* aBase) __NO_THROW
williamr@2
    20
/**
williamr@2
    21
Initialises the object to binary zeroes.
williamr@2
    22
williamr@2
    23
@param aSize The size of the derived class. This parameter is specified
williamr@2
    24
             implicitly by C++ in all circumstances in which a derived
williamr@2
    25
			 class is allocated.
williamr@2
    26
@param aBase Indicates a base address which is returned as the object's
williamr@2
    27
             address. 
williamr@2
    28
williamr@2
    29
@return A pointer to the base address.
williamr@2
    30
*/
williamr@2
    31
	{ Mem::FillZ(aBase, aSize); return aBase; }
williamr@2
    32
williamr@2
    33
williamr@2
    34
williamr@2
    35
williamr@2
    36
inline TAny* CBase::operator new(TUint aSize) __NO_THROW
williamr@2
    37
/**
williamr@2
    38
Allocates the object from the heap and then initialises its contents
williamr@2
    39
to binary zeroes.
williamr@2
    40
williamr@2
    41
@param aSize The size of the derived class. This parameter is specified
williamr@2
    42
             implicitly by C++ in all circumstances in which a derived class
williamr@2
    43
			 is allocated.
williamr@2
    44
williamr@2
    45
@return      A pointer to the allocated object; NULL if memory could not
williamr@2
    46
             be allocated.
williamr@2
    47
*/
williamr@2
    48
	{ return User::AllocZ(aSize); }
williamr@2
    49
williamr@2
    50
williamr@2
    51
williamr@2
    52
williamr@2
    53
inline TAny* CBase::operator new(TUint aSize, TLeave)
williamr@2
    54
/**
williamr@2
    55
Allocates the object from the heap and then initialises its contents
williamr@2
    56
to binary zeroes.
williamr@2
    57
williamr@2
    58
@param aSize  The size of the derived class. This parameter is specified
williamr@2
    59
              implicitly by C++ in all circumstances in which a derived class
williamr@2
    60
			  is allocated.
williamr@2
    61
williamr@2
    62
@return       A pointer to the allocated object; the TLeave parameter indicates
williamr@2
    63
              that the operation leaves if allocation fails with out-of-memory.
williamr@2
    64
*/
williamr@2
    65
	{ return User::AllocZL(aSize); }
williamr@2
    66
williamr@2
    67
williamr@2
    68
williamr@2
    69
williamr@2
    70
inline TAny* CBase::operator new(TUint aSize, TUint aExtraSize) __NO_THROW
williamr@2
    71
/**
williamr@2
    72
Allocates the object from the heap and then initialises its contents
williamr@2
    73
to binary zeroes.
williamr@2
    74
williamr@2
    75
Use of this overload is rare.
williamr@2
    76
williamr@2
    77
@param aSize  The size of the derived class. This parameter is specified
williamr@2
    78
              implicitly by C++ in all circumstances in which a derived class
williamr@2
    79
			  is allocated.
williamr@2
    80
williamr@2
    81
@param aExtraSize Indicates additional size beyond the end of the base class.
williamr@2
    82
williamr@2
    83
@return      A pointer to the allocated object; NULL if memory could not
williamr@2
    84
             be allocated.
williamr@2
    85
*/
williamr@2
    86
	{ return User::AllocZ(aSize + aExtraSize); }
williamr@2
    87
williamr@2
    88
williamr@2
    89
williamr@2
    90
williamr@2
    91
inline TAny* CBase::operator new(TUint aSize, TLeave, TUint aExtraSize)
williamr@2
    92
/**
williamr@2
    93
Allocates the object from the heap and then initialises its contents
williamr@2
    94
to binary zeroes.
williamr@2
    95
williamr@2
    96
Use of this overload is rare.
williamr@2
    97
williamr@2
    98
@param aSize  The size of the derived class. This parameter is specified
williamr@2
    99
              implicitly by C++ in all circumstances in which a derived class
williamr@2
   100
			  is allocated.
williamr@2
   101
williamr@2
   102
@param aExtraSize Indicates additional size beyond the end of the base class.
williamr@2
   103
williamr@2
   104
@return      A pointer to the allocated object; the TLeave parameter indicates
williamr@2
   105
              that the operation leaves if allocation fails with out-of-memory.
williamr@2
   106
*/
williamr@2
   107
	{ return User::AllocZL(aSize + aExtraSize); }
williamr@2
   108
williamr@2
   109
williamr@2
   110
williamr@2
   111
williamr@2
   112
// Class CBufBase
williamr@2
   113
inline TInt CBufBase::Size() const
williamr@2
   114
/**
williamr@2
   115
Gets the number of data bytes in the buffer.
williamr@2
   116
williamr@2
   117
Note that the number of heap bytes used by the buffer may be greater than its
williamr@2
   118
size, because there is typically extra room to allow for expansion. Use the
williamr@2
   119
Compress() function to reduce the extra allocation as much as possible.
williamr@2
   120
williamr@2
   121
@return The number of data bytes in the buffer.
williamr@2
   122
*/
williamr@2
   123
	{return(iSize);}
williamr@2
   124
williamr@2
   125
williamr@2
   126
williamr@2
   127
williamr@2
   128
// Class CBufFlat
williamr@2
   129
inline TInt CBufFlat::Capacity() const
williamr@2
   130
/**
williamr@2
   131
Gets the size to which the buffer may expand without re-allocation.
williamr@2
   132
williamr@2
   133
@return The size of the allocated cell associated with the buffer. This is 
williamr@2
   134
        the maximum size the buffer may be expanded to without re-allocation.
williamr@2
   135
*/
williamr@2
   136
	{return(iMaxSize);}
williamr@2
   137
williamr@2
   138
williamr@2
   139
williamr@2
   140
williamr@2
   141
// Class CArrayFixBase
williamr@2
   142
inline TInt CArrayFixBase::Count() const
williamr@2
   143
/**
williamr@2
   144
Gets the number of elements held in the array.
williamr@2
   145
williamr@2
   146
@return The number of array elements
williamr@2
   147
*/
williamr@2
   148
	{return(iCount);}
williamr@2
   149
williamr@2
   150
williamr@2
   151
williamr@2
   152
williamr@2
   153
inline TInt CArrayFixBase::Length() const
williamr@2
   154
/**
williamr@2
   155
Gets the length of an element.
williamr@2
   156
williamr@2
   157
@return The length of an element of type class T.
williamr@2
   158
*/
williamr@2
   159
	{return(iLength);}
williamr@2
   160
williamr@2
   161
williamr@2
   162
williamr@2
   163
williamr@2
   164
// Template class CArrayFix
williamr@2
   165
template <class T>
williamr@2
   166
inline CArrayFix<T>::CArrayFix(TBufRep aRep,TInt aGranularity)
williamr@2
   167
	: CArrayFixBase(aRep,sizeof(T),aGranularity)
williamr@2
   168
/**
williamr@2
   169
@internalComponent
williamr@2
   170
*/
williamr@2
   171
	{}
williamr@2
   172
williamr@2
   173
williamr@2
   174
williamr@2
   175
williamr@2
   176
template <class T>
williamr@2
   177
inline const T &CArrayFix<T>::operator[](TInt anIndex) const
williamr@2
   178
/**
williamr@2
   179
Gets a const reference to the element located at the specified position 
williamr@2
   180
within the array.
williamr@2
   181
williamr@2
   182
Note that if a pointer to the returned referenced class T object is taken,
williamr@2
   183
be aware that the pointer value becomes invalid once elements have been added
williamr@2
   184
to, or removed from the array. Always refresh the pointer.
williamr@2
   185
williamr@2
   186
@param anIndex The position of the element within the array. The position 
williamr@2
   187
               is relative to zero; i.e. zero implies the first element in
williamr@2
   188
			   the array.
williamr@2
   189
			   
williamr@2
   190
@return A const reference to the required element.
williamr@2
   191
williamr@2
   192
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   193
                         number of objects currently within the array.
williamr@2
   194
*/
williamr@2
   195
	{return(*((const T *)CArrayFixBase::At(anIndex)));}
williamr@2
   196
williamr@2
   197
williamr@2
   198
williamr@2
   199
williamr@2
   200
template <class T>
williamr@2
   201
inline T &CArrayFix<T>::operator[](TInt anIndex)
williamr@2
   202
/**
williamr@2
   203
Gets a non-const reference to the element located at the specified position 
williamr@2
   204
within the array.
williamr@2
   205
williamr@2
   206
Note that if a pointer to the returned referenced class T object is taken,
williamr@2
   207
be aware that the pointer value becomes invalid once elements have been added
williamr@2
   208
to, or removed from the array. Always refresh the pointer.
williamr@2
   209
williamr@2
   210
@param anIndex The position of the element within the array. The position 
williamr@2
   211
               is relative to zero; i.e. zero implies the first element in
williamr@2
   212
			   the array.
williamr@2
   213
			   
williamr@2
   214
@return A non-const reference to the required element.
williamr@2
   215
williamr@2
   216
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   217
                         number of objects currently within the array.
williamr@2
   218
*/
williamr@2
   219
	{return(*((T *)CArrayFixBase::At(anIndex)));}
williamr@2
   220
williamr@2
   221
williamr@2
   222
williamr@2
   223
williamr@2
   224
template <class T>
williamr@2
   225
inline const T &CArrayFix<T>::At(TInt anIndex) const
williamr@2
   226
/** 
williamr@2
   227
Gets a const reference to the element located at the specified position 
williamr@2
   228
within the array.
williamr@2
   229
williamr@2
   230
Note that if a pointer to the returned referenced class T object is taken,
williamr@2
   231
be aware that the pointer value becomes invalid once elements have been added
williamr@2
   232
to, or removed from the array. Always refresh the pointer.
williamr@2
   233
williamr@2
   234
@param anIndex The position of the element within the array. The position 
williamr@2
   235
               is relative to zero; i.e. zero implies the first element in
williamr@2
   236
			   the array.
williamr@2
   237
			   
williamr@2
   238
@return A const reference to the required element.
williamr@2
   239
williamr@2
   240
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   241
                         number of objects currently within the array.
williamr@2
   242
*/
williamr@2
   243
	{return(*((const T *)CArrayFixBase::At(anIndex)));}
williamr@2
   244
williamr@2
   245
williamr@2
   246
williamr@2
   247
williamr@2
   248
template <class T>
williamr@2
   249
inline const T *CArrayFix<T>::End(TInt anIndex) const
williamr@2
   250
/**
williamr@2
   251
Gets a pointer to the (const) first byte following the end of the 
williamr@2
   252
contiguous region containing the element at the specified position within
williamr@2
   253
the array.
williamr@2
   254
williamr@2
   255
For arrays implemented using flat buffers, the pointer always points to the 
williamr@2
   256
first byte following the end of the buffer.
williamr@2
   257
williamr@2
   258
For arrays implemented using segmented buffers, the pointer always points 
williamr@2
   259
to the first byte following the end of the segment which contains the element.
williamr@2
   260
williamr@2
   261
@param anIndex The position of the element within the array. The position 
williamr@2
   262
               is relative to zero; i.e. zero implies the first element
williamr@2
   263
			   in the array.
williamr@2
   264
			   
williamr@2
   265
@return A pointer to the constant byte following the end of the contiguous 
williamr@2
   266
        region. 
williamr@2
   267
williamr@2
   268
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   269
                         number of objects currently within the array.
williamr@2
   270
*/
williamr@2
   271
	{return((const T *)CArrayFixBase::End(anIndex));}
williamr@2
   272
williamr@2
   273
williamr@2
   274
williamr@2
   275
williamr@2
   276
template <class T>
williamr@2
   277
inline const T *CArrayFix<T>::Back(TInt anIndex) const
williamr@2
   278
/**
williamr@2
   279
Gets a pointer to the (const) beginning of a contiguous region.
williamr@2
   280
williamr@2
   281
For arrays implemented using flat buffers, the function always returns a
williamr@2
   282
pointer to the beginning of the buffer.
williamr@2
   283
williamr@2
   284
For arrays implemented using segmented buffers, the function returns a pointer 
williamr@2
   285
to the beginning of the segment for all elements in that segment except the 
williamr@2
   286
first. If the element at position anIndex is the first in a segment, then 
williamr@2
   287
the function returns a pointer the beginning of the previous segment.
williamr@2
   288
williamr@2
   289
For the first element in the array, the function returns a NULL pointer.
williamr@2
   290
williamr@2
   291
@param anIndex The position of the element within the array. The position 
williamr@2
   292
               is relative to zero; i.e. zero implies the first element
williamr@2
   293
			   in the array.
williamr@2
   294
			   
williamr@2
   295
@return A pointer to the (const) beginning of the contiguous region.
williamr@2
   296
williamr@2
   297
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   298
                         number of objects currently within the array.
williamr@2
   299
*/
williamr@2
   300
	{return((const T *)CArrayFixBase::Back(anIndex));}
williamr@2
   301
williamr@2
   302
williamr@2
   303
williamr@2
   304
williamr@2
   305
template <class T>
williamr@2
   306
inline T &CArrayFix<T>::At(TInt anIndex)
williamr@2
   307
/**
williamr@2
   308
Gets a non-const reference to the element located at the specified position 
williamr@2
   309
within the array.
williamr@2
   310
williamr@2
   311
Note that if a pointer to the returned referenced class T object is taken,
williamr@2
   312
be aware that the pointer value becomes invalid once elements have been added
williamr@2
   313
to, or removed from the array. Always refresh the pointer.
williamr@2
   314
williamr@2
   315
@param anIndex The position of the element within the array. The position 
williamr@2
   316
               is relative to zero; i.e. zero implies the first element in
williamr@2
   317
			   the array.
williamr@2
   318
			   
williamr@2
   319
@return A non-const reference to the required element.
williamr@2
   320
williamr@2
   321
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   322
                         number of objects currently within the array.
williamr@2
   323
*/
williamr@2
   324
	{return(*((T *)CArrayFixBase::At(anIndex)));}
williamr@2
   325
williamr@2
   326
williamr@2
   327
williamr@2
   328
williamr@2
   329
template <class T>
williamr@2
   330
inline T *CArrayFix<T>::End(TInt anIndex)
williamr@2
   331
/**
williamr@2
   332
Gets a pointer to the first byte following the end of the contiguous region 
williamr@2
   333
containing the element at the specified position within the array.
williamr@2
   334
williamr@2
   335
For arrays implemented using flat buffers, the pointer always points to the 
williamr@2
   336
first byte following the end of the buffer.
williamr@2
   337
williamr@2
   338
For arrays implemented using segmented buffers, the pointer always points 
williamr@2
   339
to the first byte following the end of the segment which contains the element.
williamr@2
   340
williamr@2
   341
@param anIndex The position of the element within the array. The position 
williamr@2
   342
               is relative to zero; i.e. zero implies the first element
williamr@2
   343
			   in the array.
williamr@2
   344
			   
williamr@2
   345
@return A pointer to the byte following the end of the contiguous region.
williamr@2
   346
williamr@2
   347
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   348
                         number of objects currently within the array.
williamr@2
   349
*/
williamr@2
   350
	{return(((T *)CArrayFixBase::End(anIndex)));}
williamr@2
   351
williamr@2
   352
williamr@2
   353
williamr@2
   354
williamr@2
   355
template <class T>
williamr@2
   356
inline T *CArrayFix<T>::Back(TInt anIndex)
williamr@2
   357
/**
williamr@2
   358
Gets a pointer to the beginning of a contiguous region.
williamr@2
   359
williamr@2
   360
For arrays implemented using flat buffers, the function always returns a pointer 
williamr@2
   361
to the beginning of the buffer.
williamr@2
   362
williamr@2
   363
For arrays implemented using segmented buffers, the function returns a pointer 
williamr@2
   364
to the beginning of the segment for all elements in that segment except the 
williamr@2
   365
first. If the element at position anIndex is the first in a segment, then 
williamr@2
   366
the function returns a pointer the beginning of the previous segment.
williamr@2
   367
williamr@2
   368
For the first element in the array, the function returns a NULL pointer.
williamr@2
   369
williamr@2
   370
@param anIndex The position of the element within the array. The position 
williamr@2
   371
               is relative to zero; i.e. zero implies the first element
williamr@2
   372
			   in the array.
williamr@2
   373
			   
williamr@2
   374
@return A pointer to the beginning of the contiguous region.
williamr@2
   375
williamr@2
   376
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
   377
                         number of objects currently within the array.
williamr@2
   378
*/
williamr@2
   379
	{return(((T *)CArrayFixBase::Back(anIndex)));}
williamr@2
   380
williamr@2
   381
williamr@2
   382
williamr@2
   383
williamr@2
   384
template <class T>
williamr@2
   385
inline void CArrayFix<T>::AppendL(const T &aRef)
williamr@2
   386
/**
williamr@2
   387
Appends a single element onto the end of the array.
williamr@2
   388
williamr@2
   389
@param aRef A reference to the class T element to be appended.
williamr@2
   390
williamr@2
   391
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   392
       there is insufficient memory available, the function leaves, in which
williamr@2
   393
	   case the array is left in the state it was in before the call.
williamr@2
   394
*/
williamr@2
   395
	{CArrayFixBase::InsertL(Count(),&aRef);}
williamr@2
   396
williamr@2
   397
williamr@2
   398
williamr@2
   399
williamr@2
   400
template <class T>
williamr@2
   401
inline void CArrayFix<T>::AppendL(const T *aPtr,TInt aCount)
williamr@2
   402
/**
williamr@2
   403
Appends one or more elements onto the end of the array.
williamr@2
   404
williamr@2
   405
@param aPtr   A pointer to a contiguous set of type <class T> objects to be
williamr@2
   406
              appended.
williamr@2
   407
@param aCount The number of contiguous objects of type <class T> located at 
williamr@2
   408
              aPtr to be appended.
williamr@2
   409
			  
williamr@2
   410
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   411
       there is insufficient memory available, the function leaves, in which
williamr@2
   412
	   case the array is left in the state it was in before the call.
williamr@2
   413
williamr@2
   414
@panic E32USER-CBase 23, if aCount is negative.
williamr@2
   415
*/
williamr@2
   416
	{CArrayFixBase::InsertL(Count(),aPtr,aCount);}
williamr@2
   417
williamr@2
   418
williamr@2
   419
williamr@2
   420
williamr@2
   421
template <class T>
williamr@2
   422
inline void CArrayFix<T>::AppendL(const T &aRef,TInt aReplicas)
williamr@2
   423
/**
williamr@2
   424
Appends replicated copies of an element onto the end of the array.
williamr@2
   425
williamr@2
   426
@param aRef      A reference to the <class T> object to be replicated and appended.
williamr@2
   427
@param aReplicas The number of copies of the aRef element to be appended. 
williamr@2
   428
williamr@2
   429
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   430
       there is insufficient memory available, the function leaves, in which
williamr@2
   431
	   case the array is left in the state it was in before the call.
williamr@2
   432
williamr@2
   433
@panic E32USER-CBase 28 if aReplicas is negative.
williamr@2
   434
*/
williamr@2
   435
	{CArrayFixBase::InsertRepL(Count(),&aRef,aReplicas);}
williamr@2
   436
williamr@2
   437
williamr@2
   438
williamr@2
   439
williamr@2
   440
template <class T>
williamr@2
   441
inline T &CArrayFix<T>::ExpandL(TInt anIndex)
williamr@2
   442
/**
williamr@2
   443
Expands the array by one element at the specified position.
williamr@2
   444
williamr@2
   445
It:
williamr@2
   446
williamr@2
   447
1. expands the array by one element at the specified position
williamr@2
   448
williamr@2
   449
2. constructs a new element at that position
williamr@2
   450
williamr@2
   451
3. returns a reference to the new element.
williamr@2
   452
williamr@2
   453
All existing elements from position anIndex to the end of the array are moved 
williamr@2
   454
up, so that the element originally at position anIndex is now at position 
williamr@2
   455
anIndex + 1 etc.
williamr@2
   456
williamr@2
   457
The new element of type class T is constructed at position anIndex, using 
williamr@2
   458
the default constructor of that class.
williamr@2
   459
williamr@2
   460
@param anIndex The position within the array where the array is to be expanded 
williamr@2
   461
               and the new class T object is to be constructed. 
williamr@2
   462
williamr@2
   463
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   464
       there is insufficient memory available, the function leaves, in which
williamr@2
   465
	   case the array is left in the state it was in before the call.
williamr@2
   466
williamr@2
   467
@return A reference to the newly constructed class T object at position 
williamr@2
   468
        anIndex within the array.
williamr@2
   469
williamr@2
   470
@panic E32USER-CBase 21 if anIndex is negative or greater than the number
williamr@2
   471
                        of elements currently in the array.
williamr@2
   472
*/
williamr@2
   473
	{return(*new(CArrayFixBase::ExpandL(anIndex)) T);}
williamr@2
   474
williamr@2
   475
williamr@2
   476
williamr@2
   477
williamr@2
   478
template <class T>
williamr@2
   479
inline T &CArrayFix<T>::ExtendL()
williamr@2
   480
/**
williamr@2
   481
Expands the array by one element at the end of the array.
williamr@2
   482
williamr@2
   483
It:
williamr@2
   484
williamr@2
   485
1. expands the array by one element at the end of the array, i.e. at position 
williamr@2
   486
   CArrayFixBase::Count()
williamr@2
   487
williamr@2
   488
2. constructs a new element at that position
williamr@2
   489
williamr@2
   490
3. returns a reference to the new element.
williamr@2
   491
williamr@2
   492
The new element of type class T is constructed at the end of the array, 
williamr@2
   493
using the default constructor of that class.
williamr@2
   494
williamr@2
   495
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   496
       there is insufficient memory available, the function leaves, in which
williamr@2
   497
	   case the array is left in the state it was in before the call.
williamr@2
   498
williamr@2
   499
@return A reference to the newly constructed class T object at the end of 
williamr@2
   500
        the array.
williamr@2
   501
williamr@2
   502
@see CArrayFixBase::Count
williamr@2
   503
*/
williamr@2
   504
	{return(*new(CArrayFixBase::ExpandL(Count())) T);}
williamr@2
   505
williamr@2
   506
williamr@2
   507
williamr@2
   508
williamr@2
   509
template <class T>
williamr@2
   510
inline TInt CArrayFix<T>::Find(const T &aRef,TKeyArrayFix &aKey,TInt &anIndex) const
williamr@2
   511
/**
williamr@2
   512
Finds the position of an element within the array, based on the matching of
williamr@2
   513
keys, using a sequential search.
williamr@2
   514
williamr@2
   515
The array is searched sequentially for an element whose key matches the key of the
williamr@2
   516
supplied class T object. The search starts with the first element in the array.
williamr@2
   517
williamr@2
   518
Note that where an array has elements with duplicate keys, the function only
williamr@2
   519
supplies the position of the first element in the array with that key.
williamr@2
   520
williamr@2
   521
@param aRef    A reference to an object of type class T whose key is used
williamr@2
   522
               for comparison.
williamr@2
   523
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
   524
@param anIndex A reference to a TInt supplied by the caller. On return, if the
williamr@2
   525
               element is found, the reference is set to the position of that
williamr@2
   526
			   element within the array. The position is relative to zero, 
williamr@2
   527
			   (i.e. the first element in the array is at position 0).
williamr@2
   528
			   If the element is not found and the array is not empty, then
williamr@2
   529
			   the value of the reference is set to the number of elements in
williamr@2
   530
			   the array. 
williamr@2
   531
			   If the element is not found and the array is empty, then the
williamr@2
   532
			   reference is set to zero.
williamr@2
   533
williamr@2
   534
@return Zero, if the element with the specified key is found. 
williamr@2
   535
        Non-zero, if the element with the specified key is not found.
williamr@2
   536
*/
williamr@2
   537
	{return(CArrayFixBase::Find(&aRef,aKey,anIndex));}
williamr@2
   538
williamr@2
   539
williamr@2
   540
williamr@2
   541
williamr@2
   542
template <class T>
williamr@2
   543
inline TInt CArrayFix<T>::FindIsq(const T &aRef,TKeyArrayFix &aKey,TInt &anIndex) const
williamr@2
   544
/**
williamr@2
   545
Finds the position of an element within the array, based on the matching of 
williamr@2
   546
keys, using a binary search technique.
williamr@2
   547
williamr@2
   548
The array is searched, using a binary search technique, for an element whose 
williamr@2
   549
key matches the key of the supplied class T object.
williamr@2
   550
williamr@2
   551
The array must be in key order.
williamr@2
   552
williamr@2
   553
Note that where an array has elements with duplicate keys, the function cannot
williamr@2
   554
guarantee which element, with the given key value, it will return, except that
williamr@2
   555
it will find one of them.
williamr@2
   556
williamr@2
   557
@param aRef    A reference to an object of type class T whose key is used 
williamr@2
   558
               for comparison. 
williamr@2
   559
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
   560
@param anIndex A reference to a TInt supplied by the caller. On return, if the
williamr@2
   561
               element is found, the reference is set to the position of that
williamr@2
   562
			   element within the array. The position is relative to zero,
williamr@2
   563
			   (i.e. the first element in the array is at position 0).
williamr@2
   564
			   If the element is not found and the array is not empty, then the
williamr@2
   565
			   reference is set to the position of the first element in the
williamr@2
   566
			   array with a key which is greater than the key of the 
williamr@2
   567
               object aRef.
williamr@2
   568
			   If the element is not found and the array is empty, then the 
williamr@2
   569
               reference is set to zero.
williamr@2
   570
williamr@2
   571
@return Zero, if the element with the specified key is found.
williamr@2
   572
        Non-zero, if the element with the specified key is not found.
williamr@2
   573
*/
williamr@2
   574
	{return(CArrayFixBase::FindIsq(&aRef,aKey,anIndex));}
williamr@2
   575
williamr@2
   576
williamr@2
   577
williamr@2
   578
williamr@2
   579
template <class T>
williamr@2
   580
inline void CArrayFix<T>::InsertL(TInt anIndex,const T &aRef)
williamr@2
   581
/**
williamr@2
   582
Inserts an element into the array at the specified position.
williamr@2
   583
williamr@2
   584
Note that passing a value of anIndex which is the same as the current number
williamr@2
   585
of elements in the array, has the effect of appending the element.
williamr@2
   586
williamr@2
   587
@param anIndex The position within the array where the element is to be
williamr@2
   588
               inserted. The position is relative to zero, i.e. zero implies
williamr@2
   589
			   that elements are inserted at the beginning of the array. 
williamr@2
   590
			   
williamr@2
   591
@param aRef    A reference to the class T object to be inserted into the array 
williamr@2
   592
               at position anIndex.
williamr@2
   593
williamr@2
   594
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   595
       there is insufficient memory available, the function leaves, in which
williamr@2
   596
	   case the array is left in the state it was in before the call.
williamr@2
   597
williamr@2
   598
@panic E32USER-CBase 21 if anIndex is negative, or is greater than the number
williamr@2
   599
       of elements currently in the array.
williamr@2
   600
*/
williamr@2
   601
	{CArrayFixBase::InsertL(anIndex,&aRef);}
williamr@2
   602
williamr@2
   603
williamr@2
   604
williamr@2
   605
williamr@2
   606
template <class T>
williamr@2
   607
inline void CArrayFix<T>::InsertL(TInt anIndex,const T *aPtr,TInt aCount)
williamr@2
   608
/**
williamr@2
   609
Inserts one or more elements into the array at the specified position.
williamr@2
   610
williamr@2
   611
The objects to be added must all be contiguous.
williamr@2
   612
williamr@2
   613
Note that passing a value of anIndex which is the same as the current number
williamr@2
   614
of elements in the array, has the effect of appending the element.
williamr@2
   615
williamr@2
   616
@param anIndex The position within the array where the elements are to be 
williamr@2
   617
               inserted. The position is relative to zero, i.e. zero implies
williamr@2
   618
			   that elements are inserted at the beginning of the array.
williamr@2
   619
			   
williamr@2
   620
@param aPtr    A pointer to the first of the contiguous elements of type 
williamr@2
   621
               class T to be inserted into the array at position anIndex.
williamr@2
   622
williamr@2
   623
@param aCount  The number of contiguous elements of type class T located at 
williamr@2
   624
               aPtr to be inserted into the array. 
williamr@2
   625
williamr@2
   626
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   627
       there is insufficient memory available, the function leaves, in which
williamr@2
   628
	   case the array is left in the state it was in before the call.
williamr@2
   629
williamr@2
   630
@panic E32USER-CBase 21  if anIndex is negative or is greater than the number
williamr@2
   631
                         of elements currently in the array.
williamr@2
   632
@panic E32USER-CBase 23  if aCount is negative.
williamr@2
   633
*/
williamr@2
   634
	{CArrayFixBase::InsertL(anIndex,aPtr,aCount);}
williamr@2
   635
williamr@2
   636
williamr@2
   637
williamr@2
   638
williamr@2
   639
template <class T>
williamr@2
   640
inline void CArrayFix<T>::InsertL(TInt anIndex,const T &aRef,TInt aReplicas)
williamr@2
   641
/**
williamr@2
   642
Inserts replicated copies of an element into the array at the specified
williamr@2
   643
position.
williamr@2
   644
williamr@2
   645
Note that passing a value of anIndex which is the same as the current number
williamr@2
   646
of elements in the array, has the effect of appending the element.
williamr@2
   647
williamr@2
   648
williamr@2
   649
@param anIndex   The position within the array where elements are to be
williamr@2
   650
                 inserted. The position is relative to zero, i.e. zero implies
williamr@2
   651
				 that elements are inserted at the beginning of the array.
williamr@2
   652
				 
williamr@2
   653
@param aRef      A reference to the class T object to be replicated and
williamr@2
   654
                 inserted into the array at position anIndex. 
williamr@2
   655
williamr@2
   656
@param aReplicas The number of copies of the aRef element to be inserted into 
williamr@2
   657
                 the array.
williamr@2
   658
				 
williamr@2
   659
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   660
       there is insufficient memory available, the function leaves, in which
williamr@2
   661
	   case the array is left in the state it was in before the call.
williamr@2
   662
	   
williamr@2
   663
@panic E32USER-CBase 21, if anIndex is negative or is greater than the number
williamr@2
   664
                         of elements currently in the array.
williamr@2
   665
@panic E32USER-CBase 28, if aReplicas is negative.
williamr@2
   666
*/
williamr@2
   667
	{CArrayFixBase::InsertRepL(anIndex,&aRef,aReplicas);}
williamr@2
   668
williamr@2
   669
williamr@2
   670
williamr@2
   671
williamr@2
   672
template <class T>
williamr@2
   673
inline TInt CArrayFix<T>::InsertIsqL(const T &aRef,TKeyArrayFix &aKey)
williamr@2
   674
/**
williamr@2
   675
Inserts a single element into the array at a position determined by a key.
williamr@2
   676
williamr@2
   677
The array MUST already be in key sequence (as defined by the key), otherwise 
williamr@2
   678
the position of the new element is unpredictable, or duplicates may occur.
williamr@2
   679
williamr@2
   680
Elements with duplicate keys are not permitted.
williamr@2
   681
williamr@2
   682
@param aRef A reference to the element of type <class T> to be inserted into 
williamr@2
   683
            the array.
williamr@2
   684
@param aKey A reference to a key object defining the properties of the key. 
williamr@2
   685
williamr@2
   686
@return The position within the array of the newly inserted element. 
williamr@2
   687
williamr@2
   688
@leave KErrAlreadyExists An element with the same key already exists within 
williamr@2
   689
       the array. NB the array MUST already be in key sequence, otherwise
williamr@2
   690
	   the function may insert a duplicate and fail to leave with
williamr@2
   691
	   this value.
williamr@2
   692
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   693
       there is insufficient memory available, the function leaves, in which
williamr@2
   694
	   case the array is left in the state it was in before the call.
williamr@2
   695
*/
williamr@2
   696
	{return(CArrayFixBase::InsertIsqL(&aRef,aKey));}
williamr@2
   697
williamr@2
   698
williamr@2
   699
williamr@2
   700
williamr@2
   701
template <class T>
williamr@2
   702
inline TInt CArrayFix<T>::InsertIsqAllowDuplicatesL(const T &aRef,TKeyArrayFix &aKey)
williamr@2
   703
/**
williamr@2
   704
Inserts a single element into the array at a position determined by a key, 
williamr@2
   705
allowing duplicates.
williamr@2
   706
williamr@2
   707
The array MUST already be in key sequence (as defined by the key), otherwise 
williamr@2
   708
the position of the new element is unpredictable.
williamr@2
   709
williamr@2
   710
If the new element's key is a duplicate of an existing element's key, then 
williamr@2
   711
the new element is positioned after the existing element.
williamr@2
   712
williamr@2
   713
@param aRef A reference to the element of type <class T> to be inserted into 
williamr@2
   714
            the array.
williamr@2
   715
@param aKey A reference to a key object defining the properties of the key. 
williamr@2
   716
williamr@2
   717
@return The position within the array of the newly inserted element.
williamr@2
   718
williamr@2
   719
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   720
       there is insufficient memory available, the function leaves, in which
williamr@2
   721
	   case the array is left in the state it was in before the call.
williamr@2
   722
*/
williamr@2
   723
	{return(CArrayFixBase::InsertIsqAllowDuplicatesL(&aRef,aKey));}
williamr@2
   724
williamr@2
   725
williamr@2
   726
williamr@2
   727
williamr@2
   728
template <class T>
williamr@2
   729
inline void CArrayFix<T>::ResizeL(TInt aCount)
williamr@2
   730
/**
williamr@2
   731
Changes the size of the array so that it contains the specified number
williamr@2
   732
of elements.
williamr@2
   733
williamr@2
   734
The following describes the effects of calling this function:
williamr@2
   735
williamr@2
   736
1. If aCount is less than the current number of elements in the array, then the 
williamr@2
   737
   array is shrunk. The elements at positions aCount and above are discarded. 
williamr@2
   738
   The array buffer is not compressed.
williamr@2
   739
williamr@2
   740
2. If aCount is greater than the current number of elements in the array, then 
williamr@2
   741
   the array is extended.
williamr@2
   742
williamr@2
   743
3. New elements are replicated copies of an object of type <class T>,
williamr@2
   744
   constructed using the default constructor of that class.
williamr@2
   745
williamr@2
   746
The new elements are positioned after the existing elements in the array.
williamr@2
   747
williamr@2
   748
The function may attempt to expand the array buffer. If there is insufficient 
williamr@2
   749
memory available, the function leaves. The leave code is one of the system 
williamr@2
   750
wide error codes. If the function leaves, the array is left in the state it 
williamr@2
   751
was in before the call.
williamr@2
   752
williamr@2
   753
@param aCount The number of elements the array is to contain after the resizing 
williamr@2
   754
              operation. 
williamr@2
   755
			  
williamr@2
   756
@panic E32USER-CBase 24, if aCount is negative.
williamr@2
   757
*/
williamr@2
   758
	{TUint8 b[sizeof(T)]; new(&b[0]) T; CArrayFixBase::ResizeL(aCount,&b[0]);}
williamr@2
   759
williamr@2
   760
williamr@2
   761
williamr@2
   762
williamr@2
   763
template <class T>
williamr@2
   764
inline void CArrayFix<T>::ResizeL(TInt aCount,const T &aRef)
williamr@2
   765
/**
williamr@2
   766
Changes the size of the array so that it contains the specified number
williamr@2
   767
of elements.
williamr@2
   768
williamr@2
   769
The following describes the effects of calling this function:
williamr@2
   770
williamr@2
   771
1. If aCount is less than the current number of elements in the array, then the 
williamr@2
   772
   array is shrunk. The elements at positions aCount and above are discarded. 
williamr@2
   773
   The array buffer is not compressed.
williamr@2
   774
williamr@2
   775
2. If aCount is greater than the current number of elements in the array, then 
williamr@2
   776
   the array is extended.
williamr@2
   777
williamr@2
   778
3. New elements are replicated copies of aRef.
williamr@2
   779
williamr@2
   780
The new elements are positioned after the existing elements in the array.
williamr@2
   781
williamr@2
   782
The function may attempt to expand the array buffer. If there is insufficient 
williamr@2
   783
memory available, the function leaves. The leave code is one of the system 
williamr@2
   784
wide error codes. If the function leaves, the array is left in the state it 
williamr@2
   785
was in before the call.
williamr@2
   786
williamr@2
   787
@param aCount The number of elements the array is to contain after the resizing 
williamr@2
   788
              operation.
williamr@2
   789
williamr@2
   790
@param aRef   A reference to an object of type <class T>, copies of which are
williamr@2
   791
              used as the new elements of the array, if the array is extended.
williamr@2
   792
williamr@2
   793
@panic E32USER-CBase 24, if aCount is negative.
williamr@2
   794
*/
williamr@2
   795
	{CArrayFixBase::ResizeL(aCount,&aRef);}
williamr@2
   796
williamr@2
   797
williamr@2
   798
williamr@2
   799
williamr@2
   800
template <class T>
williamr@2
   801
inline const TArray<T> CArrayFix<T>::Array() const
williamr@2
   802
/**
williamr@2
   803
Constructs and returns a TArray<T> object.
williamr@2
   804
williamr@2
   805
@return A TArray<T> object representing this array.
williamr@2
   806
*/
williamr@2
   807
	{return(TArray<T>(CountR,AtR,this));}
williamr@2
   808
williamr@2
   809
williamr@2
   810
williamr@2
   811
williamr@2
   812
inline CArrayFix<TAny>::CArrayFix(TBufRep aRep,TInt aRecordLength,TInt aGranularity)
williamr@2
   813
	: CArrayFixBase(aRep,aRecordLength,aGranularity)
williamr@2
   814
/**
williamr@2
   815
@internalComponent
williamr@2
   816
*/
williamr@2
   817
	{}
williamr@2
   818
williamr@2
   819
williamr@2
   820
williamr@2
   821
williamr@2
   822
inline const TAny *CArrayFix<TAny>::At(TInt anIndex) const
williamr@2
   823
/**
williamr@2
   824
Gets a pointer to the untyped element located at the specified position 
williamr@2
   825
within the array.
williamr@2
   826
	
williamr@2
   827
@param anIndex The position of the element within the array. The position 
williamr@2
   828
	           is relative to zero; i.e. zero implies the first element in the
williamr@2
   829
			   array. 
williamr@2
   830
			   
williamr@2
   831
@return A pointer to the untyped element located at position anIndex within 
williamr@2
   832
	    the array. 
williamr@2
   833
williamr@2
   834
@panic E32User-CBase 21, if anIndex is negative or is greater than or equal
williamr@2
   835
       to the number of objects currently within the array.
williamr@2
   836
*/
williamr@2
   837
	{return(CArrayFixBase::At(anIndex));}
williamr@2
   838
williamr@2
   839
williamr@2
   840
williamr@2
   841
williamr@2
   842
inline const TAny *CArrayFix<TAny>::End(TInt anIndex) const
williamr@2
   843
/**
williamr@2
   844
Gets a pointer to the first byte following the end of the contiguous region 
williamr@2
   845
containing the element at the specfied position within the array.
williamr@2
   846
	
williamr@2
   847
For flat buffers, the pointer always points to the first byte following the 
williamr@2
   848
end of the buffer.
williamr@2
   849
	
williamr@2
   850
For segmented buffers, the pointer always points to the first byte following 
williamr@2
   851
the end of the segment which contains the element.
williamr@2
   852
	
williamr@2
   853
@param anIndex The position of the element within the array. The position 
williamr@2
   854
	           is relative to zero; i.e. zero implies the first element in
williamr@2
   855
			   the array.
williamr@2
   856
williamr@2
   857
@return A pointer to the byte following the end of the contiguous region.
williamr@2
   858
williamr@2
   859
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
   860
       the number of objects currently within the array.
williamr@2
   861
*/
williamr@2
   862
	{return(CArrayFixBase::End(anIndex));}
williamr@2
   863
williamr@2
   864
williamr@2
   865
williamr@2
   866
williamr@2
   867
inline const TAny *CArrayFix<TAny>::Back(TInt anIndex) const
williamr@2
   868
/**
williamr@2
   869
Gets a pointer to the beginning of a contiguous region.
williamr@2
   870
	
williamr@2
   871
For flat buffers, the function always returns a pointer to the beginning of 
williamr@2
   872
the buffer.
williamr@2
   873
	
williamr@2
   874
For segmented buffers, the function returns a pointer to the beginning of 
williamr@2
   875
the segment for all elements in that segment except the first. If the element 
williamr@2
   876
at the specified position is the first in a segment, then the function returns 
williamr@2
   877
a pointer the beginning of the previous segment.
williamr@2
   878
	
williamr@2
   879
For the first element in the array, the function returns a NULL pointer.
williamr@2
   880
	
williamr@2
   881
@param anIndex The position of the element within the array. The position 
williamr@2
   882
               is relative to zero; i.e. zero implies the first element in the array.
williamr@2
   883
	
williamr@2
   884
@return A pointer to the beginning of the contiguous region.
williamr@2
   885
williamr@2
   886
@panic E32User-CBase 21, if anIndex is negative or is greater than or equal to
williamr@2
   887
       the number of objects currently within the array.
williamr@2
   888
*/
williamr@2
   889
	{return(CArrayFixBase::Back(anIndex));}
williamr@2
   890
williamr@2
   891
williamr@2
   892
williamr@2
   893
williamr@2
   894
inline TAny *CArrayFix<TAny>::At(TInt anIndex)
williamr@2
   895
/**
williamr@2
   896
Gets a pointer to the untyped element located at the specified position 
williamr@2
   897
within the array.
williamr@2
   898
	
williamr@2
   899
@param anIndex The position of the element within the array. The position 
williamr@2
   900
	           is relative to zero; i.e. zero implies the first element in the
williamr@2
   901
			   array. 
williamr@2
   902
			   
williamr@2
   903
@return A pointer to the untyped element located at position anIndex within 
williamr@2
   904
	    the array. 
williamr@2
   905
williamr@2
   906
@panic E32User-CBase 21, if anIndex is negative or is greater than or equal
williamr@2
   907
       to the number of objects currently within the array.
williamr@2
   908
*/
williamr@2
   909
	{return(CArrayFixBase::At(anIndex));}
williamr@2
   910
williamr@2
   911
williamr@2
   912
williamr@2
   913
williamr@2
   914
inline TAny *CArrayFix<TAny>::End(TInt anIndex)
williamr@2
   915
/**
williamr@2
   916
Gets a pointer to the first byte following the end of the contiguous region 
williamr@2
   917
containing the element at the specfied position within the array.
williamr@2
   918
	
williamr@2
   919
For flat buffers, the pointer always points to the first byte following the 
williamr@2
   920
end of the buffer.
williamr@2
   921
	
williamr@2
   922
For segmented buffers, the pointer always points to the first byte following 
williamr@2
   923
the end of the segment which contains the element.
williamr@2
   924
	
williamr@2
   925
@param anIndex The position of the element within the array. The position 
williamr@2
   926
	           is relative to zero; i.e. zero implies the first element in
williamr@2
   927
			   the array.
williamr@2
   928
williamr@2
   929
@return A pointer to the byte following the end of the contiguous region.
williamr@2
   930
williamr@2
   931
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
   932
       the number of objects currently within the array.
williamr@2
   933
*/
williamr@2
   934
	{return(CArrayFixBase::End(anIndex));}
williamr@2
   935
williamr@2
   936
williamr@2
   937
williamr@2
   938
williamr@2
   939
inline TAny *CArrayFix<TAny>::Back(TInt anIndex)
williamr@2
   940
/**
williamr@2
   941
Gets a pointer to the beginning of a contiguous region.
williamr@2
   942
	
williamr@2
   943
For flat buffers, the function always returns a pointer to the beginning of 
williamr@2
   944
the buffer.
williamr@2
   945
	
williamr@2
   946
For segmented buffers, the function returns a pointer to the beginning of 
williamr@2
   947
the segment for all elements in that segment except the first. If the element 
williamr@2
   948
at the specified position is the first in a segment, then the function returns 
williamr@2
   949
a pointer the beginning of the previous segment.
williamr@2
   950
	
williamr@2
   951
For the first element in the array, the function returns a NULL pointer.
williamr@2
   952
	
williamr@2
   953
@param anIndex The position of the element within the array. The position 
williamr@2
   954
               is relative to zero; i.e. zero implies the first element in the array.
williamr@2
   955
	
williamr@2
   956
@return A pointer to the beginning of the contiguous region.
williamr@2
   957
williamr@2
   958
@panic E32User-CBase 21, if anIndex is negative or is greater than or equal to
williamr@2
   959
       the number of objects currently within the array.
williamr@2
   960
*/
williamr@2
   961
	{return(CArrayFixBase::Back(anIndex));}
williamr@2
   962
williamr@2
   963
williamr@2
   964
williamr@2
   965
williamr@2
   966
inline void CArrayFix<TAny>::AppendL(const TAny *aPtr)
williamr@2
   967
/**
williamr@2
   968
Appends the specified untyped element onto the end of the array.
williamr@2
   969
	
williamr@2
   970
@param aPtr A pointer to an untyped element to be appended. 
williamr@2
   971
williamr@2
   972
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   973
	   there is insufficient memory available, the function leaves, in which
williamr@2
   974
	   case the array is left in the state it was in before the call. 
williamr@2
   975
*/
williamr@2
   976
	{CArrayFixBase::InsertL(Count(),aPtr);}
williamr@2
   977
williamr@2
   978
williamr@2
   979
williamr@2
   980
williamr@2
   981
inline void CArrayFix<TAny>::AppendL(const TAny *aPtr,TInt aCount)
williamr@2
   982
/**
williamr@2
   983
Appends one or more untyped elements onto the end of the array.
williamr@2
   984
	
williamr@2
   985
@param aPtr   A pointer to the first of the contiguous untyped elements to be 
williamr@2
   986
	          appended. 
williamr@2
   987
@param aCount The number of contiguous elements located at aPtr to be appended. 
williamr@2
   988
williamr@2
   989
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
   990
       there is insufficient memory available, the function leaves, in which
williamr@2
   991
	   case the array is left in the state it was in before the call. 
williamr@2
   992
@panic E32USER-CBase 23, if aCount is negative.
williamr@2
   993
*/
williamr@2
   994
	{CArrayFixBase::InsertL(Count(),aPtr,aCount);}
williamr@2
   995
williamr@2
   996
williamr@2
   997
williamr@2
   998
williamr@2
   999
inline TAny *CArrayFix<TAny>::ExtendL()
williamr@2
  1000
/**
williamr@2
  1001
Expands the array by the length of one element at the end of the array and 
williamr@2
  1002
returns a pointer to this new location.
williamr@2
  1003
	
williamr@2
  1004
As elements are untyped, no construction is possible and the content of the 
williamr@2
  1005
new location remains undefined.
williamr@2
  1006
williamr@2
  1007
@return A pointer to the new element location at the end of the array.
williamr@2
  1008
williamr@2
  1009
@leave KErrNoMemory The function may attempt to expand the array buffer. If 
williamr@2
  1010
	   there is insufficient memory available, the function leaves, in which
williamr@2
  1011
	   case the array is left in the state it was in before the call. 
williamr@2
  1012
*/
williamr@2
  1013
	{return(CArrayFixBase::ExpandL(Count()));}
williamr@2
  1014
williamr@2
  1015
williamr@2
  1016
williamr@2
  1017
williamr@2
  1018
// Template class CArrayFixFlat
williamr@2
  1019
template <class T>
williamr@2
  1020
inline CArrayFixFlat<T>::CArrayFixFlat(TInt aGranularity)
williamr@2
  1021
	: CArrayFix<T>((TBufRep)CBufFlat::NewL,aGranularity)
williamr@2
  1022
/**
williamr@2
  1023
Constructs a flat array of fixed length objects with the specified granularity.
williamr@2
  1024
williamr@2
  1025
The length of all array elements is the length of the class passed as the 
williamr@2
  1026
template parameter. The length must be non-zero.
williamr@2
  1027
williamr@2
  1028
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1029
williamr@2
  1030
@param aGranularity The granularity of the array. 
williamr@2
  1031
  
williamr@2
  1032
@panic E32USER-CBase 17, if the length of the class implied by the template parameter is zero.
williamr@2
  1033
williamr@2
  1034
@panic E32USER-CBase 18, if aGranularity is not positive.
williamr@2
  1035
*/
williamr@2
  1036
	{}
williamr@2
  1037
williamr@2
  1038
williamr@2
  1039
williamr@2
  1040
williamr@2
  1041
template <class T>
williamr@2
  1042
inline void CArrayFixFlat<T>::SetReserveL(TInt aCount)
williamr@2
  1043
/**
williamr@2
  1044
Reserves space in the array buffer.
williamr@2
  1045
williamr@2
  1046
If necessary, the array buffer is allocated or re-allocated so that it can
williamr@2
  1047
accommodate the specified number of elements.
williamr@2
  1048
williamr@2
  1049
After a successful call to this function, elements can be added to the array 
williamr@2
  1050
and the process is guaranteed not to fail for lack of memory - provided the 
williamr@2
  1051
total number of elements does not exceed the number specified in this function.
williamr@2
  1052
williamr@2
  1053
This function does not increase the number of elements in the array; i.e. 
williamr@2
  1054
the member function CArrayFixBase::Count() returns the same value both before 
williamr@2
  1055
and after a call to CArrayFixFlat::SetReserveL().
williamr@2
  1056
williamr@2
  1057
@param aCount The total number of elements for which space is to be reserved. 
williamr@2
  1058
	
williamr@2
  1059
@panic E32USER-CBase 27, if aCount is less than the current number of elements
williamr@2
  1060
                         in the array.
williamr@2
  1061
*/
williamr@2
  1062
	{this->SetReserveFlatL(aCount);}
williamr@2
  1063
williamr@2
  1064
williamr@2
  1065
williamr@2
  1066
williamr@2
  1067
inline CArrayFixFlat<TAny>::CArrayFixFlat(TInt aRecordLength,TInt aGranularity)
williamr@2
  1068
	: CArrayFix<TAny>((TBufRep)CBufFlat::NewL,aRecordLength,aGranularity)
williamr@2
  1069
/**
williamr@2
  1070
Constructs a flat array of fixed length objects with the specified granularity 
williamr@2
  1071
to contain elements of the specified length.
williamr@2
  1072
	
williamr@2
  1073
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1074
	
williamr@2
  1075
@param aRecordLength The length of the elements of this fixed length array. 
williamr@2
  1076
@param aGranularity  The granularity of the array.
williamr@2
  1077
	
williamr@2
  1078
@panic E32USER-CBase 17, if aRecordLength is not positive.
williamr@2
  1079
@panic E32USER-CBase 18, if aGranularity is  not positive.
williamr@2
  1080
*/
williamr@2
  1081
	{}
williamr@2
  1082
williamr@2
  1083
williamr@2
  1084
williamr@2
  1085
williamr@2
  1086
inline void CArrayFixFlat<TAny>::SetReserveL(TInt aCount)
williamr@2
  1087
/**
williamr@2
  1088
Reserves space in the array buffer.
williamr@2
  1089
williamr@2
  1090
If necessary, the array buffer is allocated or re-allocated so that it can
williamr@2
  1091
accommodate the specified number of elements.
williamr@2
  1092
	
williamr@2
  1093
After a successful call to this function, elements can be added to the array 
williamr@2
  1094
and the process is guaranteed not to fail for lack of memory - provided the 
williamr@2
  1095
total number of elements does not exceed the specified number.
williamr@2
  1096
	
williamr@2
  1097
This function does not increase the number of elements in the array; i.e. 
williamr@2
  1098
the member function CArrayFixBase::Count() returns the same value both before 
williamr@2
  1099
and after a call to this function.
williamr@2
  1100
	
williamr@2
  1101
@param aCount The total number of elements for which space is to be reserved. 
williamr@2
  1102
williamr@2
  1103
@panic E32USER-CBase 27, if aCount is less than the current number of elements
williamr@2
  1104
                         in the array.
williamr@2
  1105
*/
williamr@2
  1106
	{SetReserveFlatL(aCount);}
williamr@2
  1107
williamr@2
  1108
williamr@2
  1109
williamr@2
  1110
williamr@2
  1111
inline void CArrayFixFlat<TInt>::SetReserveL(TInt aCount)
williamr@2
  1112
/**
williamr@2
  1113
Reserves space in the array buffer.
williamr@2
  1114
	
williamr@2
  1115
If necessary, the array buffer is allocated or re-allocated so that it can 
williamr@2
  1116
accommodate the specified number of TInt elements.
williamr@2
  1117
	
williamr@2
  1118
After a successful call to this function, elements can be added to the array 
williamr@2
  1119
and the process is guaranteed not to fail for lack of memory - provided the 
williamr@2
  1120
total number of elements does not exceed the specified number.
williamr@2
  1121
	
williamr@2
  1122
This function does not increase the number of elements in the array; i.e. 
williamr@2
  1123
the member function CArrayFixBase::Count() returns the same value both before 
williamr@2
  1124
and after a call to this function.
williamr@2
  1125
	
williamr@2
  1126
@param aCount The total number of elements for which space is to be reserved. 
williamr@2
  1127
williamr@2
  1128
@panic E32USER-CBase 27, if aCount is less than the current number of elements
williamr@2
  1129
                         in the array.
williamr@2
  1130
*/
williamr@2
  1131
	{SetReserveFlatL(aCount);}
williamr@2
  1132
williamr@2
  1133
williamr@2
  1134
williamr@2
  1135
williamr@2
  1136
inline void CArrayFixFlat<TUid>::SetReserveL(TInt aCount)
williamr@2
  1137
/**
williamr@2
  1138
Reserves space in the array buffer.
williamr@2
  1139
	
williamr@2
  1140
If necessary, the array buffer is allocated or re-allocated so that it can 
williamr@2
  1141
accommodate the specified number of TUid elements.
williamr@2
  1142
	
williamr@2
  1143
After a successful call to this function, elements can be added to the array 
williamr@2
  1144
and the process is guaranteed not to fail for lack of memory - provided the 
williamr@2
  1145
total number of elements does not exceed the specified number.
williamr@2
  1146
	
williamr@2
  1147
This function does not increase the number of elements in the array; i.e. 
williamr@2
  1148
the member function CArrayFixBase::Count() returns the same value both before 
williamr@2
  1149
and after a call to this function.
williamr@2
  1150
	
williamr@2
  1151
@param aCount The total number of elements for which space is to be reserved. 
williamr@2
  1152
williamr@2
  1153
@panic E32USER-CBase 27, if aCount is less than the current number of elements
williamr@2
  1154
                         in the array.
williamr@2
  1155
*/
williamr@2
  1156
	{SetReserveFlatL(aCount);}
williamr@2
  1157
williamr@2
  1158
williamr@2
  1159
williamr@2
  1160
williamr@2
  1161
// Template class CArrayFixSeg
williamr@2
  1162
template <class T>
williamr@2
  1163
inline CArrayFixSeg<T>::CArrayFixSeg(TInt aGranularity)
williamr@2
  1164
	: CArrayFix<T>((TBufRep)CBufSeg::NewL,aGranularity)
williamr@2
  1165
/**
williamr@2
  1166
Constructs a segmented array of fixed length objects with the specified
williamr@2
  1167
granularity.
williamr@2
  1168
williamr@2
  1169
The length of all array elements is the length of the class passed as the 
williamr@2
  1170
template parameter. The length must be non-zero.
williamr@2
  1171
williamr@2
  1172
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1173
williamr@2
  1174
@param aGranularity The granularity of the array. 
williamr@2
  1175
williamr@2
  1176
@panic E32USER-CBase 17, if the length of the class implied by the template
williamr@2
  1177
                         parameter is zero.
williamr@2
  1178
@panic E32USER-CBase 18, if aGranularity is not positive.
williamr@2
  1179
*/
williamr@2
  1180
	{}
williamr@2
  1181
williamr@2
  1182
williamr@2
  1183
williamr@2
  1184
williamr@2
  1185
inline CArrayFixSeg<TAny>::CArrayFixSeg(TInt aRecordLength,TInt aGranularity)
williamr@2
  1186
	: CArrayFix<TAny>((TBufRep)CBufSeg::NewL,aRecordLength,aGranularity)
williamr@2
  1187
/**
williamr@2
  1188
Constructs a segmented array of fixed length objects with the specified
williamr@2
  1189
granularity to contain elements of the specified length.
williamr@2
  1190
	
williamr@2
  1191
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1192
	
williamr@2
  1193
@param aRecordLength The length of the elements of this array.
williamr@2
  1194
williamr@2
  1195
@param aGranularity The granularity of the array.
williamr@2
  1196
williamr@2
  1197
@panic E32USER-CBase 17, if aRecordLength is not positive.
williamr@2
  1198
@panic E32USER-CBase 18, if aGranularity is not positive.
williamr@2
  1199
*/
williamr@2
  1200
	{}
williamr@2
  1201
williamr@2
  1202
williamr@2
  1203
williamr@2
  1204
williamr@2
  1205
// Template class CArrayPtr
williamr@2
  1206
template <class T>
williamr@2
  1207
inline CArrayPtr<T>::CArrayPtr(TBufRep aRep,TInt aGranularity)
williamr@2
  1208
	: CArrayFix<T*>(aRep,aGranularity)
williamr@2
  1209
/**
williamr@2
  1210
@internalComponent
williamr@2
  1211
*/
williamr@2
  1212
	{}
williamr@2
  1213
williamr@2
  1214
williamr@2
  1215
williamr@2
  1216
williamr@2
  1217
template <class T>
williamr@2
  1218
void CArrayPtr<T>::ResetAndDestroy()
williamr@2
  1219
/**
williamr@2
  1220
Destroys all objects whose pointers form the elements of the array, before 
williamr@2
  1221
resetting the array.
williamr@2
  1222
williamr@2
  1223
The destructor of each class T object is called before the objects themselves 
williamr@2
  1224
are destroyed.
williamr@2
  1225
williamr@2
  1226
If the array is not empty, this member function must be called before the 
williamr@2
  1227
array is deleted to prevent the CBase derived objects from being orphaned 
williamr@2
  1228
on the heap.
williamr@2
  1229
williamr@2
  1230
Note that each call to this function results in a small, but non-trivial,
williamr@2
  1231
amount of code being generated.
williamr@2
  1232
*/
williamr@2
  1233
	{
williamr@2
  1234
	for (TInt i=0;i<this->Count();++i)
williamr@2
  1235
		delete this->At(i);
williamr@2
  1236
	this->Reset();
williamr@2
  1237
	}
williamr@2
  1238
williamr@2
  1239
williamr@2
  1240
williamr@2
  1241
williamr@2
  1242
// Template class CArrayPtrFlat
williamr@2
  1243
template <class T>
williamr@2
  1244
inline CArrayPtrFlat<T>::CArrayPtrFlat(TInt aGranularity)
williamr@2
  1245
	: CArrayPtr<T>((TBufRep)CBufFlat::NewL,aGranularity)
williamr@2
  1246
/** 
williamr@2
  1247
Constructs a flat array of pointers with specified granularity.
williamr@2
  1248
williamr@2
  1249
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1250
williamr@2
  1251
@param aGranularity The granularity of the array. 
williamr@2
  1252
williamr@2
  1253
@panic E32USER-CBase 18, if aGranularity is not positive.
williamr@2
  1254
*/
williamr@2
  1255
	{}
williamr@2
  1256
williamr@2
  1257
williamr@2
  1258
williamr@2
  1259
williamr@2
  1260
template <class T>
williamr@2
  1261
inline void CArrayPtrFlat<T>::SetReserveL(TInt aCount)
williamr@2
  1262
/**
williamr@2
  1263
Reserves space in the array buffer.
williamr@2
  1264
williamr@2
  1265
If necessary, the array buffer is allocated or re-allocated so that it can
williamr@2
  1266
accommodate the specified number of elements.
williamr@2
  1267
williamr@2
  1268
After a successful call to this function, elements can be added to the array 
williamr@2
  1269
and the process is guaranteed not to fail for lack of memory - provided the 
williamr@2
  1270
total number of elements does not exceed the specified number.
williamr@2
  1271
williamr@2
  1272
This function does not increase the number of elements in the array; i.e. 
williamr@2
  1273
the member function CArrayFixBase::Count() returns the same value both before 
williamr@2
  1274
and after a call to this function.
williamr@2
  1275
williamr@2
  1276
@param aCount The total number of elements for which space is to be reserved. 
williamr@2
  1277
williamr@2
  1278
@panic E32USER-CBase 27, if aCount is less than the current number of elements
williamr@2
  1279
       in the array.
williamr@2
  1280
*/
williamr@2
  1281
	{this->SetReserveFlatL(aCount);}
williamr@2
  1282
williamr@2
  1283
williamr@2
  1284
williamr@2
  1285
williamr@2
  1286
// Template class CArrayPtrSeg
williamr@2
  1287
template <class T>
williamr@2
  1288
inline CArrayPtrSeg<T>::CArrayPtrSeg(TInt aGranularity)
williamr@2
  1289
	: CArrayPtr<T>((TBufRep)CBufSeg::NewL,aGranularity)
williamr@2
  1290
/**
williamr@2
  1291
Constructs a segmented array of pointers with specified granularity.
williamr@2
  1292
williamr@2
  1293
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1294
williamr@2
  1295
@param aGranularity The granularity of the array. 
williamr@2
  1296
williamr@2
  1297
@panic E32USER-CBase 18, if aGranularity is not positive.
williamr@2
  1298
*/
williamr@2
  1299
	{}
williamr@2
  1300
williamr@2
  1301
williamr@2
  1302
williamr@2
  1303
williamr@2
  1304
// Class CArrayVarBase
williamr@2
  1305
inline TInt CArrayVarBase::Count() const
williamr@2
  1306
/**
williamr@2
  1307
Gets the number of elements held in the array.
williamr@2
  1308
williamr@2
  1309
@return The number of array elements.
williamr@2
  1310
*/
williamr@2
  1311
	{return(iCount);}
williamr@2
  1312
williamr@2
  1313
williamr@2
  1314
williamr@2
  1315
williamr@2
  1316
// Template class CArrayVar
williamr@2
  1317
template <class T>
williamr@2
  1318
inline CArrayVar<T>::CArrayVar(TBufRep aRep,TInt aGranularity)
williamr@2
  1319
	: CArrayVarBase(aRep,aGranularity)
williamr@2
  1320
/**
williamr@2
  1321
@internalComponent
williamr@2
  1322
*/
williamr@2
  1323
	{}
williamr@2
  1324
williamr@2
  1325
williamr@2
  1326
williamr@2
  1327
williamr@2
  1328
template <class T>
williamr@2
  1329
inline const T &CArrayVar<T>::operator[](TInt anIndex) const
williamr@2
  1330
/** 
williamr@2
  1331
Gets a reference to the const element located at the specified position 
williamr@2
  1332
within the array.
williamr@2
  1333
williamr@2
  1334
The compiler uses this variant of the function if the returned reference is 
williamr@2
  1335
used in an expression where it cannot be modified.
williamr@2
  1336
williamr@2
  1337
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  1338
               i.e. zero implies the first element.
williamr@2
  1339
			   
williamr@2
  1340
@return A const reference to the element located at position anIndex within 
williamr@2
  1341
        the array. 
williamr@2
  1342
williamr@2
  1343
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
  1344
       number of objects currently within the array.
williamr@2
  1345
*/
williamr@2
  1346
	{return(*((const T *)CArrayVarBase::At(anIndex)));}
williamr@2
  1347
williamr@2
  1348
williamr@2
  1349
williamr@2
  1350
williamr@2
  1351
template <class T>
williamr@2
  1352
inline T &CArrayVar<T>::operator[](TInt anIndex)
williamr@2
  1353
/**
williamr@2
  1354
Gets a reference to the element located at the specified position within 
williamr@2
  1355
the array.
williamr@2
  1356
williamr@2
  1357
The compiler uses this variant of the function if the returned reference is 
williamr@2
  1358
used in an expression where it can be modified.
williamr@2
  1359
williamr@2
  1360
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  1361
               i.e. zero implies the first element.
williamr@2
  1362
williamr@2
  1363
williamr@2
  1364
@return A reference to the non-const element located at position anIndex within 
williamr@2
  1365
        the array.
williamr@2
  1366
williamr@2
  1367
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
  1368
       number of objects currently within the array.
williamr@2
  1369
*/
williamr@2
  1370
	{return(*((T *)CArrayVarBase::At(anIndex)));}
williamr@2
  1371
williamr@2
  1372
williamr@2
  1373
williamr@2
  1374
williamr@2
  1375
template <class T>
williamr@2
  1376
inline const T &CArrayVar<T>::At(TInt anIndex) const
williamr@2
  1377
/** 
williamr@2
  1378
Gets a reference to the const element located at the specified position 
williamr@2
  1379
within the array.
williamr@2
  1380
williamr@2
  1381
The compiler uses this variant of the function if the returned reference is 
williamr@2
  1382
used in an expression where it cannot be modified.
williamr@2
  1383
williamr@2
  1384
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  1385
               i.e. zero implies the first element.
williamr@2
  1386
			   
williamr@2
  1387
@return A const reference to the element located at position anIndex within 
williamr@2
  1388
        the array. 
williamr@2
  1389
williamr@2
  1390
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
  1391
       number of objects currently within the array.
williamr@2
  1392
*/
williamr@2
  1393
	{return(*((const T *)CArrayVarBase::At(anIndex)));}
williamr@2
  1394
williamr@2
  1395
williamr@2
  1396
williamr@2
  1397
template <class T>
williamr@2
  1398
inline T &CArrayVar<T>::At(TInt anIndex)
williamr@2
  1399
/**
williamr@2
  1400
Gets a reference to the element located at the specified position within 
williamr@2
  1401
the array.
williamr@2
  1402
williamr@2
  1403
The compiler uses this variant of the function if the returned reference is 
williamr@2
  1404
used in an expression where it can be modified.
williamr@2
  1405
williamr@2
  1406
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  1407
               i.e. zero implies the first element.
williamr@2
  1408
williamr@2
  1409
@return A reference to the non-const element located at position anIndex within 
williamr@2
  1410
        the array.
williamr@2
  1411
williamr@2
  1412
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
  1413
       number of objects currently within the array.
williamr@2
  1414
*/
williamr@2
  1415
	{return(*((T *)CArrayVarBase::At(anIndex)));}
williamr@2
  1416
williamr@2
  1417
williamr@2
  1418
williamr@2
  1419
williamr@2
  1420
template <class T>
williamr@2
  1421
inline void CArrayVar<T>::AppendL(const T &aRef,TInt aLength)
williamr@2
  1422
/**
williamr@2
  1423
Appends an element of a specified length onto the array.
williamr@2
  1424
williamr@2
  1425
@param aRef    A reference to the <class T> element to be appended.
williamr@2
  1426
@param aLength The length of the element to be appended.
williamr@2
  1427
williamr@2
  1428
@leave KErrNoMemory The function always attempts to allocate a cell to
williamr@2
  1429
       contain the new element and may also attempt to expand the array buffer.
williamr@2
  1430
	   If there is insufficient memory available, the function leaves, in which
williamr@2
  1431
	   case, the array is left in the state it was in before the call.
williamr@2
  1432
williamr@2
  1433
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  1434
*/
williamr@2
  1435
	{CArrayVarBase::InsertL(Count(),&aRef,aLength);}
williamr@2
  1436
williamr@2
  1437
williamr@2
  1438
williamr@2
  1439
williamr@2
  1440
template <class T>
williamr@2
  1441
inline T &CArrayVar<T>::ExpandL(TInt anIndex,TInt aLength)
williamr@2
  1442
/**
williamr@2
  1443
Expands the array by one element of specified length at the specified position. 
williamr@2
  1444
williamr@2
  1445
It:
williamr@2
  1446
williamr@2
  1447
1. expands the array by one element position anIndex
williamr@2
  1448
williamr@2
  1449
2. constructs a new element of specified length at that position
williamr@2
  1450
williamr@2
  1451
3. returns a reference to the new element.
williamr@2
  1452
williamr@2
  1453
All existing elements from position anIndex to the end of the array are moved 
williamr@2
  1454
up, so that the element originally at position anIndex is now at position 
williamr@2
  1455
anIndex + 1 etc.
williamr@2
  1456
williamr@2
  1457
The new element of type <class T> and length aLength is constructed at position 
williamr@2
  1458
anIndex, using the default constructor of that class.
williamr@2
  1459
williamr@2
  1460
@param anIndex The position within the array where the array is to be expanded 
williamr@2
  1461
               and the new <class T> object is to be constructed.
williamr@2
  1462
			   
williamr@2
  1463
@param aLength The length of the new element. 
williamr@2
  1464
williamr@2
  1465
@return A reference to the newly constructed <class T> object at position 
williamr@2
  1466
        anIndex within the array.
williamr@2
  1467
williamr@2
  1468
@leave KErrNoMemory The function always attempts to allocate a cell to contain 
williamr@2
  1469
       the new element and may also attempt to expand the array buffer. If there 
williamr@2
  1470
       is insufficient memory available, the function leaves, in which case, the 
williamr@2
  1471
       array is left in the state it was in before the call.
williamr@2
  1472
williamr@2
  1473
@panic E32USER-CBase 21, if anIndex is negative or is greater than the number
williamr@2
  1474
       of elements currently in the array.
williamr@2
  1475
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  1476
*/
williamr@2
  1477
	{return(*new(CArrayVarBase::ExpandL(anIndex,aLength)) T);}
williamr@2
  1478
williamr@2
  1479
williamr@2
  1480
williamr@2
  1481
williamr@2
  1482
template <class T>
williamr@2
  1483
inline T &CArrayVar<T>::ExtendL(TInt aLength)
williamr@2
  1484
/**
williamr@2
  1485
Expands the array by one element of specified length at the end of the array. 
williamr@2
  1486
williamr@2
  1487
It:
williamr@2
  1488
williamr@2
  1489
1. expands the array by one element at the end of the array, i.e. at position 
williamr@2
  1490
   CArrayVarBase::Count()
williamr@2
  1491
williamr@2
  1492
2. constructs a new element of specified length at that position.
williamr@2
  1493
williamr@2
  1494
3. returns a reference to the new element.
williamr@2
  1495
williamr@2
  1496
The new element of type <class T> is constructed at the end of the array, 
williamr@2
  1497
using the default constructor of that class.
williamr@2
  1498
williamr@2
  1499
@param aLength The length of the new element.
williamr@2
  1500
williamr@2
  1501
@return A reference to the newly constructed <class T> object at the end of 
williamr@2
  1502
        the array.
williamr@2
  1503
williamr@2
  1504
@leave KErrNoMemory The function always attempts to allocate a cell to contain 
williamr@2
  1505
       the new element and may also attempt to expand the array buffer. If there 
williamr@2
  1506
       is insufficient memory available, the function leaves, in which case, the 
williamr@2
  1507
       array is left in the state it was in before the call.
williamr@2
  1508
  
williamr@2
  1509
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  1510
*/
williamr@2
  1511
	{return(*new(CArrayVarBase::ExpandL(Count(),aLength)) T);}
williamr@2
  1512
williamr@2
  1513
williamr@2
  1514
williamr@2
  1515
williamr@2
  1516
template <class T>
williamr@2
  1517
inline TInt CArrayVar<T>::Find(const T &aRef,TKeyArrayVar &aKey,TInt &anIndex) const
williamr@2
  1518
/**
williamr@2
  1519
Finds the position of an element within the array, based on the matching of 
williamr@2
  1520
keys, using a sequential search.
williamr@2
  1521
williamr@2
  1522
The array is searched sequentially for an element whose key matches the key 
williamr@2
  1523
of the supplied object. The search starts with the first element in the array.
williamr@2
  1524
williamr@2
  1525
Note that where an array has elements with duplicate keys, the function only
williamr@2
  1526
supplies the position of the first element in the array with that key.
williamr@2
  1527
williamr@2
  1528
@param aRef    A reference to an object of type <class T> whose key is used 
williamr@2
  1529
               for comparison.
williamr@2
  1530
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  1531
@param anIndex A TInt supplied by the caller. On return, if the element is
williamr@2
  1532
               found, this is set to the position of that element
williamr@2
  1533
			   within the array. The position is relative to zero, (i.e. 
williamr@2
  1534
               the first element in the array is at position 0).
williamr@2
  1535
			   If the element is not found or the array is empty, then
williamr@2
  1536
			   this is undefined.
williamr@2
  1537
williamr@2
  1538
@return Zero, if the element with the specified key is found. Non-zero, if 
williamr@2
  1539
        the element with the specified key is not found.
williamr@2
  1540
*/
williamr@2
  1541
	{return(CArrayVarBase::Find(&aRef,aKey,anIndex));}
williamr@2
  1542
williamr@2
  1543
williamr@2
  1544
williamr@2
  1545
williamr@2
  1546
template <class T>
williamr@2
  1547
inline TInt CArrayVar<T>::FindIsq(const T &aRef,TKeyArrayVar &aKey,TInt &anIndex) const
williamr@2
  1548
/**
williamr@2
  1549
Finds the position of an element within the array, based on the matching of 
williamr@2
  1550
keys, using a binary search technique.
williamr@2
  1551
williamr@2
  1552
The array is searched, using a binary search technique, for an element whose 
williamr@2
  1553
key matches the key of the supplied <class T> object.
williamr@2
  1554
williamr@2
  1555
The array must be in key order.
williamr@2
  1556
williamr@2
  1557
Note that where an array has elements with duplicate keys, the function cannot
williamr@2
  1558
guarantee which element, with the given key value, it will return, except that
williamr@2
  1559
it will find one of them.
williamr@2
  1560
williamr@2
  1561
@param aRef    A reference to an object of type <class T> whose key is used 
williamr@2
  1562
               for comparison.
williamr@2
  1563
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  1564
@param anIndex A TInt supplied by the caller. On return, if the element is
williamr@2
  1565
               found, this is set to the position  of that element within
williamr@2
  1566
			   the array. The position is relative to zero, (i.e. 
williamr@2
  1567
               the first element in the array is at position zero).
williamr@2
  1568
			   If the element is not found and the array is not empty, then
williamr@2
  1569
			   this is set to the position of the first element in the array
williamr@2
  1570
			   with a key which is greater than the key of the object aRef.
williamr@2
  1571
			   If the element is not found and the array is empty, then 
williamr@2
  1572
               this is undefined.
williamr@2
  1573
williamr@2
  1574
@return Zero, if the element with the specified key is found or the array is 
williamr@2
  1575
        empty. Non-zero, if the element with the specified key is not found.
williamr@2
  1576
*/
williamr@2
  1577
	{return(CArrayVarBase::FindIsq(&aRef,aKey,anIndex));}
williamr@2
  1578
williamr@2
  1579
williamr@2
  1580
williamr@2
  1581
williamr@2
  1582
template <class T>
williamr@2
  1583
inline void CArrayVar<T>::InsertL(TInt anIndex,const T &aRef,TInt aLength)
williamr@2
  1584
/**
williamr@2
  1585
Inserts an element of a specified length into the array at the specified
williamr@2
  1586
position.
williamr@2
  1587
williamr@2
  1588
Note that passing a value of anIndex which is the same as the current number
williamr@2
  1589
of elements in the array, has the effect of appending that element.
williamr@2
  1590
williamr@2
  1591
@param anIndex The position within the array where the element is to be
williamr@2
  1592
               inserted. The position is relative to zero, i.e. zero implies
williamr@2
  1593
			   that elements are inserted at the beginning of the array.
williamr@2
  1594
@param aRef    A reference to the <class T> object to be inserted into
williamr@2
  1595
               the array.
williamr@2
  1596
@param aLength The length of the element to be inserted into the array. 
williamr@2
  1597
williamr@2
  1598
@leave KErrNoMemory The function always attempts to allocate a cell to contain 
williamr@2
  1599
       the new element and may also attempt to expand the array buffer. If
williamr@2
  1600
	   there is insufficient memory available, the function leaves, in which
williamr@2
  1601
	   case, the array is left in the state it was in before the call.
williamr@2
  1602
williamr@2
  1603
@panic E32USER-CBase 21, if anIndex is negative or is greater than the number
williamr@2
  1604
       of objects currently in the array.
williamr@2
  1605
@panic E32USER-CBase 30, if aLength is is negative.
williamr@2
  1606
*/
williamr@2
  1607
	{CArrayVarBase::InsertL(anIndex,&aRef,aLength);}
williamr@2
  1608
williamr@2
  1609
williamr@2
  1610
williamr@2
  1611
williamr@2
  1612
template <class T>
williamr@2
  1613
inline TInt CArrayVar<T>::InsertIsqL(const T &aRef,TInt aLength,TKeyArrayVar &aKey)
williamr@2
  1614
/**
williamr@2
  1615
Inserts a single element of a specified length into the array at a position 
williamr@2
  1616
determined by a key.
williamr@2
  1617
williamr@2
  1618
The array MUST already be in key sequence (as defined by the key), otherwise 
williamr@2
  1619
the position of the new element is unpredictable, or duplicates may occur.
williamr@2
  1620
williamr@2
  1621
Elements with duplicate keys are not permitted.
williamr@2
  1622
williamr@2
  1623
@param aRef    A reference to the element of type <class T> to be inserted into 
williamr@2
  1624
               the array.
williamr@2
  1625
@param aLength The length of the new element of type <class T> to be inserted 
williamr@2
  1626
               into the array.
williamr@2
  1627
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  1628
williamr@2
  1629
@return The position within the array of the newly inserted element.
williamr@2
  1630
williamr@2
  1631
@leave KErrAlreadyExists An element with the same key already exists within 
williamr@2
  1632
       the array. NB the array MUST already be in key sequence, otherwise
williamr@2
  1633
	   the function may insert a duplicate and fail to leave with
williamr@2
  1634
	   this value.
williamr@2
  1635
@leave KErrNoMemory The function always attempts to allocate a cell to contain 
williamr@2
  1636
       the new element and may also attempt to expand the array buffer. If
williamr@2
  1637
	   there is insufficient memory available, the function leaves, in which
williamr@2
  1638
	   case, the array is left in the state it was in before the call.
williamr@2
  1639
*/
williamr@2
  1640
	{return(CArrayVarBase::InsertIsqL(&aRef,aLength,aKey));}
williamr@2
  1641
williamr@2
  1642
williamr@2
  1643
williamr@2
  1644
williamr@2
  1645
template <class T>
williamr@2
  1646
inline TInt CArrayVar<T>::InsertIsqAllowDuplicatesL(const T &aRef,TInt aLength,TKeyArrayVar &aKey)
williamr@2
  1647
/**
williamr@2
  1648
Inserts a single element of a specified length into the array at a position 
williamr@2
  1649
determined by a key, allowing duplicates.
williamr@2
  1650
williamr@2
  1651
The array MUST already be in key sequence, otherwise the position of the 
williamr@2
  1652
new element is unpredictable.
williamr@2
  1653
williamr@2
  1654
Elements with duplicate keys are permitted. If the new element's key is a 
williamr@2
  1655
duplicate of an existing element's key, then the new element is positioned 
williamr@2
  1656
after the existing element.
williamr@2
  1657
williamr@2
  1658
@param aRef    A reference to the element of type <class T> to be inserted
williamr@2
  1659
               into the array.
williamr@2
  1660
@param aLength The length of the new element to be inserted into the array. 
williamr@2
  1661
@param aKey    A reference to a key object defining the properties of the key. 
williamr@2
  1662
williamr@2
  1663
@return The position within the array of the newly inserted element.
williamr@2
  1664
williamr@2
  1665
@leave KErrNoMemory The function always attempts to allocate a cell to contain 
williamr@2
  1666
       the new element and may also attempt to expand the array buffer. If
williamr@2
  1667
	   there is insufficient memory available, the function leaves, in which
williamr@2
  1668
	   case, the array is left in the state it was in before the call.
williamr@2
  1669
*/
williamr@2
  1670
	{return(CArrayVarBase::InsertIsqAllowDuplicatesL(&aRef,aLength,aKey));}
williamr@2
  1671
williamr@2
  1672
williamr@2
  1673
williamr@2
  1674
williamr@2
  1675
template <class T>
williamr@2
  1676
inline const TArray<T> CArrayVar<T>::Array() const
williamr@2
  1677
/**
williamr@2
  1678
Constructs and returns a TArray<T> object.
williamr@2
  1679
williamr@2
  1680
@return A TArray<T> object for this array.
williamr@2
  1681
*/
williamr@2
  1682
	{return(TArray<T>(CountR,AtR,this));}
williamr@2
  1683
williamr@2
  1684
williamr@2
  1685
williamr@2
  1686
williamr@2
  1687
inline const TAny *CArrayVar<TAny>::At(TInt anIndex) const
williamr@2
  1688
/**
williamr@2
  1689
Returns a pointer to the untyped element located at the specified position 
williamr@2
  1690
within the array.
williamr@2
  1691
	
williamr@2
  1692
The compiler uses this variant of the function if the returned pointer is 
williamr@2
  1693
used in an expression where it cannot be modified.
williamr@2
  1694
	
williamr@2
  1695
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  1696
	           i.e. zero implies the first element.
williamr@2
  1697
williamr@2
  1698
@return A pointer to the const element located at position anIndex within the 
williamr@2
  1699
        array.
williamr@2
  1700
williamr@2
  1701
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
  1702
       number of objects currently within the array.
williamr@2
  1703
*/
williamr@2
  1704
	{return(CArrayVarBase::At(anIndex));}
williamr@2
  1705
williamr@2
  1706
williamr@2
  1707
williamr@2
  1708
williamr@2
  1709
inline CArrayVar<TAny>::CArrayVar(TBufRep aRep,TInt aGranularity)
williamr@2
  1710
	: CArrayVarBase(aRep,aGranularity)
williamr@2
  1711
/**
williamr@2
  1712
Constructs a variable array with the specified granularity and buffer
williamr@2
  1713
organization.
williamr@2
  1714
	
williamr@2
  1715
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1716
	
williamr@2
  1717
@param aRep         A pointer to a function used to expand the array buffer.
williamr@2
  1718
                    The organisation of the array buffer is implied by the
williamr@2
  1719
					choice of this function.
williamr@2
  1720
			        For a flat array buffer, pass (TBufRep)CBufFlat::NewL.
williamr@2
  1721
			        For a segmented array buffer, pass (TBufRep)CBufSeg::NewL. 
williamr@2
  1722
@param aGranularity The granularity of the array. 
williamr@2
  1723
williamr@2
  1724
@panic E32USER-CBase 19, if aGranularity is not positive.
williamr@2
  1725
*/
williamr@2
  1726
	{}
williamr@2
  1727
williamr@2
  1728
williamr@2
  1729
williamr@2
  1730
williamr@2
  1731
inline TAny *CArrayVar<TAny>::At(TInt anIndex)
williamr@2
  1732
/**
williamr@2
  1733
Returns a pointer to the untyped element located at the specified position 
williamr@2
  1734
within the array.
williamr@2
  1735
	
williamr@2
  1736
The compiler uses this variant of the function if the returned pointer is 
williamr@2
  1737
used in an expression where it can be modified.
williamr@2
  1738
	
williamr@2
  1739
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  1740
	           i.e. zero implies the first element.
williamr@2
  1741
williamr@2
  1742
@return A pointer to the non-const element located at position anIndex within the 
williamr@2
  1743
        array.
williamr@2
  1744
williamr@2
  1745
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to the
williamr@2
  1746
       number of objects currently within the array.
williamr@2
  1747
*/
williamr@2
  1748
	{return(CArrayVarBase::At(anIndex));}
williamr@2
  1749
williamr@2
  1750
williamr@2
  1751
williamr@2
  1752
williamr@2
  1753
inline void CArrayVar<TAny>::AppendL(const TAny *aPtr,TInt aLength)
williamr@2
  1754
/**
williamr@2
  1755
Appends an untyped element of specified length onto the end of the array.
williamr@2
  1756
	
williamr@2
  1757
@param aPtr    A pointer to an untyped element to be appended. 
williamr@2
  1758
@param aLength The length of the untyped element.
williamr@2
  1759
*/
williamr@2
  1760
	{CArrayVarBase::InsertL(Count(),aPtr,aLength);}
williamr@2
  1761
williamr@2
  1762
williamr@2
  1763
williamr@2
  1764
williamr@2
  1765
inline TAny *CArrayVar<TAny>::ExtendL(TInt aLength)
williamr@2
  1766
/**
williamr@2
  1767
Extends the array by one element of specified length at the end of the array,
williamr@2
  1768
i.e. at position CArrayVarBase::Count(), and returns a pointer to the new
williamr@2
  1769
element location.
williamr@2
  1770
williamr@2
  1771
As elements are untyped, no construction is possible and the content of the
williamr@2
  1772
new location remains undefined.
williamr@2
  1773
williamr@2
  1774
Note that the function always attempts to allocate a cell to contain the new
williamr@2
  1775
element and may also attempt to expand the array buffer. If there is
williamr@2
  1776
insufficient memory available, the function leaves.
williamr@2
  1777
The leave code is one of the system wide error codes.
williamr@2
  1778
If the function leaves, the array is left in the state it was in before
williamr@2
  1779
the call. 
williamr@2
  1780
williamr@2
  1781
@param aLength The length of the new element.
williamr@2
  1782
williamr@2
  1783
@return A pointer to the new element location at the end of the array. 
williamr@2
  1784
*/
williamr@2
  1785
	{return(CArrayVarBase::ExpandL(Count(),aLength));}
williamr@2
  1786
williamr@2
  1787
williamr@2
  1788
williamr@2
  1789
williamr@2
  1790
// Template class CArrayVarFlat
williamr@2
  1791
template <class T>
williamr@2
  1792
inline CArrayVarFlat<T>::CArrayVarFlat(TInt aGranularity)
williamr@2
  1793
	: CArrayVar<T>((TBufRep)CBufFlat::NewL,aGranularity)
williamr@2
  1794
/**
williamr@2
  1795
Constructs a variable flat array with specified granularity.
williamr@2
  1796
williamr@2
  1797
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1798
williamr@2
  1799
@param aGranularity The granularity of the array. 
williamr@2
  1800
williamr@2
  1801
@panic E32USER-CBase 19, if aGranularity is not positive.
williamr@2
  1802
*/
williamr@2
  1803
	{}
williamr@2
  1804
williamr@2
  1805
williamr@2
  1806
williamr@2
  1807
williamr@2
  1808
// Template class CArrayVarSeg
williamr@2
  1809
template <class T>
williamr@2
  1810
inline CArrayVarSeg<T>::CArrayVarSeg(TInt aGranularity)
williamr@2
  1811
	: CArrayVar<T>((TBufRep)CBufSeg::NewL,aGranularity)
williamr@2
  1812
/**
williamr@2
  1813
Constructs a variable segmented array with specified granularity.
williamr@2
  1814
williamr@2
  1815
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  1816
williamr@2
  1817
@param aGranularity The granularity of the array.
williamr@2
  1818
williamr@2
  1819
@panic E32USER-CBase 19, if aGranularity is not positive.
williamr@2
  1820
*/
williamr@2
  1821
	{}
williamr@2
  1822
williamr@2
  1823
williamr@2
  1824
williamr@2
  1825
williamr@2
  1826
// Class CArrayPakBase
williamr@2
  1827
inline TInt CArrayPakBase::Count() const
williamr@2
  1828
/**
williamr@2
  1829
Gets the number of elements held in the array.
williamr@2
  1830
williamr@2
  1831
@return The number of array elements.
williamr@2
  1832
*/
williamr@2
  1833
	{return(iCount);}
williamr@2
  1834
williamr@2
  1835
williamr@2
  1836
williamr@2
  1837
williamr@2
  1838
// Template class CArrayPak
williamr@2
  1839
template <class T>
williamr@2
  1840
inline CArrayPak<T>::CArrayPak(TBufRep aRep,TInt aGranularity)
williamr@2
  1841
	: CArrayPakBase(aRep,aGranularity)
williamr@2
  1842
/**
williamr@2
  1843
@internalComponent
williamr@2
  1844
*/
williamr@2
  1845
	{}
williamr@2
  1846
williamr@2
  1847
williamr@2
  1848
williamr@2
  1849
williamr@2
  1850
template <class T>
williamr@2
  1851
inline const T &CArrayPak<T>::operator[](TInt anIndex) const
williamr@2
  1852
/**
williamr@2
  1853
Gets a reference to the element located at the specified position within the 
williamr@2
  1854
array.
williamr@2
  1855
williamr@2
  1856
The compiler uses this variant of the function when the returned reference 
williamr@2
  1857
is used in an expression where it cannot be modified.
williamr@2
  1858
williamr@2
  1859
@param anIndex The position of the element within the array. The position 
williamr@2
  1860
               is relative to zero; i.e. zero implies the first element in
williamr@2
  1861
			   the array.  
williamr@2
  1862
		
williamr@2
  1863
@return A const reference to the element located at position anIndex within 
williamr@2
  1864
        the array.
williamr@2
  1865
williamr@2
  1866
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
  1867
       number of objects currently within the array.
williamr@2
  1868
*/
williamr@2
  1869
	{return(*((const T *)CArrayPakBase::At(anIndex)));}
williamr@2
  1870
williamr@2
  1871
williamr@2
  1872
williamr@2
  1873
williamr@2
  1874
template <class T>
williamr@2
  1875
inline T &CArrayPak<T>::operator[](TInt anIndex)
williamr@2
  1876
/**
williamr@2
  1877
Gets a reference to the element located at the specified position within the 
williamr@2
  1878
array.
williamr@2
  1879
williamr@2
  1880
The compiler uses this variant of the function when the returned reference 
williamr@2
  1881
is used in an expression where it can be modified.
williamr@2
  1882
williamr@2
  1883
@param anIndex The position of the element within the array. The position 
williamr@2
  1884
               is relative to zero; i.e. zero implies the first element in
williamr@2
  1885
			   the array.  
williamr@2
  1886
		
williamr@2
  1887
@return A non-const reference to the element located at position anIndex within 
williamr@2
  1888
        the array.
williamr@2
  1889
williamr@2
  1890
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
  1891
       number of objects currently within the array.
williamr@2
  1892
*/
williamr@2
  1893
	{return(*((T *)CArrayPakBase::At(anIndex)));}
williamr@2
  1894
williamr@2
  1895
williamr@2
  1896
williamr@2
  1897
williamr@2
  1898
template <class T>
williamr@2
  1899
inline const T &CArrayPak<T>::At(TInt anIndex) const
williamr@2
  1900
/**
williamr@2
  1901
Gets a reference to the element located at the specified position within the 
williamr@2
  1902
array.
williamr@2
  1903
williamr@2
  1904
The compiler uses this variant of the function when the returned reference 
williamr@2
  1905
is used in an expression where it cannot be modified.
williamr@2
  1906
williamr@2
  1907
@param anIndex The position of the element within the array. The position 
williamr@2
  1908
               is relative to zero; i.e. zero implies the first element in
williamr@2
  1909
			   the array.  
williamr@2
  1910
		
williamr@2
  1911
@return A const reference to the element located at position anIndex within 
williamr@2
  1912
        the array.
williamr@2
  1913
williamr@2
  1914
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
  1915
       number of objects currently within the array.
williamr@2
  1916
*/
williamr@2
  1917
	{return(*((const T *)CArrayPakBase::At(anIndex)));}
williamr@2
  1918
williamr@2
  1919
williamr@2
  1920
williamr@2
  1921
williamr@2
  1922
template <class T>
williamr@2
  1923
inline T &CArrayPak<T>::At(TInt anIndex)
williamr@2
  1924
/**
williamr@2
  1925
Gets a reference to the element located at the specified position within the 
williamr@2
  1926
array.
williamr@2
  1927
williamr@2
  1928
The compiler uses this variant of the function when the returned reference 
williamr@2
  1929
is used in an expression where it can be modified.
williamr@2
  1930
williamr@2
  1931
@param anIndex The position of the element within the array. The position 
williamr@2
  1932
               is relative to zero; i.e. zero implies the first element in
williamr@2
  1933
			   the array.  
williamr@2
  1934
		
williamr@2
  1935
@return A non-const reference to the element located at position anIndex within 
williamr@2
  1936
        the array.
williamr@2
  1937
williamr@2
  1938
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
  1939
       number of objects currently within the array.
williamr@2
  1940
*/
williamr@2
  1941
	{return(*((T *)CArrayPakBase::At(anIndex)));}
williamr@2
  1942
williamr@2
  1943
williamr@2
  1944
williamr@2
  1945
williamr@2
  1946
template <class T>
williamr@2
  1947
inline void CArrayPak<T>::AppendL(const T &aRef,TInt aLength)
williamr@2
  1948
/**
williamr@2
  1949
Appends an element of a specified length onto the array.
williamr@2
  1950
williamr@2
  1951
@param aRef    A reference to the class T element to be appended.
williamr@2
  1952
@param aLength The length of the element to be appended.
williamr@2
  1953
williamr@2
  1954
@leave KErrNoMemory The function attempted to allocate from the heap and there 
williamr@2
  1955
       is insufficient memory available. In this case, the array is left in
williamr@2
  1956
	   the state it was in before the call.
williamr@2
  1957
williamr@2
  1958
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  1959
*/
williamr@2
  1960
	{CArrayPakBase::InsertL(Count(),&aRef,aLength);}
williamr@2
  1961
williamr@2
  1962
williamr@2
  1963
williamr@2
  1964
williamr@2
  1965
template <class T>
williamr@2
  1966
inline T &CArrayPak<T>::ExpandL(TInt anIndex,TInt aLength)
williamr@2
  1967
/**
williamr@2
  1968
Expands the array by one element of specified length at the specified position. 
williamr@2
  1969
williamr@2
  1970
It:
williamr@2
  1971
williamr@2
  1972
1. expands the array by one element at the specified position.
williamr@2
  1973
williamr@2
  1974
2. constructs a new element of specified length at that position.
williamr@2
  1975
williamr@2
  1976
3. returns a reference to the new element.
williamr@2
  1977
williamr@2
  1978
All existing elements from position anIndex to the end of the array are moved 
williamr@2
  1979
up, so that the element originally at position anIndex is now at position 
williamr@2
  1980
anIndex + 1 etc.
williamr@2
  1981
williamr@2
  1982
The new element of type <class T> and length aLength is constructed at position 
williamr@2
  1983
anIndex, using the default constructor of that class.
williamr@2
  1984
williamr@2
  1985
@param anIndex The position within the array where the array is to be expanded 
williamr@2
  1986
               and the new <class T> object is to be constructed. 
williamr@2
  1987
@param aLength The length of the new element.
williamr@2
  1988
williamr@2
  1989
@return A reference to the newly constructed <class T> object at position 
williamr@2
  1990
        anIndex within the array.
williamr@2
  1991
williamr@2
  1992
@leave KErrNoMemory The function attempted to allocate from the heap and there 
williamr@2
  1993
       is insufficient memory available. In this case, the array is left in the
williamr@2
  1994
	   state it was in before the call.
williamr@2
  1995
williamr@2
  1996
@panic E32USER-CBase 21, if anIndex is negative or greater than the number of
williamr@2
  1997
       elements currently in the array.
williamr@2
  1998
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  1999
*/
williamr@2
  2000
	{return(*new(CArrayPakBase::ExpandL(anIndex,aLength)) T);}
williamr@2
  2001
williamr@2
  2002
williamr@2
  2003
williamr@2
  2004
williamr@2
  2005
template <class T>
williamr@2
  2006
inline T &CArrayPak<T>::ExtendL(TInt aLength)
williamr@2
  2007
/**
williamr@2
  2008
Expands the array by one element of specified length at the end of the array. 
williamr@2
  2009
williamr@2
  2010
It:
williamr@2
  2011
williamr@2
  2012
1. expands the array by one element at the end of the array, i.e. at position 
williamr@2
  2013
   CArrayPakbase::Count().
williamr@2
  2014
williamr@2
  2015
2. constructs a new element of length aLength at that position.
williamr@2
  2016
williamr@2
  2017
3. returns a reference to the new element.
williamr@2
  2018
williamr@2
  2019
The new element of type <class T> is constructed at the end of the array, 
williamr@2
  2020
using the default constructor of that class.
williamr@2
  2021
williamr@2
  2022
@param aLength The length of the new element.
williamr@2
  2023
williamr@2
  2024
@return A reference to the newly constructed <class T> object at the end of 
williamr@2
  2025
        the array.
williamr@2
  2026
williamr@2
  2027
@leave KErrNoMemory The function attempted to allocate from the heap and there 
williamr@2
  2028
       is insufficient memory available. In this case, the array is left in the
williamr@2
  2029
	   state it was in before the call.
williamr@2
  2030
williamr@2
  2031
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  2032
*/
williamr@2
  2033
	{return(*new(CArrayPakBase::ExpandL(Count(),aLength)) T);}
williamr@2
  2034
williamr@2
  2035
williamr@2
  2036
williamr@2
  2037
williamr@2
  2038
template <class T>
williamr@2
  2039
inline TInt CArrayPak<T>::Find(const T &aRef,TKeyArrayPak &aKey,TInt &anIndex) const
williamr@2
  2040
/**
williamr@2
  2041
Finds the position of an element within the array, based on the matching of 
williamr@2
  2042
keys, using a sequential search.
williamr@2
  2043
williamr@2
  2044
The array is searched sequentially for an element whose key matches the key 
williamr@2
  2045
of the supplied <class T> object. The search starts with the first element 
williamr@2
  2046
in the array.
williamr@2
  2047
williamr@2
  2048
Note that where an array has elements with duplicate keys, the function only
williamr@2
  2049
supplies the position of the first element in the array with that key.
williamr@2
  2050
williamr@2
  2051
@param aRef    A reference to an object of type <class T> whose key is used 
williamr@2
  2052
               for comparison.
williamr@2
  2053
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  2054
@param anIndex A reference to a TInt supplied by the caller. On return, if the
williamr@2
  2055
               element is found, this is set to the position 
williamr@2
  2056
               of that element within the array. The position is relative to zero, (i.e. 
williamr@2
  2057
               the first element in the array is at position 0).
williamr@2
  2058
			   If the element is not found or the array is empty, then this is undefined.
williamr@2
  2059
williamr@2
  2060
@return Zero, if the element with the specified key is found. Non-zero, if 
williamr@2
  2061
        the element with the specified key is not found.
williamr@2
  2062
*/
williamr@2
  2063
	{return(CArrayPakBase::Find(&aRef,aKey,anIndex));}
williamr@2
  2064
williamr@2
  2065
williamr@2
  2066
williamr@2
  2067
williamr@2
  2068
template <class T>
williamr@2
  2069
inline TInt CArrayPak<T>::FindIsq(const T &aRef,TKeyArrayPak &aKey,TInt &anIndex) const
williamr@2
  2070
/**
williamr@2
  2071
Finds the position of an element within the array, based on the matching of 
williamr@2
  2072
keys, using a binary search technique.
williamr@2
  2073
williamr@2
  2074
The array is searched, using a binary search technique, for an element whose 
williamr@2
  2075
key matches the key of the supplied <class T> object.
williamr@2
  2076
williamr@2
  2077
The array must be in key order.
williamr@2
  2078
williamr@2
  2079
Note that where an array has elements with duplicate keys, the function cannot
williamr@2
  2080
guarantee which element, with the given key value, it will return, except that it
williamr@2
  2081
will find one of them.
williamr@2
  2082
williamr@2
  2083
@param aRef    A reference to an object of type <class T> whose key is used 
williamr@2
  2084
               for comparison.
williamr@2
  2085
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  2086
@param anIndex A reference to a TInt supplied by the caller. On return, if the
williamr@2
  2087
               element is found, this is set to the position of that element
williamr@2
  2088
			   within the array. The position is relative to zero, (i.e. 
williamr@2
  2089
               the first element in the array is at position 0).
williamr@2
  2090
			   If the element is not found and the array is not empty, then
williamr@2
  2091
			   this is set to the position of the first element in the array
williamr@2
  2092
			   with a key which is greater than the key of the object aRef.
williamr@2
  2093
			   If the element is not found and the array is empty, then this 
williamr@2
  2094
               is undefined.
williamr@2
  2095
williamr@2
  2096
@return Zero, if the element with the specified key is found or the array is 
williamr@2
  2097
        empty.
williamr@2
  2098
		Non-zero, if the element with the specified key is not found.
williamr@2
  2099
*/
williamr@2
  2100
	{return(CArrayPakBase::FindIsq(&aRef,aKey,anIndex));}
williamr@2
  2101
williamr@2
  2102
williamr@2
  2103
williamr@2
  2104
williamr@2
  2105
template <class T>
williamr@2
  2106
inline void CArrayPak<T>::InsertL(TInt anIndex,const T &aRef,TInt aLength)
williamr@2
  2107
/** 
williamr@2
  2108
Inserts an element of a specified length into the array at the specified
williamr@2
  2109
position.
williamr@2
  2110
williamr@2
  2111
@param anIndex The position within the array where the element is to be
williamr@2
  2112
               inserted. The position is relative to zero, i.e. zero implies
williamr@2
  2113
			   that elements are inserted at the beginning of the array.
williamr@2
  2114
@param aRef    A reference to the class T object to be inserted into
williamr@2
  2115
               the array.
williamr@2
  2116
@param aLength The length of the element to be inserted into the array.
williamr@2
  2117
williamr@2
  2118
@leave KErrNoMemory The function attempted to expand the array buffer and there
williamr@2
  2119
       is insufficient memory available. In this case, the array is left in the
williamr@2
  2120
	   state it was in before the call.
williamr@2
  2121
williamr@2
  2122
@panic E32USER-CBase 21, if anIndex is negative or greater than the number of
williamr@2
  2123
       objects currently in the array.
williamr@2
  2124
@panic E32USER-CBase 30, if aLength is negative.
williamr@2
  2125
*/
williamr@2
  2126
	{CArrayPakBase::InsertL(anIndex,&aRef,aLength);}
williamr@2
  2127
williamr@2
  2128
williamr@2
  2129
williamr@2
  2130
williamr@2
  2131
template <class T>
williamr@2
  2132
inline TInt CArrayPak<T>::InsertIsqL(const T &aRef,TInt aLength,TKeyArrayPak &aKey)
williamr@2
  2133
/**
williamr@2
  2134
Inserts a single element of a specified length into the array at a position 
williamr@2
  2135
determined by a key.
williamr@2
  2136
williamr@2
  2137
The array MUST already be in key sequence (as defined by the key), otherwise 
williamr@2
  2138
the position of the new element is unpredictable, or duplicates may occur.
williamr@2
  2139
williamr@2
  2140
Elements with duplicate keys are not permitted.
williamr@2
  2141
williamr@2
  2142
@param aRef    A reference to the element of type <class T> to be inserted into 
williamr@2
  2143
               the array.
williamr@2
  2144
@param aLength The length of the new element of type <class T> to be inserted 
williamr@2
  2145
               into the array.
williamr@2
  2146
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  2147
williamr@2
  2148
@return The position within the array of the newly inserted element.
williamr@2
  2149
williamr@2
  2150
@leave KErrAlreadyExists An element with the same key already exists within 
williamr@2
  2151
       the array. NB the array MUST already be in key sequence, otherwise
williamr@2
  2152
	   the function may insert a duplicate and fail to leave with
williamr@2
  2153
	   this value.
williamr@2
  2154
@leave KErrNoMemory The function attempted to expand the array buffer and there 
williamr@2
  2155
       is insufficient memory available. In this case, the array is left in the
williamr@2
  2156
	   state it was in before the call.
williamr@2
  2157
*/
williamr@2
  2158
	{return(CArrayPakBase::InsertIsqL(&aRef,aLength,aKey));}
williamr@2
  2159
williamr@2
  2160
williamr@2
  2161
williamr@2
  2162
williamr@2
  2163
template <class T>
williamr@2
  2164
inline TInt CArrayPak<T>::InsertIsqAllowDuplicatesL(const T &aRef,TInt aLength,TKeyArrayPak &aKey)
williamr@2
  2165
/**
williamr@2
  2166
Inserts a single element of a specified length into the array at a position 
williamr@2
  2167
determined by a key, allowing duplicates.
williamr@2
  2168
williamr@2
  2169
The array MUST already be in key sequence, otherwise the position of the 
williamr@2
  2170
new element is unpredictable.
williamr@2
  2171
williamr@2
  2172
Elements with duplicate keys are permitted. If the new element's key is a 
williamr@2
  2173
duplicate of an existing element's key, then the new element is positioned 
williamr@2
  2174
after the existing element.
williamr@2
  2175
williamr@2
  2176
@param aRef    A reference to the element of type <class T> to be inserted into
williamr@2
  2177
               the array.
williamr@2
  2178
@param aLength The length of the new element to be inserted into the array.
williamr@2
  2179
@param aKey    A reference to a key object defining the properties of the key.
williamr@2
  2180
williamr@2
  2181
@return The position within the array of the newly inserted element. 
williamr@2
  2182
williamr@2
  2183
@leave KErrNoMemory The function attempted to expand the array buffer and there 
williamr@2
  2184
       is insufficient memory available. In this case, the array is left in the
williamr@2
  2185
	   state it was in before the call.
williamr@2
  2186
*/
williamr@2
  2187
	{return(CArrayPakBase::InsertIsqAllowDuplicatesL(&aRef,aLength,aKey));}
williamr@2
  2188
williamr@2
  2189
williamr@2
  2190
williamr@2
  2191
williamr@2
  2192
template <class T>
williamr@2
  2193
inline const TArray<T> CArrayPak<T>::Array() const
williamr@2
  2194
/**
williamr@2
  2195
Constructs and returns a TArray<T> object.
williamr@2
  2196
williamr@2
  2197
@return A Tarray<T> object for this array.
williamr@2
  2198
*/
williamr@2
  2199
	{return(TArray<T>(CountR,AtR,this));}
williamr@2
  2200
williamr@2
  2201
williamr@2
  2202
williamr@2
  2203
williamr@2
  2204
inline CArrayPak<TAny>::CArrayPak(TBufRep aRep,TInt aGranularity)
williamr@2
  2205
	: CArrayPakBase(aRep,aGranularity)
williamr@2
  2206
/**
williamr@2
  2207
Constructs a variable array with the specified granularity and
williamr@2
  2208
buffer organisation.
williamr@2
  2209
	
williamr@2
  2210
Note that no memory is allocated to the array buffer by this constructor.
williamr@2
  2211
	
williamr@2
  2212
@param aRep         A pointer to a function used to expand the array buffer. 
williamr@2
  2213
                    The organisation of the array buffer is implied by the
williamr@2
  2214
					choice of this function.
williamr@2
  2215
	                For a flat array buffer, pass (TBufRep)CBufFlat::NewL.
williamr@2
  2216
			        For a segmented array buffer, pass (TBufRep)CBufSeg::NewL. 
williamr@2
  2217
@param aGranularity The granularity of the array. 
williamr@2
  2218
williamr@2
  2219
@panic E32USER-CBase 19, if aGranularity is not positive.
williamr@2
  2220
*/
williamr@2
  2221
	{}
williamr@2
  2222
williamr@2
  2223
williamr@2
  2224
williamr@2
  2225
williamr@2
  2226
inline const TAny *CArrayPak<TAny>::At(TInt anIndex) const
williamr@2
  2227
/**
williamr@2
  2228
Gets a pointer to the untyped element located at the specified position 
williamr@2
  2229
within the array.
williamr@2
  2230
	
williamr@2
  2231
The compiler uses this variant of the function if the returned reference is 
williamr@2
  2232
used in an expression where that reference cannot be modified.
williamr@2
  2233
	
williamr@2
  2234
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  2235
               i.e. zero implies the first element.
williamr@2
  2236
williamr@2
  2237
@return A pointer to the const element located at position anIndex within 
williamr@2
  2238
	    the array.
williamr@2
  2239
williamr@2
  2240
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
  2241
       the number of objects currently within the array.
williamr@2
  2242
*/
williamr@2
  2243
	{return(CArrayPakBase::At(anIndex));}
williamr@2
  2244
williamr@2
  2245
williamr@2
  2246
williamr@2
  2247
williamr@2
  2248
inline TAny *CArrayPak<TAny>::At(TInt anIndex)
williamr@2
  2249
/**
williamr@2
  2250
Gets a pointer to the untyped element located at the specified position 
williamr@2
  2251
within the array.
williamr@2
  2252
	
williamr@2
  2253
The compiler uses this variant of the function if the returned reference is 
williamr@2
  2254
used in an expression where that reference can be modified.
williamr@2
  2255
	
williamr@2
  2256
@param anIndex The position of the element within the array, relative to zero; 
williamr@2
  2257
               i.e. zero implies the first element.
williamr@2
  2258
williamr@2
  2259
@return A pointer to the non-const element located at position anIndex within 
williamr@2
  2260
	    the array.
williamr@2
  2261
williamr@2
  2262
@panic E32USER-CBase 21, if anIndex is negative or greater than or equal to
williamr@2
  2263
       the number of objects currently within the array.
williamr@2
  2264
*/
williamr@2
  2265
	{return(CArrayPakBase::At(anIndex));}
williamr@2
  2266
williamr@2
  2267
williamr@2
  2268
williamr@2
  2269
williamr@2
  2270
inline void CArrayPak<TAny>::AppendL(const TAny *aPtr,TInt aLength)
williamr@2
  2271
/**
williamr@2
  2272
Appends the untyped element of the specified length onto the end of the array.
williamr@2
  2273
	
williamr@2
  2274
@param aPtr    A pointer to an untyped element to be appended. 
williamr@2
  2275
@param aLength The length of the untyped element. 
williamr@2
  2276
williamr@2
  2277
@leave KErrNoMemory The function attempted to expand the array buffer and there 
williamr@2
  2278
       is insufficient memory available. In this case, the array is left in the
williamr@2
  2279
	   state it was in before the call.
williamr@2
  2280
*/
williamr@2
  2281
	{CArrayPakBase::InsertL(Count(),aPtr,aLength);}
williamr@2
  2282
williamr@2
  2283
williamr@2
  2284
williamr@2
  2285
williamr@2
  2286
inline TAny *CArrayPak<TAny>::ExtendL(TInt aLength)
williamr@2
  2287
/**
williamr@2
  2288
Expands the array by one element of the specified length at the end of
williamr@2
  2289
the array, and returns a pointer to this new location.
williamr@2
  2290
williamr@2
  2291
As elements are untyped, no construction is possible and the content of
williamr@2
  2292
the new location remains undefined.
williamr@2
  2293
williamr@2
  2294
@param aLength  The length of the new element.
williamr@2
  2295
williamr@2
  2296
@return A pointer to the new element location at the end of the array.
williamr@2
  2297
williamr@2
  2298
@leave KErrNoMemory The function attempted to expand the array buffer and there
williamr@2
  2299
       is insufficient memory available. In this case, the array is left in the
williamr@2
  2300
	   state it was in before the call.
williamr@2
  2301
*/
williamr@2
  2302
	{return(CArrayPakBase::ExpandL(Count(),aLength));}
williamr@2
  2303
williamr@2
  2304
williamr@2
  2305
williamr@2
  2306
williamr@2
  2307
// Template class CArrayPakFlat
williamr@2
  2308
template <class T>
williamr@2
  2309
inline CArrayPakFlat<T>::CArrayPakFlat(TInt aGranularity)
williamr@2
  2310
	: CArrayPak<T>((TBufRep)CBufFlat::NewL,aGranularity)
williamr@2
  2311
/**
williamr@2
  2312
Constructs a packed flat array with specified granularity.
williamr@2
  2313
williamr@2
  2314
Note that no memory is allocated to the array buffer by this  constructor.
williamr@2
  2315
williamr@2
  2316
@param aGranularity The granularity of the array.
williamr@2
  2317
williamr@2
  2318
@panic E32USER-CBase 20, if aGranularity is not positive.
williamr@2
  2319
*/
williamr@2
  2320
	{}
williamr@2
  2321
williamr@2
  2322
williamr@2
  2323
williamr@2
  2324
williamr@2
  2325
// Class CObject
williamr@2
  2326
inline TInt CObject::UniqueID() const
williamr@2
  2327
/**
williamr@2
  2328
Gets this reference counting object's unique ID.
williamr@2
  2329
williamr@2
  2330
The unique ID is an integer which is a property of the object container. It 
williamr@2
  2331
forms part of the identity of all reference counting objects and is the same 
williamr@2
  2332
value for all reference counting objects held within the same object container.
williamr@2
  2333
williamr@2
  2334
@return This reference counting object's unique ID.
williamr@2
  2335
williamr@2
  2336
@see CObjectCon
williamr@2
  2337
*/
williamr@2
  2338
	{return(iContainer->UniqueID());}
williamr@2
  2339
williamr@2
  2340
williamr@2
  2341
williamr@2
  2342
williamr@2
  2343
inline TInt CObject::AccessCount() const
williamr@2
  2344
/**
williamr@2
  2345
Gets the number of open references to this reference counting object.
williamr@2
  2346
williamr@2
  2347
@return The number of open references.
williamr@2
  2348
*/
williamr@2
  2349
	{return(iAccessCount);}
williamr@2
  2350
williamr@2
  2351
williamr@2
  2352
williamr@2
  2353
williamr@2
  2354
inline void CObject::Inc()
williamr@2
  2355
/**
williamr@2
  2356
Adds one to the reference count.
williamr@2
  2357
williamr@2
  2358
This function is called by the default implementation of the Open() member 
williamr@2
  2359
function of this class.
williamr@2
  2360
williamr@2
  2361
@see CObject::Open
williamr@2
  2362
*/
williamr@2
  2363
	{iAccessCount++;}
williamr@2
  2364
williamr@2
  2365
williamr@2
  2366
williamr@2
  2367
williamr@2
  2368
inline void CObject::Dec()
williamr@2
  2369
/**
williamr@2
  2370
Subtracts one from the reference count.
williamr@2
  2371
williamr@2
  2372
This function is called by the default implementation of the Close() member 
williamr@2
  2373
function of this class.
williamr@2
  2374
williamr@2
  2375
@see CObject::Close
williamr@2
  2376
*/
williamr@2
  2377
	{iAccessCount--;}
williamr@2
  2378
williamr@2
  2379
williamr@2
  2380
williamr@2
  2381
williamr@2
  2382
inline CObject * CObject::Owner() const
williamr@2
  2383
/**
williamr@2
  2384
Gets a pointer to the reference counting object which owns this
williamr@2
  2385
reference counting object.
williamr@2
  2386
williamr@2
  2387
@return A pointer to the owning reference counting object. This is NULL, if 
williamr@2
  2388
        there is no owner.
williamr@2
  2389
*/
williamr@2
  2390
	{return(iOwner);}
williamr@2
  2391
williamr@2
  2392
williamr@2
  2393
williamr@2
  2394
williamr@2
  2395
inline void CObject::SetOwner(CObject *anOwner)
williamr@2
  2396
/**
williamr@2
  2397
Sets the owner of this reference counting object.
williamr@2
  2398
williamr@2
  2399
If this reference counting object already has an owner, then all knowledge 
williamr@2
  2400
of that owner is lost.
williamr@2
  2401
williamr@2
  2402
@param anOwner A pointer to the reference counting object which is to be the 
williamr@2
  2403
               new owner of this reference counting object.
williamr@2
  2404
*/
williamr@2
  2405
	{iOwner=anOwner;}
williamr@2
  2406
williamr@2
  2407
williamr@2
  2408
williamr@2
  2409
williamr@2
  2410
// class CObjectIx
williamr@2
  2411
inline TInt CObjectIx::Count() const
williamr@2
  2412
/**
williamr@2
  2413
Gets the number greater then the last slot number used to hold valid CObject pointer.
williamr@2
  2414
The input argument of CObject* CObjectIx::operator[]() must be less then the number returned by this method.
williamr@2
  2415
williamr@2
  2416
@return The number greater then the last used slot.
williamr@2
  2417
williamr@2
  2418
@see CObjectIx::ActiveCount
williamr@2
  2419
@see CObjectIx::operator[]
williamr@2
  2420
*/
williamr@2
  2421
	{return iHighWaterMark;}
williamr@2
  2422
williamr@2
  2423
williamr@2
  2424
williamr@2
  2425
williamr@2
  2426
inline TInt CObjectIx::ActiveCount() const
williamr@2
  2427
/**
williamr@2
  2428
Gets the current number of reference counting objects held by this
williamr@2
  2429
object index.
williamr@2
  2430
williamr@2
  2431
@return The current number.
williamr@2
  2432
*/
williamr@2
  2433
	{return iNumEntries;}
williamr@2
  2434
williamr@2
  2435
williamr@2
  2436
williamr@2
  2437
// class CObjectCon
williamr@2
  2438
inline TInt CObjectCon::UniqueID() const
williamr@2
  2439
/**
williamr@2
  2440
Gets this object container's unique ID.
williamr@2
  2441
williamr@2
  2442
@return The unique ID value.
williamr@2
  2443
*/
williamr@2
  2444
	{return iUniqueID;}
williamr@2
  2445
williamr@2
  2446
williamr@2
  2447
williamr@2
  2448
williamr@2
  2449
inline TInt CObjectCon::Count() const
williamr@2
  2450
/**
williamr@2
  2451
Gets the number of reference counting objects in this object container.
williamr@2
  2452
williamr@2
  2453
@return The number of objects.
williamr@2
  2454
*/
williamr@2
  2455
	{return iCount;}
williamr@2
  2456
williamr@2
  2457
williamr@2
  2458
williamr@2
  2459
williamr@2
  2460
williamr@2
  2461
// class CCirBufBase
williamr@2
  2462
inline TInt CCirBufBase::Count() const
williamr@2
  2463
/**
williamr@2
  2464
Gets the current number of objects in this circular buffer.
williamr@2
  2465
williamr@2
  2466
@return The number of objects in this circular buffer.
williamr@2
  2467
        This value can never be greater than the maximum capacity.
williamr@2
  2468
*/
williamr@2
  2469
	{return(iCount);}
williamr@2
  2470
williamr@2
  2471
williamr@2
  2472
williamr@2
  2473
williamr@2
  2474
inline TInt CCirBufBase::Length() const
williamr@2
  2475
/**
williamr@2
  2476
Gets the maximum capacity of this circular buffer.
williamr@2
  2477
williamr@2
  2478
The capacity is the maximum number of elements that the buffer can hold.
williamr@2
  2479
williamr@2
  2480
Use SetLengthL() to change the capacity of the circular buffer.
williamr@2
  2481
williamr@2
  2482
@return The maximum capacity of this circular buffer.
williamr@2
  2483
williamr@2
  2484
@see CCirBufBase::SetLengthL
williamr@2
  2485
*/
williamr@2
  2486
	{return(iLength);}
williamr@2
  2487
williamr@2
  2488
williamr@2
  2489
williamr@2
  2490
williamr@2
  2491
// Template class CCirBuf
williamr@2
  2492
template <class T>
williamr@2
  2493
inline CCirBuf<T>::CCirBuf()
williamr@2
  2494
	: CCirBufBase(sizeof(T))
williamr@2
  2495
/**
williamr@2
  2496
Default C++ constructor.
williamr@2
  2497
williamr@2
  2498
The size of each object in the buffer is fixed and is the length of the class 
williamr@2
  2499
passed as the template parameter. 
williamr@2
  2500
williamr@2
  2501
@panic E32USER-CBase 72, if the length of the template class is zero.
williamr@2
  2502
*/
williamr@2
  2503
	{}
williamr@2
  2504
williamr@2
  2505
williamr@2
  2506
williamr@2
  2507
williamr@2
  2508
template <class T>
williamr@2
  2509
inline TInt CCirBuf<T>::Add(const T *aPtr)
williamr@2
  2510
/**
williamr@2
  2511
Adds a single object to the circular buffer.
williamr@2
  2512
williamr@2
  2513
The object is of type class T and is only added if there is space available.
williamr@2
  2514
williamr@2
  2515
@param aPtr A pointer to the object of type class T to be added to the circular 
williamr@2
  2516
            buffer.
williamr@2
  2517
williamr@2
  2518
@return 1 if the object is successfully added. 0 if the object cannot be added 
williamr@2
  2519
        because the circular buffer is full.
williamr@2
  2520
williamr@2
  2521
@panic E32USER-CBase 74, if a call to CCirBufBase::SetLengthL() has not been
williamr@2
  2522
                         made before calling this function.
williamr@2
  2523
williamr@2
  2524
@see CCirBufBase::SetLengthL
williamr@2
  2525
*/
williamr@2
  2526
	{return(DoAdd((const TUint8 *)aPtr));}
williamr@2
  2527
williamr@2
  2528
williamr@2
  2529
williamr@2
  2530
williamr@2
  2531
template <class T>
williamr@2
  2532
inline TInt CCirBuf<T>::Add(const T *aPtr,TInt aCount)
williamr@2
  2533
/**
williamr@2
  2534
Adds multiple objects to the circular buffer.
williamr@2
  2535
williamr@2
  2536
The function attempts to add aCount objects of type class T. The objects are
williamr@2
  2537
only added if there is space available.
williamr@2
  2538
williamr@2
  2539
@param aPtr   A pointer to a set of contiguous objects of type class T to be 
williamr@2
  2540
              added to the circular buffer.
williamr@2
  2541
williamr@2
  2542
@param aCount The number of objects to be added to the circular buffer.
williamr@2
  2543
williamr@2
  2544
@return The number of objects successfully added to the buffer. This value 
williamr@2
  2545
        may be less than the number requested and can range from 0 to aCount. 
williamr@2
  2546
williamr@2
  2547
@panic E32USER-CBase 74, if a call to CCirBufBase::SetLengthL() has not been
williamr@2
  2548
                         made before calling this function.
williamr@2
  2549
@panic E32USER-CBase 75, if aCount is not a positive value. 
williamr@2
  2550
williamr@2
  2551
@see CCirBufBase::SetLengthL
williamr@2
  2552
*/
williamr@2
  2553
	{return(DoAdd((const TUint8 *)aPtr,aCount));}
williamr@2
  2554
williamr@2
  2555
williamr@2
  2556
williamr@2
  2557
williamr@2
  2558
template <class T>
williamr@2
  2559
inline TInt CCirBuf<T>::Remove(T *aPtr)
williamr@2
  2560
/**
williamr@2
  2561
Removes a single object from the circular buffer.
williamr@2
  2562
williamr@2
  2563
An object can only be removed if there are objects in the buffer.
williamr@2
  2564
williamr@2
  2565
A binary copy of the object is made to aPtr.
williamr@2
  2566
williamr@2
  2567
@param aPtr A pointer to an object of type class T supplied by the caller.
williamr@2
  2568
williamr@2
  2569
@return 1 if an object is successfully removed. 0 if an object cannot be removed 
williamr@2
  2570
        because the circular buffer is empty.
williamr@2
  2571
*/
williamr@2
  2572
	{return(DoRemove((TUint8 *)aPtr));}
williamr@2
  2573
williamr@2
  2574
williamr@2
  2575
williamr@2
  2576
williamr@2
  2577
template <class T>
williamr@2
  2578
inline TInt CCirBuf<T>::Remove(T *aPtr,TInt aCount)
williamr@2
  2579
/**
williamr@2
  2580
Removes multiple objects from the circular buffer.
williamr@2
  2581
williamr@2
  2582
The function attempts to remove aCount objects of type class T.
williamr@2
  2583
Objects can only be removed if there are objects in the buffer
williamr@2
  2584
williamr@2
  2585
A binary copy of the objects is made to aPtr.
williamr@2
  2586
williamr@2
  2587
@param aPtr   A pointer to contiguous memory able to hold aCount class T objects, 
williamr@2
  2588
              supplied by the caller. 
williamr@2
  2589
williamr@2
  2590
@param aCount The number of objects to be removed from the circular buffer.
williamr@2
  2591
williamr@2
  2592
@return The number of objects successfully removed from the buffer. This value
williamr@2
  2593
        may be less than the number requested, and can range from 0 to aCount.
williamr@2
  2594
williamr@2
  2595
@panic E32USER-CBase 76, if aCount is not a positive value.
williamr@2
  2596
*/
williamr@2
  2597
	{return(DoRemove((TUint8 *)aPtr,aCount));}
williamr@2
  2598
williamr@2
  2599
williamr@2
  2600
williamr@2
  2601
williamr@2
  2602
// Class CActive
williamr@2
  2603
inline TBool CActive::IsActive() const
williamr@2
  2604
/**
williamr@2
  2605
Determines whether the active object has a request outstanding.
williamr@2
  2606
williamr@2
  2607
A request is outstanding when:
williamr@2
  2608
williamr@2
  2609
1. it has been issued
williamr@2
  2610
williamr@2
  2611
2. it has not been cancelled
williamr@2
  2612
williamr@2
  2613
3. it servicing has not yet begun.
williamr@2
  2614
williamr@2
  2615
@return True, if a request is outstanding; false, otherwise.
williamr@2
  2616
*/
williamr@2
  2617
	{return(iStatus.iFlags&TRequestStatus::EActive);}
williamr@2
  2618
williamr@2
  2619
williamr@2
  2620
williamr@2
  2621
williamr@2
  2622
inline TBool CActive::IsAdded() const
williamr@2
  2623
/**
williamr@2
  2624
Determines whether the active object has been added to the active scheduler's 
williamr@2
  2625
list of active objects.
williamr@2
  2626
williamr@2
  2627
If the active object has not been added to a scheduler, it cannot handle the 
williamr@2
  2628
completion of any request. No request should be issued until the active object 
williamr@2
  2629
has been added to a scheduler because completion of that request generates 
williamr@2
  2630
what appears to be a stray signal.
williamr@2
  2631
williamr@2
  2632
Use the active object function Deque() to remove the active object from the 
williamr@2
  2633
scheduler.
williamr@2
  2634
williamr@2
  2635
@return True, if the active object has been added to an active scheduler; 
williamr@2
  2636
        false, otherwise. 
williamr@2
  2637
williamr@2
  2638
@see CActive::Deque
williamr@2
  2639
*/
williamr@2
  2640
	{return(iLink.iNext!=NULL);}
williamr@2
  2641
williamr@2
  2642
williamr@2
  2643
williamr@2
  2644
williamr@2
  2645
inline TInt CActive::Priority() const
williamr@2
  2646
/**
williamr@2
  2647
Gets the priority of the active object.
williamr@2
  2648
williamr@2
  2649
@return The active object's priority value.
williamr@2
  2650
*/
williamr@2
  2651
	{return iLink.iPriority;}
williamr@2
  2652
williamr@2
  2653
williamr@2
  2654
williamr@2
  2655
williamr@2
  2656
// class CDeltaTimer
williamr@2
  2657
inline TDeltaTimerEntry::TDeltaTimerEntry(TCallBack& aCallback)
williamr@2
  2658
/**
williamr@2
  2659
Constructor specifying a general callback.
williamr@2
  2660
williamr@2
  2661
@param aCallback The callback to be called when this timed event entry expires.
williamr@2
  2662
*/
williamr@2
  2663
	{iCallBack=aCallback;}
williamr@2
  2664
williamr@2
  2665
williamr@2
  2666
williamr@2
  2667
williamr@2
  2668
inline TDeltaTimerEntry::TDeltaTimerEntry()
williamr@2
  2669
/**
williamr@2
  2670
Default constructor.
williamr@2
  2671
*/
williamr@2
  2672
	{}
williamr@2
  2673
williamr@2
  2674
williamr@2
  2675
williamr@2
  2676
williamr@2
  2677
inline void TDeltaTimerEntry::Set(TCallBack& aCallback)
williamr@2
  2678
/**
williamr@2
  2679
Sets the specified callback.
williamr@2
  2680
williamr@2
  2681
@param aCallback The callback to be called when this timed event entry expires.
williamr@2
  2682
*/
williamr@2
  2683
	{iCallBack=aCallback;}
williamr@2
  2684
williamr@2
  2685
williamr@2
  2686
williamr@2
  2687
williamr@2
  2688
/**
williamr@2
  2689
Gets a reference to the server's current message.
williamr@2
  2690
williamr@2
  2691
@return The current message that contains the client request details.
williamr@2
  2692
*/
williamr@2
  2693
inline const RMessage2 &CServer2::Message() const
williamr@2
  2694
	{return iMessage;}
williamr@2
  2695
williamr@2
  2696
williamr@2
  2697
williamr@2
  2698
	
williamr@2
  2699
/**
williamr@2
  2700
Gets the server active object that handles messages for this session.
williamr@2
  2701
williamr@2
  2702
This is the instance of the CServer2 derived class that created
williamr@2
  2703
this session object.
williamr@2
  2704
williamr@2
  2705
@return The server active object.
williamr@2
  2706
*/
williamr@2
  2707
inline const CServer2 *CSession2::Server() const
williamr@2
  2708
	{return iServer;}
williamr@2
  2709
williamr@2
  2710
williamr@2
  2711
williamr@2
  2712
williamr@2
  2713
// Class CAsyncOneShot
williamr@2
  2714
inline RThread& CAsyncOneShot::Thread()
williamr@2
  2715
/**
williamr@2
  2716
Gets a handle to the current thread.
williamr@2
  2717
williamr@2
  2718
@return The handle to the current thread.
williamr@2
  2719
*/
williamr@2
  2720
	{ return iThread; }
williamr@2
  2721
williamr@2
  2722
williamr@2
  2723
williamr@2
  2724
williamr@2
  2725
// Class CActiveScheduler
williamr@2
  2726
inline TInt CActiveScheduler::Level() const
williamr@2
  2727
/**
williamr@2
  2728
@deprecated Use the StackDepth() function instead.
williamr@2
  2729
williamr@2
  2730
Gets the scheduler's level of nestedness.
williamr@2
  2731
williamr@2
  2732
@return The level of nestedness.
williamr@2
  2733
williamr@2
  2734
@see StackDepth()
williamr@2
  2735
*/
williamr@2
  2736
	{return StackDepth();}
williamr@2
  2737
williamr@2
  2738
williamr@2
  2739
williamr@2
  2740
williamr@2
  2741
// Class CActiveSchedulerWait
williamr@2
  2742
inline TBool CActiveSchedulerWait::IsStarted() const
williamr@2
  2743
/**
williamr@2
  2744
Reports whether this CActiveSchedulerWait object is currently started.
williamr@2
  2745
williamr@2
  2746
Note: a CActiveSchedulerWait object itself becomes "stopped" as
williamr@2
  2747
soon as AsyncStop() is called, and can be started again immediately if
williamr@2
  2748
required (but this would start a new nested level of the scheduler).
williamr@2
  2749
williamr@2
  2750
@return True if the scheduling loop is active; false, otherwise.
williamr@2
  2751
williamr@2
  2752
@see CActiveSchedulerWait::Start
williamr@2
  2753
@see CActiveSchedulerWait::AsyncStop
williamr@2
  2754
*/
williamr@2
  2755
	{return iLoop != NULL;}
williamr@2
  2756
williamr@2
  2757
williamr@2
  2758
williamr@2
  2759
williamr@2
  2760
// Class CleanupStack
williamr@2
  2761
#ifdef _DEBUG
williamr@2
  2762
inline void CleanupStack::Pop(TAny* aExpectedItem)
williamr@2
  2763
/**
williamr@2
  2764
Pops an object from the top of the cleanup stack.
williamr@2
  2765
williamr@2
  2766
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2767
a debug build or a release build.
williamr@2
  2768
williamr@2
  2769
1. In a debug build, the function checks that the specified item is at the top 
williamr@2
  2770
   of the cleanup stack before attempting to pop it; an E32USER-CBase 90 panic 
williamr@2
  2771
   is raised if the check fails.
williamr@2
  2772
williamr@2
  2773
2  In a release build, the function just pops the object which is at the top 
williamr@2
  2774
   of the cleanup stack; no checking is done.
williamr@2
  2775
williamr@2
  2776
@param aExpectedItem A pointer to the item expected to be at the top of the 
williamr@2
  2777
                     cleanup stack. In a release build, this parameter
williamr@2
  2778
					 is not used.
williamr@2
  2779
*/
williamr@2
  2780
	{ CleanupStack::Check(aExpectedItem); CleanupStack::Pop(); }
williamr@2
  2781
williamr@2
  2782
williamr@2
  2783
williamr@2
  2784
williamr@2
  2785
inline void CleanupStack::Pop(TInt aCount, TAny* aLastExpectedItem)
williamr@2
  2786
/**
williamr@2
  2787
Pops the specified number of objects from the top of the cleanup stack.
williamr@2
  2788
williamr@2
  2789
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2790
a debug build or a release build.
williamr@2
  2791
williamr@2
  2792
1. In a debug build, the function pops (aCount-1) items from the cleanup stack, 
williamr@2
  2793
   and then checks that the specified item is the next one on the cleanup stack 
williamr@2
  2794
   before attempting to pop it; an E32USER-CBase 90 panic is raised if the
williamr@2
  2795
   check fails.
williamr@2
  2796
williamr@2
  2797
2. In a release build, the function just pops aCount items from the cleanup stack; 
williamr@2
  2798
   no checking is done.
williamr@2
  2799
williamr@2
  2800
@param aCount            The number of items top be popped from
williamr@2
  2801
                         the cleanup stack.
williamr@2
  2802
@param aLastExpectedItem A pointer to the item expected to be at the top of 
williamr@2
  2803
                         the cleanup stack, after (aCount-1) items have been
williamr@2
  2804
						 popped. In a release build, this parameter is
williamr@2
  2805
						 not used.
williamr@2
  2806
*/
williamr@2
  2807
	{
williamr@2
  2808
	if (--aCount)
williamr@2
  2809
		CleanupStack::Pop(aCount);
williamr@2
  2810
	CleanupStack::Check(aLastExpectedItem);
williamr@2
  2811
	CleanupStack::Pop();
williamr@2
  2812
	}
williamr@2
  2813
williamr@2
  2814
williamr@2
  2815
williamr@2
  2816
williamr@2
  2817
inline void CleanupStack::PopAndDestroy(TAny* aExpectedItem)
williamr@2
  2818
/**
williamr@2
  2819
Pops an object from the top of the cleanup stack, and cleans it up.
williamr@2
  2820
williamr@2
  2821
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2822
a debug build or a release build.
williamr@2
  2823
williamr@2
  2824
1. In a debug build, the function checks that the specified item is at the top 
williamr@2
  2825
   of the cleanup stack before attempting to pop and clean it up;
williamr@2
  2826
   an E32USER-CBase 90 panic is raised if the check fails.
williamr@2
  2827
williamr@2
  2828
2. In a release build, the function just pops and cleans up the object at 
williamr@2
  2829
   the top of the cleanup stack; no checking is done.
williamr@2
  2830
williamr@2
  2831
@param aExpectedItem A pointer to the item expected to be at the top of the 
williamr@2
  2832
                     cleanup stack. In a release build, this parameter is
williamr@2
  2833
					 not used.
williamr@2
  2834
*/
williamr@2
  2835
	{ CleanupStack::Check(aExpectedItem); CleanupStack::PopAndDestroy(); }
williamr@2
  2836
williamr@2
  2837
williamr@2
  2838
williamr@2
  2839
williamr@2
  2840
inline void CleanupStack::PopAndDestroy(TInt aCount, TAny* aLastExpectedItem)
williamr@2
  2841
/**
williamr@2
  2842
Pops the specified number of objects from the top of the cleanup stack, and 
williamr@2
  2843
cleans them up.
williamr@2
  2844
williamr@2
  2845
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2846
a debug build or a release build.
williamr@2
  2847
williamr@2
  2848
1. In a debug build, the function pops and cleans up (aCount-1) items from the 
williamr@2
  2849
   cleanup stack, and then checks that the specified item is the next one on 
williamr@2
  2850
   the cleanup stack before attempting to pop it and clean it up;
williamr@2
  2851
   an E32USER-CBase  90 panic is raised if the check fails.
williamr@2
  2852
williamr@2
  2853
2. In a release build, the function just pops and cleans up aCount items from 
williamr@2
  2854
   the cleanup stack; no checking is done.
williamr@2
  2855
williamr@2
  2856
@param aCount            The number of items top be popped from the
williamr@2
  2857
                         cleanup stack, and cleaned up.
williamr@2
  2858
@param aLastExpectedItem A pointer to the item expected to be at the top of 
williamr@2
  2859
                         the cleanup stack, after (aCount-1) items have been
williamr@2
  2860
						 popped and cleaned up. In a release build, this 
williamr@2
  2861
						 parameter is not used.
williamr@2
  2862
*/
williamr@2
  2863
	{
williamr@2
  2864
	if (--aCount)
williamr@2
  2865
		CleanupStack::PopAndDestroy(aCount);
williamr@2
  2866
	CleanupStack::Check(aLastExpectedItem);
williamr@2
  2867
	CleanupStack::PopAndDestroy();
williamr@2
  2868
	}
williamr@2
  2869
#else
williamr@2
  2870
inline void CleanupStack::Pop(TAny*)
williamr@2
  2871
/**
williamr@2
  2872
Pops an object from the top of the cleanup stack.
williamr@2
  2873
williamr@2
  2874
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2875
a debug build or a release build.
williamr@2
  2876
williamr@2
  2877
1. In a debug build, the function checks that the specified item is at the top 
williamr@2
  2878
   of the cleanup stack before attempting to pop it; an E32USER-CBase 90 panic 
williamr@2
  2879
   is raised if the check fails.
williamr@2
  2880
williamr@2
  2881
2  In a release build, the function just pops the object which is at the top 
williamr@2
  2882
   of the cleanup stack; no checking is done.
williamr@2
  2883
williamr@2
  2884
@param aExpectedItem A pointer to the item expected to be at the top of the 
williamr@2
  2885
                     cleanup stack. In a release build, this parameter
williamr@2
  2886
					 is not used.
williamr@2
  2887
*/
williamr@2
  2888
	{ CleanupStack::Pop(); }
williamr@2
  2889
williamr@2
  2890
williamr@2
  2891
williamr@2
  2892
williamr@2
  2893
inline void CleanupStack::Pop(TInt aCount, TAny*)
williamr@2
  2894
/**
williamr@2
  2895
Pops the specified number of objects from the top of the cleanup stack.
williamr@2
  2896
williamr@2
  2897
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2898
a debug build or a release build.
williamr@2
  2899
williamr@2
  2900
1. In a debug build, the function pops (aCount-1) items from the cleanup stack, 
williamr@2
  2901
   and then checks that the specified item is the next one on the cleanup stack 
williamr@2
  2902
   before attempting to pop it; an E32USER-CBase 90 panic is raised if the
williamr@2
  2903
   check fails.
williamr@2
  2904
williamr@2
  2905
2. In a release build, the function just pops aCount items from the cleanup stack; 
williamr@2
  2906
   no checking is done.
williamr@2
  2907
williamr@2
  2908
@param aCount            The number of items top be popped from
williamr@2
  2909
                         the cleanup stack.
williamr@2
  2910
@param aLastExpectedItem A pointer to the item expected to be at the top of 
williamr@2
  2911
                         the cleanup stack, after (aCount-1) items have been
williamr@2
  2912
						 popped. In a release build, this parameter is
williamr@2
  2913
						 not used.
williamr@2
  2914
*/
williamr@2
  2915
	{ CleanupStack::Pop(aCount); }
williamr@2
  2916
williamr@2
  2917
williamr@2
  2918
williamr@2
  2919
williamr@2
  2920
inline void CleanupStack::PopAndDestroy(TAny*)
williamr@2
  2921
/**
williamr@2
  2922
Pops an object from the top of the cleanup stack, and cleans it up.
williamr@2
  2923
williamr@2
  2924
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2925
a debug build or a release build.
williamr@2
  2926
williamr@2
  2927
1. In a debug build, the function checks that the specified item is at the top 
williamr@2
  2928
   of the cleanup stack before attempting to pop and clean it up;
williamr@2
  2929
   an E32USER-CBase 90 panic is raised if the check fails.
williamr@2
  2930
williamr@2
  2931
2. In a release build, the function just pops and cleans up the object at 
williamr@2
  2932
   the top of the cleanup stack; no checking is done.
williamr@2
  2933
williamr@2
  2934
@param aExpectedItem A pointer to the item expected to be at the top of the 
williamr@2
  2935
                     cleanup stack. In a release build, this parameter is
williamr@2
  2936
					 not used.
williamr@2
  2937
*/
williamr@2
  2938
	{ CleanupStack::PopAndDestroy(); }
williamr@2
  2939
williamr@2
  2940
williamr@2
  2941
williamr@2
  2942
williamr@2
  2943
inline void CleanupStack::PopAndDestroy(TInt aCount, TAny*)
williamr@2
  2944
/**
williamr@2
  2945
Pops the specified number of objects from the top of the cleanup stack, and 
williamr@2
  2946
cleans them up.
williamr@2
  2947
williamr@2
  2948
The function has two modes of operation, depending on whether it is part of 
williamr@2
  2949
a debug build or a release build.
williamr@2
  2950
williamr@2
  2951
1. In a debug build, the function pops and cleans up (aCount-1) items from the 
williamr@2
  2952
   cleanup stack, and then checks that the specified item is the next one on 
williamr@2
  2953
   the cleanup stack before attempting to pop it and clean it up;
williamr@2
  2954
   an E32USER-CBase  90 panic is raised if the check fails.
williamr@2
  2955
williamr@2
  2956
2. In a release build, the function just pops and cleans up aCount items from 
williamr@2
  2957
   the cleanup stack; no checking is done.
williamr@2
  2958
williamr@2
  2959
@param aCount            The number of items top be popped from the
williamr@2
  2960
                         cleanup stack, and cleaned up.
williamr@2
  2961
@param aLastExpectedItem A pointer to the item expected to be at the top of 
williamr@2
  2962
                         the cleanup stack, after (aCount-1) items have been
williamr@2
  2963
						 popped and cleaned up. In a release build, this 
williamr@2
  2964
						 parameter is not used.
williamr@2
  2965
*/
williamr@2
  2966
	{ CleanupStack::PopAndDestroy(aCount); }
williamr@2
  2967
#endif
williamr@2
  2968
williamr@2
  2969
williamr@2
  2970
williamr@2
  2971
williamr@2
  2972
// Class TCleanupItem
williamr@2
  2973
inline TCleanupItem::TCleanupItem(TCleanupOperation anOperation)
williamr@2
  2974
	: iOperation(anOperation)
williamr@2
  2975
/**
williamr@2
  2976
Constructs the object with a cleanup operation.
williamr@2
  2977
williamr@2
  2978
@param anOperation  A cleanup operation which will be invoked by the pop and
williamr@2
  2979
                    destroy action resulting from a subsequent call to
williamr@2
  2980
					CleanupStack::PopAndDestroy().
williamr@2
  2981
*/
williamr@2
  2982
	{}
williamr@2
  2983
williamr@2
  2984
williamr@2
  2985
williamr@2
  2986
williamr@2
  2987
inline TCleanupItem::TCleanupItem(TCleanupOperation anOperation,TAny *aPtr)
williamr@2
  2988
	: iOperation(anOperation), iPtr(aPtr)
williamr@2
  2989
/**
williamr@2
  2990
Constructs the object with a cleanup operation and a pointer to the object
williamr@2
  2991
to be cleaned up.
williamr@2
  2992
williamr@2
  2993
@param anOperation A cleanup operation which will be invoked by the pop
williamr@2
  2994
                   and destroy action resulting from a subsequent call to
williamr@2
  2995
				   CleanupStack::PopAndDestroy().
williamr@2
  2996
williamr@2
  2997
@param aPtr        A pointer to an object which is the target of the
williamr@2
  2998
                   cleanup operation.
williamr@2
  2999
*/
williamr@2
  3000
	{}
williamr@2
  3001
williamr@2
  3002
williamr@2
  3003
williamr@2
  3004
williamr@2
  3005
// Class TCleanupTrapHandler
williamr@2
  3006
inline CCleanup &TCleanupTrapHandler::Cleanup()
williamr@2
  3007
	{return(*iCleanup);}
williamr@2
  3008
williamr@2
  3009
// Class TAutoClose
williamr@2
  3010
template <class T>
williamr@2
  3011
inline TAutoClose<T>::~TAutoClose()
williamr@2
  3012
/**
williamr@2
  3013
Destructor.
williamr@2
  3014
williamr@2
  3015
The implementation calls Close() on iObj, the instance of the template class.
williamr@2
  3016
*/
williamr@2
  3017
#ifdef __LEAVE_EQUALS_THROW__
williamr@2
  3018
	{if (!std::uncaught_exception()) iObj.Close();}
williamr@2
  3019
#else
williamr@2
  3020
	{iObj.Close();}
williamr@2
  3021
#endif
williamr@2
  3022
williamr@2
  3023
williamr@2
  3024
williamr@2
  3025
williamr@2
  3026
template <class T>
williamr@2
  3027
inline void TAutoClose<T>::PushL()
williamr@2
  3028
/**
williamr@2
  3029
Pushes a cleanup item onto the cleanup stack, so that Close() is called on the 
williamr@2
  3030
templated class object, iObj, if a leave occurs.
williamr@2
  3031
*/
williamr@2
  3032
	{CleanupStack::PushL(TCleanupItem(Close, (TAny *)&iObj));}
williamr@2
  3033
williamr@2
  3034
williamr@2
  3035
williamr@2
  3036
williamr@2
  3037
template <class T>
williamr@2
  3038
inline void TAutoClose<T>::Pop()
williamr@2
  3039
/**
williamr@2
  3040
Pops a single cleanup item from the cleanup stack.
williamr@2
  3041
*/
williamr@2
  3042
	{CleanupStack::Pop();}
williamr@2
  3043
williamr@2
  3044
williamr@2
  3045
williamr@2
  3046
williamr@2
  3047
template <class T>
williamr@2
  3048
void TAutoClose<T>::Close(TAny *aObj)
williamr@2
  3049
	{((T *)aObj)->Close();}
williamr@2
  3050
williamr@2
  3051
williamr@2
  3052
williamr@2
  3053
williamr@2
  3054
// Template class CleanupDelete
williamr@2
  3055
template <class T>
williamr@2
  3056
inline void CleanupDelete<T>::PushL(T* aPtr)
williamr@2
  3057
/**
williamr@2
  3058
Creates a TCleanupItem for the specified object.
williamr@2
  3059
williamr@2
  3060
The cleanup operation is the private static function Delete() of this class, which
williamr@2
  3061
deletes the specified object.
williamr@2
  3062
williamr@2
  3063
@param aPtr The object for which a TCleanupItem is to be constructed.
williamr@2
  3064
*/
williamr@2
  3065
	{CleanupStack::PushL(TCleanupItem(&Delete,aPtr));}
williamr@2
  3066
williamr@2
  3067
williamr@2
  3068
williamr@2
  3069
williamr@2
  3070
template <class T>
williamr@2
  3071
void CleanupDelete<T>::Delete(TAny *aPtr)
williamr@2
  3072
/**
williamr@2
  3073
The cleanup operation to be performed.
williamr@2
  3074
williamr@2
  3075
@param aPtr A pointer to the object for which clean up is to be performed. 
williamr@2
  3076
            The implementation deletes this object.
williamr@2
  3077
*/
williamr@2
  3078
	{delete STATIC_CAST(T*,aPtr);}
williamr@2
  3079
williamr@2
  3080
williamr@2
  3081
williamr@2
  3082
williamr@2
  3083
// See header file e32base.h for in-source comment.
williamr@2
  3084
template <class T>
williamr@2
  3085
inline void CleanupDeletePushL(T* aPtr)
williamr@2
  3086
	{CleanupDelete<T>::PushL(aPtr);}
williamr@2
  3087
williamr@2
  3088
williamr@2
  3089
williamr@2
  3090
williamr@2
  3091
// Template class CleanupArrayDelete
williamr@2
  3092
template <class T>
williamr@2
  3093
inline void CleanupArrayDelete<T>::PushL(T* aPtr)
williamr@2
  3094
/**
williamr@2
  3095
Creates a TCleanupItem for the specified array.
williamr@2
  3096
williamr@2
  3097
The cleanup operation is the private static function ArrayDelete() of
williamr@2
  3098
this class, which deletes the specified array.
williamr@2
  3099
williamr@2
  3100
@param aPtr The array of class T type objects for which a TCleanupItem is
williamr@2
  3101
            to be constructed.
williamr@2
  3102
*/
williamr@2
  3103
	{CleanupStack::PushL(TCleanupItem(&ArrayDelete,aPtr));}
williamr@2
  3104
williamr@2
  3105
williamr@2
  3106
williamr@2
  3107
williamr@2
  3108
template <class T>
williamr@2
  3109
void CleanupArrayDelete<T>::ArrayDelete(TAny *aPtr)
williamr@2
  3110
/**
williamr@2
  3111
The cleanup operation to be performed.
williamr@2
  3112
williamr@2
  3113
@param aPtr A pointer to the array for which clean up is to be performed. 
williamr@2
  3114
            The implementation deletes this array.
williamr@2
  3115
*/
williamr@2
  3116
	{delete [] STATIC_CAST(T*,aPtr);}
williamr@2
  3117
williamr@2
  3118
williamr@2
  3119
williamr@2
  3120
williamr@2
  3121
// See header file e32base.h for in-source comment.
williamr@2
  3122
template <class T>
williamr@2
  3123
inline void CleanupArrayDeletePushL(T* aPtr)
williamr@2
  3124
	{CleanupArrayDelete<T>::PushL(aPtr);}
williamr@2
  3125
williamr@2
  3126
williamr@2
  3127
williamr@2
  3128
williamr@2
  3129
// Template class CleanupClose
williamr@2
  3130
template <class T>
williamr@2
  3131
inline void CleanupClose<T>::PushL(T& aRef)
williamr@2
  3132
/**
williamr@2
  3133
Creates a TCleanupItem for the specified object.
williamr@2
  3134
williamr@2
  3135
The cleanup operation is the private static function Close() of this class.
williamr@2
  3136
williamr@2
  3137
@param aRef The object for which a TCleanupItem is to be constructed.
williamr@2
  3138
*/
williamr@2
  3139
	{CleanupStack::PushL(TCleanupItem(&Close,&aRef));}
williamr@2
  3140
williamr@2
  3141
williamr@2
  3142
williamr@2
  3143
williamr@2
  3144
template <class T>
williamr@2
  3145
void CleanupClose<T>::Close(TAny *aPtr)
williamr@2
  3146
/**
williamr@2
  3147
The cleanup operation to be performed.
williamr@2
  3148
williamr@2
  3149
@param aPtr A pointer to the object for which clean up is to be performed. 
williamr@2
  3150
            The implementation calls Close() on this object.
williamr@2
  3151
*/
williamr@2
  3152
	{(STATIC_CAST(T*,aPtr))->Close();}
williamr@2
  3153
williamr@2
  3154
williamr@2
  3155
williamr@2
  3156
williamr@2
  3157
// See header file e32base.h for in-source comment.
williamr@2
  3158
template <class T>
williamr@2
  3159
inline void CleanupClosePushL(T& aRef)
williamr@2
  3160
	{CleanupClose<T>::PushL(aRef);}
williamr@2
  3161
williamr@2
  3162
williamr@2
  3163
williamr@2
  3164
williamr@2
  3165
// Template class CleanupRelease
williamr@2
  3166
template <class T>
williamr@2
  3167
inline void CleanupRelease<T>::PushL(T& aRef)
williamr@2
  3168
/**
williamr@2
  3169
Creates a TCleanupItem for the specified object.
williamr@2
  3170
williamr@2
  3171
The cleanup operation is the private static function Release() of this class.
williamr@2
  3172
williamr@2
  3173
@param aRef The object for which a TCleanupItem is to be constructed.
williamr@2
  3174
*/
williamr@2
  3175
	{CleanupStack::PushL(TCleanupItem(&Release,&aRef));}
williamr@2
  3176
williamr@2
  3177
williamr@2
  3178
williamr@2
  3179
williamr@2
  3180
template <class T>
williamr@2
  3181
void CleanupRelease<T>::Release(TAny *aPtr)
williamr@2
  3182
/**
williamr@2
  3183
The cleanup operation to be performed.
williamr@2
  3184
williamr@2
  3185
@param aPtr A pointer to the object for which clean up is to be performed. 
williamr@2
  3186
            The implementation calls Release() on this object.
williamr@2
  3187
*/
williamr@2
  3188
	{(STATIC_CAST(T*,aPtr))->Release();}
williamr@2
  3189
williamr@2
  3190
williamr@2
  3191
williamr@2
  3192
williamr@2
  3193
// See header file e32base.h for in-source comment.
williamr@2
  3194
template <class T>
williamr@2
  3195
inline void CleanupReleasePushL(T& aRef)
williamr@2
  3196
	{CleanupRelease<T>::PushL(aRef);}