epoc32/include/e32cmn.inl
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
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@4
     4
// under the terms of the License "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.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\e32cmn.inl
williamr@2
    15
// 
williamr@2
    16
//
williamr@2
    17
williamr@2
    18
#ifndef __PLACEMENT_NEW_INLINE
williamr@2
    19
#define __PLACEMENT_NEW_INLINE
williamr@2
    20
// Global placement operator new
williamr@2
    21
inline TAny* operator new(TUint /*aSize*/, TAny* aBase) __NO_THROW
williamr@2
    22
	{return aBase;}
williamr@2
    23
williamr@2
    24
// Global placement operator delete
williamr@2
    25
inline void operator delete(TAny* /*aPtr*/, TAny* /*aBase*/) __NO_THROW
williamr@2
    26
	{}
williamr@2
    27
#endif //__PLACEMENT_NEW_INLINE
williamr@2
    28
williamr@2
    29
#ifndef __PLACEMENT_VEC_NEW_INLINE
williamr@2
    30
#define __PLACEMENT_VEC_NEW_INLINE
williamr@2
    31
// Global placement operator new[]
williamr@2
    32
inline TAny* operator new[](TUint /*aSize*/, TAny* aBase) __NO_THROW
williamr@2
    33
	{return aBase;}
williamr@2
    34
williamr@2
    35
// Global placement operator delete[]
williamr@2
    36
inline void operator delete[](TAny* /*aPtr*/, TAny* /*aBase*/) __NO_THROW
williamr@2
    37
	{}
williamr@2
    38
#endif //__PLACEMENT_VEC_NEW_INLINE
williamr@2
    39
williamr@2
    40
williamr@2
    41
// class RAllocator
williamr@2
    42
inline RAllocator::RAllocator()
williamr@2
    43
	{
williamr@2
    44
	iAccessCount=1;
williamr@2
    45
	iHandleCount=0;
williamr@2
    46
	iHandles=0;
williamr@2
    47
	iFlags=0;
williamr@2
    48
	iCellCount=0;
williamr@2
    49
	iTotalAllocSize=0;
williamr@2
    50
	}
williamr@2
    51
inline void RAllocator::__DbgMarkCheck(TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum)
williamr@2
    52
	{__DbgMarkCheck(aCountAll, aCount, TPtrC8(aFileName), aLineNum);}
williamr@2
    53
williamr@2
    54
// Class RHeap
williamr@2
    55
inline RHeap::RHeap()
williamr@2
    56
	{}
williamr@2
    57
williamr@2
    58
/**
williamr@2
    59
@return The maximum length to which the heap can grow.
williamr@2
    60
williamr@2
    61
@publishedAll
williamr@2
    62
@released
williamr@2
    63
*/
williamr@2
    64
inline TInt RHeap::MaxLength() const
williamr@2
    65
	{return iMaxLength;}
williamr@2
    66
williamr@2
    67
inline void RHeap::operator delete(TAny*, TAny*) 
williamr@2
    68
/**
williamr@2
    69
Called if constructor issued by operator new(TUint aSize, TAny* aBase) throws exception.
williamr@2
    70
This is dummy as corresponding new operator does not allocate memory.
williamr@2
    71
*/
williamr@2
    72
	{}
williamr@2
    73
williamr@2
    74
williamr@2
    75
inline TUint8* RHeap::Base() const
williamr@2
    76
/**
williamr@2
    77
Gets a pointer to the start of the heap.
williamr@2
    78
	
williamr@2
    79
Note that because of the small space overhead incurred by all allocated cells, 
williamr@2
    80
no cell will have the same address as that returned by this function.
williamr@2
    81
	
williamr@2
    82
@return A pointer to the base of the heap.
williamr@2
    83
*/
williamr@2
    84
	{return iBase;}
williamr@2
    85
williamr@2
    86
williamr@2
    87
williamr@2
    88
williamr@2
    89
inline TInt RHeap::Size() const
williamr@2
    90
/**
williamr@2
    91
Gets the current size of the heap.
williamr@2
    92
williamr@2
    93
This is the total number of bytes committed by the host chunk. 
williamr@2
    94
It is the requested size rounded up by page size minus the size of RHeap object(116 bytes)
williamr@2
    95
minus the cell alignment overhead as shown:
williamr@2
    96
williamr@2
    97
Size = (Rounded committed size - Size of RHeap - Cell Alignment Overhead).
williamr@2
    98
williamr@2
    99
The cell alignment overhead varies between release builds and debug builds.
williamr@2
   100
williamr@2
   101
Note that this value is always greater than the total space available across all allocated cells.
williamr@2
   102
	
williamr@2
   103
@return The size of the heap.
williamr@2
   104
williamr@2
   105
@see Rheap::Available( )
williamr@2
   106
*/
williamr@2
   107
	{return iTop-iBase;}
williamr@2
   108
williamr@2
   109
williamr@2
   110
williamr@2
   111
williamr@2
   112
inline TInt RHeap::Align(TInt a) const
williamr@2
   113
/**
williamr@2
   114
@internalComponent
williamr@2
   115
*/
williamr@2
   116
	{return _ALIGN_UP(a, iAlign);}
williamr@2
   117
williamr@2
   118
williamr@2
   119
williamr@2
   120
williamr@2
   121
inline const TAny* RHeap::Align(const TAny* a) const
williamr@2
   122
/**
williamr@2
   123
@internalComponent
williamr@2
   124
*/
williamr@2
   125
	{return (const TAny*)_ALIGN_UP((TLinAddr)a, iAlign);}
williamr@2
   126
williamr@2
   127
williamr@2
   128
williamr@2
   129
williamr@2
   130
inline TBool RHeap::IsLastCell(const SCell* aCell) const
williamr@2
   131
/**
williamr@2
   132
@internalComponent
williamr@2
   133
*/
williamr@2
   134
	{return (((TUint8*)aCell) + aCell->len) == iTop;}
williamr@2
   135
williamr@2
   136
williamr@2
   137
williamr@2
   138
williamr@2
   139
#ifndef __KERNEL_MODE__
williamr@2
   140
inline void RHeap::Lock() const
williamr@2
   141
/**
williamr@2
   142
@internalComponent
williamr@2
   143
*/
williamr@2
   144
	{((RFastLock&)iLock).Wait();}
williamr@2
   145
williamr@2
   146
williamr@2
   147
williamr@2
   148
williamr@2
   149
inline void RHeap::Unlock() const
williamr@2
   150
/**
williamr@2
   151
@internalComponent
williamr@2
   152
*/
williamr@2
   153
	{((RFastLock&)iLock).Signal();}
williamr@2
   154
williamr@2
   155
williamr@2
   156
inline TInt RHeap::ChunkHandle() const
williamr@2
   157
/**
williamr@2
   158
@internalComponent
williamr@2
   159
*/
williamr@2
   160
	{
williamr@2
   161
	return iChunkHandle;
williamr@2
   162
	}
williamr@2
   163
#endif
williamr@2
   164
williamr@2
   165
williamr@2
   166
williamr@2
   167
williamr@2
   168
// Class TRefByValue
williamr@2
   169
template <class T>
williamr@2
   170
inline TRefByValue<T>::TRefByValue(T &aRef)
williamr@2
   171
	: iRef(aRef)
williamr@2
   172
/**
williamr@2
   173
Constructs this value reference for the specified referenced object.
williamr@2
   174
williamr@2
   175
@param aRef The referenced object.
williamr@2
   176
*/
williamr@2
   177
	{}
williamr@2
   178
williamr@2
   179
williamr@2
   180
williamr@2
   181
williamr@2
   182
template <class T>
williamr@2
   183
inline TRefByValue<T>::operator T &()
williamr@2
   184
/**
williamr@2
   185
Gets a reference to the object encapsulated inside this value reference.
williamr@2
   186
*/
williamr@2
   187
	{return(iRef);}
williamr@2
   188
williamr@2
   189
williamr@2
   190
williamr@2
   191
williamr@2
   192
/**
williamr@2
   193
Creates the logical channel.
williamr@2
   194
williamr@2
   195
@param aDevice    The name of the logical device for which the channel
williamr@2
   196
                  is to be constructed. This is the name by which
williamr@2
   197
				  the LDD factory object, i.e. the instance of
williamr@2
   198
				  the DLogicalDevice derived class, is known.
williamr@2
   199
@param aVer       The required version of the logical device. The driver
williamr@2
   200
                  normally checks this against the version of the logical
williamr@2
   201
				  channel, returning KErrNotSupported if the logical channel
williamr@2
   202
				  is not compatible.
williamr@2
   203
@param aUnit      A unit of the device. This argument only has meaning if
williamr@2
   204
                  the flag KDeviceAllowUnit is set in the iParseMask data
williamr@2
   205
				  member of the LDD factory object.
williamr@2
   206
@param aDriver    A pointer to a descriptor containing the name of
williamr@2
   207
                  a physical device. This is the name by which the PDD
williamr@2
   208
				  factory object, i.e. the instance of the DPhysicalDevice
williamr@2
   209
				  derived class, is known.
williamr@2
   210
                  This is NULL, if no explicit name is to be supplied, or
williamr@2
   211
				  the logical device does not require an accompanying physical
williamr@2
   212
				  device.
williamr@2
   213
@param aInfo      A pointer to an explicit 8-bit descriptor containing extra
williamr@2
   214
                  information for the physical device. This argument only has
williamr@2
   215
				  meaning if the KDeviceAllowInfo flag is set in the iParseMask
williamr@2
   216
				  data member of the LDD factory object.
williamr@2
   217
@param aType      An enumeration whose enumerators define the ownership of
williamr@2
   218
                  this handle. If not explicitly specified, EOwnerProcess is
williamr@2
   219
				  taken as default.
williamr@2
   220
@param aTransferable If false, the channel is created as an object which is
williamr@2
   221
                     local/private to the current process.
williamr@2
   222
                     If true, the channel is an object which may be shared with
williamr@2
   223
                     other processes using the IPC mechanisms for handle passing.
williamr@2
   224
	
williamr@2
   225
@return  KErrNone, if successful; otherwise one of the other system wide
williamr@2
   226
         error codes.
williamr@2
   227
*/
williamr@2
   228
inline TInt RBusLogicalChannel::DoCreate(const TDesC& aDevice, const TVersion& aVer, TInt aUnit, const TDesC* aDriver, const TDesC8* aInfo, TOwnerType aType, TBool aTransferable)
williamr@2
   229
	{ return DoCreate(aDevice, aVer, aUnit, aDriver, aInfo, (TInt)aType | (aTransferable?KCreateProtectedObject:0) ); }
williamr@2
   230
williamr@2
   231
williamr@2
   232
williamr@2
   233
williamr@2
   234
// Class TChar
williamr@2
   235
inline TChar::TChar()
williamr@2
   236
/**
williamr@2
   237
Default constructor.
williamr@2
   238
williamr@2
   239
Constructs this character object with an undefined value.
williamr@2
   240
*/
williamr@2
   241
	{}
williamr@2
   242
williamr@2
   243
williamr@2
   244
williamr@2
   245
williamr@2
   246
inline TChar::TChar(TUint aChar)
williamr@2
   247
	: iChar(aChar)
williamr@2
   248
/**
williamr@2
   249
Constructs this character object and initialises it with the specified value.
williamr@2
   250
williamr@2
   251
@param aChar The initialisation value.
williamr@2
   252
*/
williamr@2
   253
	{}
williamr@2
   254
williamr@2
   255
williamr@2
   256
williamr@2
   257
williamr@2
   258
inline TChar& TChar::operator-=(TUint aChar)
williamr@2
   259
/**
williamr@2
   260
Subtracts an unsigned integer value from this character object.
williamr@2
   261
williamr@2
   262
This character object is changed by the operation.
williamr@2
   263
williamr@2
   264
@param aChar The value to be subtracted.
williamr@2
   265
williamr@2
   266
@return A reference to this character object.
williamr@2
   267
*/
williamr@2
   268
	{iChar-=aChar;return(*this);}
williamr@2
   269
williamr@2
   270
williamr@2
   271
williamr@2
   272
williamr@2
   273
inline TChar& TChar::operator+=(TUint aChar)
williamr@2
   274
/**
williamr@2
   275
Adds an unsigned integer value to this character object.
williamr@2
   276
williamr@2
   277
This character object is changed by the operation.
williamr@2
   278
williamr@2
   279
@param aChar The value to be added.
williamr@2
   280
williamr@2
   281
@return A reference to this character object.
williamr@2
   282
*/
williamr@2
   283
	{iChar+=aChar;return(*this);}
williamr@2
   284
williamr@2
   285
williamr@2
   286
williamr@2
   287
williamr@2
   288
inline TChar TChar::operator-(TUint aChar)
williamr@2
   289
/**
williamr@2
   290
Gets the result of subtracting an unsigned integer value from this character 
williamr@2
   291
object.
williamr@2
   292
williamr@2
   293
This character object is not changed.
williamr@2
   294
williamr@2
   295
@param aChar The value to be subtracted.
williamr@2
   296
williamr@2
   297
@return A character object whose value is the result of the subtraction
williamr@2
   298
        operation.
williamr@2
   299
*/
williamr@2
   300
	{return(iChar-aChar);}
williamr@2
   301
williamr@2
   302
williamr@2
   303
williamr@2
   304
williamr@2
   305
inline TChar TChar::operator+(TUint aChar)
williamr@2
   306
/** 
williamr@2
   307
Gets the result of adding an unsigned integer value to this character object. 
williamr@2
   308
williamr@2
   309
This character object is not changed.
williamr@2
   310
williamr@2
   311
@param aChar The value to be added.
williamr@2
   312
williamr@2
   313
@return A character object whose value is the result of the addition operation.
williamr@2
   314
*/
williamr@2
   315
	{return(iChar+aChar);}
williamr@2
   316
williamr@2
   317
williamr@2
   318
williamr@2
   319
williamr@2
   320
inline TChar::operator TUint() const
williamr@2
   321
/**
williamr@2
   322
Gets the value of the character as an unsigned integer. 
williamr@2
   323
williamr@2
   324
The operator casts a TChar to a TUint, returning the TUint value wrapped by
williamr@2
   325
this character object.
williamr@2
   326
*/
williamr@2
   327
	{return(iChar);}
williamr@2
   328
williamr@2
   329
williamr@2
   330
williamr@2
   331
williamr@2
   332
// Class TDesC8
williamr@2
   333
inline TBool TDesC8::operator<(const TDesC8 &aDes) const
williamr@2
   334
/**
williamr@2
   335
Determines whether this descriptor's data is less than the specified
williamr@2
   336
descriptor's data.
williamr@2
   337
williamr@2
   338
The comparison is implemented using the Compare() member function.
williamr@2
   339
williamr@2
   340
@param aDes The 8-bit non-modifable descriptor whose data is to be compared 
williamr@2
   341
            with this descriptor's data.
williamr@2
   342
            
williamr@2
   343
@return True if greater than or equal, false otherwise.
williamr@2
   344
williamr@2
   345
@see TDesC8::Compare
williamr@2
   346
*/
williamr@2
   347
	{return(Compare(aDes)<0);}
williamr@2
   348
williamr@2
   349
williamr@2
   350
williamr@2
   351
williamr@2
   352
inline TBool TDesC8::operator<=(const TDesC8 &aDes) const
williamr@2
   353
/**
williamr@2
   354
Determines whether this descriptor's data is less than or equal to the
williamr@2
   355
specified descriptor's data.
williamr@2
   356
williamr@2
   357
The comparison is implemented using the Compare() member function.
williamr@2
   358
williamr@2
   359
@param aDes The 8-bit non-modifable descriptor whose data is to be compared 
williamr@2
   360
            with this descriptor's data. 
williamr@2
   361
            
williamr@2
   362
@return True if less than or equal, false otherwise. 
williamr@2
   363
williamr@2
   364
@see TDesC8::Compare
williamr@2
   365
*/
williamr@2
   366
	{return(Compare(aDes)<=0);}
williamr@2
   367
williamr@2
   368
williamr@2
   369
williamr@2
   370
williamr@2
   371
inline TBool TDesC8::operator>(const TDesC8 &aDes) const
williamr@2
   372
/**
williamr@2
   373
Determines whether this descriptor's data is greater than the specified
williamr@2
   374
descriptor's data.
williamr@2
   375
williamr@2
   376
The comparison is implemented using the Compare() member function.
williamr@2
   377
williamr@2
   378
@param aDes The 8-bit non-modifable descriptor whose data is to be compared 
williamr@2
   379
            with this descriptor's data. 
williamr@2
   380
            
williamr@2
   381
@return True if greater than, false otherwise. 
williamr@2
   382
williamr@2
   383
@see TDesC8::Compare
williamr@2
   384
*/
williamr@2
   385
	{return(Compare(aDes)>0);}
williamr@2
   386
williamr@2
   387
williamr@2
   388
williamr@2
   389
williamr@2
   390
inline TBool TDesC8::operator>=(const TDesC8 &aDes) const
williamr@2
   391
/**
williamr@2
   392
Determines whether this descriptor's data is greater than or equal to the
williamr@2
   393
specified descriptor's data.
williamr@2
   394
williamr@2
   395
The comparison is implemented using the Compare() member function.
williamr@2
   396
williamr@2
   397
@param aDes The 8-bit non-modifable descriptor whose data is to be compared 
williamr@2
   398
            with this descriptor's data. 
williamr@2
   399
            
williamr@2
   400
@return True if greater than, false otherwise.
williamr@2
   401
williamr@2
   402
@see TDesC8::Compare
williamr@2
   403
*/
williamr@2
   404
	{return(Compare(aDes)>=0);}
williamr@2
   405
williamr@2
   406
williamr@2
   407
williamr@2
   408
williamr@2
   409
inline TBool TDesC8::operator==(const TDesC8 &aDes) const
williamr@2
   410
/**
williamr@2
   411
Determines whether this descriptor's data is equal to the specified
williamr@2
   412
descriptor's data.
williamr@2
   413
williamr@2
   414
The comparison is implemented using the Compare() member function.
williamr@2
   415
williamr@2
   416
@param aDes The 8-bit non-modifable descriptor whose data is to be compared 
williamr@2
   417
            with this descriptor's data. 
williamr@2
   418
            
williamr@2
   419
@return True if equal, false otherwise. 
williamr@2
   420
williamr@2
   421
@see TDesC8::Compare
williamr@2
   422
*/
williamr@2
   423
	{return(Compare(aDes)==0);}
williamr@2
   424
williamr@2
   425
williamr@2
   426
williamr@2
   427
williamr@2
   428
inline TBool TDesC8::operator!=(const TDesC8 &aDes) const
williamr@2
   429
/**
williamr@2
   430
Determines whether this descriptor's data is not equal to the specified
williamr@2
   431
descriptor's data.
williamr@2
   432
williamr@2
   433
The comparison is implemented using the Compare() member function.
williamr@2
   434
williamr@2
   435
@param aDes The 8-bit non-modifable descriptor whose data is to be compared 
williamr@2
   436
            with this descriptor's data. 
williamr@2
   437
            
williamr@2
   438
@return True if not equal, false otherwise. 
williamr@2
   439
williamr@2
   440
@see TDesC8::Compare
williamr@2
   441
*/
williamr@2
   442
	{return(Compare(aDes)!=0);}
williamr@2
   443
williamr@2
   444
williamr@2
   445
williamr@2
   446
williamr@2
   447
inline const TUint8 &TDesC8::operator[](TInt anIndex) const
williamr@2
   448
/**
williamr@2
   449
Gets a reference to a single data item within this descriptor's data.
williamr@2
   450
williamr@2
   451
@param anIndex The position of the individual data item within the descriptor's 
williamr@2
   452
               data. This is an offset value; a zero value refers to the
williamr@2
   453
               leftmost data position. 
williamr@2
   454
               
williamr@2
   455
@return A reference to the data item.
williamr@2
   456
williamr@2
   457
@panic USER 21, if anIndex is negative or greater than or equal to the current
williamr@2
   458
                length of the descriptor.
williamr@2
   459
*/
williamr@2
   460
	{return(AtC(anIndex));}
williamr@2
   461
williamr@2
   462
williamr@2
   463
williamr@2
   464
williamr@2
   465
inline TInt TDesC8::Length() const
williamr@2
   466
/**
williamr@2
   467
Gets the length of the data.
williamr@2
   468
williamr@2
   469
This is the number of 8-bit values or data items represented by the descriptor.
williamr@2
   470
williamr@2
   471
@return The length of the data represented by the descriptor.
williamr@2
   472
*/
williamr@2
   473
	{return(iLength&KMaskDesLength8);}
williamr@2
   474
williamr@2
   475
williamr@2
   476
williamr@2
   477
williamr@2
   478
inline TInt TDesC8::Size() const
williamr@2
   479
/**
williamr@2
   480
Gets the size of the data.
williamr@2
   481
williamr@2
   482
This is the number of bytes occupied by the data represented by the descriptor.
williamr@2
   483
williamr@2
   484
@return The size of the data represented by the descriptor.
williamr@2
   485
*/
williamr@2
   486
	{return(Length());}
williamr@2
   487
williamr@2
   488
williamr@2
   489
williamr@2
   490
williamr@2
   491
inline void TDesC8::DoSetLength(TInt aLength)
williamr@2
   492
	{iLength=(iLength&(~KMaskDesLength8))|aLength;}
williamr@2
   493
williamr@2
   494
williamr@2
   495
williamr@2
   496
williamr@2
   497
// Class TPtrC8
williamr@2
   498
inline void TPtrC8::Set(const TUint8 *aBuf,TInt aLength)
williamr@2
   499
/**
williamr@2
   500
Sets the 8-bit non-modifiable pointer descriptor to point to the specified 
williamr@2
   501
location in memory, whether in RAM or ROM.
williamr@2
   502
williamr@2
   503
The length of the descriptor is set to the specified length.
williamr@2
   504
williamr@2
   505
@param aBuf    A pointer to the location that the descriptor is to represent.
williamr@2
   506
@param aLength The length of the descriptor. This value must be non-negative.
williamr@2
   507
williamr@2
   508
@panic USER 29, if aLength is negative.
williamr@2
   509
*/
williamr@2
   510
	{new(this) TPtrC8(aBuf,aLength);}
williamr@2
   511
williamr@2
   512
williamr@2
   513
williamr@2
   514
williamr@2
   515
inline void TPtrC8::Set(const TDesC8 &aDes)
williamr@2
   516
/**
williamr@2
   517
Sets the 8-bit non-modifiable pointer descriptor from the specified descriptor.
williamr@2
   518
williamr@2
   519
It is set to point to the same data and is given the same length.
williamr@2
   520
williamr@2
   521
@param aDes A reference to an 8-bit non-modifiable descriptor.
williamr@2
   522
*/
williamr@2
   523
	{new(this) TPtrC8(aDes);}
williamr@2
   524
williamr@2
   525
williamr@2
   526
williamr@2
   527
williamr@2
   528
inline void TPtrC8::Set(const TPtrC8& aPtr)
williamr@2
   529
/**
williamr@2
   530
Sets the 8-bit non-modifiable pointer descriptor from the specified
williamr@2
   531
non-modifiable pointer descriptor.
williamr@2
   532
williamr@2
   533
It is set to point to the same data and is given the same length.
williamr@2
   534
williamr@2
   535
@param aPtr A reference to an 8-bit non-modifiable pointer descriptor.
williamr@2
   536
*/
williamr@2
   537
	{new(this) TPtrC8(aPtr);}
williamr@2
   538
williamr@2
   539
williamr@2
   540
williamr@2
   541
williamr@2
   542
williamr@2
   543
// class TBufCBase8
williamr@2
   544
inline TPtr8 TBufCBase8::DoDes(TInt aMaxLength)
williamr@2
   545
	{return TPtr8(*this,aMaxLength);}
williamr@2
   546
williamr@2
   547
williamr@2
   548
williamr@2
   549
williamr@2
   550
// Template class TBufC8
williamr@2
   551
template <TInt S>
williamr@2
   552
inline TBufC8<S>::TBufC8()
williamr@2
   553
	: TBufCBase8()
williamr@2
   554
/** 
williamr@2
   555
Constructs an empty 8-bit non-modifiable buffer descriptor.
williamr@2
   556
williamr@2
   557
It contains no data.
williamr@2
   558
williamr@2
   559
The integer template parameter determines the size of the data area which 
williamr@2
   560
is created as part of the buffer descriptor object.
williamr@2
   561
williamr@2
   562
Data can, subsequently, be assigned into this buffer descriptor using the 
williamr@2
   563
assignment operators.
williamr@2
   564
williamr@2
   565
@see TBufC8::operator=
williamr@2
   566
*/
williamr@2
   567
	{}
williamr@2
   568
williamr@2
   569
williamr@2
   570
williamr@2
   571
williamr@2
   572
template <TInt S>
williamr@2
   573
inline TBufC8<S>::TBufC8(const TUint8 *aString)
williamr@2
   574
	: TBufCBase8(aString,S)
williamr@2
   575
/**
williamr@2
   576
Constructs the 8-bit non-modifiable buffer descriptor from a zero terminated 
williamr@2
   577
string.
williamr@2
   578
williamr@2
   579
The integer template parameter determines the size of the data area which 
williamr@2
   580
is created as part of this object.
williamr@2
   581
williamr@2
   582
The string, excluding the zero terminator, is copied into this buffer descriptor's 
williamr@2
   583
data area. The length of this buffer descriptor is set to the length of the 
williamr@2
   584
string, excluding the zero terminator.
williamr@2
   585
williamr@2
   586
@param aString A pointer to a zero terminated string.
williamr@2
   587
williamr@2
   588
@panic USER 20, if the length of the string, excluding the zero terminator, is
williamr@2
   589
                greater than the value of the integer template parameter.
williamr@2
   590
*/
williamr@2
   591
	{}
williamr@2
   592
williamr@2
   593
williamr@2
   594
williamr@2
   595
williamr@2
   596
template <TInt S>
williamr@2
   597
inline TBufC8<S>::TBufC8(const TDesC8 &aDes)
williamr@2
   598
	: TBufCBase8(aDes,S)
williamr@2
   599
/**
williamr@2
   600
Constructs the 8-bit non-modifiable buffer descriptor from any
williamr@2
   601
existing descriptor.
williamr@2
   602
williamr@2
   603
The integer template parameter determines the size of the data area which 
williamr@2
   604
is created as part of this object.
williamr@2
   605
williamr@2
   606
Data is copied from the source descriptor into this buffer descriptor and 
williamr@2
   607
the length of this buffer descriptor is set to the length of the
williamr@2
   608
source descriptor.
williamr@2
   609
williamr@2
   610
@param aDes The source 8-bit non-modifiable descriptor.
williamr@2
   611
williamr@2
   612
@panic USER 20, if the length of the source descriptor is
williamr@2
   613
                greater than the value of the integer template parameter.
williamr@2
   614
*/
williamr@2
   615
	{}
williamr@2
   616
williamr@2
   617
williamr@2
   618
williamr@2
   619
williamr@2
   620
template <TInt S>
williamr@2
   621
inline TBufC8<S> &TBufC8<S>::operator=(const TUint8 *aString)
williamr@2
   622
/**
williamr@2
   623
Copies data into this descriptor, replacing any existing data.
williamr@2
   624
williamr@2
   625
The length of this descriptor is set to reflect the new data.
williamr@2
   626
williamr@2
   627
@param aString A pointer to a zero-terminated string. 
williamr@2
   628
williamr@2
   629
@return A reference to this descriptor.
williamr@2
   630
williamr@2
   631
@panic USER 23, if the length of the string, excluding the zero terminator, is
williamr@2
   632
                greater than the maximum length of this (target) descriptor.
williamr@2
   633
*/
williamr@2
   634
	{Copy(aString,S);return(*this);}
williamr@2
   635
williamr@2
   636
williamr@2
   637
williamr@2
   638
williamr@2
   639
template <TInt S>
williamr@2
   640
inline TBufC8<S> &TBufC8<S>::operator=(const TDesC8 &aDes)
williamr@2
   641
/**
williamr@2
   642
Copies data into this descriptor, replacing any existing data.
williamr@2
   643
williamr@2
   644
The length of this descriptor is set to reflect the new data.
williamr@2
   645
williamr@2
   646
@param aDes An 8-bit non-modifiable descriptor. 
williamr@2
   647
williamr@2
   648
@return A reference to this descriptor.
williamr@2
   649
williamr@2
   650
@panic USER 23, if the length of the descriptor aDes is
williamr@2
   651
                greater than the maximum length of this (target) descriptor.
williamr@2
   652
*/
williamr@2
   653
	{Copy(aDes,S);return(*this);}
williamr@2
   654
williamr@2
   655
williamr@2
   656
williamr@2
   657
williamr@2
   658
template <TInt S>
williamr@2
   659
inline TPtr8 TBufC8<S>::Des()
williamr@2
   660
/**
williamr@2
   661
Creates and returns an 8-bit modifiable pointer descriptor for the data
williamr@2
   662
represented by this 8-bit non-modifiable buffer descriptor.
williamr@2
   663
williamr@2
   664
The content of a non-modifiable buffer descriptor normally cannot be altered, 
williamr@2
   665
other than by complete replacement of the data. Creating a modifiable pointer 
williamr@2
   666
descriptor provides a way of changing the data.
williamr@2
   667
williamr@2
   668
The modifiable pointer descriptor is set to point to this non-modifiable buffer 
williamr@2
   669
descriptor's data.
williamr@2
   670
williamr@2
   671
The length of the modifiable pointer descriptor is set to the length of this 
williamr@2
   672
non-modifiable buffer descriptor.
williamr@2
   673
williamr@2
   674
The maximum length of the modifiable pointer descriptor is set to the value 
williamr@2
   675
of the integer template parameter.
williamr@2
   676
williamr@2
   677
When data is modified through this new pointer descriptor, the lengths of 
williamr@2
   678
both it and this constant buffer descriptor are changed.
williamr@2
   679
williamr@2
   680
@return An 8-bit modifiable pointer descriptor representing the data in this 
williamr@2
   681
        8-bit non-modifiable buffer descriptor.
williamr@2
   682
*/
williamr@2
   683
	{return DoDes(S);}
williamr@2
   684
williamr@2
   685
williamr@2
   686
williamr@2
   687
williamr@2
   688
#ifndef __KERNEL_MODE__
williamr@2
   689
// Class HBufC8
williamr@2
   690
inline HBufC8 &HBufC8::operator=(const HBufC8 &aLcb)
williamr@2
   691
/**
williamr@2
   692
Copies data into this 8-bit heap descriptor replacing any existing data.
williamr@2
   693
williamr@2
   694
The length of this descriptor is set to reflect the new data.
williamr@2
   695
williamr@2
   696
Note that the maximum length of this (target) descriptor is the length
williamr@2
   697
of the descriptor buffer in the allocated host heap cell; this may be greater
williamr@2
   698
than the maximum length specified when this descriptor was created or
williamr@2
   699
last re-allocated.
williamr@2
   700
williamr@2
   701
@param aLcb The source 8-bit heap descriptor.
williamr@2
   702
williamr@2
   703
@return A reference to this 8-bit heap descriptor.
williamr@2
   704
williamr@2
   705
@panic USER 23, if the length of the descriptor aLcb is greater than the
williamr@2
   706
                maximum length of this (target) descriptor
williamr@2
   707
*/
williamr@2
   708
	{return *this=static_cast<const TDesC8&>(aLcb);}
williamr@2
   709
williamr@2
   710
williamr@2
   711
williamr@2
   712
williamr@2
   713
// Class RBuf8
williamr@2
   714
inline RBuf8& RBuf8::operator=(const TUint8* aString)
williamr@2
   715
/**
williamr@2
   716
Copies data into this descriptor replacing any existing data.
williamr@2
   717
williamr@2
   718
The length of this descriptor is set to reflect the new data.
williamr@2
   719
williamr@2
   720
@param aString A pointer to a zero-terminated string.
williamr@2
   721
williamr@2
   722
@return A reference to this, the target descriptor.
williamr@2
   723
williamr@2
   724
@panic USER 11, if the length of the string, excluding the zero terminator, is
williamr@2
   725
                greater than the maximum length of this (target) descriptor.
williamr@2
   726
*/
williamr@2
   727
    {Copy(aString);return(*this);}
williamr@2
   728
williamr@2
   729
williamr@2
   730
williamr@2
   731
williamr@2
   732
inline RBuf8& RBuf8::operator=(const TDesC8& aDes)
williamr@2
   733
/**
williamr@2
   734
Copies data into this descriptor replacing any existing data.
williamr@2
   735
williamr@2
   736
The length of this descriptor is set to reflect the new data.
williamr@2
   737
williamr@2
   738
@param aDes An 8-bit non-modifiable descriptor.
williamr@2
   739
williamr@2
   740
@return A reference to this, the target descriptor.
williamr@2
   741
williamr@2
   742
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
   743
                maximum length of this (target) descriptor.
williamr@2
   744
*/
williamr@2
   745
    {Copy(aDes);return(*this);}
williamr@2
   746
williamr@2
   747
williamr@2
   748
williamr@2
   749
williamr@2
   750
inline RBuf8& RBuf8::operator=(const RBuf8& aDes)
williamr@2
   751
/**
williamr@2
   752
Copies data into this descriptor replacing any existing data.
williamr@2
   753
williamr@2
   754
The length of this descriptor is set to reflect the new data.
williamr@2
   755
williamr@2
   756
@param aDes A 8-bit buffer descriptor.
williamr@2
   757
williamr@2
   758
@return A reference to this, the target descriptor.
williamr@2
   759
williamr@2
   760
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
   761
                maximum length of this (target) descriptor.
williamr@2
   762
*/
williamr@2
   763
    {Copy(aDes);return(*this);}
williamr@2
   764
williamr@2
   765
williamr@2
   766
williamr@2
   767
williamr@2
   768
/**
williamr@2
   769
Creates an 8-bit resizable buffer descriptor that has been initialised with
williamr@2
   770
data from the specified read stream; leaves on failure.
williamr@2
   771
			 
williamr@2
   772
Data is assigned to the new descriptor from the specified stream.
williamr@2
   773
This variant assumes that the stream contains the length of the data followed
williamr@2
   774
by the data itself.
williamr@2
   775
williamr@2
   776
The function is implemented by calling the HBufC8::NewL(RReadStream&amp;,TInt)
williamr@2
   777
variant and then assigning the resulting heap descriptor using
williamr@2
   778
the RBuf8::Assign(HBufC8*) variant. The comments that describe
williamr@2
   779
the HBufC8::NewL() variant	also apply to this RBuf8::CreateL() function.
williamr@2
   780
williamr@2
   781
The function may leave with one of the system-wide error codes,	specifically 
williamr@2
   782
KErrOverflow, if the length of the data as read from the stream is greater than
williamr@2
   783
the upper limit as specified by the aMaxLength parameter.
williamr@2
   784
williamr@2
   785
@param aStream    The stream from which the data length and the data to be
williamr@2
   786
                  assigned to the new descriptor, are taken.
williamr@2
   787
@param aMaxLength The upper limit on the length of data that the descriptor is
williamr@2
   788
                  to represent. The value of this parameter must be non-negative
williamr@2
   789
                  otherwise the	underlying function will panic.
williamr@2
   790
*/
williamr@2
   791
inline void RBuf8::CreateL(RReadStream &aStream,TInt aMaxLength)
williamr@2
   792
	{
williamr@2
   793
	Assign(HBufC8::NewL(aStream,aMaxLength));
williamr@2
   794
	}
williamr@2
   795
#endif
williamr@2
   796
williamr@2
   797
williamr@2
   798
williamr@2
   799
williamr@2
   800
// Class TDes8
williamr@2
   801
inline TDes8 &TDes8::operator=(const TUint8 *aString)
williamr@2
   802
/**
williamr@2
   803
Copies data into this descriptor replacing any existing data.
williamr@2
   804
williamr@2
   805
The length of this descriptor is set to reflect the new data.
williamr@2
   806
williamr@2
   807
@param aString A pointer to a zero-terminated string.
williamr@2
   808
williamr@2
   809
@return A reference to this, the target descriptor.
williamr@2
   810
williamr@2
   811
@panic USER 23, if the length of the string, excluding the zero terminator, is
williamr@2
   812
                greater than the maximum length of this (target) descriptor.
williamr@2
   813
*/
williamr@2
   814
    {Copy(aString);return(*this);}
williamr@2
   815
williamr@2
   816
williamr@2
   817
williamr@2
   818
williamr@2
   819
inline TDes8 &TDes8::operator=(const TDesC8 &aDes)
williamr@2
   820
/**
williamr@2
   821
Copies data into this descriptor replacing any existing data.
williamr@2
   822
williamr@2
   823
The length of this descriptor is set to reflect the new data.
williamr@2
   824
williamr@2
   825
@param aDes An 8-bit non-modifiable descriptor. 
williamr@2
   826
 
williamr@2
   827
@return A reference to this, the target descriptor.
williamr@2
   828
williamr@2
   829
@panic USER 23, if the length of the descriptor aDes is greater than the
williamr@2
   830
                maximum length of this (target) descriptor.
williamr@2
   831
*/
williamr@2
   832
    {Copy(aDes);return(*this);}
williamr@2
   833
williamr@2
   834
williamr@2
   835
williamr@2
   836
williamr@2
   837
inline TDes8 &TDes8::operator=(const TDes8 &aDes)
williamr@2
   838
/**
williamr@2
   839
Copies data into this descriptor replacing any existing data.
williamr@2
   840
williamr@2
   841
The length of this descriptor is set to reflect the new data.
williamr@2
   842
williamr@2
   843
@param aDes An 8-bit modifiable descriptor.
williamr@2
   844
williamr@2
   845
@return A reference to this, the target descriptor.
williamr@2
   846
williamr@2
   847
@panic USER 23, if the length of the descriptor aDes is greater than the
williamr@2
   848
                maximum length of this (target) descriptor.
williamr@2
   849
*/
williamr@2
   850
    {Copy(aDes);return(*this);}
williamr@2
   851
williamr@2
   852
williamr@2
   853
williamr@2
   854
williamr@2
   855
inline TDes8 &TDes8::operator+=(const TDesC8 &aDes)
williamr@2
   856
/**
williamr@2
   857
Appends data onto the end of this descriptor's data and returns a reference 
williamr@2
   858
to this descriptor.
williamr@2
   859
williamr@2
   860
The length of this descriptor is incremented to reflect the new content.
williamr@2
   861
williamr@2
   862
@param aDes An-8 bit non-modifiable descriptor whose data is to be appended.
williamr@2
   863
williamr@2
   864
@return A reference to this descriptor.
williamr@2
   865
williamr@2
   866
@panic USER 23, if the resulting length of this descriptor is greater than its
williamr@2
   867
                maximum length.  
williamr@2
   868
*/
williamr@2
   869
	{Append(aDes);return(*this);}
williamr@2
   870
williamr@2
   871
williamr@2
   872
williamr@2
   873
williamr@2
   874
inline const TUint8 &TDes8::operator[](TInt anIndex) const
williamr@2
   875
/**
williamr@2
   876
Gets a const reference to a single data item within this descriptor's data.
williamr@2
   877
williamr@2
   878
@param anIndex The position of the data item within this descriptor's data.
williamr@2
   879
               This is an offset value; a zero value refers to the leftmost
williamr@2
   880
			   data position.
williamr@2
   881
williamr@2
   882
@return A const reference to the data item at the specified position. 
williamr@2
   883
williamr@2
   884
@panic USER 21, if anIndex is negative or is greater than or equal to the
williamr@2
   885
                current length of this descriptor.
williamr@2
   886
*/
williamr@2
   887
	{return(AtC(anIndex));}
williamr@2
   888
williamr@2
   889
williamr@2
   890
williamr@2
   891
williamr@2
   892
inline TUint8 &TDes8::operator[](TInt anIndex)
williamr@2
   893
/**
williamr@2
   894
Gets a non-const reference to a single data item within this descriptor's 
williamr@2
   895
data.
williamr@2
   896
williamr@2
   897
@param anIndex The position of the data item within this descriptor's data.
williamr@2
   898
               This is an offset value; a zero value refers to the leftmost
williamr@2
   899
			   data position.
williamr@2
   900
williamr@2
   901
@return A non-const reference to the data item at the specified position.
williamr@2
   902
williamr@2
   903
@panic USER 21, if anIndex is negative or is greater than or equal to the
williamr@2
   904
                current length of this descriptor.
williamr@2
   905
*/
williamr@2
   906
	{return((TUint8 &)AtC(anIndex));}
williamr@2
   907
williamr@2
   908
williamr@2
   909
williamr@2
   910
williamr@2
   911
inline TInt TDes8::MaxLength() const
williamr@2
   912
/**
williamr@2
   913
Gets the maximum length of the descriptor.
williamr@2
   914
williamr@2
   915
This is the upper limit for the number of 8-bit values or data items that
williamr@2
   916
the descriptor can represent.
williamr@2
   917
williamr@2
   918
@return The maximum length of data that the descriptor can represent.
williamr@2
   919
*/
williamr@2
   920
	{return(iMaxLength);}
williamr@2
   921
williamr@2
   922
williamr@2
   923
williamr@2
   924
williamr@2
   925
inline TInt TDes8::MaxSize() const
williamr@2
   926
/**
williamr@2
   927
Gets the maximum size of the descriptor.
williamr@2
   928
williamr@2
   929
This is the upper limit for the number of bytes which the data represented by
williamr@2
   930
the descriptor can occupy.
williamr@2
   931
williamr@2
   932
@return The maximum size of the descriptor data.
williamr@2
   933
*/
williamr@2
   934
	{return(iMaxLength);}
williamr@2
   935
williamr@2
   936
williamr@2
   937
williamr@2
   938
williamr@2
   939
inline TUint8 * TDes8::WPtr() const
williamr@2
   940
	{return((TUint8 *)Ptr());}
williamr@2
   941
williamr@2
   942
williamr@2
   943
williamr@2
   944
williamr@2
   945
// Class TPtr8
williamr@2
   946
inline TPtr8 &TPtr8::operator=(const TUint8 *aString)
williamr@2
   947
/**
williamr@2
   948
Copies data into this 8-bit modifiable pointer descriptor replacing any
williamr@2
   949
existing data.
williamr@2
   950
williamr@2
   951
The length of this descriptor is set to reflect the new data.
williamr@2
   952
williamr@2
   953
@param aString A pointer to a zero-terminated string.
williamr@2
   954
williamr@2
   955
@return A reference to this 8-bit modifiable pointer descriptor.
williamr@2
   956
williamr@2
   957
@panic USER 23, if the length of the string, excluding the zero terminator, is
williamr@2
   958
                greater than the maximum length of this descriptor.
williamr@2
   959
*/
williamr@2
   960
	{Copy(aString);return(*this);}
williamr@2
   961
williamr@2
   962
williamr@2
   963
williamr@2
   964
williamr@2
   965
inline TPtr8 &TPtr8::operator=(const TDesC8 &aDes)
williamr@2
   966
/**
williamr@2
   967
Copies data into this 8-bit modifiable pointer descriptor replacing any
williamr@2
   968
existing data.
williamr@2
   969
williamr@2
   970
The length of this descriptor is set to reflect the new data.
williamr@2
   971
williamr@2
   972
@param aDes An 8-bit modifiable pointer descriptor whose data is to be copied 
williamr@2
   973
            into this descriptor.
williamr@2
   974
williamr@2
   975
@return A reference to this 8-bit modifiable pointer descriptor.
williamr@2
   976
williamr@2
   977
@panic USER 23, if the length of aDes is greater than the maximum 
williamr@2
   978
                length of this descriptor.
williamr@2
   979
*/
williamr@2
   980
	{Copy(aDes);return(*this);}
williamr@2
   981
williamr@2
   982
williamr@2
   983
williamr@2
   984
williamr@2
   985
inline TPtr8 &TPtr8::operator=(const TPtr8 &aDes)
williamr@2
   986
/**
williamr@2
   987
Copies data into this 8-bit modifiable pointer descriptor replacing any
williamr@2
   988
existing data.
williamr@2
   989
williamr@2
   990
The length of this descriptor is set to reflect the new data.
williamr@2
   991
williamr@2
   992
@param aDes An 8-bit modifiable pointer descriptor whose data is to be copied
williamr@2
   993
            into this descriptor.
williamr@2
   994
williamr@2
   995
@return A reference to this 8-bit modifiable pointer descriptor.
williamr@2
   996
williamr@2
   997
@panic USER 23, if the length of aDes is greater than the maximum 
williamr@2
   998
                length of this descriptor.
williamr@2
   999
*/
williamr@2
  1000
	{Copy(aDes);return(*this);}
williamr@2
  1001
williamr@2
  1002
williamr@2
  1003
williamr@2
  1004
williamr@2
  1005
inline void TPtr8::Set(TUint8 *aBuf,TInt aLength,TInt aMaxLength)
williamr@2
  1006
/**
williamr@2
  1007
Sets the 8-bit modifiable pointer descriptor to point to the specified location
williamr@2
  1008
in memory, whether in RAM or ROM.
williamr@2
  1009
williamr@2
  1010
The length of the descriptor and its maximum length are set to the specified
williamr@2
  1011
values.
williamr@2
  1012
williamr@2
  1013
@param aBuf       A pointer to the location that the descriptor is to represent.
williamr@2
  1014
@param aLength    The length of the descriptor.
williamr@2
  1015
@param aMaxLength The maximum length of the descriptor.
williamr@2
  1016
williamr@2
  1017
@panic USER 20, if aLength is negative or is greater than the maximum length of
williamr@2
  1018
                this descriptor.
williamr@2
  1019
@panic USER 30, if aMaxLength is negative.
williamr@2
  1020
*/
williamr@2
  1021
	{new(this) TPtr8(aBuf,aLength,aMaxLength);}
williamr@2
  1022
williamr@2
  1023
williamr@2
  1024
williamr@2
  1025
williamr@2
  1026
inline void TPtr8::Set(const TPtr8 &aPtr)
williamr@2
  1027
/**
williamr@2
  1028
Sets the 8-bit modifiable pointer descriptor from an existing 8-bit modifiable
williamr@2
  1029
pointer descriptor.
williamr@2
  1030
  
williamr@2
  1031
It is set to point to the same data, is given the same length and the same
williamr@2
  1032
maximum length as the source pointer descriptor.
williamr@2
  1033
williamr@2
  1034
@param aPtr The source 8-bit modifiable pointer descriptor.
williamr@2
  1035
*/
williamr@2
  1036
	{new(this) TPtr8(aPtr);}
williamr@2
  1037
williamr@2
  1038
williamr@2
  1039
williamr@2
  1040
williamr@2
  1041
// Template class TBuf8
williamr@2
  1042
template <TInt S>
williamr@2
  1043
inline TBuf8<S>::TBuf8()
williamr@2
  1044
	: TBufBase8(S)
williamr@2
  1045
/**
williamr@2
  1046
Constructs an empty 8-bit modifiable buffer descriptor.
williamr@2
  1047
williamr@2
  1048
It contains no data.
williamr@2
  1049
williamr@2
  1050
The integer template parameter determines the size of the data area that is created 
williamr@2
  1051
as part of the object, and defines the descriptor's maximum length.
williamr@2
  1052
*/
williamr@2
  1053
	{}
williamr@2
  1054
williamr@2
  1055
williamr@2
  1056
williamr@2
  1057
williamr@2
  1058
template <TInt S>
williamr@2
  1059
inline TBuf8<S>::TBuf8(TInt aLength)
williamr@2
  1060
	: TBufBase8(aLength,S)
williamr@2
  1061
/**
williamr@2
  1062
Constructs an empty 8-bit modifiable buffer descriptor and sets the its length 
williamr@2
  1063
to the specified value.
williamr@2
  1064
williamr@2
  1065
No data is assigned to the descriptor.
williamr@2
  1066
williamr@2
  1067
The integer template parameter determines the size of the data area that is created 
williamr@2
  1068
as part of the object, and defines the descriptor's maximum length.
williamr@2
  1069
williamr@2
  1070
@param aLength The length of this modifiable buffer descriptor.
williamr@2
  1071
williamr@2
  1072
@panic USER 20, if aLength is negative or is greater than the 
williamr@2
  1073
                value of the integer template parameter.
williamr@2
  1074
*/
williamr@2
  1075
	{}
williamr@2
  1076
williamr@2
  1077
williamr@2
  1078
williamr@2
  1079
williamr@2
  1080
template <TInt S>
williamr@2
  1081
inline TBuf8<S>::TBuf8(const TUint8 *aString)
williamr@2
  1082
	: TBufBase8(aString,S)
williamr@2
  1083
/**
williamr@2
  1084
Constructs the 8-bit modifiable buffer descriptor from a
williamr@2
  1085
zero terminated string.
williamr@2
  1086
williamr@2
  1087
The integer template parameter determines the size of the data area that
williamr@2
  1088
is created as part of the object, and defines the descriptor's maximum length.
williamr@2
  1089
williamr@2
  1090
The string, excluding the zero terminator, is copied into this buffer
williamr@2
  1091
descriptor's data area. The length of this buffer descriptor is set to the
williamr@2
  1092
length of the string, excluding the zero terminator.
williamr@2
  1093
williamr@2
  1094
@param aString A pointer to a zero terminated string.
williamr@2
  1095
williamr@2
  1096
@panic USER 23, if the length of the string, excluding the zero terminator,
williamr@2
  1097
                is greater than the value of the integer template parameter.
williamr@2
  1098
*/
williamr@2
  1099
	{}
williamr@2
  1100
williamr@2
  1101
williamr@2
  1102
williamr@2
  1103
williamr@2
  1104
template <TInt S>
williamr@2
  1105
inline TBuf8<S>::TBuf8(const TDesC8 &aDes)
williamr@2
  1106
	: TBufBase8(aDes,S)
williamr@2
  1107
/**
williamr@2
  1108
Constructs the 8-bit modifiable buffer descriptor from any existing
williamr@2
  1109
8-bit descriptor.
williamr@2
  1110
williamr@2
  1111
The integer template parameter determines the size of the data area created 
williamr@2
  1112
as part of this object and defines the descriptor's maximum length.
williamr@2
  1113
williamr@2
  1114
Data is copied from the source descriptor into this modifiable buffer
williamr@2
  1115
descriptor and the length of this modifiable buffer descriptor is set to
williamr@2
  1116
the length of the source descriptor.
williamr@2
  1117
williamr@2
  1118
@param aDes The source 8-bit non-modifiable descriptor.
williamr@2
  1119
williamr@2
  1120
@panic USER 23, if the length of the source descriptor is greater than the
williamr@2
  1121
                value of the integer template parameter.
williamr@2
  1122
*/
williamr@2
  1123
	{}
williamr@2
  1124
williamr@2
  1125
williamr@2
  1126
williamr@2
  1127
williamr@2
  1128
template <TInt S>
williamr@2
  1129
inline TBuf8<S> &TBuf8<S>::operator=(const TUint8 *aString)
williamr@2
  1130
/**
williamr@2
  1131
Copies data into this 8-bit modifiable buffer descriptor, replacing any
williamr@2
  1132
existing data.
williamr@2
  1133
williamr@2
  1134
The length of this descriptor is set to reflect the new data.
williamr@2
  1135
williamr@2
  1136
@param aString A pointer to a zero-terminated string.
williamr@2
  1137
williamr@2
  1138
@return A reference to this 8-bit modifiable buffer descriptor. 
williamr@2
  1139
williamr@2
  1140
@panic USER 23, if the length of the string, excluding the zero terminator,
williamr@2
  1141
                is greater than the maximum length of this (target) descriptor.
williamr@2
  1142
*/
williamr@2
  1143
	{Copy(aString);return(*this);}
williamr@2
  1144
williamr@2
  1145
williamr@2
  1146
williamr@2
  1147
williamr@2
  1148
template <TInt S>
williamr@2
  1149
inline TBuf8<S> &TBuf8<S>::operator=(const TDesC8 &aDes)
williamr@2
  1150
/**
williamr@2
  1151
Copies data into this 8-bit modifiable buffer descriptor, replacing any
williamr@2
  1152
existing data.
williamr@2
  1153
williamr@2
  1154
The length of this descriptor is set to reflect the new data.
williamr@2
  1155
williamr@2
  1156
@param aDes An 8 bit non-modifiable descriptor.
williamr@2
  1157
williamr@2
  1158
@return A reference to this 8-bit modifiable buffer descriptor. 
williamr@2
  1159
williamr@2
  1160
@panic USER 23, if the length of the descriptor aDes is greater than the
williamr@2
  1161
                maximum length of this (target) descriptor.
williamr@2
  1162
*/
williamr@2
  1163
	{Copy(aDes);return(*this);}
williamr@2
  1164
williamr@2
  1165
williamr@2
  1166
williamr@2
  1167
williamr@2
  1168
template <TInt S>
williamr@2
  1169
inline TBuf8<S>& TBuf8<S>::operator=(const TBuf8<S>& aBuf)
williamr@2
  1170
/**
williamr@2
  1171
Copies data into this 8-bit modifiable buffer descriptor replacing any
williamr@2
  1172
existing data.
williamr@2
  1173
williamr@2
  1174
The length of this descriptor is set to reflect the new data.
williamr@2
  1175
williamr@2
  1176
@param aBuf The source 8-bit modifiable buffer descriptor with the same
williamr@2
  1177
            template value.
williamr@2
  1178
williamr@2
  1179
@return A reference to this 8-bit modifiable buffer descriptor. 
williamr@2
  1180
*/
williamr@2
  1181
	{Copy(aBuf);return *this;}
williamr@2
  1182
williamr@2
  1183
williamr@2
  1184
williamr@2
  1185
williamr@2
  1186
// Template class TAlignedBuf8
williamr@2
  1187
template <TInt S>
williamr@2
  1188
inline TAlignedBuf8<S>::TAlignedBuf8()
williamr@2
  1189
	: TBufBase8(S)
williamr@2
  1190
/**
williamr@2
  1191
Constructs an empty 8-bit modifiable buffer descriptor.
williamr@2
  1192
williamr@2
  1193
It contains no data.
williamr@2
  1194
williamr@2
  1195
The integer template parameter determines the size of the data area that is created 
williamr@2
  1196
as part of the object, and defines the descriptor's maximum length.
williamr@2
  1197
*/
williamr@2
  1198
	{}
williamr@2
  1199
williamr@2
  1200
williamr@2
  1201
williamr@2
  1202
williamr@2
  1203
template <TInt S>
williamr@2
  1204
inline TAlignedBuf8<S>::TAlignedBuf8(TInt aLength)
williamr@2
  1205
	: TBufBase8(aLength,S)
williamr@2
  1206
/**
williamr@2
  1207
Constructs an empty 8-bit modifiable buffer descriptor and sets the its length 
williamr@2
  1208
to the specified value.
williamr@2
  1209
williamr@2
  1210
No data is assigned to the descriptor.
williamr@2
  1211
williamr@2
  1212
The integer template parameter determines the size of the data area that is created 
williamr@2
  1213
as part of the object, and defines the descriptor's maximum length.
williamr@2
  1214
williamr@2
  1215
@param aLength The length of this modifiable buffer descriptor.
williamr@2
  1216
williamr@2
  1217
@panic USER 20, if aLength is negative or is greater than the 
williamr@2
  1218
                value of the integer template parameter.
williamr@2
  1219
*/
williamr@2
  1220
	{}
williamr@2
  1221
williamr@2
  1222
williamr@2
  1223
williamr@2
  1224
williamr@2
  1225
template <TInt S>
williamr@2
  1226
inline TAlignedBuf8<S>::TAlignedBuf8(const TUint8 *aString)
williamr@2
  1227
	: TBufBase8(aString,S)
williamr@2
  1228
/**
williamr@2
  1229
Constructs the 8-bit modifiable buffer descriptor from a
williamr@2
  1230
zero terminated string.
williamr@2
  1231
williamr@2
  1232
The integer template parameter determines the size of the data area that
williamr@2
  1233
is created as part of the object, and defines the descriptor's maximum length.
williamr@2
  1234
williamr@2
  1235
The string, excluding the zero terminator, is copied into this buffer
williamr@2
  1236
descriptor's data area. The length of this buffer descriptor is set to the
williamr@2
  1237
length of the string, excluding the zero terminator.
williamr@2
  1238
williamr@2
  1239
@param aString A pointer to a zero terminated string.
williamr@2
  1240
williamr@2
  1241
@panic USER 23, if the length of the string, excluding the zero terminator,
williamr@2
  1242
                is greater than the value of the integer template parameter.
williamr@2
  1243
*/
williamr@2
  1244
	{}
williamr@2
  1245
williamr@2
  1246
williamr@2
  1247
williamr@2
  1248
williamr@2
  1249
template <TInt S>
williamr@2
  1250
inline TAlignedBuf8<S>::TAlignedBuf8(const TDesC8 &aDes)
williamr@2
  1251
	: TBufBase8(aDes,S)
williamr@2
  1252
/**
williamr@2
  1253
Constructs the 8-bit modifiable buffer descriptor from any existing
williamr@2
  1254
8-bit descriptor.
williamr@2
  1255
williamr@2
  1256
The integer template parameter determines the size of the data area created 
williamr@2
  1257
as part of this object and defines the descriptor's maximum length.
williamr@2
  1258
williamr@2
  1259
Data is copied from the source descriptor into this modifiable buffer
williamr@2
  1260
descriptor and the length of this modifiable buffer descriptor is set to
williamr@2
  1261
the length of the source descriptor.
williamr@2
  1262
williamr@2
  1263
@param aDes The source 8-bit non-modifiable descriptor.
williamr@2
  1264
williamr@2
  1265
@panic USER 23, if the length of the source descriptor is greater than the
williamr@2
  1266
                value of the integer template parameter.
williamr@2
  1267
*/
williamr@2
  1268
	{}
williamr@2
  1269
williamr@2
  1270
williamr@2
  1271
williamr@2
  1272
williamr@2
  1273
template <TInt S>
williamr@2
  1274
inline TAlignedBuf8<S> &TAlignedBuf8<S>::operator=(const TUint8 *aString)
williamr@2
  1275
/**
williamr@2
  1276
Copies data into this 8-bit modifiable buffer descriptor, replacing any
williamr@2
  1277
existing data.
williamr@2
  1278
williamr@2
  1279
The length of this descriptor is set to reflect the new data.
williamr@2
  1280
williamr@2
  1281
@param aString A pointer to a zero-terminated string.
williamr@2
  1282
williamr@2
  1283
@return A reference to this 8-bit modifiable buffer descriptor. 
williamr@2
  1284
williamr@2
  1285
@panic USER 23, if the length of the string, excluding the zero terminator,
williamr@2
  1286
                is greater than the maximum length of this (target) descriptor.
williamr@2
  1287
*/
williamr@2
  1288
	{Copy(aString);return(*this);}
williamr@2
  1289
williamr@2
  1290
williamr@2
  1291
williamr@2
  1292
williamr@2
  1293
template <TInt S>
williamr@2
  1294
inline TAlignedBuf8<S> &TAlignedBuf8<S>::operator=(const TDesC8 &aDes)
williamr@2
  1295
/**
williamr@2
  1296
Copies data into this 8-bit modifiable buffer descriptor, replacing any
williamr@2
  1297
existing data.
williamr@2
  1298
williamr@2
  1299
The length of this descriptor is set to reflect the new data.
williamr@2
  1300
williamr@2
  1301
@param aDes An 8 bit non-modifiable descriptor.
williamr@2
  1302
williamr@2
  1303
@return A reference to this 8-bit modifiable buffer descriptor. 
williamr@2
  1304
williamr@2
  1305
@panic USER 23, if the length of the descriptor aDes is greater than the
williamr@2
  1306
                maximum length of this (target) descriptor.
williamr@2
  1307
*/
williamr@2
  1308
	{Copy(aDes);return(*this);}
williamr@2
  1309
williamr@2
  1310
williamr@2
  1311
williamr@2
  1312
williamr@2
  1313
template <TInt S>
williamr@2
  1314
inline TAlignedBuf8<S>& TAlignedBuf8<S>::operator=(const TAlignedBuf8<S>& aBuf)
williamr@2
  1315
/**
williamr@2
  1316
Copies data into this 8-bit modifiable buffer descriptor replacing any
williamr@2
  1317
existing data.
williamr@2
  1318
williamr@2
  1319
The length of this descriptor is set to reflect the new data.
williamr@2
  1320
williamr@2
  1321
@param aBuf The source 8-bit modifiable buffer descriptor with the same
williamr@2
  1322
            template value.
williamr@2
  1323
williamr@2
  1324
@return A reference to this 8-bit modifiable buffer descriptor. 
williamr@2
  1325
*/
williamr@2
  1326
	{Copy(aBuf);return *this;}
williamr@2
  1327
williamr@2
  1328
williamr@2
  1329
williamr@2
  1330
williamr@2
  1331
// Template class TLitC8
williamr@2
  1332
template <TInt S>
williamr@2
  1333
inline const TDesC8* TLitC8<S>::operator&() const
williamr@2
  1334
/**
williamr@2
  1335
Returns a const TDesC8 type pointer.
williamr@2
  1336
williamr@2
  1337
@return A descriptor type pointer to this literal. 
williamr@2
  1338
*/
williamr@2
  1339
	{return REINTERPRET_CAST(const TDesC8*,this);}
williamr@2
  1340
williamr@2
  1341
williamr@2
  1342
williamr@2
  1343
williamr@2
  1344
template <TInt S>
williamr@2
  1345
inline const TDesC8& TLitC8<S>::operator()() const
williamr@2
  1346
/**
williamr@2
  1347
Returns a const TDesC8 type reference.
williamr@2
  1348
williamr@2
  1349
@return A descriptor type reference to this literal 
williamr@2
  1350
*/
williamr@2
  1351
	{return *operator&();}
williamr@2
  1352
williamr@2
  1353
williamr@2
  1354
williamr@2
  1355
williamr@2
  1356
template <TInt S>
williamr@2
  1357
inline TLitC8<S>::operator const TDesC8&() const
williamr@2
  1358
/**
williamr@2
  1359
Invoked by the compiler when a TLitC8<TInt> type is passed to a function
williamr@2
  1360
which is prototyped to take a const TDesC8& type.
williamr@2
  1361
*/
williamr@2
  1362
	{return *operator&();}
williamr@2
  1363
williamr@2
  1364
williamr@2
  1365
williamr@2
  1366
template <TInt S>
williamr@2
  1367
inline TLitC8<S>::operator const __TRefDesC8() const
williamr@2
  1368
/**
williamr@2
  1369
Invoked by the compiler when a TLitC8<TInt> type is passed to a function
williamr@2
  1370
which is prototyped to take a const TRefByValue<const TDesC8> type.
williamr@2
  1371
williamr@2
  1372
@see __TRefDesC8
williamr@2
  1373
*/
williamr@2
  1374
	{return *operator&();}
williamr@2
  1375
williamr@2
  1376
williamr@2
  1377
williamr@2
  1378
williamr@2
  1379
#ifndef __KERNEL_MODE__
williamr@2
  1380
// Class TDesC16
williamr@2
  1381
inline TBool TDesC16::operator<(const TDesC16 &aDes) const
williamr@2
  1382
/**
williamr@2
  1383
Determines whether this descriptor's data is less than the specified descriptor's 
williamr@2
  1384
data.
williamr@2
  1385
williamr@2
  1386
The comparison is implemented using the Compare() member function.
williamr@2
  1387
williamr@2
  1388
@param aDes The 16-bit non-modifable descriptor whose data is to be compared 
williamr@2
  1389
            with this descriptor's data. 
williamr@2
  1390
williamr@2
  1391
@return True if less than, false otherwise. 
williamr@2
  1392
williamr@2
  1393
@see TDesC16::Compare
williamr@2
  1394
*/
williamr@2
  1395
	{return(Compare(aDes)<0);}
williamr@2
  1396
williamr@2
  1397
williamr@2
  1398
williamr@2
  1399
williamr@2
  1400
inline TBool TDesC16::operator<=(const TDesC16 &aDes) const
williamr@2
  1401
/**
williamr@2
  1402
Determines whether this descriptor's data is less than or equal
williamr@2
  1403
to the specified descriptor's data.
williamr@2
  1404
williamr@2
  1405
The comparison is implemented using the Compare() member function.
williamr@2
  1406
williamr@2
  1407
@param aDes The 16-bit non- modifiable descriptor whose data is to be compared 
williamr@2
  1408
            with this descriptor's data. 
williamr@2
  1409
williamr@2
  1410
@return True if less than or equal, false otherwise. 
williamr@2
  1411
williamr@2
  1412
@see TDesC16::Compare
williamr@2
  1413
*/
williamr@2
  1414
	{return(Compare(aDes)<=0);}
williamr@2
  1415
williamr@2
  1416
williamr@2
  1417
williamr@2
  1418
williamr@2
  1419
inline TBool TDesC16::operator>(const TDesC16 &aDes) const
williamr@2
  1420
/**
williamr@2
  1421
Determines whether this descriptor's data is greater than the specified
williamr@2
  1422
descriptor's data.
williamr@2
  1423
williamr@2
  1424
The comparison is implemented using the Compare() member function.
williamr@2
  1425
williamr@2
  1426
@param aDes The 16-bit non-modifiable descriptor whose data is to be compared 
williamr@2
  1427
            with this descriptor's data. 
williamr@2
  1428
williamr@2
  1429
@return True if greater than, false otherwise. 
williamr@2
  1430
williamr@2
  1431
@see TDesC16::Compare
williamr@2
  1432
*/
williamr@2
  1433
	{return(Compare(aDes)>0);}
williamr@2
  1434
williamr@2
  1435
williamr@2
  1436
williamr@2
  1437
williamr@2
  1438
inline TBool TDesC16::operator>=(const TDesC16 &aDes) const
williamr@2
  1439
/**
williamr@2
  1440
Determines whether this descriptor's data is greater than or equal to the
williamr@2
  1441
specified descriptor's data.
williamr@2
  1442
williamr@2
  1443
The comparison is implemented using the Compare() member function.
williamr@2
  1444
williamr@2
  1445
@param aDes The 16-bit non-modifiable descriptor whose data is to be compared 
williamr@2
  1446
            with this descriptor's data. 
williamr@2
  1447
williamr@2
  1448
@return True if greater than or equal, false otherwise. 
williamr@2
  1449
williamr@2
  1450
@see TDesC16::Compare
williamr@2
  1451
*/
williamr@2
  1452
	{return(Compare(aDes)>=0);}
williamr@2
  1453
williamr@2
  1454
williamr@2
  1455
williamr@2
  1456
williamr@2
  1457
inline TBool TDesC16::operator==(const TDesC16 &aDes) const
williamr@2
  1458
/**
williamr@2
  1459
Determines whether this descriptor's data is equal to the specified
williamr@2
  1460
descriptor's data.
williamr@2
  1461
williamr@2
  1462
The comparison is implemented using the Compare() member function.
williamr@2
  1463
williamr@2
  1464
@param aDes The 16-bit non-modifiable descriptor whose data is to be compared 
williamr@2
  1465
            with this descriptor's data. 
williamr@2
  1466
williamr@2
  1467
@return True if equal, false otherwise. 
williamr@2
  1468
williamr@2
  1469
@see TDesC16::Compare
williamr@2
  1470
*/
williamr@2
  1471
	{return(Compare(aDes)==0);}
williamr@2
  1472
williamr@2
  1473
williamr@2
  1474
williamr@2
  1475
williamr@2
  1476
inline TBool TDesC16::operator!=(const TDesC16 &aDes) const
williamr@2
  1477
/**
williamr@2
  1478
Determines whether this descriptor's data is not equal to the specified
williamr@2
  1479
descriptor's data.
williamr@2
  1480
williamr@2
  1481
The comparison is implemented using the Compare() member function.
williamr@2
  1482
williamr@2
  1483
@param aDes The 16-bit non-modifiable descriptor whose data is to be compared 
williamr@2
  1484
            with this descriptor's data. 
williamr@2
  1485
williamr@2
  1486
@return True if not equal, false otherwise. 
williamr@2
  1487
williamr@2
  1488
@see TDesC16::Compare
williamr@2
  1489
*/
williamr@2
  1490
	{return(Compare(aDes)!=0);}
williamr@2
  1491
williamr@2
  1492
williamr@2
  1493
williamr@2
  1494
williamr@2
  1495
inline const TUint16 &TDesC16::operator[](TInt anIndex) const
williamr@2
  1496
/**
williamr@2
  1497
Gets a reference to a single data item within this descriptor's data.
williamr@2
  1498
williamr@2
  1499
@param anIndex The position of the individual data item within the descriptor's 
williamr@2
  1500
               data. This is an offset value; a zero value refers to the
williamr@2
  1501
			   leftmost data position. 
williamr@2
  1502
williamr@2
  1503
@return A reference to the data item.
williamr@2
  1504
williamr@2
  1505
@panic USER 9, if anIndex is negative or greater than or equal to the current
williamr@2
  1506
               length of the descriptor.
williamr@2
  1507
*/
williamr@2
  1508
	{return(AtC(anIndex));}
williamr@2
  1509
williamr@2
  1510
williamr@2
  1511
williamr@2
  1512
williamr@2
  1513
inline TInt TDesC16::Length() const
williamr@2
  1514
/**
williamr@2
  1515
Gets the length of the data.
williamr@2
  1516
williamr@2
  1517
This is the number of 16-bit values or data items represented by the descriptor.
williamr@2
  1518
williamr@2
  1519
@return The length of the data represented by the descriptor.
williamr@2
  1520
*/
williamr@2
  1521
	{return(iLength&KMaskDesLength16);}
williamr@2
  1522
williamr@2
  1523
williamr@2
  1524
williamr@2
  1525
williamr@2
  1526
inline TInt TDesC16::Size() const
williamr@2
  1527
/**
williamr@2
  1528
Gets the size of the data.
williamr@2
  1529
williamr@2
  1530
This is the number of bytes occupied by the data represented by the descriptor.
williamr@2
  1531
williamr@2
  1532
@return The size of the data represented by the descriptor. This is always 
williamr@2
  1533
        twice the length.
williamr@2
  1534
 */
williamr@2
  1535
	{return(Length()<<1);}
williamr@2
  1536
williamr@2
  1537
williamr@2
  1538
williamr@2
  1539
williamr@2
  1540
inline void TDesC16::DoSetLength(TInt aLength)
williamr@2
  1541
	{iLength=(iLength&(~KMaskDesLength16))|aLength;}
williamr@2
  1542
williamr@2
  1543
williamr@2
  1544
williamr@2
  1545
williamr@2
  1546
// Class TPtrC16
williamr@2
  1547
inline void TPtrC16::Set(const TUint16 *aBuf,TInt aLength)
williamr@2
  1548
/**
williamr@2
  1549
Sets the 16-bit non-modifiable pointer descriptor to point to the specified 
williamr@2
  1550
location in memory, whether in RAM or ROM.
williamr@2
  1551
williamr@2
  1552
The length of the descriptor is set to the specified length.
williamr@2
  1553
williamr@2
  1554
@param aBuf    A pointer to the location that the descriptor is to represent.
williamr@2
  1555
@param aLength The length of the descriptor. This value must be non-negative 
williamr@2
  1556
williamr@2
  1557
@panic USER 17, if aLength is negative.
williamr@2
  1558
*/
williamr@2
  1559
	{new(this) TPtrC16(aBuf,aLength);}
williamr@2
  1560
williamr@2
  1561
williamr@2
  1562
williamr@2
  1563
williamr@2
  1564
inline void TPtrC16::Set(const TDesC16 &aDes)
williamr@2
  1565
/**
williamr@2
  1566
Sets the 16-bit non-modifiable pointer descriptor from the specified descriptor.
williamr@2
  1567
williamr@2
  1568
It is set to point to the same data and is given the same length.
williamr@2
  1569
williamr@2
  1570
@param aDes A reference to a 16-bit non-modifiable descriptor
williamr@2
  1571
*/
williamr@2
  1572
	{new(this) TPtrC16(aDes);}
williamr@2
  1573
williamr@2
  1574
williamr@2
  1575
williamr@2
  1576
williamr@2
  1577
inline void TPtrC16::Set(const TPtrC16& aPtr)
williamr@2
  1578
	{new(this) TPtrC16(aPtr);}
williamr@2
  1579
williamr@2
  1580
williamr@2
  1581
williamr@2
  1582
williamr@2
  1583
// class TBufCBase16
williamr@2
  1584
inline TPtr16 TBufCBase16::DoDes(TInt aMaxLength)
williamr@2
  1585
	{return TPtr16(*this,aMaxLength);}
williamr@2
  1586
williamr@2
  1587
williamr@2
  1588
williamr@2
  1589
williamr@2
  1590
// Template class TBufC16
williamr@2
  1591
template <TInt S>
williamr@2
  1592
inline TBufC16<S>::TBufC16()
williamr@2
  1593
	: TBufCBase16()
williamr@2
  1594
/**
williamr@2
  1595
Constructs an empty 16-bit non-modifiable buffer descriptor. 
williamr@2
  1596
williamr@2
  1597
It contains no data.
williamr@2
  1598
williamr@2
  1599
The integer template parameter determines the size of the data area which 
williamr@2
  1600
is created as part of the buffer descriptor object.
williamr@2
  1601
williamr@2
  1602
Data can, subsequently, be assigned into this buffer descriptor using the 
williamr@2
  1603
assignment operators.
williamr@2
  1604
williamr@2
  1605
@see TBufC16::operator=
williamr@2
  1606
*/
williamr@2
  1607
	{}
williamr@2
  1608
williamr@2
  1609
williamr@2
  1610
williamr@2
  1611
williamr@2
  1612
template <TInt S>
williamr@2
  1613
inline TBufC16<S>::TBufC16(const TUint16 *aString)
williamr@2
  1614
	: TBufCBase16(aString,S)
williamr@2
  1615
/** 
williamr@2
  1616
Constructs the 16-bit non-modifiable buffer descriptor from a zero terminated
williamr@2
  1617
string.
williamr@2
  1618
williamr@2
  1619
The integer template parameter determines the size of the data area which 
williamr@2
  1620
is created as part of this object.
williamr@2
  1621
williamr@2
  1622
The string, excluding the zero terminator, is copied into this buffer descriptor's 
williamr@2
  1623
data area. The length of this buffer descriptor is set to the length of the 
williamr@2
  1624
string, excluding the zero terminator.
williamr@2
  1625
williamr@2
  1626
@panic USER 8, if the length of the string, excluding the zero terminator, is
williamr@2
  1627
               greater than the value of the integer template parameter.
williamr@2
  1628
williamr@2
  1629
@param aString A pointer to a zero terminated string.
williamr@2
  1630
*/
williamr@2
  1631
	{}
williamr@2
  1632
williamr@2
  1633
williamr@2
  1634
williamr@2
  1635
williamr@2
  1636
template <TInt S>
williamr@2
  1637
inline TBufC16<S>::TBufC16(const TDesC16 &aDes)
williamr@2
  1638
	: TBufCBase16(aDes,S)
williamr@2
  1639
/**
williamr@2
  1640
Constructs the 16-bit non-modifiable buffer descriptor from any
williamr@2
  1641
existing descriptor.
williamr@2
  1642
williamr@2
  1643
The integer template parameter determines the size of the data area which 
williamr@2
  1644
is created as part of this object.
williamr@2
  1645
williamr@2
  1646
Data is copied from the source descriptor into this buffer descriptor and 
williamr@2
  1647
the length of this buffer descriptor is set to the length of the
williamr@2
  1648
source descriptor.
williamr@2
  1649
williamr@2
  1650
@param aDes The source 16-bit non-modifiable descriptor.
williamr@2
  1651
williamr@2
  1652
@panic USER 8, if the length of the source descriptor is
williamr@2
  1653
               greater than the value of the integer template parameter.
williamr@2
  1654
*/
williamr@2
  1655
	{}
williamr@2
  1656
williamr@2
  1657
williamr@2
  1658
williamr@2
  1659
williamr@2
  1660
template <TInt S>
williamr@2
  1661
inline TBufC16<S> &TBufC16<S>::operator=(const TUint16 *aString)
williamr@2
  1662
/**
williamr@2
  1663
Copies data into this descriptor replacing any existing data.
williamr@2
  1664
williamr@2
  1665
The length of this descriptor is set to reflect the new data.
williamr@2
  1666
williamr@2
  1667
@param aString A pointer to a zero-terminated string.
williamr@2
  1668
williamr@2
  1669
@return A reference to this descriptor.
williamr@2
  1670
williamr@2
  1671
@panic USER 11, if the length of the string, excluding the zero terminator, is
williamr@2
  1672
                greater than the maximum length of this (target) descriptor.
williamr@2
  1673
*/
williamr@2
  1674
	{Copy(aString,S);return(*this);}
williamr@2
  1675
williamr@2
  1676
williamr@2
  1677
williamr@2
  1678
williamr@2
  1679
template <TInt S>
williamr@2
  1680
inline TBufC16<S> &TBufC16<S>::operator=(const TDesC16 &aDes)
williamr@2
  1681
/**
williamr@2
  1682
Copies data into this descriptor, replacing any existing data.
williamr@2
  1683
williamr@2
  1684
The length of this descriptor is set to reflect the new data.
williamr@2
  1685
williamr@2
  1686
@param aDes A 16-bit non-modifiable descriptor.
williamr@2
  1687
williamr@2
  1688
@panic USER 11, if the length of the descriptor aDes is
williamr@2
  1689
                greater than the maximum length of this (target) descriptor.
williamr@2
  1690
williamr@2
  1691
@return A reference to this descriptor.
williamr@2
  1692
*/
williamr@2
  1693
	{Copy(aDes,S);return(*this);}
williamr@2
  1694
williamr@2
  1695
williamr@2
  1696
williamr@2
  1697
williamr@2
  1698
template <TInt S>
williamr@2
  1699
inline TPtr16 TBufC16<S>::Des()
williamr@2
  1700
/**
williamr@2
  1701
Creates and returns a 16-bit modifiable pointer descriptor for the data
williamr@2
  1702
represented by this 16-bit non-modifiable buffer descriptor.
williamr@2
  1703
williamr@2
  1704
The content of a non-modifiable buffer descriptor normally cannot be altered, 
williamr@2
  1705
other than by complete replacement of the data. Creating a modifiable pointer 
williamr@2
  1706
descriptor provides a way of changing the data.
williamr@2
  1707
williamr@2
  1708
The modifiable pointer descriptor is set to point to this non-modifiable buffer 
williamr@2
  1709
descriptor's data.
williamr@2
  1710
williamr@2
  1711
The length of the modifiable pointer descriptor is set to the length of this 
williamr@2
  1712
non-modifiable buffer descriptor.
williamr@2
  1713
williamr@2
  1714
The maximum length of the modifiable pointer descriptor is set to the value 
williamr@2
  1715
of the integer template parameter.
williamr@2
  1716
williamr@2
  1717
When data is modified through this new pointer descriptor, the lengths of 
williamr@2
  1718
both it and this constant buffer descriptor are changed.
williamr@2
  1719
williamr@2
  1720
@return A 16-bit modifiable pointer descriptor representing the data in this 
williamr@2
  1721
        16-bit non-modifiable buffer descriptor.
williamr@2
  1722
*/
williamr@2
  1723
	{return(DoDes(S));}
williamr@2
  1724
williamr@2
  1725
williamr@2
  1726
williamr@2
  1727
williamr@2
  1728
#ifndef __KERNEL_MODE__
williamr@2
  1729
// Class HBufC16
williamr@2
  1730
inline HBufC16 &HBufC16::operator=(const HBufC16 &aLcb)
williamr@2
  1731
/**
williamr@2
  1732
Copies data into this 16-bit heap descriptor replacing any existing data.
williamr@2
  1733
williamr@2
  1734
The length of this descriptor is set to reflect the new data.
williamr@2
  1735
williamr@2
  1736
Note that the maximum length of this (target) descriptor is the length
williamr@2
  1737
of the descriptor buffer in the allocated host heap cell; this may be greater
williamr@2
  1738
than the maximum length specified when this descriptor was created or
williamr@2
  1739
last re-allocated.
williamr@2
  1740
williamr@2
  1741
@param aLcb The source 16-bit heap descriptor.
williamr@2
  1742
williamr@2
  1743
@return A reference to this 16-bit heap descriptor.
williamr@2
  1744
williamr@2
  1745
@panic USER 11, if the length of the descriptor aLcb is greater than the
williamr@2
  1746
                maximum length of this (target) descriptor
williamr@2
  1747
*/
williamr@2
  1748
	{return *this=static_cast<const TDesC16&>(aLcb);}
williamr@2
  1749
#endif
williamr@2
  1750
williamr@2
  1751
williamr@2
  1752
williamr@2
  1753
williamr@2
  1754
// Class TDes16
williamr@2
  1755
inline TDes16 &TDes16::operator=(const TUint16 *aString)
williamr@2
  1756
/**
williamr@2
  1757
Copies data into this descriptor replacing any existing data.
williamr@2
  1758
williamr@2
  1759
The length of this descriptor is set to reflect the new data.
williamr@2
  1760
williamr@2
  1761
@param aString A pointer to a zero-terminated string.
williamr@2
  1762
williamr@2
  1763
@return A reference to this, the target descriptor.
williamr@2
  1764
williamr@2
  1765
@panic USER 11, if the length of the string, excluding the zero terminator, is
williamr@2
  1766
                greater than the maximum length of this (target) descriptor.
williamr@2
  1767
*/
williamr@2
  1768
    {Copy(aString);return(*this);}
williamr@2
  1769
williamr@2
  1770
williamr@2
  1771
williamr@2
  1772
williamr@2
  1773
inline TDes16 &TDes16::operator=(const TDesC16 &aDes)
williamr@2
  1774
/**
williamr@2
  1775
Copies data into this descriptor replacing any existing data.
williamr@2
  1776
williamr@2
  1777
The length of this descriptor is set to reflect the new data.
williamr@2
  1778
williamr@2
  1779
@param aDes A 16-bit non-modifiable descriptor.
williamr@2
  1780
williamr@2
  1781
@return A reference to this, the target descriptor.
williamr@2
  1782
williamr@2
  1783
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  1784
                maximum length of this (target) descriptor.
williamr@2
  1785
*/
williamr@2
  1786
    {Copy(aDes);return(*this);}
williamr@2
  1787
williamr@2
  1788
williamr@2
  1789
williamr@2
  1790
williamr@2
  1791
inline TDes16 &TDes16::operator=(const TDes16 &aDes)
williamr@2
  1792
/**
williamr@2
  1793
Copies data into this descriptor replacing any existing data.
williamr@2
  1794
williamr@2
  1795
The length of this descriptor is set to reflect the new data.
williamr@2
  1796
williamr@2
  1797
@param aDes A 16-bit modifiable descriptor.
williamr@2
  1798
williamr@2
  1799
@return A reference to this, the target descriptor.
williamr@2
  1800
williamr@2
  1801
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  1802
                maximum length of this (target) descriptor.
williamr@2
  1803
*/
williamr@2
  1804
    {Copy(aDes);return(*this);}
williamr@2
  1805
williamr@2
  1806
williamr@2
  1807
williamr@2
  1808
williamr@2
  1809
inline TDes16 &TDes16::operator+=(const TDesC16 &aDes)
williamr@2
  1810
/** 
williamr@2
  1811
Appends data onto the end of this descriptor's data and returns a reference 
williamr@2
  1812
to this descriptor.
williamr@2
  1813
williamr@2
  1814
The length of this descriptor is incremented to reflect the new content.
williamr@2
  1815
williamr@2
  1816
@param aDes A 16-bit non-modifiable descriptor whose data is to be appended. 
williamr@2
  1817
williamr@2
  1818
@return A reference to this descriptor.
williamr@2
  1819
williamr@2
  1820
@panic USER 11, if the resulting length of this descriptor is greater than its
williamr@2
  1821
                maximum length.  
williamr@2
  1822
*/
williamr@2
  1823
	{Append(aDes);return(*this);}
williamr@2
  1824
williamr@2
  1825
williamr@2
  1826
williamr@2
  1827
williamr@2
  1828
inline const TUint16 &TDes16::operator[](TInt anIndex) const
williamr@2
  1829
/**
williamr@2
  1830
Gets a const reference to a single data item within this descriptor's data.
williamr@2
  1831
williamr@2
  1832
@param anIndex The position the data item within this descriptor's data. This 
williamr@2
  1833
is an offset value; a zero value refers to the leftmost data position.
williamr@2
  1834
williamr@2
  1835
@return A const reference to the data item at the specified position.
williamr@2
  1836
williamr@2
  1837
@panic USER 9, if anIndex is negative or is greater than or equal to the
williamr@2
  1838
                current length of this descriptor.
williamr@2
  1839
*/
williamr@2
  1840
	{return(AtC(anIndex));}
williamr@2
  1841
williamr@2
  1842
williamr@2
  1843
williamr@2
  1844
williamr@2
  1845
inline TUint16 &TDes16::operator[](TInt anIndex)
williamr@2
  1846
/** 
williamr@2
  1847
Gets a non-const reference to a single data item within this descriptor's 
williamr@2
  1848
data.
williamr@2
  1849
williamr@2
  1850
@param anIndex The position of the data item within this descriptor's data.
williamr@2
  1851
               This is an offset value; a zero value refers to the leftmost
williamr@2
  1852
			   data position. 
williamr@2
  1853
			   
williamr@2
  1854
@return A non-const reference to the data item at the specified position.
williamr@2
  1855
williamr@2
  1856
@panic USER 9, if anIndex is negative or is greater than or equal to the
williamr@2
  1857
                current length of this descriptor.
williamr@2
  1858
*/
williamr@2
  1859
	{return((TUint16 &)AtC(anIndex));}
williamr@2
  1860
williamr@2
  1861
williamr@2
  1862
williamr@2
  1863
williamr@2
  1864
inline TInt TDes16::MaxLength() const
williamr@2
  1865
/**
williamr@2
  1866
Gets the maximum length of the descriptor.
williamr@2
  1867
williamr@2
  1868
This is the upper limit for the number of 16-bit values or data items that
williamr@2
  1869
the descriptor can represent.
williamr@2
  1870
williamr@2
  1871
@return The maximum length of data that the descriptor can represent.
williamr@2
  1872
*/
williamr@2
  1873
	{return(iMaxLength);}
williamr@2
  1874
williamr@2
  1875
williamr@2
  1876
williamr@2
  1877
williamr@2
  1878
inline TInt TDes16::MaxSize() const
williamr@2
  1879
/**
williamr@2
  1880
Gets the maximum size of the descriptor.
williamr@2
  1881
williamr@2
  1882
This is the upper limit for the number of bytes which the data represented by
williamr@2
  1883
the descriptor can occupy.
williamr@2
  1884
williamr@2
  1885
@return The maximum size of the descriptor data.
williamr@2
  1886
*/
williamr@2
  1887
	{return(iMaxLength<<1);}
williamr@2
  1888
williamr@2
  1889
williamr@2
  1890
williamr@2
  1891
williamr@2
  1892
inline TUint16 * TDes16::WPtr() const
williamr@2
  1893
	{return((TUint16 *)Ptr());}
williamr@2
  1894
williamr@2
  1895
williamr@2
  1896
williamr@2
  1897
williamr@2
  1898
// Class TPtr16
williamr@2
  1899
inline TPtr16 &TPtr16::operator=(const TUint16 *aString)
williamr@2
  1900
/**
williamr@2
  1901
Copies data into this 16-bit modifiable pointer descriptor replacing
williamr@2
  1902
any existing data.
williamr@2
  1903
williamr@2
  1904
The length of this descriptor is set to reflect the new data.
williamr@2
  1905
williamr@2
  1906
@param aString A pointer to a zero-terminated string.
williamr@2
  1907
williamr@2
  1908
@return A reference to this 16-bit modifiable pointer descriptor.
williamr@2
  1909
williamr@2
  1910
@panic USER 11, if the length of the string, excluding the zero terminator, is
williamr@2
  1911
                greater than the maximum length of this descriptor.
williamr@2
  1912
*/
williamr@2
  1913
	{Copy(aString);return(*this);}
williamr@2
  1914
williamr@2
  1915
williamr@2
  1916
williamr@2
  1917
williamr@2
  1918
inline TPtr16 &TPtr16::operator=(const TDesC16 &aDes)
williamr@2
  1919
/**
williamr@2
  1920
Copies data into this 16-bit modifiable pointer descriptor replacing any
williamr@2
  1921
existing data.
williamr@2
  1922
williamr@2
  1923
The length of this descriptor is set to reflect the new data.
williamr@2
  1924
williamr@2
  1925
@param aDes A 16-bit non-modifiable descriptor whose data is to be copied 
williamr@2
  1926
            into this descriptor.
williamr@2
  1927
williamr@2
  1928
@return A reference to this 16-bit modifiable pointer descriptor.
williamr@2
  1929
williamr@2
  1930
@panic USER 11, if the length of aDes is greater than the maximum 
williamr@2
  1931
                length of this descriptor.
williamr@2
  1932
*/
williamr@2
  1933
	{Copy(aDes);return(*this);}
williamr@2
  1934
williamr@2
  1935
williamr@2
  1936
williamr@2
  1937
williamr@2
  1938
inline TPtr16 &TPtr16::operator=(const TPtr16 &aDes)
williamr@2
  1939
/**
williamr@2
  1940
Copies data into this 16-bit modifiable pointer descriptor replacing any
williamr@2
  1941
existing data.
williamr@2
  1942
williamr@2
  1943
The length of this descriptor is set to reflect the new data.
williamr@2
  1944
williamr@2
  1945
@param aDes A 16-bit modifiable pointer descriptor whose data is to be copied 
williamr@2
  1946
            into this descriptor.
williamr@2
  1947
williamr@2
  1948
@return A reference to this 16-bit modifiable pointer descriptor.
williamr@2
  1949
williamr@2
  1950
@panic USER 11, if the length of aDes is greater than the maximum 
williamr@2
  1951
                length of this descriptor.
williamr@2
  1952
*/
williamr@2
  1953
	{Copy(aDes);return(*this);}
williamr@2
  1954
williamr@2
  1955
williamr@2
  1956
williamr@2
  1957
williamr@2
  1958
inline void TPtr16::Set(TUint16 *aBuf,TInt aLength,TInt aMaxLength)
williamr@2
  1959
/**
williamr@2
  1960
Sets the 16-bit modifiable pointer descriptor to point to the specified location 
williamr@2
  1961
in memory, whether in RAM or ROM.
williamr@2
  1962
williamr@2
  1963
The length of the descriptor and its maximum length are set to the specified
williamr@2
  1964
values.
williamr@2
  1965
williamr@2
  1966
@param aBuf       A pointer to the location that the descriptor is to represent.
williamr@2
  1967
@param aLength    The length of the descriptor.
williamr@2
  1968
@param aMaxLength The maximum length of the descriptor.
williamr@2
  1969
williamr@2
  1970
@panic USER 8,  if aLength is negative or is greater than the maximum length of
williamr@2
  1971
                this descriptor.
williamr@2
  1972
@panic USER 18, if aMaxLength is negative.
williamr@2
  1973
*/
williamr@2
  1974
	{new(this) TPtr16(aBuf,aLength,aMaxLength);}
williamr@2
  1975
williamr@2
  1976
williamr@2
  1977
williamr@2
  1978
williamr@2
  1979
inline void TPtr16::Set(const TPtr16 &aPtr)
williamr@2
  1980
/**
williamr@2
  1981
Sets the 16-bit modifiable pointer descriptor from an existing
williamr@2
  1982
16-bit modifiable pointer descriptor.
williamr@2
  1983
  
williamr@2
  1984
It is set to point to the same data, is given the same length and the same
williamr@2
  1985
maximum length as the source pointer descriptor.
williamr@2
  1986
williamr@2
  1987
@param aPtr The source 16-bit modifiable pointer descriptor.
williamr@2
  1988
*/
williamr@2
  1989
	{new(this) TPtr16(aPtr);}
williamr@2
  1990
williamr@2
  1991
williamr@2
  1992
williamr@2
  1993
williamr@2
  1994
// Template class TBuf16
williamr@2
  1995
template <TInt S>
williamr@2
  1996
inline TBuf16<S>::TBuf16()
williamr@2
  1997
	: TBufBase16(S)
williamr@2
  1998
/**
williamr@2
  1999
Constructs an empty 16-bit modifiable buffer descriptor.
williamr@2
  2000
williamr@2
  2001
It contains no data.
williamr@2
  2002
williamr@2
  2003
The integer template parameter determines the size of the data area created 
williamr@2
  2004
as part of the object and defines the descriptor's maximum length.
williamr@2
  2005
*/
williamr@2
  2006
	{}
williamr@2
  2007
williamr@2
  2008
williamr@2
  2009
williamr@2
  2010
williamr@2
  2011
template <TInt S>
williamr@2
  2012
inline TBuf16<S>::TBuf16(TInt aLength)
williamr@2
  2013
	: TBufBase16(aLength,S)
williamr@2
  2014
/**
williamr@2
  2015
Constructs an empty 16-bit modifiable buffer descriptor and sets the its length 
williamr@2
  2016
to the specified value.
williamr@2
  2017
williamr@2
  2018
No data is assigned to the descriptor.
williamr@2
  2019
williamr@2
  2020
The integer template parameter defines the size of the data area created as 
williamr@2
  2021
part of the object and defines the descriptor's maximum length.
williamr@2
  2022
williamr@2
  2023
@param aLength The length of this modifiable buffer descriptor.
williamr@2
  2024
williamr@2
  2025
@panic USER 8, if aLength is negative or is greater than the 
williamr@2
  2026
                value of the integer template parameter.
williamr@2
  2027
*/
williamr@2
  2028
	{}
williamr@2
  2029
williamr@2
  2030
williamr@2
  2031
williamr@2
  2032
williamr@2
  2033
template <TInt S>
williamr@2
  2034
inline TBuf16<S>::TBuf16(const TUint16 *aString)
williamr@2
  2035
	: TBufBase16(aString,S)
williamr@2
  2036
/**
williamr@2
  2037
Constructs the 16-bit modifiable buffer descriptor from
williamr@2
  2038
a zero terminated string.
williamr@2
  2039
williamr@2
  2040
The integer template parameter determines the size of the data area that is
williamr@2
  2041
created as part of this object, and defines the descriptor's maximum length.
williamr@2
  2042
williamr@2
  2043
The string, excluding the zero terminator, is copied into this buffer
williamr@2
  2044
descriptor's data area. The length of this buffer descriptor is set to the
williamr@2
  2045
length of the string, excluding the zero terminator.
williamr@2
  2046
williamr@2
  2047
@param aString A pointer to a zero terminated string.
williamr@2
  2048
williamr@2
  2049
@panic USER 11, if the length of the string, excluding the zero terminator,
williamr@2
  2050
                is greater than the value of the integer template parameter.
williamr@2
  2051
*/
williamr@2
  2052
	{}
williamr@2
  2053
williamr@2
  2054
williamr@2
  2055
williamr@2
  2056
williamr@2
  2057
template <TInt S>
williamr@2
  2058
inline TBuf16<S>::TBuf16(const TDesC16 &aDes)
williamr@2
  2059
	: TBufBase16(aDes,S)
williamr@2
  2060
/**
williamr@2
  2061
Constructs the 16-bit modifiable buffer descriptor from any existing
williamr@2
  2062
16-bit descriptor.
williamr@2
  2063
williamr@2
  2064
The integer template parameter determines the size of the data area created 
williamr@2
  2065
as part of this object and defines the descriptor's maximum length.
williamr@2
  2066
williamr@2
  2067
Data is copied from the source descriptor into this modifiable buffer descriptor 
williamr@2
  2068
and the length of this modifiable buffer descriptor is set to the length of 
williamr@2
  2069
the source descriptor.
williamr@2
  2070
williamr@2
  2071
@param aDes The source 16-bit non-modifiable descriptor.
williamr@2
  2072
williamr@2
  2073
@panic USER 11, if the length of the source descriptor is greater than the
williamr@2
  2074
                value of the integer template parameter.
williamr@2
  2075
*/
williamr@2
  2076
	{}
williamr@2
  2077
williamr@2
  2078
williamr@2
  2079
williamr@2
  2080
williamr@2
  2081
template <TInt S>
williamr@2
  2082
inline TBuf16<S> &TBuf16<S>::operator=(const TUint16 *aString)
williamr@2
  2083
/**
williamr@2
  2084
Copies data into this 16-bit modifiable buffer descriptor, replacing any
williamr@2
  2085
existing data. 
williamr@2
  2086
williamr@2
  2087
The length of this descriptor is set to reflect the new data.
williamr@2
  2088
williamr@2
  2089
@param aString A pointer to a zero-terminated string.
williamr@2
  2090
williamr@2
  2091
@return A reference to this descriptor.
williamr@2
  2092
williamr@2
  2093
@panic USER 11, if the length of the string, excluding the zero terminator,
williamr@2
  2094
                is greater than the maximum length of this (target) descriptor.
williamr@2
  2095
*/
williamr@2
  2096
	{Copy(aString);return(*this);}
williamr@2
  2097
williamr@2
  2098
williamr@2
  2099
williamr@2
  2100
williamr@2
  2101
template <TInt S>
williamr@2
  2102
inline TBuf16<S> &TBuf16<S>::operator=(const TDesC16 &aDes)
williamr@2
  2103
/**
williamr@2
  2104
Copies data into this 16-bit modifiable descriptor, replacing any
williamr@2
  2105
existing data.
williamr@2
  2106
williamr@2
  2107
The length of this descriptor is set to reflect the new data.
williamr@2
  2108
williamr@2
  2109
@param aDes A 16-bit non-modifiable descriptor.
williamr@2
  2110
williamr@2
  2111
@return A reference to this descriptor.
williamr@2
  2112
williamr@2
  2113
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  2114
                maximum length of this (target) descriptor.
williamr@2
  2115
*/
williamr@2
  2116
	{Copy(aDes);return(*this);}
williamr@2
  2117
williamr@2
  2118
williamr@2
  2119
williamr@2
  2120
williamr@2
  2121
template <TInt S>
williamr@2
  2122
inline TBuf16<S>& TBuf16<S>::operator=(const TBuf16<S>& aBuf)
williamr@2
  2123
/**
williamr@2
  2124
Copies data into this 16-bit modifiable buffer descriptor replacing any
williamr@2
  2125
existing data.
williamr@2
  2126
williamr@2
  2127
The length of this descriptor is set to reflect the new data.
williamr@2
  2128
williamr@2
  2129
@param aBuf The source 16-bit modifiable buffer descriptor with the same
williamr@2
  2130
            template value.
williamr@2
  2131
williamr@2
  2132
@return A reference to this 16-bit modifiable buffer descriptor. 
williamr@2
  2133
williamr@2
  2134
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  2135
                maximum length of this (target) descriptor.
williamr@2
  2136
*/
williamr@2
  2137
	{Copy(aBuf);return *this;}
williamr@2
  2138
williamr@2
  2139
williamr@2
  2140
// Class RBuf16
williamr@2
  2141
inline RBuf16& RBuf16::operator=(const TUint16* aString)
williamr@2
  2142
/**
williamr@2
  2143
Copies data into this descriptor replacing any existing data.
williamr@2
  2144
williamr@2
  2145
The length of this descriptor is set to reflect the new data.
williamr@2
  2146
williamr@2
  2147
@param aString A pointer to a zero-terminated string.
williamr@2
  2148
williamr@2
  2149
@return A reference to this, the target descriptor.
williamr@2
  2150
williamr@2
  2151
@panic USER 11, if the length of the string, excluding the zero terminator, is
williamr@2
  2152
                greater than the maximum length of this (target) descriptor.
williamr@2
  2153
*/
williamr@2
  2154
    {Copy(aString);return(*this);}
williamr@2
  2155
williamr@2
  2156
williamr@2
  2157
williamr@2
  2158
williamr@2
  2159
inline RBuf16& RBuf16::operator=(const TDesC16& aDes)
williamr@2
  2160
/**
williamr@2
  2161
Copies data into this descriptor replacing any existing data.
williamr@2
  2162
williamr@2
  2163
The length of this descriptor is set to reflect the new data.
williamr@2
  2164
williamr@2
  2165
@param aDes A 16-bit non-modifiable descriptor.
williamr@2
  2166
williamr@2
  2167
@return A reference to this, the target descriptor.
williamr@2
  2168
williamr@2
  2169
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  2170
                maximum length of this (target) descriptor.
williamr@2
  2171
*/
williamr@2
  2172
    {Copy(aDes);return(*this);}
williamr@2
  2173
williamr@2
  2174
williamr@2
  2175
williamr@2
  2176
williamr@2
  2177
inline RBuf16& RBuf16::operator=(const RBuf16& aDes)
williamr@2
  2178
/**
williamr@2
  2179
Copies data into this descriptor replacing any existing data.
williamr@2
  2180
williamr@2
  2181
The length of this descriptor is set to reflect the new data.
williamr@2
  2182
williamr@2
  2183
@param aDes A 16-bit buffer descriptor.
williamr@2
  2184
williamr@2
  2185
@return A reference to this, the target descriptor.
williamr@2
  2186
williamr@2
  2187
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  2188
                maximum length of this (target) descriptor.
williamr@2
  2189
*/
williamr@2
  2190
    {Copy(aDes);return(*this);}
williamr@2
  2191
williamr@2
  2192
williamr@2
  2193
williamr@2
  2194
williamr@2
  2195
/**
williamr@2
  2196
Creates a 16-bit resizable buffer descriptor that has been initialised with
williamr@2
  2197
data from the specified read stream; leaves on failure.
williamr@2
  2198
			 
williamr@2
  2199
Data is assigned to the new descriptor from the specified stream.
williamr@2
  2200
This variant assumes that the stream contains the length of the data followed
williamr@2
  2201
by the data itself.
williamr@2
  2202
williamr@2
  2203
The function is implemented by calling the HBufC16::NewL(RReadStream&amp;,TInt)
williamr@2
  2204
variant and then assigning the resulting heap descriptor using
williamr@2
  2205
the RBuf16::Assign(HBufC16*) variant. The comments that describe
williamr@2
  2206
the HBufC16::NewL() variant	also apply to this RBuf16::CreateL() function.
williamr@2
  2207
williamr@2
  2208
The function may leave with one of the system-wide error codes,	specifically 
williamr@2
  2209
KErrOverflow, if the length of the data as read from the stream is greater than
williamr@2
  2210
the upper limit as specified by the aMaxLength parameter.
williamr@2
  2211
williamr@2
  2212
@param aStream    The stream from which the data length and the data to be
williamr@2
  2213
                  assigned to the new descriptor, are taken.
williamr@2
  2214
@param aMaxLength The upper limit on the length of data that the descriptor is
williamr@2
  2215
                  to represent. The value of this parameter must be non-negative
williamr@2
  2216
                  otherwise the	underlying function will panic.
williamr@2
  2217
*/
williamr@2
  2218
inline void RBuf16::CreateL(RReadStream &aStream,TInt aMaxLength)
williamr@2
  2219
	{
williamr@2
  2220
	Assign(HBufC16::NewL(aStream,aMaxLength));
williamr@2
  2221
	}
williamr@2
  2222
williamr@2
  2223
williamr@2
  2224
// Template class TLitC16
williamr@2
  2225
template <TInt S>
williamr@2
  2226
inline const TDesC16* TLitC16<S>::operator&() const
williamr@2
  2227
/**
williamr@2
  2228
Returns a const TDesC16 type pointer.
williamr@2
  2229
williamr@2
  2230
@return A descriptor type pointer to this literal. 
williamr@2
  2231
*/
williamr@2
  2232
	{return REINTERPRET_CAST(const TDesC16*,this);}
williamr@2
  2233
williamr@2
  2234
williamr@2
  2235
williamr@2
  2236
williamr@2
  2237
template <TInt S>
williamr@2
  2238
inline const TDesC16& TLitC16<S>::operator()() const
williamr@2
  2239
/**
williamr@2
  2240
Returns a const TDesC16 type reference.
williamr@2
  2241
williamr@2
  2242
@return A descriptor type reference to this literal 
williamr@2
  2243
*/
williamr@2
  2244
	{return *operator&();}
williamr@2
  2245
williamr@2
  2246
williamr@2
  2247
williamr@2
  2248
williamr@2
  2249
template <TInt S>
williamr@2
  2250
inline TLitC16<S>::operator const TDesC16&() const
williamr@2
  2251
/**
williamr@2
  2252
Invoked by the compiler when a TLitC16<TInt> type is passed to a function
williamr@2
  2253
which is prototyped to take a const TDesC16& type.
williamr@2
  2254
*/
williamr@2
  2255
	{return *operator&();}
williamr@2
  2256
williamr@2
  2257
williamr@2
  2258
williamr@2
  2259
williamr@2
  2260
template <TInt S>
williamr@2
  2261
inline TLitC16<S>::operator const __TRefDesC16() const
williamr@2
  2262
/**
williamr@2
  2263
Invoked by the compiler when a TLitC16<TInt> type is passed to a function
williamr@2
  2264
which is prototyped to take a const TRefByValue<const TDesC16> type.
williamr@2
  2265
williamr@2
  2266
@see __TRefDesC16
williamr@2
  2267
*/
williamr@2
  2268
	{return *operator&();}
williamr@2
  2269
#endif //__KERNEL_MODE__
williamr@2
  2270
williamr@2
  2271
williamr@2
  2272
williamr@2
  2273
williamr@2
  2274
// Template class TBufC
williamr@2
  2275
#if defined(_UNICODE) && !defined(__KERNEL_MODE__)
williamr@2
  2276
template <TInt S>
williamr@2
  2277
inline TBufC<S>::TBufC()
williamr@2
  2278
	: TBufCBase16()
williamr@2
  2279
/**
williamr@2
  2280
Constructs an empty build independent non-modifiable buffer descriptor.
williamr@2
  2281
williamr@2
  2282
It contains no data.
williamr@2
  2283
williamr@2
  2284
The integer template parameter determines the size of the data area which 
williamr@2
  2285
is created as part of the buffer descriptor object.
williamr@2
  2286
williamr@2
  2287
Data can, subsequently, be assigned into this buffer descriptor using the 
williamr@2
  2288
assignment operators.
williamr@2
  2289
williamr@2
  2290
@see TBufC::operator=
williamr@2
  2291
*/
williamr@2
  2292
	{}
williamr@2
  2293
williamr@2
  2294
williamr@2
  2295
williamr@2
  2296
williamr@2
  2297
template <TInt S>
williamr@2
  2298
inline TBufC<S>::TBufC(const TText *aString)
williamr@2
  2299
	: TBufCBase16(aString,S)
williamr@2
  2300
/** 
williamr@2
  2301
Constructs a build independent non-modifiable 
williamr@2
  2302
buffer descriptor from a zero terminated string.
williamr@2
  2303
williamr@2
  2304
The integer template parameter determines the size of the data area which 
williamr@2
  2305
is created as part of this object.
williamr@2
  2306
williamr@2
  2307
The string, excluding the zero terminator, is copied into this buffer descriptor's 
williamr@2
  2308
data area. The length of this buffer descriptor is set to the length of the 
williamr@2
  2309
string, excluding the zero terminator.
williamr@2
  2310
williamr@2
  2311
@param aString A pointer to a zero terminated string.
williamr@2
  2312
williamr@2
  2313
@panic USER 8,  if the length of the string, excluding the zero terminator, is
williamr@2
  2314
                greater than the value of the integer template parameter for
williamr@2
  2315
				the 16-bit build variant.
williamr@2
  2316
williamr@2
  2317
@panic USER 20, if the length of the string, excluding the zero terminator, is
williamr@2
  2318
                greater than the value of the integer template parameter for
williamr@2
  2319
				the 8-bit build variant.
williamr@2
  2320
*/
williamr@2
  2321
	{}
williamr@2
  2322
williamr@2
  2323
williamr@2
  2324
williamr@2
  2325
williamr@2
  2326
template <TInt S>
williamr@2
  2327
inline TBufC<S>::TBufC(const TDesC &aDes)
williamr@2
  2328
	: TBufCBase16(aDes,S)
williamr@2
  2329
/**
williamr@2
  2330
Constructs a build-independent non-modifiable buffer descriptor from any 
williamr@2
  2331
existing build independent descriptor.
williamr@2
  2332
williamr@2
  2333
The integer template parameter determines the size of the data area which 
williamr@2
  2334
is created as part of this object.
williamr@2
  2335
williamr@2
  2336
Data is copied from the source descriptor into this buffer descriptor and 
williamr@2
  2337
the length of this buffer descriptor is set to the length of the source descriptor.
williamr@2
  2338
williamr@2
  2339
The length of the source descriptor must not be greater than the value of 
williamr@2
  2340
the integer template parameter, otherwise the constructor raises a USER 20 
williamr@2
  2341
panic for an 8 bit build variant or a USER 8 panic for a 16 bit (Unicode) 
williamr@2
  2342
build variant.
williamr@2
  2343
williamr@2
  2344
@param aDes The source build independent non-modifiable descriptor.
williamr@2
  2345
williamr@2
  2346
@panic USER 8,  if the length of the source descriptor is
williamr@2
  2347
                greater than the value of the integer template parameter for
williamr@2
  2348
				the 16-bit build variant.
williamr@2
  2349
williamr@2
  2350
@panic USER 20, if the length of the source descriptor is
williamr@2
  2351
                greater than the value of the integer template parameter for
williamr@2
  2352
				the 8-bit build variant.
williamr@2
  2353
*/
williamr@2
  2354
	{}
williamr@2
  2355
#else
williamr@2
  2356
template <TInt S>
williamr@2
  2357
inline TBufC<S>::TBufC()
williamr@2
  2358
	: TBufCBase8()
williamr@2
  2359
	{}
williamr@2
  2360
template <TInt S>
williamr@2
  2361
inline TBufC<S>::TBufC(const TText *aString)
williamr@2
  2362
	: TBufCBase8(aString,S)
williamr@2
  2363
	{}
williamr@2
  2364
template <TInt S>
williamr@2
  2365
inline TBufC<S>::TBufC(const TDesC &aDes)
williamr@2
  2366
	: TBufCBase8(aDes,S)
williamr@2
  2367
	{}
williamr@2
  2368
#endif
williamr@2
  2369
template <TInt S>
williamr@2
  2370
inline TBufC<S> &TBufC<S>::operator=(const TText *aString)
williamr@2
  2371
/** 
williamr@2
  2372
Copies data into this descriptor, replacing any existing data.
williamr@2
  2373
williamr@2
  2374
The length of this descriptor is set to reflect the new data.
williamr@2
  2375
williamr@2
  2376
@param aString A pointer to a zero-terminated string.
williamr@2
  2377
williamr@2
  2378
@return A reference to this descriptor.
williamr@2
  2379
williamr@2
  2380
@panic USER 11, if the length of the string, excluding the zero terminator,
williamr@2
  2381
                is greater than the maximum length of this (target) descriptor
williamr@2
  2382
				for the 16-bit build variant.
williamr@2
  2383
williamr@2
  2384
@panic USER 23, if the length of the string, excluding the zero terminator,
williamr@2
  2385
                is greater than the maximum length of this (target) descriptor
williamr@2
  2386
				for the 8-bit build variant.
williamr@2
  2387
*/
williamr@2
  2388
	{Copy(aString,S);return(*this);}
williamr@2
  2389
williamr@2
  2390
williamr@2
  2391
williamr@2
  2392
williamr@2
  2393
template <TInt S>
williamr@2
  2394
inline TBufC<S> &TBufC<S>::operator=(const TDesC &aDes)
williamr@2
  2395
/**
williamr@2
  2396
Copies data into this descriptor, replacing any existing data.
williamr@2
  2397
williamr@2
  2398
The length of this descriptor is set to reflect the new data.
williamr@2
  2399
williamr@2
  2400
@param aDes A build independent non-modifiable descriptor. 
williamr@2
  2401
williamr@2
  2402
@return A reference to this descriptor.
williamr@2
  2403
williamr@2
  2404
@panic USER 11, if the length of the descriptor aDes is greater than the
williamr@2
  2405
                maximum length of this (target) descriptor for the 16-bit
williamr@2
  2406
				build variant.
williamr@2
  2407
williamr@2
  2408
@panic USER 23, if the length of the descriptor aDes is greater than the
williamr@2
  2409
                maximum length of this (target) descriptor for the 8-bit
williamr@2
  2410
				build variant.
williamr@2
  2411
*/
williamr@2
  2412
	{Copy(aDes,S);return(*this);}
williamr@2
  2413
williamr@2
  2414
williamr@2
  2415
williamr@2
  2416
williamr@2
  2417
template <TInt S>
williamr@2
  2418
inline TPtr TBufC<S>::Des()
williamr@2
  2419
/**
williamr@2
  2420
Creates and returns a build-independent modifiable pointer descriptor for
williamr@2
  2421
the data represented by this build-independent non-modifiable buffer
williamr@2
  2422
descriptor.
williamr@2
  2423
williamr@2
  2424
The content of a non-modifiable buffer descriptor normally cannot be altered, 
williamr@2
  2425
other than by complete replacement of the data. Creating a modifiable pointer 
williamr@2
  2426
descriptor provides a way of changing the data.
williamr@2
  2427
williamr@2
  2428
The modifiable pointer descriptor is set to point to this non-modifiable buffer 
williamr@2
  2429
descriptor's data.
williamr@2
  2430
williamr@2
  2431
The length of the modifiable pointer descriptor is set to the length of this 
williamr@2
  2432
non-modifiable buffer descriptor.
williamr@2
  2433
williamr@2
  2434
The maximum length of the modifiable pointer descriptor is set to the value 
williamr@2
  2435
of the integer template parameter.
williamr@2
  2436
williamr@2
  2437
When data is modified through this new pointer descriptor, the lengths of 
williamr@2
  2438
both it and this constant buffer descriptor are changed.
williamr@2
  2439
williamr@2
  2440
@return A build independent modifiable pointer descriptor representing the 
williamr@2
  2441
        data in this build independent non-modifiable buffer descriptor.
williamr@2
  2442
*/
williamr@2
  2443
	{return(DoDes(S));}
williamr@2
  2444
williamr@2
  2445
williamr@2
  2446
williamr@2
  2447
williamr@2
  2448
// Template class TBuf
williamr@2
  2449
#if defined(_UNICODE) && !defined(__KERNEL_MODE__)
williamr@2
  2450
template <TInt S>
williamr@2
  2451
inline TBuf<S>::TBuf()
williamr@2
  2452
	: TBufBase16(S)
williamr@2
  2453
/**
williamr@2
  2454
Creates a build-independent modifiable buffer descriptor which 
williamr@2
  2455
contains no data.
williamr@2
  2456
williamr@2
  2457
The integer template parameter determines the size of the data area that is created 
williamr@2
  2458
as part of the object, and defines the descriptor's maximum length.
williamr@2
  2459
*/
williamr@2
  2460
	{}
williamr@2
  2461
williamr@2
  2462
williamr@2
  2463
williamr@2
  2464
williamr@2
  2465
template <TInt S>
williamr@2
  2466
inline TBuf<S>::TBuf(TInt aLength)
williamr@2
  2467
	: TBufBase16(aLength,S)
williamr@2
  2468
/**
williamr@2
  2469
Constructs an empty build independent modifiable buffer descriptor and
williamr@2
  2470
sets its length to the specified value.
williamr@2
  2471
williamr@2
  2472
No data is assigned to the descriptor.
williamr@2
  2473
williamr@2
  2474
The integer template parameter determines the size of the data area created 
williamr@2
  2475
as part of the object and defines the descriptor's maximum length.
williamr@2
  2476
williamr@2
  2477
@param aLength The length of this modifiable buffer descriptor.
williamr@2
  2478
williamr@2
  2479
@panic USER 8,  if aLength is negative and is greater than the value of the
williamr@2
  2480
                integer template parameter for a 16-bit build variant.
williamr@2
  2481
williamr@2
  2482
@panic USER 20, if aLength is negative and is greater than the value of the
williamr@2
  2483
                integer template parameter for a 8-bit build variant.
williamr@2
  2484
*/
williamr@2
  2485
	{}
williamr@2
  2486
williamr@2
  2487
williamr@2
  2488
williamr@2
  2489
williamr@2
  2490
template <TInt S>
williamr@2
  2491
inline TBuf<S>::TBuf(const TText *aString)
williamr@2
  2492
	: TBufBase16(aString,S)
williamr@2
  2493
/**
williamr@2
  2494
Constructs the build-independent modifiable buffer descriptor from
williamr@2
  2495
a zero terminated string.
williamr@2
  2496
williamr@2
  2497
The integer template parameter determines the size of the data area which 
williamr@2
  2498
is created as part of this object.
williamr@2
  2499
williamr@2
  2500
The string, excluding the zero terminator, is copied into this buffer
williamr@2
  2501
descriptor's data area. The length of this buffer descriptor is set to
williamr@2
  2502
the length of the string, excluding the zero terminator.
williamr@2
  2503
williamr@2
  2504
@param aString A pointer to a zero terminated string.
williamr@2
  2505
williamr@2
  2506
@panic USER 11, if the length of the string, excluding the zero terminator,
williamr@2
  2507
                is greater than the value of the integer template parameter
williamr@2
  2508
				for a 16-bit build variant.
williamr@2
  2509
@panic USER 23, if the length of the string, excluding the zero terminator,
williamr@2
  2510
                is greater than the value of the integer template parameter
williamr@2
  2511
				for a 8-bit build variant.
williamr@2
  2512
*/
williamr@2
  2513
	{}
williamr@2
  2514
williamr@2
  2515
williamr@2
  2516
williamr@2
  2517
williamr@2
  2518
template <TInt S>
williamr@2
  2519
inline TBuf<S>::TBuf(const TDesC &aDes)
williamr@2
  2520
	: TBufBase16(aDes,S)
williamr@2
  2521
/**
williamr@2
  2522
Constructs the build-independent modifiable buffer descriptor from any
williamr@2
  2523
existing build-independent descriptor.
williamr@2
  2524
williamr@2
  2525
The integer template parameter determines the size of the data area created 
williamr@2
  2526
as part of this object, and defines the descriptor's maximum length.
williamr@2
  2527
williamr@2
  2528
Data is copied from the source descriptor into this modifiable buffer descriptor 
williamr@2
  2529
and the length of this modifiable buffer descriptor is set to the length of 
williamr@2
  2530
the source descriptor.
williamr@2
  2531
williamr@2
  2532
@param aDes The source build independent non-modifiable descriptor.
williamr@2
  2533
williamr@2
  2534
@panic USER 11, if the length of the source descriptor is greater than the
williamr@2
  2535
                value of the integer template parameter for a 16-bit
williamr@2
  2536
				build variant.
williamr@2
  2537
@panic USER 23, if the length of the source descriptor is greater than the
williamr@2
  2538
                value of the integer template parameter for an 8-bit
williamr@2
  2539
				build variant.
williamr@2
  2540
	
williamr@2
  2541
*/
williamr@2
  2542
	{}
williamr@2
  2543
#else
williamr@2
  2544
template <TInt S>
williamr@2
  2545
inline TBuf<S>::TBuf()
williamr@2
  2546
	: TBufBase8(S)
williamr@2
  2547
	{}
williamr@2
  2548
template <TInt S>
williamr@2
  2549
inline TBuf<S>::TBuf(TInt aLength)
williamr@2
  2550
	: TBufBase8(aLength,S)
williamr@2
  2551
	{}
williamr@2
  2552
template <TInt S>
williamr@2
  2553
inline TBuf<S>::TBuf(const TText *aString)
williamr@2
  2554
	: TBufBase8(aString,S)
williamr@2
  2555
	{}
williamr@2
  2556
template <TInt S>
williamr@2
  2557
inline TBuf<S>::TBuf(const TDesC &aDes)
williamr@2
  2558
	: TBufBase8(aDes,S)
williamr@2
  2559
	{}
williamr@2
  2560
#endif
williamr@2
  2561
template <TInt S>
williamr@2
  2562
inline TBuf<S> &TBuf<S>::operator=(const TText *aString)
williamr@2
  2563
	{Copy(aString);return(*this);}
williamr@2
  2564
template <TInt S>
williamr@2
  2565
inline TBuf<S> &TBuf<S>::operator=(const TDesC &aDes)
williamr@2
  2566
	{Copy(aDes);return(*this);}
williamr@2
  2567
template <TInt S>
williamr@2
  2568
inline TBuf<S> &TBuf<S>::operator=(const TBuf<S> &aBuf)
williamr@2
  2569
	{Copy(aBuf);return(*this);}
williamr@2
  2570
williamr@2
  2571
williamr@2
  2572
williamr@2
  2573
williamr@2
  2574
// Template class TLitC
williamr@2
  2575
template <TInt S>
williamr@2
  2576
inline const TDesC* TLitC<S>::operator&() const
williamr@2
  2577
/**
williamr@2
  2578
Returns a const TDesC type pointer.
williamr@2
  2579
williamr@2
  2580
@return A descriptor type pointer to this literal. 
williamr@2
  2581
*/
williamr@2
  2582
	{return REINTERPRET_CAST(const TDesC*,this);}
williamr@2
  2583
williamr@2
  2584
williamr@2
  2585
williamr@2
  2586
williamr@2
  2587
template <TInt S>
williamr@2
  2588
inline const TDesC& TLitC<S>::operator()() const
williamr@2
  2589
/**
williamr@2
  2590
Returns a const TDesC type reference.
williamr@2
  2591
williamr@2
  2592
@return A descriptor type reference to this literal 
williamr@2
  2593
*/
williamr@2
  2594
	{return *operator&();}
williamr@2
  2595
williamr@2
  2596
williamr@2
  2597
williamr@2
  2598
williamr@2
  2599
template <TInt S>
williamr@2
  2600
inline TLitC<S>::operator const TDesC&() const
williamr@2
  2601
/**
williamr@2
  2602
Invoked by the compiler when a TLitC<TInt> type is passed to a function
williamr@2
  2603
which is prototyped to take a const TDesC& type.
williamr@2
  2604
*/
williamr@2
  2605
	{return *operator&();}
williamr@2
  2606
williamr@2
  2607
williamr@2
  2608
williamr@2
  2609
williamr@2
  2610
template <TInt S>
williamr@2
  2611
inline TLitC<S>::operator const __TRefDesC() const
williamr@2
  2612
/**
williamr@2
  2613
Invoked by the compiler when a TLitC<TInt> type is passed to a function
williamr@2
  2614
which is prototyped to take a const TRefByValue<const TDesC> type.
williamr@2
  2615
williamr@2
  2616
@see __TRefDesC.
williamr@2
  2617
*/
williamr@2
  2618
	{return *operator&();}
williamr@2
  2619
williamr@2
  2620
williamr@2
  2621
williamr@2
  2622
williamr@2
  2623
// Template class TPckgC
williamr@2
  2624
template <class T>
williamr@2
  2625
inline TPckgC<T>::TPckgC(const T &aRef)
williamr@2
  2626
	: TPtrC8((const TUint8 *)&aRef,sizeof(T))
williamr@2
  2627
/**
williamr@2
  2628
Constructs a packaged non-modifiable pointer descriptor to represent
williamr@2
  2629
the specified object whose type is defined by the template parameter.
williamr@2
  2630
williamr@2
  2631
@param aRef The object to be represented by this packaged non-modifiable 
williamr@2
  2632
            pointer descriptor.
williamr@2
  2633
*/
williamr@2
  2634
	{}
williamr@2
  2635
williamr@2
  2636
williamr@2
  2637
williamr@2
  2638
williamr@2
  2639
template <class T>
williamr@2
  2640
inline const T &TPckgC<T>::operator()() const
williamr@2
  2641
/**
williamr@2
  2642
Gets a reference to the object represented by this packaged non-modifiable
williamr@2
  2643
pointer descriptor.
williamr@2
  2644
williamr@2
  2645
@return The packaged object 
williamr@2
  2646
*/
williamr@2
  2647
	{return(*((const T *)iPtr));}
williamr@2
  2648
williamr@2
  2649
williamr@2
  2650
williamr@2
  2651
williamr@2
  2652
// Template class TPckg
williamr@2
  2653
template <class T>
williamr@2
  2654
inline TPckg<T>::TPckg(const T &aRef)
williamr@2
  2655
	: TPtr8((TUint8 *)&aRef,sizeof(T),sizeof(T))
williamr@2
  2656
/**
williamr@2
  2657
Constructs a packaged modifiable pointer descriptor to represent the specified 
williamr@2
  2658
object whose type is defined by the template parameter.
williamr@2
  2659
williamr@2
  2660
@param aRef The object to be represented by this packaged modifiable pointer 
williamr@2
  2661
            descriptor.
williamr@2
  2662
*/
williamr@2
  2663
	{}
williamr@2
  2664
williamr@2
  2665
williamr@2
  2666
williamr@2
  2667
williamr@2
  2668
template <class T>
williamr@2
  2669
inline T &TPckg<T>::operator()()
williamr@2
  2670
/**
williamr@2
  2671
Gets a reference to the object represented by this packaged
williamr@2
  2672
modifiable pointer descriptor.
williamr@2
  2673
williamr@2
  2674
@return The packaged object.
williamr@2
  2675
*/
williamr@2
  2676
	{return(*((T *)iPtr));}
williamr@2
  2677
williamr@2
  2678
williamr@2
  2679
williamr@2
  2680
williamr@2
  2681
// Template class TPckgBuf
williamr@2
  2682
template <class T>
williamr@2
  2683
inline TPckgBuf<T>::TPckgBuf()
williamr@2
  2684
	: TAlignedBuf8<sizeof(T)>(sizeof(T))
williamr@2
  2685
/**
williamr@2
  2686
Constructs a packaged modifiable buffer descriptor for an object whose type 
williamr@2
  2687
is defined by the template parameter.
williamr@2
  2688
williamr@2
  2689
The length of the packaged descriptor is set to the length of the templated 
williamr@2
  2690
class but no data is assigned into the descriptor.
williamr@2
  2691
*/
williamr@2
  2692
	{new(&this->iBuf[0]) T;}
williamr@2
  2693
williamr@2
  2694
williamr@2
  2695
williamr@2
  2696
williamr@2
  2697
template <class T>
williamr@2
  2698
inline TPckgBuf<T>::TPckgBuf(const T &aRef)
williamr@2
  2699
	: TAlignedBuf8<sizeof(T)>(sizeof(T))
williamr@2
  2700
/**
williamr@2
  2701
Constructs a packaged modifiable buffer descriptor for an object whose type 
williamr@2
  2702
is defined by the template parameter and copies the supplied object into the 
williamr@2
  2703
descriptor.
williamr@2
  2704
williamr@2
  2705
The length of the packaged descriptor is set to the length of the templated 
williamr@2
  2706
class.
williamr@2
  2707
williamr@2
  2708
@param aRef The source object to be copied into the packaged modifiable buffer 
williamr@2
  2709
            descriptor.
williamr@2
  2710
*/
williamr@2
  2711
	{new(&this->iBuf[0]) T(aRef);}
williamr@2
  2712
williamr@2
  2713
williamr@2
  2714
williamr@2
  2715
williamr@2
  2716
template <class T>
williamr@2
  2717
inline TPckgBuf<T> &TPckgBuf<T>::operator=(const TPckgBuf<T> &aRef)
williamr@2
  2718
/**
williamr@2
  2719
Copies data from the specified packaged modifiable buffer descriptor into this 
williamr@2
  2720
packaged modifiable buffer descriptor, replacing any existing data.
williamr@2
  2721
williamr@2
  2722
@param aRef The source packaged modifiable buffer descriptor. 
williamr@2
  2723
@return A reference to this packaged modifiable descriptor.
williamr@2
  2724
*/
williamr@2
  2725
	{this->Copy(aRef);return(*this);}
williamr@2
  2726
williamr@2
  2727
williamr@2
  2728
williamr@2
  2729
williamr@2
  2730
template <class T>
williamr@2
  2731
inline T &TPckgBuf<T>::operator=(const T &aRef)
williamr@2
  2732
/**
williamr@2
  2733
Copies data from the specified object into this packaged modifiable buffer 
williamr@2
  2734
descriptor, replacing any existing data.
williamr@2
  2735
williamr@2
  2736
@param aRef The source object. 
williamr@2
  2737
@return A reference to the copy of the source object in the packaged modifiable 
williamr@2
  2738
        buffer descriptor.
williamr@2
  2739
*/
williamr@2
  2740
	{this->Copy((TUint8 *)&aRef,sizeof(T));return(*((T *)&this->iBuf[0]));}
williamr@2
  2741
williamr@2
  2742
williamr@2
  2743
williamr@2
  2744
williamr@2
  2745
template <class T>
williamr@2
  2746
inline T &TPckgBuf<T>::operator()()
williamr@2
  2747
/**
williamr@2
  2748
Gets a reference to the object contained by this packaged modifiable
williamr@2
  2749
buffer descriptor.
williamr@2
  2750
williamr@2
  2751
@return The packaged object.
williamr@2
  2752
*/
williamr@2
  2753
	{return(*((T *)&this->iBuf[0]));}
williamr@2
  2754
williamr@2
  2755
williamr@2
  2756
williamr@2
  2757
williamr@2
  2758
template <class T>
williamr@2
  2759
inline const T &TPckgBuf<T>::operator()() const
williamr@2
  2760
/**
williamr@2
  2761
Gets a const reference to the object contained by this packaged modifiable
williamr@2
  2762
buffer descriptor.
williamr@2
  2763
williamr@2
  2764
@return The (const) packaged object.
williamr@2
  2765
*/
williamr@2
  2766
	{return(*((T *)&this->iBuf[0]));}
williamr@2
  2767
williamr@2
  2768
williamr@2
  2769
williamr@2
  2770
williamr@2
  2771
// Class TRequestStatus
williamr@2
  2772
inline TRequestStatus::TRequestStatus()
williamr@2
  2773
/**
williamr@2
  2774
Default constructor.
williamr@2
  2775
*/
williamr@2
  2776
: iFlags(0)
williamr@2
  2777
	{}
williamr@2
  2778
williamr@2
  2779
williamr@2
  2780
williamr@2
  2781
williamr@2
  2782
inline TRequestStatus::TRequestStatus(TInt aVal)
williamr@2
  2783
/**
williamr@2
  2784
Constructs an asynchronous request status object and assigns a completion value 
williamr@2
  2785
to it.
williamr@2
  2786
williamr@2
  2787
@param aVal The completion value to be assigned to the constructed request 
williamr@2
  2788
            status object.
williamr@2
  2789
*/
williamr@2
  2790
	: iStatus(aVal),
williamr@2
  2791
	iFlags(aVal==KRequestPending ? TRequestStatus::ERequestPending : 0)
williamr@2
  2792
williamr@2
  2793
	{}
williamr@2
  2794
williamr@2
  2795
williamr@2
  2796
williamr@2
  2797
williamr@2
  2798
inline TInt TRequestStatus::operator=(TInt aVal)
williamr@2
  2799
/**
williamr@2
  2800
Assigns the specified completion code to the request status object.
williamr@2
  2801
williamr@2
  2802
@param aVal The value to be assigned.
williamr@2
  2803
williamr@2
  2804
@return The value assigned.
williamr@2
  2805
*/
williamr@2
  2806
	{
williamr@2
  2807
	if(aVal==KRequestPending)
williamr@2
  2808
		iFlags|=TRequestStatus::ERequestPending;
williamr@2
  2809
	else
williamr@2
  2810
		iFlags&=~TRequestStatus::ERequestPending;
williamr@2
  2811
	return (iStatus=aVal);
williamr@2
  2812
	}
williamr@2
  2813
williamr@2
  2814
williamr@2
  2815
williamr@2
  2816
williamr@2
  2817
inline TBool TRequestStatus::operator==(TInt aVal) const
williamr@2
  2818
/**
williamr@2
  2819
Tests whether the request status object's completion code is the same as
williamr@2
  2820
the specified value.
williamr@2
  2821
williamr@2
  2822
@param aVal The value to be compared.
williamr@2
  2823
williamr@2
  2824
@return True, if the values are equal; false otherwise.
williamr@2
  2825
*/
williamr@2
  2826
	{return(iStatus==aVal);}
williamr@2
  2827
williamr@2
  2828
williamr@2
  2829
williamr@2
  2830
williamr@2
  2831
inline TBool TRequestStatus::operator!=(TInt aVal) const
williamr@2
  2832
/**
williamr@2
  2833
Tests whether the request status object's completion code is not equal to
williamr@2
  2834
the specified value.
williamr@2
  2835
williamr@2
  2836
@param aVal The value to be compared.
williamr@2
  2837
williamr@2
  2838
@return True, if the values are unequal; false otherwise.
williamr@2
  2839
*/
williamr@2
  2840
	{return(iStatus!=aVal);}
williamr@2
  2841
williamr@2
  2842
williamr@2
  2843
williamr@2
  2844
williamr@2
  2845
inline TBool TRequestStatus::operator>=(TInt aVal) const
williamr@2
  2846
/**
williamr@2
  2847
Tests whether the request status object's completion code is greater than 
williamr@2
  2848
or equal to the specified value.
williamr@2
  2849
williamr@2
  2850
@param aVal The value to be compared.
williamr@2
  2851
williamr@2
  2852
@return True, if the request status object's value is greater than or equal 
williamr@2
  2853
        to the specified value; false, otherwise.
williamr@2
  2854
*/
williamr@2
  2855
	{return(iStatus>=aVal);}
williamr@2
  2856
williamr@2
  2857
williamr@2
  2858
williamr@2
  2859
williamr@2
  2860
inline TBool TRequestStatus::operator<=(TInt aVal) const
williamr@2
  2861
/**
williamr@2
  2862
Tests whether the request status object's completion code is less than or 
williamr@2
  2863
equal to the specified value.
williamr@2
  2864
williamr@2
  2865
@param aVal The value to be compared.
williamr@2
  2866
williamr@2
  2867
@return True, if the request status object's value is less than or equal 
williamr@2
  2868
        to the specified value; false, otherwise.
williamr@2
  2869
*/
williamr@2
  2870
	{return(iStatus<=aVal);}
williamr@2
  2871
williamr@2
  2872
williamr@2
  2873
williamr@2
  2874
williamr@2
  2875
inline TBool TRequestStatus::operator>(TInt aVal) const
williamr@2
  2876
/**
williamr@2
  2877
Tests whether the request status object's completion code is greater than 
williamr@2
  2878
the specified value.
williamr@2
  2879
williamr@2
  2880
@param aVal The value to be compared.
williamr@2
  2881
williamr@2
  2882
@return True, if the request status object's value is greater than
williamr@2
  2883
        the specified value; false, otherwise.
williamr@2
  2884
*/
williamr@2
  2885
	{return(iStatus>aVal);}
williamr@2
  2886
williamr@2
  2887
williamr@2
  2888
williamr@2
  2889
williamr@2
  2890
inline TBool TRequestStatus::operator<(TInt aVal) const
williamr@2
  2891
/**
williamr@2
  2892
Tests whether the request status object's completion code is less than the 
williamr@2
  2893
specified value.
williamr@2
  2894
williamr@2
  2895
@param aVal The value to be compared.
williamr@2
  2896
williamr@2
  2897
@return True, if the request status object's value is less than the specified 
williamr@2
  2898
        value; false, otherwise.
williamr@2
  2899
*/
williamr@2
  2900
	{return(iStatus<aVal);}
williamr@2
  2901
williamr@2
  2902
williamr@2
  2903
williamr@2
  2904
williamr@2
  2905
inline TInt TRequestStatus::Int() const
williamr@2
  2906
/**
williamr@2
  2907
Gets this request status object's completion code value.
williamr@2
  2908
williamr@2
  2909
@return The completion code.
williamr@2
  2910
*/
williamr@2
  2911
	{return(iStatus);}
williamr@2
  2912
williamr@2
  2913
williamr@2
  2914
williamr@2
  2915
williamr@2
  2916
// Class TPoint
williamr@2
  2917
#ifndef __KERNEL_MODE__
williamr@2
  2918
inline TPoint::TPoint()
williamr@2
  2919
	: iX(0),iY(0)
williamr@2
  2920
/**
williamr@2
  2921
Constructs default point, initialising its iX and iY members to zero.
williamr@2
  2922
*/
williamr@2
  2923
	{}
williamr@2
  2924
williamr@2
  2925
williamr@2
  2926
williamr@2
  2927
williamr@2
  2928
inline TPoint::TPoint(TInt aX,TInt aY)
williamr@2
  2929
	: iX(aX),iY(aY)
williamr@2
  2930
/**
williamr@2
  2931
Constructs a point with the specified x and y co-ordinates.
williamr@2
  2932
williamr@2
  2933
@param aX The x co-ordinate value.
williamr@2
  2934
@param aY The y co-ordinate value.
williamr@2
  2935
*/
williamr@2
  2936
	{}
williamr@2
  2937
williamr@2
  2938
williamr@2
  2939
williamr@2
  2940
williamr@2
  2941
// Class TSize
williamr@2
  2942
inline TSize::TSize()
williamr@2
  2943
	: iWidth(0),iHeight(0)
williamr@2
  2944
/**
williamr@2
  2945
Constructs the size object with its iWidth and iHeight members set to zero.
williamr@2
  2946
*/
williamr@2
  2947
	{}
williamr@2
  2948
williamr@2
  2949
williamr@2
  2950
williamr@2
  2951
williamr@2
  2952
inline TSize::TSize(TInt aWidth,TInt aHeight)
williamr@2
  2953
	: iWidth(aWidth),iHeight(aHeight)
williamr@2
  2954
/**
williamr@2
  2955
Constructs the size object with the specified width and height values.
williamr@2
  2956
williamr@2
  2957
@param aWidth The width value.
williamr@2
  2958
@param aHeight The height value .
williamr@2
  2959
*/
williamr@2
  2960
	{}
williamr@2
  2961
#endif
williamr@2
  2962
williamr@2
  2963
williamr@2
  2964
williamr@4
  2965
// Class TPoint3D
williamr@4
  2966
#ifndef __KERNEL_MODE__
williamr@4
  2967
inline TPoint3D::TPoint3D()
williamr@4
  2968
	: iX(0),iY(0),iZ(0)
williamr@4
  2969
/**
williamr@4
  2970
Constructs default 3Dpoint, initialising its iX, iY and iZ members to zero.
williamr@4
  2971
*/
williamr@4
  2972
	{}
williamr@4
  2973
williamr@4
  2974
inline TPoint3D::TPoint3D(TInt aX,TInt aY,TInt aZ)
williamr@4
  2975
	: iX(aX),iY(aY),iZ(aZ)
williamr@4
  2976
/**
williamr@4
  2977
Constructs  TPoint3D with the specified x,y  and z co-ordinates.
williamr@4
  2978
williamr@4
  2979
@param aX The x co-ordinate value.
williamr@4
  2980
@param aY The y co-ordinate value.
williamr@4
  2981
@param aZ The z co-ordinate value.
williamr@4
  2982
*/
williamr@4
  2983
	{}
williamr@4
  2984
williamr@4
  2985
williamr@4
  2986
williamr@4
  2987
williamr@4
  2988
inline TPoint3D::TPoint3D(const  TPoint& aPoint)
williamr@4
  2989
:iX(aPoint.iX),iY(aPoint.iY),iZ(0)
williamr@4
  2990
/* 
williamr@4
  2991
Copy Construct from TPoint , initialises Z co-ordinate to  Zero
williamr@4
  2992
@param aPoint The TPoint from which we create TPoint3D object
williamr@4
  2993
*/
williamr@4
  2994
	{}
williamr@4
  2995
williamr@4
  2996
williamr@4
  2997
#endif
williamr@4
  2998
williamr@2
  2999
williamr@2
  3000
// Class TFindHandle
williamr@2
  3001
inline TFindHandle::TFindHandle()
williamr@2
  3002
	: iHandle(0), iSpare1(0), iObjectIdLow(0), iObjectIdHigh(0)
williamr@2
  3003
	{}
williamr@2
  3004
williamr@2
  3005
williamr@2
  3006
williamr@2
  3007
williamr@2
  3008
inline TInt TFindHandle::Handle() const
williamr@2
  3009
/**
williamr@2
  3010
@publishedAll
williamr@2
  3011
@released
williamr@2
  3012
williamr@2
  3013
Gets the find-handle number associated with the Kernel object. 
williamr@2
  3014
williamr@2
  3015
The find-handle number identifies the kernel object with respect to
williamr@2
  3016
its container.
williamr@2
  3017
	
williamr@2
  3018
Note that setting the find-handle number into a TFindHandle object is not
williamr@2
  3019
implemented by this class; it is implemented by derived classes, typically by
williamr@2
  3020
their Next() member functions. The class TFindSemaphore is a good example.
williamr@2
  3021
	
williamr@2
  3022
@return The find-handle number.
williamr@2
  3023
*/
williamr@2
  3024
	{return iHandle;}
williamr@2
  3025
williamr@2
  3026
williamr@2
  3027
williamr@2
  3028
williamr@2
  3029
#ifdef __KERNEL_MODE__
williamr@2
  3030
const TInt KFindHandleUniqueIdShift=16;    ///< @internalComponent
williamr@2
  3031
const TInt KFindHandleUniqueIdMask=0x7fff; ///< @internalComponent
williamr@2
  3032
const TInt KFindHandleIndexMask=0x7fff;    ///< @internalComponent
williamr@2
  3033
williamr@2
  3034
williamr@2
  3035
williamr@2
  3036
williamr@2
  3037
/**
williamr@2
  3038
Gets the index into its container at which the kernel object was last seen.
williamr@2
  3039
williamr@2
  3040
@return The object's index in its container.
williamr@2
  3041
*/
williamr@2
  3042
inline TInt TFindHandle::Index() const
williamr@2
  3043
	{return(iHandle&KFindHandleIndexMask);}
williamr@2
  3044
williamr@2
  3045
williamr@2
  3046
williamr@2
  3047
williamr@2
  3048
/**
williamr@2
  3049
Gets the unique ID of the kernel container this object resides in.
williamr@2
  3050
williamr@2
  3051
@return The ID of this object's container.
williamr@2
  3052
*/
williamr@2
  3053
inline TInt TFindHandle::UniqueID() const
williamr@2
  3054
	{return((iHandle>>KFindHandleUniqueIdShift)&KFindHandleUniqueIdMask);}
williamr@2
  3055
williamr@2
  3056
williamr@2
  3057
williamr@2
  3058
williamr@2
  3059
/**
williamr@2
  3060
Gets the unique ID of the kernel object itself.
williamr@2
  3061
williamr@2
  3062
@return The ID of the object.
williamr@2
  3063
*/
williamr@2
  3064
inline TUint64 TFindHandle::ObjectID() const
williamr@2
  3065
	{return MAKE_TUINT64(iObjectIdHigh, iObjectIdLow);}
williamr@2
  3066
williamr@2
  3067
williamr@2
  3068
williamr@2
  3069
williamr@2
  3070
/**
williamr@2
  3071
Sets the find handle to refer to a specific object.
williamr@2
  3072
williamr@2
  3073
@oaram aIndex The current index of the object in its container.
williamr@2
  3074
@param aUniqueId The unique ID of the container object.
williamr@2
  3075
@param aObjectId The unique ID of the object iteself.
williamr@2
  3076
*/
williamr@2
  3077
inline void TFindHandle::Set(TInt aIndex, TInt aUniqueId, TUint64 aObjectId)
williamr@2
  3078
	{
williamr@2
  3079
	iHandle=(TInt)((aUniqueId<<KFindHandleUniqueIdShift)|aIndex);
williamr@2
  3080
	iObjectIdLow=I64LOW(aObjectId);
williamr@2
  3081
	iObjectIdHigh=I64HIGH(aObjectId);
williamr@2
  3082
	}
williamr@2
  3083
williamr@2
  3084
williamr@2
  3085
#else
williamr@2
  3086
williamr@2
  3087
williamr@2
  3088
/**
williamr@2
  3089
Resets the find handle to its initial state.
williamr@2
  3090
*/
williamr@2
  3091
inline void TFindHandle::Reset()
williamr@2
  3092
	{
williamr@2
  3093
	iHandle=iSpare1=iObjectIdLow=iObjectIdHigh=0;
williamr@2
  3094
	}
williamr@2
  3095
#endif
williamr@2
  3096
williamr@2
  3097
williamr@2
  3098
williamr@2
  3099
williamr@2
  3100
// Class RHandleBase
williamr@2
  3101
inline RHandleBase::RHandleBase()
williamr@2
  3102
	: iHandle(0)
williamr@2
  3103
/**
williamr@2
  3104
Default constructor.
williamr@2
  3105
*/
williamr@2
  3106
	{}
williamr@2
  3107
williamr@2
  3108
williamr@2
  3109
williamr@2
  3110
williamr@2
  3111
#ifndef __KERNEL_MODE__
williamr@2
  3112
inline RHandleBase::RHandleBase(TInt aHandle)
williamr@2
  3113
	: iHandle(aHandle)
williamr@2
  3114
/**
williamr@2
  3115
Copy constructor.
williamr@2
  3116
williamr@2
  3117
It constructs this handle from an existing one. Specifically, the handle-number 
williamr@2
  3118
encapsulated by the specified handle is copied to this handle.
williamr@2
  3119
williamr@2
  3120
@param aHandle The existing handle to be copied.
williamr@2
  3121
*/
williamr@2
  3122
	{}
williamr@2
  3123
#endif
williamr@2
  3124
williamr@2
  3125
williamr@2
  3126
williamr@2
  3127
williamr@2
  3128
inline void RHandleBase::SetHandle(TInt aHandle)
williamr@2
  3129
/**
williamr@2
  3130
Sets the handle-number of this handle to the specified 
williamr@2
  3131
value.
williamr@2
  3132
williamr@2
  3133
@param aHandle The handle-number to be set.
williamr@2
  3134
*/
williamr@2
  3135
	{ iHandle=aHandle; }
williamr@2
  3136
williamr@2
  3137
williamr@2
  3138
williamr@2
  3139
williamr@2
  3140
inline TInt RHandleBase::Handle() const
williamr@2
  3141
/**
williamr@2
  3142
Retrieves the handle-number of the object associated with this handle.
williamr@2
  3143
williamr@2
  3144
@return The handle number
williamr@2
  3145
*/
williamr@2
  3146
	{return(iHandle);}
williamr@2
  3147
williamr@2
  3148
williamr@2
  3149
williamr@2
  3150
williamr@2
  3151
inline TInt RHandleBase::SetReturnedHandle(TInt aHandleOrError)
williamr@2
  3152
/**
williamr@2
  3153
Sets the handle-number of this handle to the specified 
williamr@2
  3154
value.
williamr@2
  3155
williamr@2
  3156
The function can take a (zero or positive) handle-number,
williamr@2
  3157
or a (negative) error number.
williamr@2
  3158
williamr@2
  3159
If aHandleOrError represents a handle-number, then the handle-number of this handle
williamr@2
  3160
is set to that value.
williamr@2
  3161
If aHandleOrError represents an error number, then the handle-number of this handle is set to zero
williamr@2
  3162
and the negative value is returned.
williamr@2
  3163
williamr@2
  3164
@param aHandleOrError A handle-number, if zero or positive; an error value, if negative.
williamr@2
  3165
williamr@2
  3166
@return KErrNone, if aHandle is a handle-number; the value of aHandleOrError, otherwise.
williamr@2
  3167
*/
williamr@2
  3168
	{
williamr@2
  3169
	if(aHandleOrError>=0)
williamr@2
  3170
		{
williamr@2
  3171
		iHandle = aHandleOrError;
williamr@2
  3172
		return KErrNone;
williamr@2
  3173
		}
williamr@2
  3174
	iHandle = 0;
williamr@2
  3175
	return aHandleOrError;
williamr@2
  3176
	}
williamr@2
  3177
williamr@2
  3178
williamr@2
  3179
williamr@2
  3180
williamr@2
  3181
// Class RSemaphore
williamr@2
  3182
#ifndef __KERNEL_MODE__
williamr@2
  3183
inline TInt RSemaphore::Open(const TFindSemaphore& aFind,TOwnerType aType)
williamr@2
  3184
/**
williamr@2
  3185
Opens a handle to the global semaphore found using a TFindSemaphore object.
williamr@2
  3186
williamr@2
  3187
A TFindSemaphore object is used to find all global semaphores whose full names 
williamr@2
  3188
match a specified pattern.
williamr@2
  3189
williamr@2
  3190
By default, any thread in the process can use this instance of RSemaphore 
williamr@2
  3191
to access the semaphore. However, specifying EOwnerThread as the second parameter 
williamr@2
  3192
to this function, means that only the opening thread can use this instance 
williamr@2
  3193
of RSemaphore to access the semaphore; any other thread in this process that 
williamr@2
  3194
wants to access the semaphore must either duplicate the handle or use OpenGlobal() 
williamr@2
  3195
again.
williamr@2
  3196
williamr@2
  3197
@param aFind A reference to the TFindSemaphore object used to find the semaphore. 
williamr@2
  3198
@param aType An enumeration whose enumerators define the ownership of this 
williamr@2
  3199
             semaphore handle. If not explicitly specified, EOwnerProcess is
williamr@2
  3200
			 taken as default. 
williamr@2
  3201
williamr@2
  3202
@return KErrNone if successful otherwise another of the system wide error codes.
williamr@2
  3203
*/
williamr@2
  3204
	{return(RHandleBase::Open((const TFindHandleBase&)aFind,aType));}
williamr@2
  3205
#endif
williamr@2
  3206
williamr@2
  3207
williamr@2
  3208
williamr@2
  3209
williamr@2
  3210
// Class RFastLock
williamr@2
  3211
williamr@2
  3212
williamr@2
  3213
/**
williamr@2
  3214
Default constructor.
williamr@2
  3215
*/
williamr@2
  3216
inline RFastLock::RFastLock()
williamr@2
  3217
	:	iCount(0)
williamr@2
  3218
	{}
williamr@2
  3219
williamr@2
  3220
williamr@2
  3221
williamr@2
  3222
williamr@4
  3223
/**
williamr@4
  3224
Default constructor.
williamr@4
  3225
*/
williamr@4
  3226
inline RReadWriteLock::RReadWriteLock()
williamr@4
  3227
	: iValues(0), iPriority(EAlternatePriority), iReaderSem(), iWriterSem()
williamr@4
  3228
	{}
williamr@4
  3229
williamr@4
  3230
williamr@4
  3231
williamr@4
  3232
williamr@2
  3233
// Class RMessagePtr2
williamr@2
  3234
williamr@2
  3235
williamr@2
  3236
/**
williamr@2
  3237
Default constructor
williamr@2
  3238
*/
williamr@2
  3239
inline RMessagePtr2::RMessagePtr2()
williamr@2
  3240
	: iHandle(0)
williamr@2
  3241
	{}
williamr@2
  3242
williamr@2
  3243
williamr@2
  3244
williamr@2
  3245
williamr@2
  3246
/**
williamr@2
  3247
Tests whether this message handle is empty.
williamr@2
  3248
williamr@2
  3249
@return True, if this message handle is empty, false, otherwise.
williamr@2
  3250
*/
williamr@2
  3251
inline TBool RMessagePtr2::IsNull() const
williamr@2
  3252
	{return iHandle==0;}
williamr@2
  3253
williamr@2
  3254
williamr@2
  3255
williamr@2
  3256
williamr@2
  3257
/**
williamr@2
  3258
Gets the message handle value.
williamr@2
  3259
williamr@2
  3260
@return The message handle value.
williamr@2
  3261
*/
williamr@2
  3262
inline TInt RMessagePtr2::Handle() const
williamr@2
  3263
	{return iHandle;}
williamr@2
  3264
inline TBool operator==(RMessagePtr2 aLeft,RMessagePtr2 aRight)
williamr@2
  3265
	{return aLeft.Handle()==aRight.Handle();}
williamr@2
  3266
inline TBool operator!=(RMessagePtr2 aLeft,RMessagePtr2 aRight)
williamr@2
  3267
	{return aLeft.Handle()!=aRight.Handle();}
williamr@2
  3268
williamr@2
  3269
williamr@2
  3270
williamr@2
  3271
williamr@2
  3272
williamr@2
  3273
// Class RMessage
williamr@2
  3274
williamr@2
  3275
williamr@2
  3276
/**
williamr@2
  3277
Default constructor
williamr@2
  3278
*/
williamr@2
  3279
inline RMessage2::RMessage2()
williamr@4
  3280
	:iFunction(0), iSpare1(0), iSessionPtr(NULL), iFlags(0), iSpare3(0)
williamr@2
  3281
	{}
williamr@2
  3282
williamr@2
  3283
williamr@2
  3284
williamr@2
  3285
williamr@2
  3286
/**
williamr@2
  3287
Gets the the number of the function requested by the client.
williamr@2
  3288
williamr@2
  3289
@return The function number. 
williamr@2
  3290
*/
williamr@2
  3291
inline TInt RMessage2::Function() const
williamr@2
  3292
	{return(iFunction);}
williamr@2
  3293
williamr@2
  3294
williamr@2
  3295
williamr@2
  3296
williamr@2
  3297
/**
williamr@2
  3298
Gets the first message argument as an integer value.
williamr@2
  3299
williamr@2
  3300
@return The first message argument.
williamr@2
  3301
*/
williamr@2
  3302
inline TInt RMessage2::Int0() const
williamr@2
  3303
	{return(iArgs[0]);}
williamr@2
  3304
williamr@2
  3305
williamr@2
  3306
williamr@2
  3307
williamr@2
  3308
/**
williamr@2
  3309
Gets the second message argument as an integer value.
williamr@2
  3310
williamr@2
  3311
@return The second message argument.
williamr@2
  3312
*/
williamr@2
  3313
inline TInt RMessage2::Int1() const
williamr@2
  3314
	{return(iArgs[1]);}
williamr@2
  3315
williamr@2
  3316
williamr@2
  3317
williamr@2
  3318
williamr@2
  3319
/**
williamr@2
  3320
Gets the third message argument as an integer value.
williamr@2
  3321
williamr@2
  3322
@return The third message argument.
williamr@2
  3323
*/
williamr@2
  3324
inline TInt RMessage2::Int2() const
williamr@2
  3325
	{return(iArgs[2]);}
williamr@2
  3326
williamr@2
  3327
williamr@2
  3328
williamr@2
  3329
/**
williamr@2
  3330
Gets the fourth message argument as an integer value.
williamr@2
  3331
williamr@2
  3332
@return The fourth message argument.
williamr@2
  3333
*/
williamr@2
  3334
inline TInt RMessage2::Int3() const
williamr@2
  3335
	{return(iArgs[3]);}
williamr@2
  3336
williamr@2
  3337
williamr@2
  3338
williamr@2
  3339
/**
williamr@2
  3340
Gets the first message argument as a pointer type.
williamr@2
  3341
williamr@2
  3342
@return The first message argument.
williamr@2
  3343
*/
williamr@2
  3344
inline const TAny *RMessage2::Ptr0() const
williamr@2
  3345
	{return((const TAny *)iArgs[0]);}
williamr@2
  3346
williamr@2
  3347
williamr@2
  3348
williamr@2
  3349
williamr@2
  3350
/**
williamr@2
  3351
Gets the second message argument as a pointer type.
williamr@2
  3352
williamr@2
  3353
@return The second message argument.
williamr@2
  3354
*/
williamr@2
  3355
inline const TAny *RMessage2::Ptr1() const
williamr@2
  3356
	{return((const TAny *)iArgs[1]);}
williamr@2
  3357
williamr@2
  3358
williamr@2
  3359
williamr@2
  3360
williamr@2
  3361
/**
williamr@2
  3362
Gets the third message argument as a pointer type.
williamr@2
  3363
williamr@2
  3364
@return The third message argument.
williamr@2
  3365
*/
williamr@2
  3366
inline const TAny *RMessage2::Ptr2() const
williamr@2
  3367
	{return((const TAny *)iArgs[2]);}
williamr@2
  3368
williamr@2
  3369
williamr@2
  3370
williamr@2
  3371
williamr@2
  3372
/**
williamr@2
  3373
Gets the fourth message argument as a pointer type.
williamr@2
  3374
williamr@2
  3375
@return The fourth message argument.
williamr@2
  3376
*/
williamr@2
  3377
inline const TAny *RMessage2::Ptr3() const
williamr@2
  3378
	{return((const TAny *)iArgs[3]);}
williamr@2
  3379
williamr@2
  3380
williamr@2
  3381
williamr@2
  3382
/**
williamr@2
  3383
Gets a pointer to the session.
williamr@2
  3384
williamr@2
  3385
@return A pointer to the session object.
williamr@2
  3386
*/
williamr@2
  3387
inline CSession2* RMessage2::Session() const
williamr@2
  3388
	{return (CSession2*)iSessionPtr; }
williamr@2
  3389
williamr@2
  3390
williamr@2
  3391
williamr@2
  3392
williamr@2
  3393
// Class TUid
williamr@2
  3394
inline TUid TUid::Uid(TInt aUid)
williamr@2
  3395
/**
williamr@2
  3396
Constructs the TUid object from a 32-bit integer.
williamr@2
  3397
williamr@2
  3398
@param aUid The 32-bit integer value from which the TUid object is to be
williamr@2
  3399
            constructed.
williamr@2
  3400
williamr@2
  3401
@return The constructed TUid object.
williamr@2
  3402
*/
williamr@2
  3403
	{TUid uid={aUid};return uid;}
williamr@2
  3404
williamr@2
  3405
williamr@2
  3406
williamr@2
  3407
williamr@2
  3408
inline TUid TUid::Null()
williamr@2
  3409
/**
williamr@2
  3410
Constructs a Null-valued TUid object.
williamr@2
  3411
williamr@2
  3412
@return The constructed Null-valued TUid object.
williamr@2
  3413
*/
williamr@2
  3414
	{TUid uid={KNullUidValue};return uid;}
williamr@2
  3415
williamr@2
  3416
williamr@2
  3417
williamr@2
  3418
williamr@2
  3419
#ifndef __KERNEL_MODE__
williamr@2
  3420
// Template class TArray
williamr@2
  3421
template <class T>
williamr@2
  3422
inline TArray<T>::TArray(TInt (*aCount)(const CBase *aPtr),const TAny *(*anAt)(const CBase *aPtr,TInt anIndex),const CBase *aPtr)
williamr@2
  3423
	: iPtr(aPtr),iCount(aCount),iAt(anAt)
williamr@2
  3424
/**
williamr@2
  3425
Constructor.
williamr@2
  3426
williamr@2
  3427
A TArray object is not intended to be instantiated explicitly. An object of
williamr@2
  3428
this type is instantiated as a result of a call to to the Array() member
williamr@2
  3429
function of a concrete array class
williamr@2
  3430
williamr@2
  3431
@param aCount A pointer to a function which takes a
williamr@2
  3432
              @code
williamr@2
  3433
			  const CBase*
williamr@2
  3434
              @endcode
williamr@2
  3435
              argument and returns a
williamr@2
  3436
              @code
williamr@2
  3437
              TInt
williamr@2
  3438
              @endcode
williamr@2
  3439
              aCount must point to the member function which returns the
williamr@2
  3440
              current number of elements of type class T contained in the
williamr@2
  3441
	          array at aPtr, for which this TArray is being constructed.
williamr@2
  3442
              This argument is supplied by the Array() member function of the
williamr@2
  3443
              array class. 
williamr@2
  3444
@param anAt   A pointer to a function which takes a
williamr@2
  3445
              @code
williamr@2
  3446
              const CBase*
williamr@2
  3447
              @endcode
williamr@2
  3448
              and a 
williamr@2
  3449
              @code
williamr@2
  3450
              TInt
williamr@2
  3451
              @endcode
williamr@2
  3452
              argument, and returns a pointer to
williamr@2
  3453
              @code
williamr@2
  3454
              TAny
williamr@2
  3455
              @endcode
williamr@2
  3456
              anAt must point to the member function which returns a reference
williamr@2
  3457
              to the element located at position anIndex within the array at
williamr@2
  3458
              aPtr, for which this TArray is being constructed.
williamr@2
  3459
              This argument is supplied by the Array() member function of the
williamr@2
  3460
              array class.
williamr@2
  3461
@param aPtr   A pointer to the array for which this TArray is being
williamr@2
  3462
              constructed. This argument is supplied by the Array() member
williamr@2
  3463
              function of the array class.
williamr@2
  3464
williamr@2
  3465
@see CArrayFixFlat::Array
williamr@2
  3466
@see CArrayFixSeg::Array
williamr@2
  3467
@see CArrayVarFlat::Array
williamr@2
  3468
@see CArrayVarSeg::Array
williamr@2
  3469
@see CArrayPakFlat::Array
williamr@2
  3470
@see RArray::Array
williamr@2
  3471
@see RPointerArray::Array
williamr@2
  3472
@see RArray<TInt>::Array
williamr@2
  3473
@see RArray<TUint>::Array
williamr@2
  3474
*/
williamr@2
  3475
	{}
williamr@2
  3476
williamr@2
  3477
williamr@2
  3478
williamr@2
  3479
williamr@2
  3480
template <class T>
williamr@2
  3481
inline TInt TArray<T>::Count() const
williamr@2
  3482
/**
williamr@2
  3483
Gets the number of elements currently held in the array for which this generic 
williamr@2
  3484
array has been constructed.
williamr@2
  3485
williamr@2
  3486
@return The number of array elements.
williamr@2
  3487
*/
williamr@2
  3488
	{return((*iCount)(iPtr));}
williamr@2
  3489
williamr@2
  3490
williamr@2
  3491
williamr@2
  3492
williamr@2
  3493
template <class T>
williamr@2
  3494
inline const T &TArray<T>::operator[](TInt anIndex) const
williamr@2
  3495
/**
williamr@2
  3496
Gets a reference to the element located at the specified position.
williamr@2
  3497
williamr@2
  3498
The returned reference is const and cannot be used to change the element.
williamr@2
  3499
Any member function of the referenced template class T must be declared
williamr@2
  3500
as const if that function is to be accessed through this operator.
williamr@2
  3501
williamr@2
  3502
@param anIndex The position of the element within the array for which this
williamr@2
  3503
               TArray has been constructed. The position is relative to zero;
williamr@2
  3504
			   i.e. zero implies the first element in the array. 
williamr@2
  3505
williamr@2
  3506
@return A const reference to the element located at position anIndex within
williamr@2
  3507
        the array for which this TArray has been constructed.
williamr@2
  3508
williamr@2
  3509
@panic E32USER-CBase 21, if anIndex is negative, or greater than or equal to
williamr@2
  3510
       the number of objects currently within the array.
williamr@2
  3511
*/
williamr@2
  3512
	{return(*((const T *)(*iAt)(iPtr,anIndex)));}
williamr@2
  3513
#endif
williamr@2
  3514
williamr@2
  3515
williamr@2
  3516
williamr@2
  3517
williamr@2
  3518
// Class TIdentityRelation<T>
williamr@2
  3519
template <class T>
williamr@4
  3520
inline TIdentityRelation<T>::TIdentityRelation()
williamr@4
  3521
/**
williamr@4
  3522
Constructs the object to use the equality operator (==) defined for class T
williamr@4
  3523
to determine whether two class T type objects match.
williamr@4
  3524
*/
williamr@4
  3525
	{iIdentity=(TGeneralIdentityRelation)&EqualityOperatorCompare;}
williamr@4
  3526
williamr@4
  3527
williamr@4
  3528
williamr@4
  3529
williamr@4
  3530
template <class T>
williamr@2
  3531
inline TIdentityRelation<T>::TIdentityRelation( TBool (*anIdentity)(const T&, const T&) )
williamr@2
  3532
/**
williamr@2
  3533
Constructs the object taking the specified function as an argument.
williamr@2
  3534
williamr@2
  3535
The specified function should implement an algorithm for determining whether
williamr@2
  3536
two class T type objects match. It should return:
williamr@2
  3537
williamr@2
  3538
1. true, if the two objects match.
williamr@2
  3539
williamr@2
  3540
2. false, if the two objects do not match.
williamr@2
  3541
williamr@2
  3542
@param anIdentity A pointer to a function that takes constant references to two
williamr@2
  3543
                  class T objects and returns a TInt value. 
williamr@2
  3544
*/
williamr@2
  3545
	{ iIdentity=(TGeneralIdentityRelation)anIdentity; }
williamr@2
  3546
williamr@2
  3547
williamr@2
  3548
williamr@2
  3549
williamr@2
  3550
template <class T>
williamr@2
  3551
inline TIdentityRelation<T>::operator TGeneralIdentityRelation() const
williamr@2
  3552
/**
williamr@2
  3553
Operator that gets the function that determines whether two
williamr@2
  3554
objects of a given class type match.
williamr@2
  3555
*/
williamr@2
  3556
	{ return iIdentity; }
williamr@2
  3557
williamr@2
  3558
williamr@2
  3559
williamr@4
  3560
template <class T>
williamr@4
  3561
inline TBool TIdentityRelation<T>::EqualityOperatorCompare(const T& aLeft, const T& aRight)
williamr@4
  3562
/**
williamr@4
  3563
Compares two objects of class T using the equality operator defined for class T.
williamr@4
  3564
*/
williamr@4
  3565
	{return aLeft == aRight;}
williamr@4
  3566
williamr@4
  3567
williamr@2
  3568
williamr@2
  3569
// Class TLinearOrder<T>
williamr@2
  3570
template <class T>
williamr@2
  3571
inline TLinearOrder<T>::TLinearOrder( TInt(*anOrder)(const T&, const T&) )
williamr@2
  3572
/**
williamr@2
  3573
Constructs the object taking the specified function as an argument.
williamr@2
  3574
williamr@2
  3575
The specified function should implement an algorithm that determines the
williamr@2
  3576
order of two class T type objects. It should return:
williamr@2
  3577
williamr@2
  3578
1. zero, if the two objects are equal.
williamr@2
  3579
williamr@2
  3580
2. a negative value, if the first object is less than the second.
williamr@2
  3581
williamr@2
  3582
3. a positive value, if the first object is greater than the second.
williamr@2
  3583
williamr@2
  3584
@param anOrder A pointer to a function that takes constant references to two
williamr@2
  3585
               class T objects and returns a TInt value. 
williamr@2
  3586
*/
williamr@2
  3587
	{ iOrder=(TGeneralLinearOrder)anOrder; }
williamr@2
  3588
williamr@2
  3589
williamr@2
  3590
williamr@2
  3591
williamr@2
  3592
template <class T>
williamr@2
  3593
inline TLinearOrder<T>::operator TGeneralLinearOrder() const
williamr@2
  3594
/**
williamr@2
  3595
Operator that gets the function that determines the order of two
williamr@2
  3596
objects of a given class type.
williamr@2
  3597
*/
williamr@2
  3598
	{ return iOrder; }
williamr@2
  3599
williamr@2
  3600
williamr@2
  3601
williamr@2
  3602
williamr@2
  3603
// Class RPointerArray<T>
williamr@2
  3604
williamr@2
  3605
/**
williamr@2
  3606
Default C++ constructor.
williamr@2
  3607
williamr@2
  3608
This constructs an array object for an array of pointers with default
williamr@2
  3609
granularity, which is 8.
williamr@2
  3610
*/
williamr@2
  3611
template <class T>
williamr@2
  3612
inline RPointerArray<T>::RPointerArray()
williamr@2
  3613
	: RPointerArrayBase()
williamr@2
  3614
	{}
williamr@2
  3615
williamr@2
  3616
williamr@2
  3617
williamr@2
  3618
williamr@2
  3619
/**
williamr@2
  3620
C++ constructor with granularity.
williamr@2
  3621
williamr@2
  3622
This constructs an array object for an array of pointers with the specified 
williamr@2
  3623
granularity.
williamr@2
  3624
williamr@2
  3625
@param aGranularity The granularity of the array.
williamr@2
  3626
williamr@2
  3627
@panic USER 127, if aGranularity is not positive, or greater than or equal
williamr@2
  3628
       to 0x10000000.
williamr@2
  3629
*/
williamr@2
  3630
template <class T>
williamr@2
  3631
inline RPointerArray<T>::RPointerArray(TInt aGranularity)
williamr@2
  3632
	: RPointerArrayBase(aGranularity)
williamr@2
  3633
	{}
williamr@2
  3634
williamr@2
  3635
williamr@2
  3636
williamr@2
  3637
williamr@2
  3638
/**
williamr@2
  3639
C++ constructor with minimum growth step and exponential growth factor.
williamr@2
  3640
williamr@2
  3641
This constructs an array object for an array of pointers with the specified 
williamr@2
  3642
minimum growth step and exponential growth factor.
williamr@2
  3643
williamr@2
  3644
@param aMinGrowBy	The minimum growth step of the array. Must be between 1 and
williamr@2
  3645
					65535 inclusive.
williamr@2
  3646
@param aFactor		The factor by which the array grows, multiplied by 256.
williamr@2
  3647
					For example 512 specifies a factor of 2. Must be between 257
williamr@2
  3648
					and 32767 inclusive.
williamr@2
  3649
williamr@2
  3650
@panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535.
williamr@2
  3651
@panic USER 193, if aFactor<=257 or aFactor>32767.
williamr@2
  3652
*/
williamr@2
  3653
template <class T>
williamr@2
  3654
inline RPointerArray<T>::RPointerArray(TInt aMinGrowBy, TInt aFactor)
williamr@2
  3655
	: RPointerArrayBase(aMinGrowBy, aFactor)
williamr@2
  3656
	{}
williamr@2
  3657
williamr@2
  3658
williamr@2
  3659
williamr@2
  3660
williamr@2
  3661
template <class T>
williamr@2
  3662
inline void RPointerArray<T>::Close()
williamr@2
  3663
/**
williamr@2
  3664
Closes the array and frees all memory allocated to it.
williamr@2
  3665
williamr@2
  3666
The function must be called before this array object goes out of scope.
williamr@2
  3667
williamr@2
  3668
Note that the function does not delete the objects whose pointers are contained
williamr@2
  3669
in the array.
williamr@2
  3670
*/
williamr@2
  3671
	{RPointerArrayBase::Close();}
williamr@2
  3672
williamr@2
  3673
williamr@2
  3674
williamr@2
  3675
williamr@2
  3676
template <class T>
williamr@2
  3677
inline TInt RPointerArray<T>::Count() const
williamr@2
  3678
/**
williamr@2
  3679
Gets the number of object pointers in the array.
williamr@2
  3680
williamr@2
  3681
@return The number of object pointers in the array.
williamr@2
  3682
*/
williamr@2
  3683
	{ return RPointerArrayBase::Count(); }
williamr@2
  3684
williamr@2
  3685
williamr@2
  3686
williamr@2
  3687
williamr@2
  3688
template <class T>
williamr@2
  3689
inline T* const& RPointerArray<T>::operator[](TInt anIndex) const
williamr@2
  3690
/**
williamr@2
  3691
Gets a reference to the object pointer located at the specified 
williamr@2
  3692
position within the array.
williamr@2
  3693
williamr@2
  3694
The compiler chooses this option if the returned reference is used in
williamr@2
  3695
an expression where the reference cannot be modified.
williamr@2
  3696
williamr@2
  3697
@param anIndex The position of the object pointer within the array. The
williamr@2
  3698
               position is relative to zero, i.e. zero implies the object
williamr@2
  3699
			   pointer at the beginning of the array.
williamr@2
  3700
williamr@2
  3701
@return A const reference to the object pointer at position anIndex within 
williamr@2
  3702
        the array.
williamr@2
  3703
williamr@2
  3704
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  3705
       objects currently in the array.
williamr@2
  3706
*/
williamr@2
  3707
	{return (T* const&)At(anIndex);}
williamr@2
  3708
williamr@2
  3709
williamr@2
  3710
williamr@2
  3711
williamr@2
  3712
template <class T>
williamr@2
  3713
inline T*& RPointerArray<T>::operator[](TInt anIndex)
williamr@2
  3714
/**
williamr@2
  3715
Gets a reference to the object pointer located at the specified 
williamr@2
  3716
position within the array.
williamr@2
  3717
williamr@2
  3718
The compiler chooses this option if the returned reference is used in
williamr@2
  3719
an expression where the reference can be modified.
williamr@2
  3720
williamr@2
  3721
@param anIndex The position of the object pointer within the array. The
williamr@2
  3722
               position is relative to zero, i.e. zero implies the object
williamr@2
  3723
			   pointer at the beginning of the array.
williamr@2
  3724
williamr@2
  3725
@return A non-const reference to the object pointer at position anIndex within 
williamr@2
  3726
        the array.
williamr@2
  3727
williamr@2
  3728
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  3729
       objects currently in the array.
williamr@2
  3730
*/
williamr@2
  3731
	{return (T*&)At(anIndex);}
williamr@2
  3732
williamr@2
  3733
williamr@2
  3734
williamr@2
  3735
williamr@2
  3736
template <class T>
williamr@2
  3737
inline TInt RPointerArray<T>::Append(const T* anEntry)
williamr@2
  3738
/**
williamr@2
  3739
Appends an object pointer onto the array.
williamr@2
  3740
williamr@2
  3741
@param anEntry The object pointer to be appended.
williamr@2
  3742
williamr@2
  3743
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  3744
        wide error codes.
williamr@2
  3745
*/
williamr@2
  3746
	{ return RPointerArrayBase::Append(anEntry); }
williamr@2
  3747
williamr@2
  3748
williamr@2
  3749
williamr@2
  3750
williamr@2
  3751
template <class T>
williamr@2
  3752
inline TInt RPointerArray<T>::Insert(const T* anEntry, TInt aPos)
williamr@2
  3753
/**
williamr@2
  3754
Inserts an object pointer into the array at the specified position.
williamr@2
  3755
williamr@2
  3756
@param anEntry The object pointer to be inserted.
williamr@2
  3757
@param aPos    The position within the array where the object pointer is to be 
williamr@2
  3758
               inserted. The position is relative to zero, i.e. zero implies
williamr@2
  3759
			   that a pointer is inserted at the beginning of the array.
williamr@2
  3760
williamr@2
  3761
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  3762
        wide error codes.
williamr@2
  3763
williamr@2
  3764
@panic USER 131, if aPos is negative, or is greater than the number of object
williamr@2
  3765
       pointers currently in the array.
williamr@2
  3766
*/
williamr@2
  3767
	{ return RPointerArrayBase::Insert(anEntry,aPos); }
williamr@2
  3768
williamr@2
  3769
williamr@2
  3770
williamr@2
  3771
williamr@2
  3772
template <class T>
williamr@2
  3773
inline void RPointerArray<T>::Remove(TInt anIndex)
williamr@2
  3774
/**
williamr@2
  3775
Removes the object pointer at the specified position from the array.
williamr@2
  3776
williamr@2
  3777
Note that the function does not delete the object whose pointer is removed.
williamr@2
  3778
williamr@2
  3779
@param anIndex The position within the array from where the object pointer 
williamr@2
  3780
               is to be removed. The position is relative to zero, i.e. zero
williamr@2
  3781
			   implies that a pointer at the beginning of the array is to be
williamr@2
  3782
			   removed.
williamr@2
  3783
			   
williamr@2
  3784
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  3785
       objects currently in the array. 
williamr@2
  3786
*/
williamr@2
  3787
	{RPointerArrayBase::Remove(anIndex);}
williamr@2
  3788
williamr@2
  3789
williamr@2
  3790
williamr@2
  3791
williamr@2
  3792
template <class T>
williamr@2
  3793
inline void RPointerArray<T>::Compress()
williamr@2
  3794
/**
williamr@2
  3795
Compresses the array down to a minimum.
williamr@2
  3796
williamr@2
  3797
After a call to this function, the memory allocated to the array is just
williamr@2
  3798
sufficient for its contained object pointers.
williamr@2
  3799
Subsequently adding a new object pointer to the array 
williamr@2
  3800
always results in a re-allocation of memory.
williamr@2
  3801
*/
williamr@2
  3802
	{RPointerArrayBase::Compress();}
williamr@2
  3803
williamr@2
  3804
williamr@2
  3805
williamr@2
  3806
williamr@2
  3807
template <class T>
williamr@2
  3808
inline void RPointerArray<T>::Reset()
williamr@2
  3809
/**
williamr@2
  3810
Empties the array.
williamr@2
  3811
williamr@2
  3812
It frees all memory allocated to the array and resets the internal state so 
williamr@2
  3813
that it is ready to be reused.
williamr@2
  3814
williamr@2
  3815
This array object can be allowed to go out of scope after a call to this
williamr@2
  3816
function.
williamr@2
  3817
williamr@2
  3818
Note that the function does not delete the objects whose pointers are contained
williamr@2
  3819
in the array.
williamr@2
  3820
*/
williamr@2
  3821
	{RPointerArrayBase::Reset();}
williamr@2
  3822
williamr@2
  3823
williamr@2
  3824
williamr@2
  3825
williamr@2
  3826
template <class T>
williamr@2
  3827
inline TInt RPointerArray<T>::Find(const T* anEntry) const
williamr@2
  3828
/**
williamr@2
  3829
Finds the first object pointer in the array which matches the specified object 
williamr@2
  3830
pointer, using a sequential search.
williamr@2
  3831
williamr@2
  3832
Matching is based on the comparison of pointers.
williamr@2
  3833
williamr@2
  3834
The find operation always starts at the low index end of the array. There 
williamr@2
  3835
is no assumption about the order of objects in the array.
williamr@2
  3836
williamr@2
  3837
@param anEntry The object pointer to be found.
williamr@2
  3838
@return The index of the first matching object pointer within the array.
williamr@2
  3839
        KErrNotFound, if no matching object pointer can be found.
williamr@2
  3840
*/
williamr@2
  3841
	{ return RPointerArrayBase::Find(anEntry); }
williamr@2
  3842
williamr@2
  3843
williamr@2
  3844
williamr@2
  3845
williamr@2
  3846
template <class T>
williamr@2
  3847
inline TInt RPointerArray<T>::Find(const T* anEntry, TIdentityRelation<T> anIdentity) const
williamr@2
  3848
/**
williamr@2
  3849
Finds the first object pointer in the array whose object matches the specified 
williamr@2
  3850
object, using a sequential search and a matching algorithm.
williamr@2
  3851
williamr@2
  3852
The algorithm for determining whether two class T objects match is provided 
williamr@2
  3853
by a function supplied by the caller.
williamr@2
  3854
williamr@2
  3855
The find operation always starts at the low index end of the array. There 
williamr@2
  3856
is no assumption about the order of objects in the array.
williamr@2
  3857
williamr@2
  3858
@param anEntry    The object pointer to be found.
williamr@2
  3859
@param anIdentity A package encapsulating the function which determines whether 
williamr@2
  3860
                  two class T objects match.
williamr@2
  3861
williamr@2
  3862
@return The index of the first matching object pointer within the array.
williamr@2
  3863
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  3864
*/
williamr@2
  3865
	{ return RPointerArrayBase::Find(anEntry,anIdentity); }
williamr@2
  3866
williamr@2
  3867
williamr@2
  3868
williamr@2
  3869
williamr@2
  3870
template <class T>
williamr@2
  3871
inline TInt RPointerArray<T>::FindReverse(const T* anEntry) const
williamr@2
  3872
/**
williamr@2
  3873
Finds the last object pointer in the array which matches the specified object 
williamr@2
  3874
pointer, using a sequential search.
williamr@2
  3875
williamr@2
  3876
Matching is based on the comparison of pointers.
williamr@2
  3877
williamr@2
  3878
The find operation always starts at the high index end of the array. There 
williamr@2
  3879
is no assumption about the order of objects in the array.
williamr@2
  3880
williamr@2
  3881
@param anEntry The object pointer to be found.
williamr@2
  3882
@return The index of the last matching object pointer within the array.
williamr@2
  3883
        KErrNotFound, if no matching object pointer can be found.
williamr@2
  3884
*/
williamr@2
  3885
	{ return RPointerArrayBase::FindReverse(anEntry); }
williamr@2
  3886
williamr@2
  3887
williamr@2
  3888
williamr@2
  3889
williamr@2
  3890
template <class T>
williamr@2
  3891
inline TInt RPointerArray<T>::FindReverse(const T* anEntry, TIdentityRelation<T> anIdentity) const
williamr@2
  3892
/**
williamr@2
  3893
Finds the last object pointer in the array whose object matches the specified 
williamr@2
  3894
object, using a sequential search and a matching algorithm.
williamr@2
  3895
williamr@2
  3896
The algorithm for determining whether two class T objects match is provided 
williamr@2
  3897
by a function supplied by the caller.
williamr@2
  3898
williamr@2
  3899
The find operation always starts at the high index end of the array. There 
williamr@2
  3900
is no assumption about the order of objects in the array.
williamr@2
  3901
williamr@2
  3902
@param anEntry    The object pointer to be found.
williamr@2
  3903
@param anIdentity A package encapsulating the function which determines whether 
williamr@2
  3904
                  two class T objects match.
williamr@2
  3905
williamr@2
  3906
@return The index of the last matching object pointer within the array.
williamr@2
  3907
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  3908
*/
williamr@2
  3909
	{ return RPointerArrayBase::FindReverse(anEntry,anIdentity); }
williamr@2
  3910
williamr@2
  3911
williamr@2
  3912
williamr@2
  3913
williamr@2
  3914
template <class T>
williamr@2
  3915
inline TInt RPointerArray<T>::FindInAddressOrder(const T* anEntry) const
williamr@2
  3916
/**
williamr@2
  3917
Finds the object pointer in the array that matches the specified object
williamr@2
  3918
pointer, using a binary search technique.
williamr@2
  3919
williamr@2
  3920
The function assumes that object pointers in the array are in address order.
williamr@2
  3921
williamr@2
  3922
@param anEntry The object pointer to be found.
williamr@2
  3923
williamr@2
  3924
@return The index of the matching object pointer within the array or KErrNotFound 
williamr@2
  3925
        if no suitable object pointer can be found.
williamr@2
  3926
*/
williamr@2
  3927
	{ return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry); }
williamr@2
  3928
williamr@2
  3929
williamr@2
  3930
williamr@2
  3931
williamr@2
  3932
template <class T>
williamr@2
  3933
inline TInt RPointerArray<T>::FindInOrder(const T* anEntry, TLinearOrder<T> anOrder) const
williamr@2
  3934
/**
williamr@2
  3935
Finds the object pointer in the array whose object matches the specified
williamr@2
  3936
object, using a binary search technique and an ordering algorithm.
williamr@2
  3937
williamr@2
  3938
The function assumes that existing object pointers in the array are ordered 
williamr@2
  3939
so that the objects themselves are in object order as determined by an algorithm 
williamr@2
  3940
supplied by the caller and packaged as a TLinearOrder<T>.
williamr@2
  3941
williamr@2
  3942
@param anEntry The object pointer to be found.
williamr@2
  3943
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  3944
               of two class T objects.
williamr@2
  3945
williamr@2
  3946
@return The index of the matching object pointer within the array or KErrNotFound, 
williamr@2
  3947
        if no suitable object pointer can be found.
williamr@2
  3948
*/
williamr@2
  3949
	{ return RPointerArrayBase::FindIsq(anEntry,anOrder); }
williamr@2
  3950
williamr@2
  3951
williamr@2
  3952
williamr@2
  3953
williamr@2
  3954
template <class T>
williamr@2
  3955
inline TInt RPointerArray<T>::FindInAddressOrder(const T* anEntry, TInt& anIndex) const
williamr@2
  3956
/**
williamr@2
  3957
Finds the object pointer in the array that matches the specified object
williamr@2
  3958
pointer, using a binary search technique.
williamr@2
  3959
williamr@2
  3960
The function assumes that object pointers in the array are in address order.
williamr@2
  3961
williamr@2
  3962
@param anEntry The object pointer to be found.
williamr@2
  3963
@param anIndex A TInt supplied by the caller. On return, contains an index
williamr@2
  3964
               value:
williamr@2
  3965
               If the function returns KErrNone, this is the index of the
williamr@2
  3966
               matching object pointer within the array. 
williamr@2
  3967
               If the function returns KErrNotFound,  this is the
williamr@2
  3968
               index of the first object pointer within the array which
williamr@2
  3969
               logically follows after anEntry.
williamr@2
  3970
williamr@2
  3971
@return KErrNone, if a matching object pointer is found.
williamr@2
  3972
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  3973
*/
williamr@2
  3974
	{ return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex); }
williamr@2
  3975
williamr@2
  3976
williamr@2
  3977
williamr@2
  3978
williamr@2
  3979
template <class T>
williamr@2
  3980
inline TInt RPointerArray<T>::FindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const
williamr@2
  3981
/**
williamr@2
  3982
Finds the object pointer in the array whose object matches the specified
williamr@2
  3983
object, using a binary search technique and an ordering algorithm.
williamr@2
  3984
williamr@2
  3985
The function assumes that existing object pointers in the array are ordered 
williamr@2
  3986
so that the objects themselves are in object order as determined by an
williamr@2
  3987
algorithm supplied by the caller and packaged as a TLinearOrder<T>.
williamr@2
  3988
williamr@2
  3989
@param anEntry The object pointer to be found.
williamr@2
  3990
@param anIndex A TInt supplied by the caller. On return, contains an
williamr@2
  3991
               index value:
williamr@2
  3992
               If the function returns KErrNone, this is the index of the
williamr@2
  3993
               matching object pointer within the array. 
williamr@2
  3994
               If the function returns KErrNotFound, this is the index of
williamr@2
  3995
               the first object pointer in the array whose object is larger
williamr@2
  3996
               than the entry being searched for - if no objects pointed to in
williamr@2
  3997
               the array are larger, then the index value is the same as the
williamr@2
  3998
               total number of object pointers in the array.
williamr@2
  3999
williamr@2
  4000
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  4001
               of two class T objects.
williamr@2
  4002
williamr@2
  4003
@return KErrNone, if a matching object pointer is found.
williamr@2
  4004
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  4005
*/
williamr@2
  4006
	{ return RPointerArrayBase::BinarySearch(anEntry,anIndex,anOrder); }
williamr@2
  4007
williamr@2
  4008
williamr@2
  4009
williamr@2
  4010
williamr@2
  4011
template <class T>
williamr@2
  4012
inline TInt RPointerArray<T>::SpecificFindInAddressOrder(const T* anEntry, TInt aMode) const
williamr@2
  4013
/**
williamr@2
  4014
Finds the object pointer in the array that matches the specified object
williamr@2
  4015
pointer, using a binary search technique.
williamr@2
  4016
williamr@2
  4017
Where there is more than one matching element, it finds the first, the last 
williamr@2
  4018
or any matching element as specified by the value of aMode.
williamr@2
  4019
williamr@2
  4020
The function assumes that object pointers in the array are in address order.
williamr@2
  4021
williamr@2
  4022
@param	anEntry The object pointer to be found.
williamr@2
  4023
@param	aMode   Specifies whether to find the first match, the last match or
williamr@2
  4024
                any match, as defined by one of the TArrayFindMode enum values.
williamr@2
  4025
williamr@2
  4026
@return KErrNotFound, if there is no matching element, otherwise the array
williamr@2
  4027
        index of a matching element - what the index refers to depends on the
williamr@2
  4028
        value of aMode:
williamr@2
  4029
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  4030
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  4031
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  4032
        the last matching element - if the last matching element is also the last element of
williamr@2
  4033
        the array, then the index value is the same as the total number of elements in the array.
williamr@2
  4034
        
williamr@2
  4035
@see TArrayFindMode
williamr@2
  4036
*/
williamr@2
  4037
	{ return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry, aMode); }
williamr@2
  4038
williamr@2
  4039
williamr@2
  4040
williamr@2
  4041
williamr@2
  4042
template <class T>
williamr@2
  4043
inline TInt RPointerArray<T>::SpecificFindInOrder(const T* anEntry, TLinearOrder<T> anOrder, TInt aMode) const
williamr@2
  4044
/**
williamr@2
  4045
Finds the object pointer in the array whose object matches the specified
williamr@2
  4046
object, using a binary search technique and an ordering algorithm.
williamr@2
  4047
williamr@2
  4048
Where there is more than one matching element, it finds the first, the last
williamr@2
  4049
or any matching element as specified by the value of aMode.
williamr@2
  4050
williamr@2
  4051
The function assumes that existing object pointers in the array are ordered 
williamr@2
  4052
so that the objects themselves are in object order as determined by an algorithm 
williamr@2
  4053
supplied by the caller and packaged as a TLinearOrder<T> type.
williamr@2
  4054
williamr@2
  4055
@param anEntry The object pointer to be found.
williamr@2
  4056
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  4057
               of two class T objects.
williamr@2
  4058
@param	aMode  Specifies whether to find the first match, the last match or any match,
williamr@2
  4059
               as defined by one of the TArrayFindMode enum values.
williamr@2
  4060
williamr@2
  4061
@return KErrNotFound, if there is no matching element, otherwise the array
williamr@2
  4062
        index of a matching element -  what the index refers to depends on
williamr@2
  4063
        the value of aMode:
williamr@2
  4064
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  4065
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  4066
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  4067
        the last matching element - if the last matching element is also the last element of the array,
williamr@2
  4068
        then the index value is the same as the total number of elements in the array.
williamr@2
  4069
        
williamr@2
  4070
@see TArrayFindMode   
williamr@2
  4071
*/
williamr@2
  4072
	{ return RPointerArrayBase::FindIsq(anEntry,anOrder,aMode); }
williamr@2
  4073
williamr@2
  4074
williamr@2
  4075
williamr@2
  4076
williamr@2
  4077
template <class T>
williamr@2
  4078
inline TInt RPointerArray<T>::SpecificFindInAddressOrder(const T* anEntry, TInt& anIndex, TInt aMode) const
williamr@2
  4079
/**
williamr@2
  4080
Finds the object pointer in the array that matches the specified object
williamr@2
  4081
pointer, using a binary search technique.
williamr@2
  4082
williamr@2
  4083
Where there is more than one matching element, it finds the first, the last
williamr@2
  4084
or any matching element as specified by the value of aMode.
williamr@2
  4085
williamr@2
  4086
The function assumes that object pointers in the array are in address order.
williamr@2
  4087
williamr@2
  4088
@param anEntry The object pointer to be found.
williamr@2
  4089
@param anIndex A TInt type supplied by the caller. On return, it contains an
williamr@2
  4090
               index value depending on whether a match is found and on the
williamr@2
  4091
               value of aMode.
williamr@2
  4092
               If there is no matching element in the array, then this is
williamr@2
  4093
               the index of the first element in the array that is bigger than
williamr@2
  4094
               the element being searched for - if no elements in the array are
williamr@2
  4095
               bigger, then the index value is the same as the total number of
williamr@2
  4096
               elements in the array. If there is a matching element, then what
williamr@2
  4097
               the index refers to depends on the value of aMode:
williamr@2
  4098
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  4099
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  4100
               if this is EArrayFindMode_Last, then the index refers to first element that follows the
williamr@2
  4101
               last matching element - if the last matching element is also the last element of the array,
williamr@2
  4102
               then the index value is the same as the total number of elements in the array.
williamr@2
  4103
               
williamr@2
  4104
@param	aMode  Specifies whether to find the first match, the last match or any
williamr@2
  4105
               match, as defined by one of the TArrayFindMode enum values.
williamr@2
  4106
williamr@2
  4107
@return KErrNone, if a matching object pointer is found.
williamr@2
  4108
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  4109
        
williamr@2
  4110
@see TArrayFindMode
williamr@2
  4111
*/
williamr@2
  4112
	{ return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex,aMode); }
williamr@2
  4113
williamr@2
  4114
williamr@2
  4115
williamr@2
  4116
williamr@2
  4117
template <class T>
williamr@2
  4118
inline TInt RPointerArray<T>::SpecificFindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder<T> anOrder, TInt aMode) const
williamr@2
  4119
/**
williamr@2
  4120
Finds the object pointer in the array whose object matches the specified
williamr@2
  4121
object, using a binary search technique and an ordering algorithm.
williamr@2
  4122
williamr@2
  4123
Where there is more than one matching element, it finds the first, the last or any
williamr@2
  4124
matching element as specified by the value of aMode.
williamr@2
  4125
williamr@2
  4126
The function assumes that existing object pointers in the array are ordered 
williamr@2
  4127
so that the objects themselves are in object order as determined by an
williamr@2
  4128
algorithm supplied by the caller and packaged as a TLinearOrder<T> type.
williamr@2
  4129
williamr@2
  4130
@param anEntry The object pointer to be found.
williamr@2
  4131
@param anIndex A TInt type supplied by the caller. On return, it contains an
williamr@2
  4132
               index value depending on whether a match is found and on the
williamr@2
  4133
               value of aMode. If there is no matching element in the array,
williamr@2
  4134
               then this is the index of the first element in the array
williamr@2
  4135
               that is bigger than the element being searched for - if
williamr@2
  4136
               no elements in the array are bigger, then the index value
williamr@2
  4137
               is the same as the total number of elements in the array.
williamr@2
  4138
               If there is a matching element, then what the index refers to
williamr@2
  4139
               depends on the value of aMode:
williamr@2
  4140
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  4141
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  4142
               if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  4143
               the last matching element - if the last matching element is also the last element
williamr@2
  4144
               of the array, then the index value is the same as the total number of elements in the array.
williamr@2
  4145
williamr@2
  4146
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  4147
               of two class T objects.
williamr@2
  4148
@param	aMode  Specifies whether to find the first match, the last match or
williamr@2
  4149
               any match, as defined by one of the TArrayFindMode enum values.
williamr@2
  4150
williamr@2
  4151
@return KErrNone, if a matching object pointer is found.
williamr@2
  4152
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  4153
        
williamr@2
  4154
@see TArrayFindMode
williamr@2
  4155
*/
williamr@2
  4156
	{ return RPointerArrayBase::BinarySearch(anEntry,anIndex,anOrder,aMode); }
williamr@2
  4157
williamr@2
  4158
williamr@2
  4159
williamr@2
  4160
williamr@2
  4161
template <class T>
williamr@2
  4162
inline TInt RPointerArray<T>::InsertInAddressOrder(const T* anEntry)
williamr@2
  4163
/**
williamr@2
  4164
Inserts an object pointer into the array in address order.
williamr@2
  4165
williamr@2
  4166
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  4167
an attempt to insert a duplicate entry.
williamr@2
  4168
williamr@2
  4169
The function assumes that existing object pointers within the array are in 
williamr@2
  4170
address order.
williamr@2
  4171
williamr@2
  4172
@param anEntry The object pointer to be inserted.
williamr@2
  4173
williamr@2
  4174
@return KErrNone, if the insertion is successful;
williamr@2
  4175
        KErrAlreadyExists, if an attempt is being made
williamr@2
  4176
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  4177
        error codes.
williamr@2
  4178
*/
williamr@2
  4179
	{ return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,EFalse); }
williamr@2
  4180
williamr@2
  4181
williamr@2
  4182
williamr@2
  4183
williamr@2
  4184
template <class T>
williamr@2
  4185
inline TInt RPointerArray<T>::InsertInOrder(const T* anEntry, TLinearOrder<T> anOrder)
williamr@2
  4186
/**
williamr@2
  4187
Inserts an object pointer into the array so that the object itself is in object 
williamr@2
  4188
order.
williamr@2
  4189
williamr@2
  4190
The algorithm for determining the order of two class T objects is provided 
williamr@2
  4191
by a function supplied by the caller.
williamr@2
  4192
williamr@2
  4193
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  4194
an attempt to insert a duplicate entry.
williamr@2
  4195
williamr@2
  4196
The function assumes that the array is ordered so that the referenced objects 
williamr@2
  4197
are in object order.
williamr@2
  4198
williamr@2
  4199
@param anEntry The object pointer to be inserted.
williamr@2
  4200
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  4201
               of two class T objects.
williamr@2
  4202
williamr@2
  4203
@return KErrNone, if the insertion is successful;
williamr@2
  4204
        KErrAlreadyExists, if an attempt is being made
williamr@2
  4205
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  4206
        error codes.
williamr@2
  4207
*/
williamr@2
  4208
	{ return RPointerArrayBase::InsertIsq(anEntry,anOrder,EFalse); }
williamr@2
  4209
williamr@2
  4210
williamr@2
  4211
williamr@2
  4212
williamr@2
  4213
template <class T>
williamr@2
  4214
inline TInt RPointerArray<T>::InsertInAddressOrderAllowRepeats(const T* anEntry)
williamr@2
  4215
/**
williamr@2
  4216
Inserts an object pointer into the array in address order, allowing duplicates.
williamr@2
  4217
williamr@2
  4218
If the new object pointer is a duplicate of an existing object pointer in 
williamr@2
  4219
the array, then the new pointer is inserted after the existing one. If more 
williamr@2
  4220
than one duplicate object pointer already exists in the array, then any new 
williamr@2
  4221
duplicate pointer is inserted after the last one.
williamr@2
  4222
williamr@2
  4223
The function assumes that existing object pointers within the array are in 
williamr@2
  4224
address order.
williamr@2
  4225
williamr@2
  4226
@param anEntry The object pointer to be inserted.
williamr@2
  4227
williamr@2
  4228
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  4229
        wide error codes.
williamr@2
  4230
*/
williamr@2
  4231
	{ return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,ETrue); }
williamr@2
  4232
williamr@2
  4233
williamr@2
  4234
williamr@2
  4235
williamr@2
  4236
template <class T>
williamr@2
  4237
inline TInt RPointerArray<T>::InsertInOrderAllowRepeats(const T* anEntry, TLinearOrder<T> anOrder)
williamr@2
  4238
/**
williamr@2
  4239
Inserts an object pointer into the array so that the object itself is in object 
williamr@2
  4240
order, allowing duplicates
williamr@2
  4241
williamr@2
  4242
The algorithm for determining the order of two class T objects is provided 
williamr@2
  4243
by a function supplied by the caller.
williamr@2
  4244
williamr@2
  4245
If the specified object is a duplicate of an existing object, then the new 
williamr@2
  4246
pointer is inserted after the pointer to the existing object. If more than 
williamr@2
  4247
one duplicate object already exists, then the new pointer is inserted after 
williamr@2
  4248
the pointer to the last one.
williamr@2
  4249
williamr@2
  4250
@param anEntry The object pointer to be inserted. 
williamr@2
  4251
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  4252
               of two class T objects.
williamr@2
  4253
williamr@2
  4254
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  4255
        wide error codes.
williamr@2
  4256
*/
williamr@2
  4257
	{ return RPointerArrayBase::InsertIsq(anEntry,anOrder,ETrue); }
williamr@2
  4258
williamr@2
  4259
williamr@2
  4260
williamr@2
  4261
williamr@2
  4262
#ifndef __KERNEL_MODE__
williamr@2
  4263
template <class T>
williamr@2
  4264
inline RPointerArray<T>::RPointerArray(T** aEntries, TInt aCount)
williamr@2
  4265
	: RPointerArrayBase((TAny **)aEntries, aCount)
williamr@2
  4266
/**
williamr@2
  4267
C++ constructor with a pointer to the first array entry in a pre-existing
williamr@2
  4268
array, and the number of entries in that array.
williamr@2
  4269
williamr@2
  4270
This constructor takes a pointer to a pre-existing set of entries of type 
williamr@2
  4271
pointer to class T, which is owned by another RPointerArray object. Ownership 
williamr@2
  4272
of the set of entries still resides with the original RPointerArray object.
williamr@2
  4273
williamr@2
  4274
@param aEntries A pointer to the first entry of type pointer to class T in 
williamr@2
  4275
                the set of entries belonging to the existing array.
williamr@2
  4276
@param aCount   The number of entries in the existing array. The granularity of
williamr@2
  4277
                this array is set to this value.
williamr@2
  4278
williamr@2
  4279
@panic USER 156, if aCount is not positive.
williamr@2
  4280
*/
williamr@2
  4281
	{}
williamr@2
  4282
williamr@2
  4283
williamr@2
  4284
williamr@2
  4285
williamr@2
  4286
template <class T>
williamr@2
  4287
inline void RPointerArray<T>::GranularCompress()
williamr@2
  4288
/**
williamr@2
  4289
Compresses the array down to a granular boundary.
williamr@2
  4290
williamr@2
  4291
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  4292
for its contained object pointers. Adding new object pointers to the array 
williamr@2
  4293
does not result in a re-allocation of memory until the the total number of 
williamr@2
  4294
pointers reaches a multiple of the granularity.
williamr@2
  4295
*/
williamr@2
  4296
	{RPointerArrayBase::GranularCompress();}
williamr@2
  4297
williamr@2
  4298
williamr@2
  4299
williamr@2
  4300
williamr@2
  4301
template <class T>
williamr@2
  4302
inline TInt RPointerArray<T>::Reserve(TInt aCount)
williamr@2
  4303
/**
williamr@2
  4304
Reserves space for the specified number of elements.
williamr@2
  4305
williamr@2
  4306
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  4307
to hold the number of object pointers specified. Adding new object pointers to the array 
williamr@2
  4308
does not result in a re-allocation of memory until the the total number of 
williamr@2
  4309
pointers exceeds the specified count.
williamr@2
  4310
williamr@2
  4311
@param	aCount	The number of object pointers for which space should be reserved
williamr@2
  4312
@return	KErrNone		If the operation completed successfully
williamr@2
  4313
@return KErrNoMemory	If the requested amount of memory could not be allocated
williamr@2
  4314
*/
williamr@2
  4315
	{ return RPointerArrayBase::DoReserve(aCount); }
williamr@2
  4316
williamr@2
  4317
williamr@2
  4318
williamr@2
  4319
williamr@2
  4320
template <class T>
williamr@2
  4321
inline void RPointerArray<T>::SortIntoAddressOrder()
williamr@2
  4322
/**
williamr@2
  4323
Sorts the object pointers within the array into address order.
williamr@2
  4324
*/
williamr@2
  4325
	{ HeapSortUnsigned(); }
williamr@2
  4326
williamr@2
  4327
williamr@2
  4328
williamr@2
  4329
williamr@2
  4330
template <class T>
williamr@2
  4331
inline void RPointerArray<T>::Sort(TLinearOrder<T> anOrder)
williamr@2
  4332
/**
williamr@2
  4333
Sorts the object pointers within the array. 
williamr@2
  4334
williamr@2
  4335
The sort order of the pointers is based on the order of the referenced objects. 
williamr@2
  4336
The referenced object order is determined by an algorithm supplied by the 
williamr@2
  4337
caller and packaged as a TLinerOrder<T>.
williamr@2
  4338
williamr@2
  4339
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  4340
               of two class T objects.
williamr@2
  4341
*/
williamr@2
  4342
	{ HeapSort(anOrder); }
williamr@2
  4343
williamr@2
  4344
williamr@2
  4345
williamr@2
  4346
williamr@2
  4347
template <class T>
williamr@2
  4348
inline TArray<T*> RPointerArray<T>::Array() const
williamr@2
  4349
/**
williamr@2
  4350
Constructs and returns a generic array.
williamr@2
  4351
williamr@2
  4352
@return A generic array representing this array.
williamr@2
  4353
williamr@2
  4354
@see TArray
williamr@2
  4355
*/
williamr@2
  4356
	{ return TArray<T*>(GetCount,GetElementPtr,(const CBase*)this); }
williamr@2
  4357
#endif
williamr@2
  4358
williamr@2
  4359
williamr@2
  4360
williamr@2
  4361
template <class T>
williamr@2
  4362
void RPointerArray<T>::ResetAndDestroy()
williamr@2
  4363
/**
williamr@2
  4364
Empties the array and deletes the referenced objects.
williamr@2
  4365
williamr@2
  4366
It frees all memory allocated to the array and resets the internal state so 
williamr@2
  4367
that it is ready to be reused. The function also deletes all of the objects 
williamr@2
  4368
whose pointers are contained by the array.
williamr@2
  4369
williamr@2
  4370
This array object can be allowed to go out of scope after a call to this function.
williamr@2
  4371
*/
williamr@2
  4372
	{
williamr@2
  4373
	TInt c=Count();
williamr@2
  4374
	T** pE=(T**)Entries();
williamr@2
  4375
	ZeroCount();
williamr@2
  4376
	TInt i;
williamr@2
  4377
	for (i=0; i<c; i++)
williamr@2
  4378
		{
williamr@2
  4379
		delete *pE;
williamr@2
  4380
		pE++;
williamr@2
  4381
		}
williamr@2
  4382
	Reset();
williamr@2
  4383
	}
williamr@2
  4384
williamr@2
  4385
williamr@2
  4386
williamr@2
  4387
// Specialization for RPointerArray<TAny>
williamr@2
  4388
williamr@2
  4389
/**
williamr@2
  4390
Default C++ constructor.
williamr@2
  4391
williamr@2
  4392
This constructs an array object for an array of TAny pointers with default
williamr@2
  4393
granularity, which is 8.
williamr@2
  4394
*/
williamr@2
  4395
inline RPointerArray<TAny>::RPointerArray()
williamr@2
  4396
	: RPointerArrayBase()
williamr@2
  4397
	{}
williamr@2
  4398
williamr@2
  4399
williamr@2
  4400
williamr@2
  4401
williamr@2
  4402
/**
williamr@2
  4403
C++ constructor with granularity.
williamr@2
  4404
williamr@2
  4405
This constructs an array object for an array of TAny pointers with the specified 
williamr@2
  4406
granularity.
williamr@2
  4407
williamr@2
  4408
@param aGranularity The granularity of the array.
williamr@2
  4409
williamr@2
  4410
@panic USER 127, if aGranularity is not positive, or greater than or equal
williamr@2
  4411
       to 0x10000000.
williamr@2
  4412
*/
williamr@2
  4413
inline RPointerArray<TAny>::RPointerArray(TInt aGranularity)
williamr@2
  4414
	: RPointerArrayBase(aGranularity)
williamr@2
  4415
	{}
williamr@2
  4416
williamr@2
  4417
williamr@2
  4418
williamr@2
  4419
williamr@2
  4420
/**
williamr@2
  4421
C++ constructor with minimum growth step and exponential growth factor.
williamr@2
  4422
williamr@2
  4423
This constructs an array object for an array of TAny pointers with the specified 
williamr@2
  4424
minimum growth step and exponential growth factor.
williamr@2
  4425
williamr@2
  4426
@param aMinGrowBy	The minimum growth step of the array. Must be between 1 and
williamr@2
  4427
					65535 inclusive.
williamr@2
  4428
@param aFactor		The factor by which the array grows, multiplied by 256.
williamr@2
  4429
					For example 512 specifies a factor of 2. Must be between 257
williamr@2
  4430
					and 32767 inclusive.
williamr@2
  4431
williamr@2
  4432
@panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535.
williamr@2
  4433
@panic USER 193, if aFactor<=257 or aFactor>32767.
williamr@2
  4434
*/
williamr@2
  4435
inline RPointerArray<TAny>::RPointerArray(TInt aMinGrowBy, TInt aFactor)
williamr@2
  4436
	: RPointerArrayBase(aMinGrowBy, aFactor)
williamr@2
  4437
	{}
williamr@2
  4438
williamr@2
  4439
williamr@2
  4440
williamr@2
  4441
williamr@2
  4442
inline void RPointerArray<TAny>::Close()
williamr@2
  4443
/**
williamr@2
  4444
Closes the array and frees all memory allocated to it.
williamr@2
  4445
williamr@2
  4446
The function must be called before this array object goes out of scope.
williamr@2
  4447
williamr@2
  4448
Note that the function does not delete the objects whose pointers are contained
williamr@2
  4449
in the array.
williamr@2
  4450
*/
williamr@2
  4451
	{RPointerArrayBase::Close();}
williamr@2
  4452
williamr@2
  4453
williamr@2
  4454
williamr@2
  4455
williamr@2
  4456
inline TInt RPointerArray<TAny>::Count() const
williamr@2
  4457
/**
williamr@2
  4458
Gets the number of pointers in the array.
williamr@2
  4459
williamr@2
  4460
@return The number of pointers in the array.
williamr@2
  4461
*/
williamr@2
  4462
	{ return RPointerArrayBase::Count(); }
williamr@2
  4463
williamr@2
  4464
williamr@2
  4465
williamr@2
  4466
williamr@2
  4467
inline TAny* const& RPointerArray<TAny>::operator[](TInt anIndex) const
williamr@2
  4468
/**
williamr@2
  4469
Gets a reference to the pointer located at the specified 
williamr@2
  4470
position within the array.
williamr@2
  4471
williamr@2
  4472
The compiler chooses this option if the returned reference is used in
williamr@2
  4473
an expression where the reference cannot be modified.
williamr@2
  4474
williamr@2
  4475
@param anIndex The position of the pointer within the array. The
williamr@2
  4476
               position is relative to zero, i.e. zero implies the object
williamr@2
  4477
			   pointer at the beginning of the array.
williamr@2
  4478
williamr@2
  4479
@return A const reference to the pointer at position anIndex within 
williamr@2
  4480
        the array.
williamr@2
  4481
williamr@2
  4482
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  4483
       objects currently in the array.
williamr@2
  4484
*/
williamr@2
  4485
	{return At(anIndex);}
williamr@2
  4486
williamr@2
  4487
williamr@2
  4488
williamr@2
  4489
williamr@2
  4490
inline TAny*& RPointerArray<TAny>::operator[](TInt anIndex)
williamr@2
  4491
/**
williamr@2
  4492
Gets a reference to the pointer located at the specified 
williamr@2
  4493
position within the array.
williamr@2
  4494
williamr@2
  4495
The compiler chooses this option if the returned reference is used in
williamr@2
  4496
an expression where the reference can be modified.
williamr@2
  4497
williamr@2
  4498
@param anIndex The position of the pointer within the array. The
williamr@2
  4499
               position is relative to zero, i.e. zero implies the object
williamr@2
  4500
			   pointer at the beginning of the array.
williamr@2
  4501
williamr@2
  4502
@return A non-const reference to the pointer at position anIndex within 
williamr@2
  4503
        the array.
williamr@2
  4504
williamr@2
  4505
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  4506
       objects currently in the array.
williamr@2
  4507
*/
williamr@2
  4508
	{return At(anIndex);}
williamr@2
  4509
williamr@2
  4510
williamr@2
  4511
williamr@2
  4512
williamr@2
  4513
inline TInt RPointerArray<TAny>::Append(const TAny* anEntry)
williamr@2
  4514
/**
williamr@2
  4515
Appends an pointer onto the array.
williamr@2
  4516
williamr@2
  4517
@param anEntry The pointer to be appended.
williamr@2
  4518
williamr@2
  4519
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  4520
        wide error codes.
williamr@2
  4521
*/
williamr@2
  4522
	{ return RPointerArrayBase::Append(anEntry); }
williamr@2
  4523
williamr@2
  4524
williamr@2
  4525
williamr@2
  4526
williamr@2
  4527
inline TInt RPointerArray<TAny>::Insert(const TAny* anEntry, TInt aPos)
williamr@2
  4528
/**
williamr@2
  4529
Inserts an pointer into the array at the specified position.
williamr@2
  4530
williamr@2
  4531
@param anEntry The pointer to be inserted.
williamr@2
  4532
@param aPos    The position within the array where the pointer is to be 
williamr@2
  4533
               inserted. The position is relative to zero, i.e. zero implies
williamr@2
  4534
			   that a pointer is inserted at the beginning of the array.
williamr@2
  4535
williamr@2
  4536
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  4537
        wide error codes.
williamr@2
  4538
williamr@2
  4539
@panic USER 131, if aPos is negative, or is greater than the number of object
williamr@2
  4540
       pointers currently in the array.
williamr@2
  4541
*/
williamr@2
  4542
	{ return RPointerArrayBase::Insert(anEntry,aPos); }
williamr@2
  4543
williamr@2
  4544
williamr@2
  4545
williamr@2
  4546
williamr@2
  4547
inline void RPointerArray<TAny>::Remove(TInt anIndex)
williamr@2
  4548
/**
williamr@2
  4549
Removes the pointer at the specified position from the array.
williamr@2
  4550
williamr@2
  4551
Note that the function does not delete the object whose pointer is removed.
williamr@2
  4552
williamr@2
  4553
@param anIndex The position within the array from where the pointer 
williamr@2
  4554
               is to be removed. The position is relative to zero, i.e. zero
williamr@2
  4555
			   implies that a pointer at the beginning of the array is to be
williamr@2
  4556
			   removed.
williamr@2
  4557
			   
williamr@2
  4558
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  4559
       objects currently in the array. 
williamr@2
  4560
*/
williamr@2
  4561
	{RPointerArrayBase::Remove(anIndex);}
williamr@2
  4562
williamr@2
  4563
williamr@2
  4564
williamr@2
  4565
williamr@2
  4566
inline void RPointerArray<TAny>::Compress()
williamr@2
  4567
/**
williamr@2
  4568
Compresses the array down to a minimum.
williamr@2
  4569
williamr@2
  4570
After a call to this function, the memory allocated to the array is just
williamr@2
  4571
sufficient for its contained pointers.
williamr@2
  4572
Subsequently adding a new pointer to the array 
williamr@2
  4573
always results in a re-allocation of memory.
williamr@2
  4574
*/
williamr@2
  4575
	{RPointerArrayBase::Compress();}
williamr@2
  4576
williamr@2
  4577
williamr@2
  4578
williamr@2
  4579
williamr@2
  4580
inline void RPointerArray<TAny>::Reset()
williamr@2
  4581
/**
williamr@2
  4582
Empties the array.
williamr@2
  4583
williamr@2
  4584
It frees all memory allocated to the array and resets the internal state so 
williamr@2
  4585
that it is ready to be reused.
williamr@2
  4586
williamr@2
  4587
This array object can be allowed to go out of scope after a call to this
williamr@2
  4588
function.
williamr@2
  4589
williamr@2
  4590
Note that the function does not delete the objects whose pointers are contained
williamr@2
  4591
in the array.
williamr@2
  4592
*/
williamr@2
  4593
	{RPointerArrayBase::Reset();}
williamr@2
  4594
williamr@2
  4595
williamr@2
  4596
williamr@2
  4597
williamr@2
  4598
inline TInt RPointerArray<TAny>::Find(const TAny* anEntry) const
williamr@2
  4599
/**
williamr@2
  4600
Finds the first pointer in the array which matches the specified pointer, using
williamr@2
  4601
a sequential search.
williamr@2
  4602
williamr@2
  4603
Matching is based on the comparison of pointers.
williamr@2
  4604
williamr@2
  4605
The find operation always starts at the low index end of the array. There 
williamr@2
  4606
is no assumption about the order of objects in the array.
williamr@2
  4607
williamr@2
  4608
@param anEntry The pointer to be found.
williamr@2
  4609
@return The index of the first matching pointer within the array.
williamr@2
  4610
        KErrNotFound, if no matching pointer can be found.
williamr@2
  4611
*/
williamr@2
  4612
	{ return RPointerArrayBase::Find(anEntry); }
williamr@2
  4613
williamr@2
  4614
williamr@2
  4615
williamr@2
  4616
williamr@2
  4617
inline TInt RPointerArray<TAny>::FindReverse(const TAny* anEntry) const
williamr@2
  4618
/**
williamr@2
  4619
Finds the last pointer in the array which matches the specified pointer, using
williamr@2
  4620
a sequential search.
williamr@2
  4621
williamr@2
  4622
Matching is based on the comparison of pointers.
williamr@2
  4623
williamr@2
  4624
The find operation always starts at the high index end of the array. There 
williamr@2
  4625
is no assumption about the order of objects in the array.
williamr@2
  4626
williamr@2
  4627
@param anEntry The pointer to be found.
williamr@2
  4628
@return The index of the last matching pointer within the array.
williamr@2
  4629
        KErrNotFound, if no matching pointer can be found.
williamr@2
  4630
*/
williamr@2
  4631
	{ return RPointerArrayBase::FindReverse(anEntry); }
williamr@2
  4632
williamr@2
  4633
williamr@2
  4634
williamr@2
  4635
williamr@2
  4636
inline TInt RPointerArray<TAny>::FindInAddressOrder(const TAny* anEntry) const
williamr@2
  4637
/**
williamr@2
  4638
Finds the pointer in the array that matches the specified object
williamr@2
  4639
pointer, using a binary search technique.
williamr@2
  4640
williamr@2
  4641
The function assumes that pointers in the array are in address order.
williamr@2
  4642
williamr@2
  4643
@param anEntry The pointer to be found.
williamr@2
  4644
williamr@2
  4645
@return The index of the matching pointer within the array or KErrNotFound 
williamr@2
  4646
        if no suitable pointer can be found.
williamr@2
  4647
*/
williamr@2
  4648
	{ return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry); }
williamr@2
  4649
williamr@2
  4650
williamr@2
  4651
williamr@2
  4652
williamr@2
  4653
inline TInt RPointerArray<TAny>::FindInAddressOrder(const TAny* anEntry, TInt& anIndex) const
williamr@2
  4654
/**
williamr@2
  4655
Finds the pointer in the array that matches the specified object
williamr@2
  4656
pointer, using a binary search technique.
williamr@2
  4657
williamr@2
  4658
The function assumes that pointers in the array are in address order.
williamr@2
  4659
williamr@2
  4660
@param anEntry The pointer to be found.
williamr@2
  4661
@param anIndex A TInt supplied by the caller. On return, contains an index
williamr@2
  4662
               value:
williamr@2
  4663
               If the function returns KErrNone, this is the index of the
williamr@2
  4664
			   matching pointer within the array. 
williamr@2
  4665
               If the function returns KErrNotFound, this is the index of the
williamr@2
  4666
			   last pointer within the array which logically
williamr@2
  4667
			   precedes anEntry.
williamr@2
  4668
williamr@2
  4669
@return KErrNone, if a matching pointer is found.
williamr@2
  4670
        KErrNotFound, if no suitable pointer can be found.
williamr@2
  4671
*/
williamr@2
  4672
	{ return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex); }
williamr@2
  4673
williamr@2
  4674
williamr@2
  4675
williamr@2
  4676
williamr@2
  4677
inline TInt RPointerArray<TAny>::SpecificFindInAddressOrder(const TAny* anEntry, TInt aMode) const
williamr@2
  4678
/**
williamr@2
  4679
Finds the pointer in the array that matches the specified pointer, using a
williamr@2
  4680
binary search technique.
williamr@2
  4681
williamr@2
  4682
Where there is more than one matching element, it finds the first, the last 
williamr@2
  4683
or any matching element as specified by the value of aMode.
williamr@2
  4684
williamr@2
  4685
The function assumes that pointers in the array are in address order.
williamr@2
  4686
williamr@2
  4687
@param	anEntry The pointer to be found.
williamr@2
  4688
@param	aMode   Specifies whether to find the first match, the last match or
williamr@2
  4689
                any match, as defined by one of the TArrayFindMode enum values.
williamr@2
  4690
williamr@2
  4691
@return KErrNotFound, if there is no matching element, otherwise the array
williamr@2
  4692
        index of a matching element - what the index refers to depends on the
williamr@2
  4693
        value of aMode:
williamr@2
  4694
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  4695
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  4696
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  4697
        the last matching element - if the last matching element is also the last element of
williamr@2
  4698
        the array, then the index value is the same as the total number of elements in the array.
williamr@2
  4699
        
williamr@2
  4700
@see TArrayFindMode
williamr@2
  4701
*/
williamr@2
  4702
	{ return RPointerArrayBase::FindIsqUnsigned((TUint)anEntry, aMode); }
williamr@2
  4703
williamr@2
  4704
williamr@2
  4705
williamr@2
  4706
williamr@2
  4707
inline TInt RPointerArray<TAny>::SpecificFindInAddressOrder(const TAny* anEntry, TInt& anIndex, TInt aMode) const
williamr@2
  4708
/**
williamr@2
  4709
Finds the pointer in the array that matches the specified pointer, using a
williamr@2
  4710
binary search technique.
williamr@2
  4711
williamr@2
  4712
Where there is more than one matching element, it finds the first, the last
williamr@2
  4713
or any matching element as specified by the value of aMode.
williamr@2
  4714
williamr@2
  4715
The function assumes that pointers in the array are in address order.
williamr@2
  4716
williamr@2
  4717
@param anEntry The pointer to be found.
williamr@2
  4718
@param anIndex A TInt type supplied by the caller. On return, it contains an
williamr@2
  4719
               index value depending on whether a match is found and on the
williamr@2
  4720
               value of aMode.
williamr@2
  4721
               If there is no matching element in the array, then this is
williamr@2
  4722
               the index of the first element in the array that is bigger than
williamr@2
  4723
               the element being searched for - if no elements in the array are
williamr@2
  4724
               bigger, then the index value is the same as the total number of
williamr@2
  4725
               elements in the array. If there is a matching element, then what
williamr@2
  4726
               the index refers to depends on the value of aMode:
williamr@2
  4727
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  4728
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  4729
               if this is EArrayFindMode_Last, then the index refers to first element that follows the
williamr@2
  4730
               last matching element - if the last matching element is also the last element of the array,
williamr@2
  4731
               then the index value is the same as the total number of elements in the array.
williamr@2
  4732
               
williamr@2
  4733
@param	aMode  Specifies whether to find the first match, the last match or any
williamr@2
  4734
               match, as defined by one of the TArrayFindMode enum values.
williamr@2
  4735
williamr@2
  4736
@return KErrNone, if a matching pointer is found.
williamr@2
  4737
        KErrNotFound, if no suitable pointer can be found.
williamr@2
  4738
        
williamr@2
  4739
@see TArrayFindMode
williamr@2
  4740
*/
williamr@2
  4741
	{ return RPointerArrayBase::BinarySearchUnsigned((TUint)anEntry,anIndex,aMode); }
williamr@2
  4742
williamr@2
  4743
williamr@2
  4744
williamr@2
  4745
williamr@2
  4746
inline TInt RPointerArray<TAny>::InsertInAddressOrder(const TAny* anEntry)
williamr@2
  4747
/**
williamr@2
  4748
Inserts an pointer into the array in address order.
williamr@2
  4749
williamr@2
  4750
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  4751
an attempt to insert a duplicate entry.
williamr@2
  4752
williamr@2
  4753
The function assumes that existing pointers within the array are in 
williamr@2
  4754
address order.
williamr@2
  4755
williamr@2
  4756
@param anEntry The pointer to be inserted.
williamr@2
  4757
williamr@2
  4758
@return KErrNone, if the insertion is successful;
williamr@2
  4759
        KErrAlreadyExists, if an attempt is being made
williamr@2
  4760
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  4761
        error codes.
williamr@2
  4762
*/
williamr@2
  4763
	{ return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,EFalse); }
williamr@2
  4764
williamr@2
  4765
williamr@2
  4766
williamr@2
  4767
williamr@2
  4768
inline TInt RPointerArray<TAny>::InsertInAddressOrderAllowRepeats(const TAny* anEntry)
williamr@2
  4769
/**
williamr@2
  4770
Inserts an pointer into the array in address order, allowing duplicates.
williamr@2
  4771
williamr@2
  4772
If the new pointer is a duplicate of an existing pointer in 
williamr@2
  4773
the array, then the new pointer is inserted after the existing one. If more 
williamr@2
  4774
than one duplicate pointer already exists in the array, then any new 
williamr@2
  4775
duplicate pointer is inserted after the last one.
williamr@2
  4776
williamr@2
  4777
The function assumes that existing pointers within the array are in 
williamr@2
  4778
address order.
williamr@2
  4779
williamr@2
  4780
@param anEntry The pointer to be inserted.
williamr@2
  4781
williamr@2
  4782
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  4783
        wide error codes.
williamr@2
  4784
*/
williamr@2
  4785
	{ return RPointerArrayBase::InsertIsqUnsigned((TUint)anEntry,ETrue); }
williamr@2
  4786
williamr@2
  4787
williamr@2
  4788
williamr@2
  4789
williamr@2
  4790
#ifndef __KERNEL_MODE__
williamr@2
  4791
inline RPointerArray<TAny>::RPointerArray(TAny** aEntries, TInt aCount)
williamr@2
  4792
	: RPointerArrayBase((TAny **)aEntries, aCount)
williamr@2
  4793
/**
williamr@2
  4794
C++ constructor with a pointer to the first array entry in a pre-existing
williamr@2
  4795
array, and the number of entries in that array.
williamr@2
  4796
williamr@2
  4797
This constructor takes a pointer to a pre-existing set of entries of type TAny*,
williamr@2
  4798
which is owned by another RPointerArray object. Ownership of the set of entries
williamr@2
  4799
still resides with the original RPointerArray object.
williamr@2
  4800
williamr@2
  4801
@param aEntries A pointer to the first entry of type TAny* in the set of entries
williamr@2
  4802
                belonging to the existing array.                
williamr@2
  4803
@param aCount   The number of entries in the existing array. The granularity of
williamr@2
  4804
                this array is set to this value.
williamr@2
  4805
williamr@2
  4806
@panic USER 156, if aCount is not positive.
williamr@2
  4807
*/
williamr@2
  4808
	{}
williamr@2
  4809
williamr@2
  4810
williamr@2
  4811
williamr@2
  4812
williamr@2
  4813
inline void RPointerArray<TAny>::GranularCompress()
williamr@2
  4814
/**
williamr@2
  4815
Compresses the array down to a granular boundary.
williamr@2
  4816
williamr@2
  4817
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  4818
for its contained pointers. Adding new pointers to the array 
williamr@2
  4819
does not result in a re-allocation of memory until the the total number of 
williamr@2
  4820
pointers reaches a multiple of the granularity.
williamr@2
  4821
*/
williamr@2
  4822
	{RPointerArrayBase::GranularCompress();}
williamr@2
  4823
williamr@2
  4824
williamr@2
  4825
williamr@2
  4826
williamr@2
  4827
inline void RPointerArray<TAny>::SortIntoAddressOrder()
williamr@2
  4828
/**
williamr@2
  4829
Sorts the pointers within the array into address order.
williamr@2
  4830
*/
williamr@2
  4831
	{ HeapSortUnsigned(); }
williamr@2
  4832
williamr@2
  4833
williamr@2
  4834
williamr@2
  4835
williamr@2
  4836
inline TArray<TAny*> RPointerArray<TAny>::Array() const
williamr@2
  4837
/**
williamr@2
  4838
Constructs and returns a generic array.
williamr@2
  4839
williamr@2
  4840
@return A generic array representing this array.
williamr@2
  4841
williamr@2
  4842
@see TArray
williamr@2
  4843
*/
williamr@2
  4844
	{ return TArray<TAny*>(GetCount,GetElementPtr,(const CBase*)this); }
williamr@2
  4845
#endif
williamr@2
  4846
williamr@2
  4847
williamr@2
  4848
williamr@2
  4849
template <class T>
williamr@2
  4850
inline RArray<T>::RArray()
williamr@2
  4851
	: RArrayBase(sizeof(T))
williamr@2
  4852
/** 
williamr@2
  4853
Default C++ constructor. 
williamr@2
  4854
williamr@2
  4855
This constructs an array object for an array of type class T objects with 
williamr@2
  4856
default granularity and key offset value. The default granularity is 8 and 
williamr@2
  4857
the defaul key offset value is zero.
williamr@2
  4858
williamr@2
  4859
@panic USER 129, if the size of class T is not positive or is not less
williamr@2
  4860
       than 640.
williamr@2
  4861
*/
williamr@2
  4862
	{}
williamr@2
  4863
williamr@2
  4864
williamr@2
  4865
williamr@2
  4866
williamr@2
  4867
template <class T>
williamr@2
  4868
inline RArray<T>::RArray(TInt aGranularity)
williamr@2
  4869
	: RArrayBase(sizeof(T),aGranularity)
williamr@2
  4870
/**
williamr@2
  4871
C++ constructor with granularity. 
williamr@2
  4872
williamr@2
  4873
This constructs an array object for an array of type class T objects with 
williamr@2
  4874
a specified granularity and default key offset value. The default key offset 
williamr@2
  4875
value is zero.
williamr@2
  4876
williamr@2
  4877
@param aGranularity The granularity of the array.
williamr@2
  4878
williamr@2
  4879
@panic USER 129, if the size of class T is not positive or is not less
williamr@2
  4880
       than 640.
williamr@2
  4881
@panic USER 127, if aGranularity is not positive or the product of this
williamr@2
  4882
       value and the size of class T is not less than 0x10000000.
williamr@2
  4883
*/
williamr@2
  4884
	{}
williamr@2
  4885
williamr@2
  4886
williamr@2
  4887
williamr@2
  4888
williamr@2
  4889
template <class T>
williamr@2
  4890
inline RArray<T>::RArray(TInt aGranularity, TInt aKeyOffset)
williamr@2
  4891
	: RArrayBase(sizeof(T),aGranularity,aKeyOffset)
williamr@2
  4892
/**
williamr@2
  4893
C++ constructor with granularity and key offset.
williamr@2
  4894
williamr@2
  4895
This constructs an array object for an array of type class T objects with 
williamr@2
  4896
a specified granularity and a specified key offset value.
williamr@2
  4897
williamr@2
  4898
@param aGranularity The granularity of the array.
williamr@2
  4899
@param aKeyOffset   The key offset.
williamr@2
  4900
williamr@2
  4901
@panic USER 129, if the size of class T is not positive or is not less
williamr@2
  4902
       than 640.
williamr@2
  4903
@panic USER 127, if aGranularity is not positive or the product of this
williamr@2
  4904
       value and the size of class T is not less than 0x10000000.
williamr@2
  4905
@panic USER 128, if aKeyOffset is not positive, or is not less than the 
williamr@2
  4906
       size of class T, or is not a multiple of 4.
williamr@2
  4907
*/
williamr@2
  4908
	{}
williamr@2
  4909
williamr@2
  4910
williamr@2
  4911
williamr@2
  4912
williamr@2
  4913
/**
williamr@2
  4914
C++ constructor with minimum growth step and exponential growth factor.
williamr@2
  4915
williamr@2
  4916
This constructs an array object for an array of class T objects with the
williamr@2
  4917
specified minimum growth step and exponential growth factor.
williamr@2
  4918
williamr@2
  4919
@param aMinGrowBy	The minimum growth step of the array. Must be between 1 and
williamr@2
  4920
					65535 inclusive.
williamr@2
  4921
@param aKeyOffset   The key offset.
williamr@2
  4922
@param aFactor		The factor by which the array grows, multiplied by 256.
williamr@2
  4923
					For example 512 specifies a factor of 2. Must be between 257
williamr@2
  4924
					and 32767 inclusive.
williamr@2
  4925
williamr@2
  4926
@panic USER 129, if the size of class T is not positive or is not less than 640.
williamr@2
  4927
@panic USER 128, if aKeyOffset is negative, or is not less than the 
williamr@2
  4928
       size of class T, or is not a multiple of 4.
williamr@2
  4929
@panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535.
williamr@2
  4930
@panic USER 193, if aFactor<=257 or aFactor>32767.
williamr@2
  4931
*/
williamr@2
  4932
template <class T>
williamr@2
  4933
inline RArray<T>::RArray(TInt aMinGrowBy, TInt aKeyOffset, TInt aFactor)
williamr@2
  4934
	: RArrayBase(sizeof(T), aMinGrowBy, aKeyOffset, aFactor)
williamr@2
  4935
	{}
williamr@2
  4936
williamr@2
  4937
williamr@2
  4938
williamr@2
  4939
williamr@2
  4940
template <class T>
williamr@2
  4941
inline RArray<T>::RArray(TInt aEntrySize,T* aEntries, TInt aCount)
williamr@2
  4942
	: RArrayBase(aEntrySize,aEntries,aCount)
williamr@2
  4943
/**
williamr@2
  4944
C++ constructor with size of entry, a pointer to the first array entry in a 
williamr@2
  4945
pre-existing array, and the number of entries in that array.
williamr@2
  4946
williamr@2
  4947
This constructor takes a pointer to a pre-existing set of entries of type 
williamr@2
  4948
class T objects owned by another RArray object. Ownership of the set of entries 
williamr@2
  4949
still resides with the original RArray object.
williamr@2
  4950
williamr@2
  4951
This array is assigned a default granularity and key offset value. The default 
williamr@2
  4952
granularity is 8 and the default key offset value is zero.
williamr@2
  4953
williamr@2
  4954
The purpose of constructing an array in this way is to allow sorting and
williamr@2
  4955
finding operations to be done without further allocation of memory.
williamr@2
  4956
williamr@2
  4957
@param aEntrySize The size of an entry in the existing array. 
williamr@2
  4958
@param aEntries   A pointer to the first entry of type class T in the set of 
williamr@2
  4959
                  entries belonging to the existing array.
williamr@2
  4960
@param aCount     The number of entries in the existing array.
williamr@2
  4961
 
williamr@2
  4962
@panic USER 129, if aEntrySize is not positive or is not less than 640.
williamr@2
  4963
@panic USER 156, if aCount is not positive.
williamr@2
  4964
*/
williamr@2
  4965
	{}
williamr@2
  4966
williamr@2
  4967
williamr@2
  4968
williamr@2
  4969
williamr@2
  4970
template <class T>
williamr@2
  4971
inline void RArray<T>::Close()
williamr@2
  4972
/**
williamr@2
  4973
Closes the array and frees all memory allocated to the array. 
williamr@2
  4974
williamr@2
  4975
The function must be called before this array object is destroyed.
williamr@2
  4976
*/
williamr@2
  4977
	{RArrayBase::Close();}
williamr@2
  4978
williamr@2
  4979
williamr@2
  4980
williamr@2
  4981
williamr@2
  4982
template <class T>
williamr@2
  4983
inline TInt RArray<T>::Count() const
williamr@2
  4984
/**
williamr@2
  4985
Gets the number of objects in the array.
williamr@2
  4986
williamr@2
  4987
@return The number of objects in the array.
williamr@2
  4988
*/
williamr@2
  4989
	{return RArrayBase::Count();}
williamr@2
  4990
williamr@2
  4991
williamr@2
  4992
williamr@2
  4993
williamr@2
  4994
template <class T>
williamr@2
  4995
inline const T& RArray<T>::operator[](TInt anIndex) const
williamr@2
  4996
/**
williamr@2
  4997
Gets a reference to an object located at a specified position within the array.
williamr@2
  4998
williamr@2
  4999
The compiler chooses this function if the returned reference is used in an 
williamr@2
  5000
expression where the reference cannot be modified.
williamr@2
  5001
williamr@2
  5002
@param anIndex The position of the object within the array. The position is 
williamr@2
  5003
               relative to zero, i.e. zero implies the object at the beginning
williamr@2
  5004
			   of the array. 
williamr@2
  5005
williamr@2
  5006
@return A const reference to the object at position anIndex within the array.
williamr@2
  5007
williamr@2
  5008
@panic USER 130, if anIndex is negative or is greater than the number of 
williamr@2
  5009
       objects currently in the array
williamr@2
  5010
*/
williamr@2
  5011
	{return *(const T*)At(anIndex); }
williamr@2
  5012
williamr@2
  5013
williamr@2
  5014
williamr@2
  5015
williamr@2
  5016
template <class T>
williamr@2
  5017
inline T& RArray<T>::operator[](TInt anIndex)
williamr@2
  5018
/**
williamr@2
  5019
Gets a reference to an object located at a specified position within the array.
williamr@2
  5020
williamr@2
  5021
The compiler chooses this function if the returned reference is used in an 
williamr@2
  5022
expression where the reference can be modified.
williamr@2
  5023
williamr@2
  5024
@param anIndex The position of the object within the array. The position is 
williamr@2
  5025
               relative to zero, i.e. zero implies the object at the beginning
williamr@2
  5026
			   of the array. 
williamr@2
  5027
williamr@2
  5028
@return A non-const reference to the object at position anIndex within the array.
williamr@2
  5029
williamr@2
  5030
@panic USER 130, if anIndex is negative or is greater than the number of 
williamr@2
  5031
       objects currently in the array
williamr@2
  5032
*/
williamr@2
  5033
	{return *(T*)At(anIndex); }
williamr@2
  5034
williamr@2
  5035
williamr@2
  5036
williamr@2
  5037
williamr@2
  5038
template <class T>
williamr@2
  5039
inline TInt RArray<T>::Append(const T& anEntry)
williamr@2
  5040
/**
williamr@2
  5041
Apends an object onto the array.
williamr@2
  5042
williamr@2
  5043
@param anEntry    A reference to the object of type class T to be appended.
williamr@2
  5044
williamr@2
  5045
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5046
        wide error codes.
williamr@2
  5047
*/
williamr@2
  5048
	{return RArrayBase::Append(&anEntry);}
williamr@2
  5049
williamr@2
  5050
williamr@2
  5051
williamr@2
  5052
williamr@2
  5053
template <class T>
williamr@2
  5054
inline TInt RArray<T>::Insert(const T& anEntry, TInt aPos)
williamr@2
  5055
/**
williamr@2
  5056
Inserts an object into the array at a specified position.
williamr@2
  5057
williamr@2
  5058
@param anEntry The class T object to be inserted.
williamr@2
  5059
@param aPos    The position within the array where the object is to
williamr@2
  5060
               be inserted. The position is relative to zero, i.e. zero
williamr@2
  5061
			   implies that an object is inserted at the beginning of
williamr@2
  5062
			   the array.
williamr@2
  5063
			   
williamr@2
  5064
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5065
        wide error codes.
williamr@2
  5066
williamr@2
  5067
@panic USER 131, if aPos is negative or is greater than the number of objects
williamr@2
  5068
       currently in the array.
williamr@2
  5069
*/
williamr@2
  5070
	{return RArrayBase::Insert(&anEntry,aPos);}
williamr@2
  5071
williamr@2
  5072
williamr@2
  5073
williamr@2
  5074
williamr@2
  5075
template <class T>
williamr@2
  5076
inline void RArray<T>::Remove(TInt anIndex)
williamr@2
  5077
/**
williamr@2
  5078
Removes the object at a specified position from the array.
williamr@2
  5079
williamr@2
  5080
@param anIndex The position within the array from where the object is to be 
williamr@2
  5081
               removed. The position is relative to zero, i.e. zero implies
williamr@2
  5082
			   that an object at the beginning of the array is to be removed.
williamr@2
  5083
	
williamr@2
  5084
@panic USER 130, if anIndex is negative or is greater than the number of
williamr@2
  5085
       objects currently in the array.
williamr@2
  5086
*/
williamr@2
  5087
	{RArrayBase::Remove(anIndex);}
williamr@2
  5088
williamr@2
  5089
williamr@2
  5090
williamr@2
  5091
williamr@2
  5092
template <class T>
williamr@2
  5093
inline void RArray<T>::Compress()
williamr@2
  5094
/** 
williamr@2
  5095
Compresses the array down to a minimum.
williamr@2
  5096
williamr@2
  5097
After a call to this function, the memory allocated to the array is just
williamr@2
  5098
sufficient for its contained objects. Subsequently adding a new object to the
williamr@2
  5099
array always results in a re-allocation of memory.
williamr@2
  5100
*/
williamr@2
  5101
	{RArrayBase::Compress();}
williamr@2
  5102
williamr@2
  5103
williamr@2
  5104
williamr@2
  5105
williamr@2
  5106
template <class T>
williamr@2
  5107
inline void RArray<T>::Reset()
williamr@2
  5108
/**
williamr@2
  5109
Empties the array, so that it is ready to be reused.
williamr@2
  5110
williamr@2
  5111
The function frees all memory allocated to the array and resets the internal 
williamr@2
  5112
state so that it is ready to be reused.
williamr@2
  5113
williamr@2
  5114
This array object can be allowed to go out of scope after a call to this function.
williamr@2
  5115
*/
williamr@2
  5116
	{RArrayBase::Reset();}
williamr@2
  5117
williamr@2
  5118
williamr@2
  5119
williamr@2
  5120
williamr@2
  5121
template <class T>
williamr@2
  5122
inline TInt RArray<T>::Find(const T& anEntry) const
williamr@2
  5123
/**
williamr@2
  5124
Finds the first object in the array which matches the specified object using 
williamr@2
  5125
a sequential search.
williamr@2
  5126
williamr@2
  5127
Matching is based on the comparison of a TInt value at the key offset position 
williamr@2
  5128
within the objects.
williamr@2
  5129
williamr@4
  5130
For classes which define their own equality operator (==), the alternative method
williamr@4
  5131
Find(const T& anEntry, TIdentityRelation<T> anIdentity) is recommended.
williamr@4
  5132
williamr@2
  5133
The find operation always starts at the low index end of the array. There 
williamr@2
  5134
is no assumption about the order of objects in the array.
williamr@2
  5135
williamr@2
  5136
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5137
williamr@2
  5138
@return The index of the first matching object within the array. 
williamr@2
  5139
        KErrNotFound, if no matching object can be found.
williamr@2
  5140
*/
williamr@2
  5141
	{return RArrayBase::Find(&anEntry);}
williamr@2
  5142
williamr@2
  5143
williamr@2
  5144
williamr@2
  5145
williamr@2
  5146
template <class T>
williamr@2
  5147
inline TInt RArray<T>::Find(const T& anEntry, TIdentityRelation<T> anIdentity) const
williamr@2
  5148
/**
williamr@2
  5149
Finds the first object in the array which matches the specified object using 
williamr@2
  5150
a sequential search and a matching algorithm.
williamr@2
  5151
williamr@2
  5152
The algorithm for determining whether two class T type objects match is provided 
williamr@2
  5153
by a function supplied by the caller.
williamr@2
  5154
williamr@4
  5155
Such a function need not be supplied if an equality operator (==) is defined for class T. 
williamr@4
  5156
In this case, default construction of anIdentity provides matching, as in the example below:
williamr@4
  5157
williamr@4
  5158
@code
williamr@4
  5159
//Construct a TPoint and append to an RArray<TPoint>
williamr@4
  5160
TPoint p1(0,0);
williamr@4
  5161
RArray<TPoint> points;
williamr@4
  5162
points.AppendL(p1);
williamr@4
  5163
//Find position of p1 in points using TIdentityRelation<TPoint> default construction
williamr@4
  5164
TInt r = points.Find(p1, TIdentityRelation<TPoint>());
williamr@4
  5165
@endcode
williamr@4
  5166
williamr@2
  5167
The find operation always starts at the low index end of the array. There 
williamr@2
  5168
is no assumption about the order of objects in the array.
williamr@2
  5169
williamr@2
  5170
@param anEntry    A reference to an object of type class T to be used
williamr@2
  5171
                  for matching.
williamr@2
  5172
@param anIdentity A package encapsulating the function which determines whether 
williamr@2
  5173
                  two class T type objects match.
williamr@2
  5174
williamr@2
  5175
@return The index of the first matching object within the array.
williamr@2
  5176
        KErrNotFound, if no matching object can be found.
williamr@2
  5177
*/
williamr@2
  5178
	{return RArrayBase::Find(&anEntry,anIdentity);}
williamr@2
  5179
williamr@2
  5180
williamr@2
  5181
williamr@2
  5182
williamr@2
  5183
template <class T>
williamr@2
  5184
inline TInt RArray<T>::FindReverse(const T& anEntry) const
williamr@2
  5185
/**
williamr@2
  5186
Finds the last object in the array which matches the specified object using 
williamr@2
  5187
a sequential search.
williamr@2
  5188
williamr@2
  5189
Matching is based on the comparison of a TInt value at the key offset position 
williamr@2
  5190
within the objects.
williamr@2
  5191
williamr@4
  5192
For classes which define their own equality operator (==), the alternative method
williamr@4
  5193
FindReverse(const T& anEntry, TIdentityRelation<T> anIdentity) is recommended.
williamr@4
  5194
williamr@2
  5195
The find operation always starts at the high index end of the array. There 
williamr@2
  5196
is no assumption about the order of objects in the array.
williamr@2
  5197
williamr@2
  5198
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5199
williamr@2
  5200
@return The index of the last matching object within the array. 
williamr@2
  5201
        KErrNotFound, if no matching object can be found.
williamr@2
  5202
*/
williamr@2
  5203
	{return RArrayBase::FindReverse(&anEntry);}
williamr@2
  5204
williamr@2
  5205
williamr@2
  5206
williamr@2
  5207
williamr@2
  5208
template <class T>
williamr@2
  5209
inline TInt RArray<T>::FindReverse(const T& anEntry, TIdentityRelation<T> anIdentity) const
williamr@2
  5210
/**
williamr@2
  5211
Finds the last object in the array which matches the specified object using 
williamr@2
  5212
a sequential search and a matching algorithm.
williamr@2
  5213
williamr@2
  5214
The algorithm for determining whether two class T type objects match is provided 
williamr@2
  5215
by a function supplied by the caller.
williamr@2
  5216
williamr@4
  5217
Such a function need not be supplied if an equality operator (==) is defined for class T. 
williamr@4
  5218
In this case, default construction of anIdentity provides matching.
williamr@4
  5219
williamr@4
  5220
See Find(const T& anEntry, TIdentityRelation<T> anIdentity) for more details.
williamr@4
  5221
williamr@2
  5222
The find operation always starts at the high index end of the array. There 
williamr@2
  5223
is no assumption about the order of objects in the array.
williamr@2
  5224
williamr@2
  5225
@param anEntry    A reference to an object of type class T to be used
williamr@2
  5226
                  for matching.
williamr@2
  5227
@param anIdentity A package encapsulating the function which determines whether 
williamr@2
  5228
                  two class T type objects match.
williamr@2
  5229
williamr@2
  5230
@return The index of the last matching object within the array.
williamr@2
  5231
        KErrNotFound, if no matching object can be found.
williamr@2
  5232
*/
williamr@2
  5233
	{return RArrayBase::FindReverse(&anEntry,anIdentity);}
williamr@2
  5234
williamr@2
  5235
williamr@2
  5236
williamr@2
  5237
williamr@2
  5238
template <class T>
williamr@2
  5239
inline TInt RArray<T>::FindInSignedKeyOrder(const T& anEntry) const
williamr@2
  5240
/**
williamr@2
  5241
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5242
search technique.
williamr@2
  5243
williamr@2
  5244
The function assumes that existing objects within the array are in signed 
williamr@2
  5245
key order.
williamr@2
  5246
williamr@2
  5247
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5248
williamr@2
  5249
@return The index of the matching object within the array, or KErrNotFound 
williamr@2
  5250
        if no matching object can be found.
williamr@2
  5251
*/
williamr@2
  5252
	{return RArrayBase::FindIsqSigned(&anEntry);}
williamr@2
  5253
williamr@2
  5254
williamr@2
  5255
williamr@2
  5256
williamr@2
  5257
template <class T>
williamr@2
  5258
inline TInt RArray<T>::FindInUnsignedKeyOrder(const T& anEntry) const
williamr@2
  5259
/**
williamr@2
  5260
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5261
search technique.
williamr@2
  5262
williamr@2
  5263
The function assumes that existing objects within the array are in unsigned 
williamr@2
  5264
key order.
williamr@2
  5265
williamr@2
  5266
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5267
williamr@2
  5268
@return The index of the matching object within the array, or KErrNotFound 
williamr@2
  5269
        if no matching object can be found.
williamr@2
  5270
*/
williamr@2
  5271
	{return RArrayBase::FindIsqUnsigned(&anEntry);}
williamr@2
  5272
williamr@2
  5273
williamr@2
  5274
williamr@2
  5275
williamr@2
  5276
template <class T>
williamr@2
  5277
inline TInt RArray<T>::FindInOrder(const T& anEntry, TLinearOrder<T> anOrder) const
williamr@2
  5278
/**
williamr@2
  5279
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5280
search technique and an ordering algorithm.
williamr@2
  5281
williamr@2
  5282
The function assumes that existing objects within the array are in object 
williamr@2
  5283
order as determined by an algorithm supplied by the caller and packaged as 
williamr@2
  5284
a TLinearOrder<T>.
williamr@2
  5285
williamr@2
  5286
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5287
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5288
               of two class T objects.
williamr@2
  5289
williamr@2
  5290
@return The index of the matching object within the array, or KErrNotFound if 
williamr@2
  5291
        no matching object can be found.
williamr@2
  5292
*/
williamr@2
  5293
	{return RArrayBase::FindIsq(&anEntry,anOrder);}
williamr@2
  5294
williamr@2
  5295
williamr@2
  5296
williamr@2
  5297
williamr@2
  5298
template <class T>
williamr@2
  5299
inline TInt RArray<T>::FindInSignedKeyOrder(const T& anEntry, TInt& anIndex) const
williamr@2
  5300
/**
williamr@2
  5301
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5302
search technique.
williamr@2
  5303
williamr@2
  5304
The function assumes that existing objects within the array are in signed 
williamr@2
  5305
key order.
williamr@2
  5306
williamr@2
  5307
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5308
@param anIndex On return contains an index value. If the function returns KErrNone,
williamr@2
  5309
               this is the index of the matching object within the array.
williamr@2
  5310
               If the function returns KErrNotFound, this is the index of the
williamr@2
  5311
               first element in the array whose key is bigger than the key of the
williamr@2
  5312
               element being sought. If there are no elements in the array with
williamr@2
  5313
               a bigger key, then the index value is the same as the total 
williamr@2
  5314
               number of elements in the array.
williamr@2
  5315
@return KErrNone if a matching object is found, or KErrNotFound if no matching 
williamr@2
  5316
        object can be found.
williamr@2
  5317
*/
williamr@2
  5318
	{return RArrayBase::BinarySearchSigned(&anEntry,anIndex);}
williamr@2
  5319
williamr@2
  5320
williamr@2
  5321
williamr@2
  5322
williamr@2
  5323
template <class T>
williamr@2
  5324
inline TInt RArray<T>::FindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex) const
williamr@2
  5325
/**
williamr@2
  5326
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5327
search technique.
williamr@2
  5328
williamr@2
  5329
The function assumes that existing objects within the array are in unsigned 
williamr@2
  5330
key order.
williamr@2
  5331
williamr@2
  5332
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5333
@param anIndex On return contains an index value. If the function returns
williamr@2
  5334
               KErrNone, this is the index of the matching object within the
williamr@2
  5335
               array. 
williamr@2
  5336
               If the function returns KErrNotFound, this is the index of the
williamr@2
  5337
               first element in the array whose key is bigger than the key of the
williamr@2
  5338
               element being sought. If there are no elements in the array with
williamr@2
  5339
               a bigger key, then the index value is the same as the total 
williamr@2
  5340
               number of elements in the array.
williamr@2
  5341
@return KErrNone if a matching object is found, or KErrNotFound if no matching 
williamr@2
  5342
        object can be found.
williamr@2
  5343
*/
williamr@2
  5344
	{return RArrayBase::BinarySearchUnsigned(&anEntry,anIndex);}
williamr@2
  5345
williamr@2
  5346
williamr@2
  5347
williamr@2
  5348
williamr@2
  5349
template <class T>
williamr@2
  5350
inline TInt RArray<T>::FindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const
williamr@2
  5351
/**
williamr@2
  5352
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5353
search technique and an ordering algorithm.
williamr@2
  5354
williamr@2
  5355
The function assumes that existing objects within the array are in object 
williamr@2
  5356
order as determined by an algorithm supplied by the caller and packaged as 
williamr@2
  5357
a TLinearOrder<T>.
williamr@2
  5358
williamr@2
  5359
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5360
@param anIndex On return contains an index value. If the function returns
williamr@2
  5361
               KErrNone, this is the index of the matching object within the
williamr@2
  5362
               array.
williamr@2
  5363
               If the function returns KErrNotFound, this is the index of the
williamr@2
  5364
               first element in the array that is bigger than the element being
williamr@2
  5365
               searched for - if no elements in the array are bigger, then
williamr@2
  5366
               the index value is the same as the total number of elements in
williamr@2
  5367
               the array.
williamr@2
  5368
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5369
               of two class T objects.
williamr@2
  5370
williamr@2
  5371
@return KErrNone if a matching object is found. KErrNotFound if no matching 
williamr@2
  5372
        object can be found.
williamr@2
  5373
*/
williamr@2
  5374
	{return RArrayBase::BinarySearch(&anEntry,anIndex,anOrder);}
williamr@2
  5375
williamr@2
  5376
williamr@2
  5377
williamr@2
  5378
williamr@2
  5379
template <class T>
williamr@2
  5380
inline TInt RArray<T>::SpecificFindInSignedKeyOrder(const T& anEntry, TInt aMode) const
williamr@2
  5381
/**
williamr@2
  5382
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5383
search technique.
williamr@2
  5384
williamr@2
  5385
The element ordering is determined by a signed 32-bit word
williamr@2
  5386
(the key) embedded in each array element. In the case that there is more than
williamr@2
  5387
one matching element, finds the first, last or any match as specified by
williamr@2
  5388
the value of aMode.
williamr@2
  5389
williamr@2
  5390
The function assumes that existing objects within the array are in signed 
williamr@2
  5391
key order.
williamr@2
  5392
williamr@2
  5393
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5394
@param	aMode  Specifies whether to find the first match, the last match or
williamr@2
  5395
               any match, as defined by one of the TArrayFindMode enum values.
williamr@2
  5396
               
williamr@2
  5397
@return KErrNotFound, if there is no matching element, otherwise the array
williamr@2
  5398
        index of a matching element -  what the index refers to depends on the
williamr@2
  5399
        value of aMode:
williamr@2
  5400
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  5401
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  5402
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  5403
        the last matching element - if the last matching element is also the last element of
williamr@2
  5404
        the array, then the index value is the same as the total number of elements in the array.
williamr@2
  5405
        
williamr@2
  5406
@see TArrayFindMode        
williamr@2
  5407
*/
williamr@2
  5408
	{return RArrayBase::FindIsqSigned(&anEntry,aMode);}
williamr@2
  5409
williamr@2
  5410
williamr@2
  5411
williamr@2
  5412
williamr@2
  5413
template <class T>
williamr@2
  5414
inline TInt RArray<T>::SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt aMode) const
williamr@2
  5415
/**
williamr@2
  5416
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5417
search technique.
williamr@2
  5418
williamr@2
  5419
The element ordering is determined by an unsigned 32-bit word
williamr@2
  5420
(the key) embedded in each array element. Where there is more than
williamr@2
  5421
one matching element, it finds the first, last or any matching element
williamr@2
  5422
as specified by the value of aMode.
williamr@2
  5423
williamr@2
  5424
The function assumes that existing objects within the array are in unsigned 
williamr@2
  5425
key order.
williamr@2
  5426
williamr@2
  5427
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5428
@param	aMode  Specifies whether to find the first match, the last match or
williamr@2
  5429
               any match, as defined by one of the TArrayFindMode enum values.
williamr@2
  5430
williamr@2
  5431
@return KErrNotFound, if there is no matching element, otherwise the array
williamr@2
  5432
        index of a matching element - what the index refers to depends on the
williamr@2
  5433
        value of aMode:
williamr@2
  5434
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  5435
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  5436
        if this is EArrayFindMode_Last, then the index refers to first element that follows the
williamr@2
  5437
        last matching element - if the last matching element is also the last element of the array,
williamr@2
  5438
        then the index value is the same as the total number of elements in the array.
williamr@2
  5439
        
williamr@2
  5440
@see TArrayFindMode
williamr@2
  5441
*/
williamr@2
  5442
	{return RArrayBase::FindIsqUnsigned(&anEntry,aMode);}
williamr@2
  5443
williamr@2
  5444
williamr@2
  5445
williamr@2
  5446
williamr@2
  5447
template <class T>
williamr@2
  5448
inline TInt RArray<T>::SpecificFindInOrder(const T& anEntry, TLinearOrder<T> anOrder, TInt aMode) const
williamr@2
  5449
/**
williamr@2
  5450
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5451
search technique and an ordering algorithm.
williamr@2
  5452
williamr@2
  5453
Where there is more than one matching element, it finds the first, the last
williamr@2
  5454
or any matching element as specified by the value of aMode.
williamr@2
  5455
williamr@2
  5456
The function assumes that existing objects within the array are in object 
williamr@2
  5457
order as determined by an algorithm supplied by the caller and packaged as 
williamr@2
  5458
a TLinearOrder<T> type.
williamr@2
  5459
williamr@2
  5460
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5461
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5462
               of two class T objects.
williamr@2
  5463
@param	aMode  Specifies whether to find the first match, the last match or any
williamr@2
  5464
               match, as defined by one of the TArrayFindMode enum values.
williamr@2
  5465
williamr@2
  5466
@return KErrNotFound, if there is no matching element, otherwise the array index
williamr@2
  5467
        of a matching element -  what the index refers to depends on the value of
williamr@2
  5468
        aMode:
williamr@2
  5469
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  5470
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  5471
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  5472
        the last matching element - if the last matching element is also the last element of
williamr@2
  5473
        the array, then the index value is the same as the total number of elements in the array.
williamr@2
  5474
*/
williamr@2
  5475
	{return RArrayBase::FindIsq(&anEntry,anOrder,aMode);}
williamr@2
  5476
williamr@2
  5477
williamr@2
  5478
williamr@2
  5479
williamr@2
  5480
template <class T>
williamr@2
  5481
inline TInt RArray<T>::SpecificFindInSignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const
williamr@2
  5482
/**
williamr@2
  5483
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5484
search technique.
williamr@2
  5485
williamr@2
  5486
The element ordering is determined by a signed 32-bit word
williamr@2
  5487
(the key) embedded in each array element. Where there is more than
williamr@2
  5488
one matching element, finds the first, last or any matching element as
williamr@2
  5489
specified specified by the value of aMode.
williamr@2
  5490
williamr@2
  5491
The function assumes that existing objects within the array are in signed 
williamr@2
  5492
key order.
williamr@2
  5493
williamr@2
  5494
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5495
@param anIndex A TInt type supplied by the caller. On return, it contains
williamr@2
  5496
               an index value depending on whether a match is found and on the
williamr@2
  5497
               value of aMode. If there is no matching element in the array,
williamr@2
  5498
               then this is the index of the first element in the array that
williamr@2
  5499
               is bigger than the element being searched for - if no elements
williamr@2
  5500
               in the array are bigger, then the index value is the same as the
williamr@2
  5501
               total number of elements in the array. If there is a matching
williamr@2
  5502
               element, then what the index refers to depends on the value of aMode:
williamr@2
  5503
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  5504
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  5505
               if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  5506
               the last matching element - if the last matching element is also the last element of
williamr@2
  5507
               the array, then the index value is the same as the total number of elements in the array.
williamr@2
  5508
@param	aMode  Specifies whether to find the first match, the last match or any match,
williamr@2
  5509
               as defined by one of the TArrayFindMode enum values.
williamr@2
  5510
               
williamr@2
  5511
@return	KErrNone, if a matching object pointer is found;
williamr@2
  5512
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  5513
*/
williamr@2
  5514
	{return RArrayBase::BinarySearchSigned(&anEntry,anIndex,aMode);}
williamr@2
  5515
williamr@2
  5516
williamr@2
  5517
williamr@2
  5518
williamr@2
  5519
template <class T>
williamr@2
  5520
inline TInt RArray<T>::SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const
williamr@2
  5521
/**
williamr@2
  5522
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5523
search technique.
williamr@2
  5524
williamr@2
  5525
The element ordering is determined by an unsigned 32-bit word
williamr@2
  5526
(the key) embedded in each array element. Where there is more than
williamr@2
  5527
one matching element, it finds the first, last or any matching element as
williamr@2
  5528
specified by the value of aMode.
williamr@2
  5529
williamr@2
  5530
The function assumes that existing objects within the array are in unsigned 
williamr@2
  5531
key order.
williamr@2
  5532
williamr@2
  5533
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5534
@param anIndex A TInt type supplied by the caller. On return, it contains an index
williamr@2
  5535
               value depending on whether a match is found and on the value of aMode.
williamr@2
  5536
               If there is no matching element in the array, then this is the index
williamr@2
  5537
               of the first element in the array that is bigger than the element
williamr@2
  5538
               being searched for - if no elements in the array are bigger, then
williamr@2
  5539
               the index value is the same as the total number of elements in the array.
williamr@2
  5540
               If there is a matching element, then what the index refers to depends on
williamr@2
  5541
               the value of aMode:
williamr@2
  5542
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  5543
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  5544
               if this is EArrayFindMode_Last, then the index refers to first element that follows the
williamr@2
  5545
               last matching element - if the last matching element is also the last element of the array,
williamr@2
  5546
               then the index value is the same as the total number of elements in the array.
williamr@2
  5547
@param	aMode  Specifies whether to find the first match, the last match or any match, as defined by one
williamr@2
  5548
               of the TArrayFindMode enum values.
williamr@2
  5549
@return	KErrNone, if a matching object pointer is found; KErrNotFound, if no suitable object pointer can be found.
williamr@2
  5550
williamr@2
  5551
@see TArrayFindMode
williamr@2
  5552
*/
williamr@2
  5553
	{return RArrayBase::BinarySearchUnsigned(&anEntry,anIndex,aMode);}
williamr@2
  5554
williamr@2
  5555
williamr@2
  5556
williamr@2
  5557
williamr@2
  5558
template <class T>
williamr@2
  5559
inline TInt RArray<T>::SpecificFindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder, TInt aMode) const
williamr@2
  5560
/**
williamr@2
  5561
Finds the object in the array which matches the specified object using a binary 
williamr@2
  5562
search technique and a specified ordering algorithm.
williamr@2
  5563
williamr@2
  5564
Where there is more than one matching element, it finds the first, the last or
williamr@2
  5565
any matching element as specified by the value of aMode.
williamr@2
  5566
williamr@2
  5567
The function assumes that existing objects within the array are in object 
williamr@2
  5568
order as determined by an algorithm supplied by the caller and packaged as 
williamr@2
  5569
a TLinearOrder<T> type.
williamr@2
  5570
williamr@2
  5571
@param anEntry A reference to an object of type class T to be used for matching.
williamr@2
  5572
@param anIndex A TInt type supplied by the caller. On return, it contains
williamr@2
  5573
               an index value depending on whether a match is found and on the
williamr@2
  5574
               value of aMode. If there is no matching element in the array,
williamr@2
  5575
               then this is the index of the first element in the array that
williamr@2
  5576
               is bigger than the element being searched for - if no elements
williamr@2
  5577
               in the array are bigger, then the index value is the same as 
williamr@2
  5578
               the total number of elements in the array.
williamr@2
  5579
               If there is a matching element, then what the index refers to
williamr@2
  5580
               depends on the value of aMode:
williamr@2
  5581
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  5582
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  5583
               if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  5584
               the last matching element - if the last matching element is also
williamr@2
  5585
               the last element of the array, then the index value is the same as
williamr@2
  5586
               the total number of elements in the array.
williamr@2
  5587
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5588
               of two class T objects.
williamr@2
  5589
@param	aMode  Specifies whether to find the first match, the last match or any match,
williamr@2
  5590
               as defined by one of the TArrayFindMode enum values.
williamr@2
  5591
@return	KErrNone, if a matching object pointer is found;
williamr@2
  5592
        KErrNotFound, if no suitable object pointer can be found.
williamr@2
  5593
williamr@2
  5594
*/
williamr@2
  5595
	{return RArrayBase::BinarySearch(&anEntry,anIndex,anOrder,aMode);}
williamr@2
  5596
williamr@2
  5597
williamr@2
  5598
williamr@2
  5599
williamr@2
  5600
template <class T>
williamr@2
  5601
inline TInt RArray<T>::InsertInSignedKeyOrder(const T& anEntry)
williamr@2
  5602
/**
williamr@2
  5603
Inserts an object into the array in ascending signed key order.
williamr@2
  5604
williamr@2
  5605
The order of two class T type objects is based on comparing a TInt value
williamr@2
  5606
located at the key offset position within the class T object.
williamr@2
  5607
williamr@2
  5608
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  5609
an attempt to insert a duplicate entry.
williamr@2
  5610
williamr@2
  5611
@param anEntry A reference to the object of type class T to be inserted.
williamr@2
  5612
williamr@2
  5613
@return KErrNone, if the insertion is successful;
williamr@2
  5614
        KErrAlreadyExists, if an attempt is being made
williamr@2
  5615
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  5616
        error codes.
williamr@2
  5617
*/
williamr@2
  5618
	{return RArrayBase::InsertIsqSigned(&anEntry,EFalse);}
williamr@2
  5619
williamr@2
  5620
williamr@2
  5621
williamr@2
  5622
williamr@2
  5623
template <class T>
williamr@2
  5624
inline TInt RArray<T>::InsertInUnsignedKeyOrder(const T& anEntry)
williamr@2
  5625
/**
williamr@2
  5626
Inserts an object into the array in ascending unsigned key order.
williamr@2
  5627
williamr@2
  5628
The order of two class T type objects is based on comparing a TUint value 
williamr@2
  5629
located at the key offset position within the class T object. 
williamr@2
  5630
williamr@2
  5631
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  5632
an attempt to insert a duplicate entry.
williamr@2
  5633
williamr@2
  5634
@param anEntry A reference to the object of type class T to be inserted.
williamr@2
  5635
williamr@2
  5636
@return KErrNone, if the insertion is successful;
williamr@2
  5637
        KErrAlreadyExists, if an attempt is being made
williamr@2
  5638
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  5639
        error codes.
williamr@2
  5640
*/
williamr@2
  5641
	{return RArrayBase::InsertIsqUnsigned(&anEntry,EFalse);}
williamr@2
  5642
williamr@2
  5643
williamr@2
  5644
williamr@2
  5645
williamr@2
  5646
template <class T>
williamr@2
  5647
inline TInt RArray<T>::InsertInOrder(const T& anEntry, TLinearOrder<T> anOrder)
williamr@2
  5648
/**
williamr@2
  5649
Inserts an object of into the array in object order.
williamr@2
  5650
williamr@2
  5651
The algorithm for determining the order of two class T type objects is provided 
williamr@2
  5652
by a function supplied by the caller.
williamr@2
  5653
williamr@2
  5654
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  5655
an attempt to insert a duplicate entry.
williamr@2
  5656
williamr@2
  5657
The function assumes that existing objects within the array are in object 
williamr@2
  5658
order.
williamr@2
  5659
williamr@2
  5660
@param anEntry A reference to the object of type class T to be inserted.
williamr@2
  5661
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5662
               of two class T objects.
williamr@2
  5663
williamr@2
  5664
@return KErrNone, if the insertion is successful;
williamr@2
  5665
        KErrAlreadyExists, if an attempt is being made
williamr@2
  5666
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  5667
        error codes.
williamr@2
  5668
*/
williamr@2
  5669
	{return RArrayBase::InsertIsq(&anEntry,anOrder,EFalse);}
williamr@2
  5670
williamr@2
  5671
williamr@2
  5672
williamr@2
  5673
williamr@2
  5674
template <class T>
williamr@2
  5675
inline TInt RArray<T>::InsertInSignedKeyOrderAllowRepeats(const T& anEntry)
williamr@2
  5676
/**
williamr@2
  5677
Inserts an object into the array in ascending signed key order,
williamr@2
  5678
allowing duplicates.
williamr@2
  5679
williamr@2
  5680
The order of two class T type objects is based on comparing a TInt value
williamr@2
  5681
located at the key offset position within the class T object. 
williamr@2
  5682
williamr@2
  5683
If anEntry is a duplicate of an existing object in the array, then the new 
williamr@2
  5684
object is inserted after the existing object. If more than one duplicate object 
williamr@2
  5685
already exists in the array, then any new duplicate object is inserted after 
williamr@2
  5686
the last one.
williamr@2
  5687
williamr@2
  5688
@param anEntry A reference to the object of type class T to be inserted.
williamr@2
  5689
williamr@2
  5690
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5691
        wide error codes.
williamr@2
  5692
*/
williamr@2
  5693
	{return RArrayBase::InsertIsqSigned(&anEntry,ETrue);}
williamr@2
  5694
williamr@2
  5695
williamr@2
  5696
williamr@2
  5697
williamr@2
  5698
template <class T>
williamr@2
  5699
inline TInt RArray<T>::InsertInUnsignedKeyOrderAllowRepeats(const T& anEntry)
williamr@2
  5700
/**
williamr@2
  5701
Inserts an object into the array in ascending unsigned key order, allowing 
williamr@2
  5702
duplicates.
williamr@2
  5703
williamr@2
  5704
The order of two class T type objects is based on comparing a TUint value 
williamr@2
  5705
located at the key offset position within the class T object. 
williamr@2
  5706
williamr@2
  5707
If anEntry is a duplicate of an existing object in the array, then the new 
williamr@2
  5708
object is inserted after the existing object. If more than one duplicate object 
williamr@2
  5709
already exists in the array, then any new duplicate object is inserted after 
williamr@2
  5710
the last one.
williamr@2
  5711
williamr@2
  5712
@param anEntry A reference to the object of type class T to be inserted.
williamr@2
  5713
williamr@2
  5714
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5715
        wide error codes. 
williamr@2
  5716
*/
williamr@2
  5717
	{return RArrayBase::InsertIsqUnsigned(&anEntry,ETrue);}
williamr@2
  5718
williamr@2
  5719
williamr@2
  5720
williamr@2
  5721
williamr@2
  5722
template <class T>
williamr@2
  5723
inline TInt RArray<T>::InsertInOrderAllowRepeats(const T& anEntry, TLinearOrder<T> anOrder)
williamr@2
  5724
/**
williamr@2
  5725
Inserts an object into the array in object order, allowing duplicates.
williamr@2
  5726
williamr@2
  5727
The algorithm for determining the order of two class T type objects is provided 
williamr@2
  5728
by a function supplied by the caller.
williamr@2
  5729
williamr@2
  5730
If anEntry is a duplicate of an existing object in the array, then the new 
williamr@2
  5731
object is inserted after the existing object. If more than one duplicate object 
williamr@2
  5732
already exists in the array, then anEntry is inserted after the last one.
williamr@2
  5733
williamr@2
  5734
The function assumes that existing objects within the array are in object 
williamr@2
  5735
order.
williamr@2
  5736
williamr@2
  5737
@param anEntry A reference to the object of type class T to be inserted.
williamr@2
  5738
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5739
               of two class T objects.
williamr@2
  5740
williamr@2
  5741
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5742
        wide error codes.
williamr@2
  5743
*/
williamr@2
  5744
	{return RArrayBase::InsertIsq(&anEntry,anOrder,ETrue);}
williamr@2
  5745
williamr@2
  5746
williamr@2
  5747
williamr@2
  5748
#ifndef __KERNEL_MODE__
williamr@2
  5749
williamr@2
  5750
template <class T>
williamr@2
  5751
inline void RArray<T>::GranularCompress()
williamr@2
  5752
/**
williamr@2
  5753
Compresses the array down to a granular boundary.
williamr@2
  5754
williamr@2
  5755
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  5756
for its contained objects. Adding new objects to the array does not result 
williamr@2
  5757
in a re-allocation of memory until the the total number of objects reaches 
williamr@2
  5758
a multiple of the granularity.
williamr@2
  5759
*/
williamr@2
  5760
	{RArrayBase::GranularCompress();}
williamr@2
  5761
williamr@2
  5762
williamr@2
  5763
williamr@2
  5764
williamr@2
  5765
template <class T>
williamr@2
  5766
inline TInt RArray<T>::Reserve(TInt aCount)
williamr@2
  5767
/**
williamr@2
  5768
Reserves space for the specified number of elements.
williamr@2
  5769
williamr@2
  5770
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  5771
to hold the number of objects specified. Adding new objects to the array 
williamr@2
  5772
does not result in a re-allocation of memory until the the total number of 
williamr@2
  5773
objects exceeds the specified count.
williamr@2
  5774
williamr@2
  5775
@param	aCount	The number of objects for which space should be reserved
williamr@2
  5776
@return	KErrNone		If the operation completed successfully
williamr@2
  5777
@return KErrNoMemory	If the requested amount of memory could not be allocated
williamr@2
  5778
*/
williamr@2
  5779
	{ return RArrayBase::DoReserve(aCount); }
williamr@2
  5780
williamr@2
  5781
williamr@2
  5782
williamr@2
  5783
williamr@2
  5784
template <class T>
williamr@2
  5785
inline void RArray<T>::SortSigned()
williamr@2
  5786
/**
williamr@2
  5787
Sorts the objects within the array; the sort order is assumed to be in signed 
williamr@2
  5788
integer order.
williamr@2
  5789
*/
williamr@2
  5790
	{HeapSortSigned();}
williamr@2
  5791
williamr@2
  5792
williamr@2
  5793
williamr@2
  5794
williamr@2
  5795
template <class T>
williamr@2
  5796
inline void RArray<T>::SortUnsigned()
williamr@2
  5797
/**
williamr@2
  5798
Sorts the objects within the array; the sort order is assumed to be in unsigned 
williamr@2
  5799
integer order.
williamr@2
  5800
*/
williamr@2
  5801
	{HeapSortUnsigned();}
williamr@2
  5802
williamr@2
  5803
williamr@2
  5804
williamr@2
  5805
williamr@2
  5806
template <class T>
williamr@2
  5807
inline void RArray<T>::Sort(TLinearOrder<T> anOrder)
williamr@2
  5808
/**
williamr@2
  5809
Sorts the objects within the array using the specified TLinearOrder. 
williamr@2
  5810
williamr@2
  5811
The sort order is determined by an algorithm supplied by the caller and
williamr@2
  5812
packaged as a TLinerOrder<T>.
williamr@2
  5813
williamr@2
  5814
@param anOrder A package encapsulating the function which determines the order 
williamr@2
  5815
               of two class T type objects.
williamr@2
  5816
*/
williamr@2
  5817
	{HeapSort(anOrder);}
williamr@2
  5818
williamr@2
  5819
williamr@2
  5820
williamr@2
  5821
williamr@2
  5822
template <class T>
williamr@2
  5823
inline TArray<T> RArray<T>::Array() const
williamr@2
  5824
/**
williamr@2
  5825
Constructs and returns a generic array.
williamr@2
  5826
williamr@2
  5827
@return A generic array representing this array.
williamr@2
  5828
*/
williamr@2
  5829
	{ return TArray<T>(GetCount,GetElementPtr,(const CBase*)this); }
williamr@2
  5830
#endif
williamr@2
  5831
williamr@2
  5832
williamr@2
  5833
williamr@2
  5834
williamr@2
  5835
inline RArray<TInt>::RArray()
williamr@2
  5836
	: RPointerArrayBase()
williamr@2
  5837
/**
williamr@2
  5838
Constructs an array object for an array of signed integers with
williamr@2
  5839
default granularity. 
williamr@2
  5840
williamr@2
  5841
The default granularity is 8. 
williamr@2
  5842
*/
williamr@2
  5843
	{}
williamr@2
  5844
williamr@2
  5845
williamr@2
  5846
williamr@2
  5847
williamr@2
  5848
inline RArray<TInt>::RArray(TInt aGranularity)
williamr@2
  5849
	: RPointerArrayBase(aGranularity)
williamr@2
  5850
/**
williamr@2
  5851
Constructs an array object for an array of signed integers with the specified 
williamr@2
  5852
granularity.
williamr@2
  5853
	
williamr@2
  5854
@param aGranularity The granularity of the array.
williamr@2
  5855
williamr@2
  5856
@panic USER 127, if aGranularity is not positive or is greater than or
williamr@2
  5857
       equal to 0x10000000.
williamr@2
  5858
*/
williamr@2
  5859
	{}
williamr@2
  5860
williamr@2
  5861
williamr@2
  5862
williamr@2
  5863
williamr@2
  5864
/**
williamr@2
  5865
C++ constructor with minimum growth step and exponential growth factor.
williamr@2
  5866
williamr@2
  5867
This constructs an array object for an array of signed integers with the
williamr@2
  5868
specified minimum growth step and exponential growth factor.
williamr@2
  5869
williamr@2
  5870
@param aMinGrowBy	The minimum growth step of the array. Must be between 1 and
williamr@2
  5871
					65535 inclusive.
williamr@2
  5872
@param aFactor		The factor by which the array grows, multiplied by 256.
williamr@2
  5873
					For example 512 specifies a factor of 2. Must be between 257
williamr@2
  5874
					and 32767 inclusive.
williamr@2
  5875
williamr@2
  5876
@panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535.
williamr@2
  5877
@panic USER 193, if aFactor<=257 or aFactor>32767.
williamr@2
  5878
*/
williamr@2
  5879
inline RArray<TInt>::RArray(TInt aMinGrowBy, TInt aFactor)
williamr@2
  5880
	: RPointerArrayBase(aMinGrowBy, aFactor)
williamr@2
  5881
	{}
williamr@2
  5882
williamr@2
  5883
williamr@2
  5884
williamr@2
  5885
williamr@2
  5886
inline void RArray<TInt>::Close()
williamr@2
  5887
/**
williamr@2
  5888
Closes the array and frees all memory allocated to the array.
williamr@2
  5889
	
williamr@2
  5890
The function must be called before this array object goes out of scope. 
williamr@2
  5891
*/
williamr@2
  5892
	{RPointerArrayBase::Close();}
williamr@2
  5893
williamr@2
  5894
williamr@2
  5895
williamr@2
  5896
williamr@2
  5897
inline TInt RArray<TInt>::Count() const
williamr@2
  5898
/**
williamr@2
  5899
Gets the number of signed integers in the array.
williamr@2
  5900
	
williamr@2
  5901
@return The number of signed integers in the array.
williamr@2
  5902
*/
williamr@2
  5903
	{ return RPointerArrayBase::Count(); }
williamr@2
  5904
williamr@2
  5905
williamr@2
  5906
williamr@2
  5907
williamr@2
  5908
inline const TInt& RArray<TInt>::operator[](TInt anIndex) const
williamr@2
  5909
/**
williamr@2
  5910
Gets a reference to the signed integer located at a specified position within 
williamr@2
  5911
the array.
williamr@2
  5912
	
williamr@2
  5913
The compiler chooses this function if the returned reference is used in an 
williamr@2
  5914
expression where the reference cannot be modified.
williamr@2
  5915
	
williamr@2
  5916
@param anIndex The position of the signed integer within the array. The
williamr@2
  5917
               position is relative to zero, i.e. zero implies the entry
williamr@2
  5918
			   at the beginning of the array. 
williamr@2
  5919
williamr@2
  5920
@return A const reference to the signed integer at position anIndex within 
williamr@2
  5921
        the array.
williamr@2
  5922
williamr@2
  5923
@panic USER 130, if anIndex is negative, or is greater than the number of 
williamr@2
  5924
	   entries currently in the array.
williamr@2
  5925
*/
williamr@2
  5926
	{return (const TInt&)At(anIndex);}
williamr@2
  5927
williamr@2
  5928
williamr@2
  5929
williamr@2
  5930
williamr@2
  5931
inline TInt& RArray<TInt>::operator[](TInt anIndex)
williamr@2
  5932
/**
williamr@2
  5933
Gets a reference to the signed integer located at a specified position within 
williamr@2
  5934
the array.
williamr@2
  5935
	
williamr@2
  5936
The compiler chooses this function if the returned reference is used in an 
williamr@2
  5937
expression where the reference can be modified.
williamr@2
  5938
	
williamr@2
  5939
@param anIndex The position of the signed integer within the array. The
williamr@2
  5940
               position is relative to zero, i.e. zero implies the entry
williamr@2
  5941
			   at the beginning of the array. 
williamr@2
  5942
williamr@2
  5943
@return A non-const reference to the signed integer at position anIndex within 
williamr@2
  5944
        the array.
williamr@2
  5945
williamr@2
  5946
@panic USER 130, if anIndex is negative, or is greater than the number of 
williamr@2
  5947
	   entries currently in the array.
williamr@2
  5948
*/
williamr@2
  5949
	{return (TInt&)At(anIndex);}
williamr@2
  5950
williamr@2
  5951
williamr@2
  5952
williamr@2
  5953
williamr@2
  5954
inline TInt RArray<TInt>::Append(TInt anEntry)
williamr@2
  5955
/**
williamr@2
  5956
Appends a signed integer onto the array.
williamr@2
  5957
	
williamr@2
  5958
@param anEntry The signed integer to be appended.
williamr@2
  5959
	
williamr@2
  5960
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5961
	    wide error codes.
williamr@2
  5962
*/
williamr@2
  5963
	{ return RPointerArrayBase::Append((const TAny*)anEntry); }
williamr@2
  5964
williamr@2
  5965
williamr@2
  5966
williamr@2
  5967
williamr@2
  5968
inline TInt RArray<TInt>::Insert(TInt anEntry, TInt aPos)
williamr@2
  5969
/**
williamr@2
  5970
Inserts a signed integer into the array at the specified position.
williamr@2
  5971
	
williamr@2
  5972
@param anEntry The signed integer to be inserted.
williamr@2
  5973
@param aPos    The position within the array where the signed integer is to be 
williamr@2
  5974
	           inserted. The position is relative to zero, i.e. zero implies
williamr@2
  5975
			   that an entry is inserted at the beginning of the array.
williamr@2
  5976
			   
williamr@2
  5977
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  5978
	    wide error codes.
williamr@2
  5979
williamr@2
  5980
@panic USER 131, if aPos is negative, or is greater than the number of entries
williamr@2
  5981
       currently in the array.
williamr@2
  5982
*/
williamr@2
  5983
	{ return RPointerArrayBase::Insert((const TAny*)anEntry,aPos); }
williamr@2
  5984
williamr@2
  5985
williamr@2
  5986
williamr@2
  5987
williamr@2
  5988
inline void RArray<TInt>::Remove(TInt anIndex)
williamr@2
  5989
/**
williamr@2
  5990
Removes the signed integer at the specified position from the array.
williamr@2
  5991
	
williamr@2
  5992
@param anIndex The position within the array from where the signed integer 
williamr@2
  5993
	           is to be removed. The position is relative to zero, i.e. zero
williamr@2
  5994
			   implies that an entry at the beginning of the array is to be
williamr@2
  5995
			   removed. 
williamr@2
  5996
williamr@2
  5997
@panic USER 130, if anIndex is negative or is greater than the number of
williamr@2
  5998
       entries currently in the array.
williamr@2
  5999
*/
williamr@2
  6000
	{RPointerArrayBase::Remove(anIndex);}
williamr@2
  6001
williamr@2
  6002
williamr@2
  6003
williamr@2
  6004
williamr@2
  6005
inline void RArray<TInt>::Compress()
williamr@2
  6006
/**
williamr@2
  6007
Compresses the array down to a minimum.
williamr@2
  6008
	
williamr@2
  6009
After a call to this function, the memory allocated to the array is just
williamr@2
  6010
sufficient for its entries. Subsequently adding a new signed integer to the
williamr@2
  6011
array always results in a re-allocation of memory.
williamr@2
  6012
*/
williamr@2
  6013
	{RPointerArrayBase::Compress();}
williamr@2
  6014
williamr@2
  6015
williamr@2
  6016
williamr@2
  6017
williamr@2
  6018
inline void RArray<TInt>::Reset()
williamr@2
  6019
/**
williamr@2
  6020
Empties the array.
williamr@2
  6021
williamr@2
  6022
The function frees all memory allocated to the array and 
williamr@2
  6023
resets the internal state so that it is ready to be reused.
williamr@2
  6024
	
williamr@2
  6025
This array object can be allowed to go out of scope after a call to this
williamr@2
  6026
function.
williamr@2
  6027
*/
williamr@2
  6028
	{RPointerArrayBase::Reset();}
williamr@2
  6029
williamr@2
  6030
williamr@2
  6031
williamr@2
  6032
williamr@2
  6033
inline TInt RArray<TInt>::Find(TInt anEntry) const
williamr@2
  6034
/**
williamr@2
  6035
Finds the first signed integer in the array which matches the specified signed 
williamr@2
  6036
integer using a sequential search.
williamr@2
  6037
	
williamr@2
  6038
The find operation always starts at the low index end of the array. There 
williamr@2
  6039
is no assumption about the order of entries in the array.
williamr@2
  6040
	
williamr@2
  6041
@param anEntry The signed integer to be found.
williamr@2
  6042
williamr@2
  6043
@return The index of the first matching signed integer within the array.
williamr@2
  6044
        KErrNotFound, if no matching entry can be found.
williamr@2
  6045
*/
williamr@2
  6046
	{ return RPointerArrayBase::Find((const TAny*)anEntry); }
williamr@2
  6047
williamr@2
  6048
williamr@2
  6049
williamr@2
  6050
williamr@2
  6051
inline TInt RArray<TInt>::FindReverse(TInt anEntry) const
williamr@2
  6052
/**
williamr@2
  6053
Finds the last signed integer in the array which matches the specified signed 
williamr@2
  6054
integer using a sequential search.
williamr@2
  6055
	
williamr@2
  6056
The find operation always starts at the high index end of the array. There 
williamr@2
  6057
is no assumption about the order of entries in the array.
williamr@2
  6058
	
williamr@2
  6059
@param anEntry The signed integer to be found.
williamr@2
  6060
williamr@2
  6061
@return The index of the last matching signed integer within the array.
williamr@2
  6062
        KErrNotFound, if no matching entry can be found.
williamr@2
  6063
*/
williamr@2
  6064
	{ return RPointerArrayBase::FindReverse((const TAny*)anEntry); }
williamr@2
  6065
williamr@2
  6066
williamr@2
  6067
williamr@2
  6068
williamr@2
  6069
inline TInt RArray<TInt>::FindInOrder(TInt anEntry) const
williamr@2
  6070
/**
williamr@2
  6071
Finds the signed integer in the array that matches the specified signed integer 
williamr@2
  6072
using a binary search technique.
williamr@2
  6073
	
williamr@2
  6074
The function assumes that the array is in signed integer order.
williamr@2
  6075
	
williamr@2
  6076
@param anEntry The signed integer to find.
williamr@2
  6077
williamr@2
  6078
@return The index of the matching signed integer within the array or KErrNotFound, 
williamr@2
  6079
        if no match can be found.
williamr@2
  6080
*/
williamr@2
  6081
	{ return RPointerArrayBase::FindIsqSigned(anEntry); }
williamr@2
  6082
williamr@2
  6083
williamr@2
  6084
williamr@2
  6085
williamr@2
  6086
inline TInt RArray<TInt>::FindInOrder(TInt anEntry, TInt& anIndex) const
williamr@2
  6087
/**
williamr@2
  6088
Finds the signed integer in the array that matches the specified signed integer
williamr@2
  6089
using a binary search technique.
williamr@2
  6090
	
williamr@2
  6091
The function assumes that the array is in signed integer order.
williamr@2
  6092
	
williamr@2
  6093
@param anEntry The signed integer to find.
williamr@2
  6094
@param anIndex A TInt suplied by the caller. On return contains an index value.
williamr@2
  6095
               If the function returns KErrNone, this is the index of the
williamr@2
  6096
               matching signed integer within the array.   
williamr@2
  6097
               If the function returns KErrNotFound, this is the index of the
williamr@2
  6098
               first signed integer within the array that is bigger than the
williamr@2
  6099
               signed integer being searched for - if no signed integers within
williamr@2
  6100
               the array are bigger, then the index value is the same as the
williamr@2
  6101
               total number of signed integers within the array.
williamr@2
  6102
williamr@2
  6103
@return KErrNone if a matching signed integer is found.
williamr@2
  6104
        KErrNotFound if no  match can be found.
williamr@2
  6105
*/
williamr@2
  6106
	{ return RPointerArrayBase::BinarySearchSigned(anEntry,anIndex); }
williamr@2
  6107
williamr@2
  6108
williamr@2
  6109
williamr@2
  6110
williamr@2
  6111
inline TInt RArray<TInt>::SpecificFindInOrder(TInt anEntry, TInt aMode) const
williamr@2
  6112
/**
williamr@2
  6113
Finds the signed integer in the array that matches the specified signed integer 
williamr@2
  6114
using a binary search technique.
williamr@2
  6115
williamr@2
  6116
Where there is more than one matching element, it finds the first, last or any
williamr@2
  6117
matching element as specified by the value of aMode.
williamr@2
  6118
	
williamr@2
  6119
The function assumes that the array is in signed integer order.
williamr@2
  6120
	
williamr@2
  6121
@param anEntry The signed integer to be found.
williamr@2
  6122
@param aMode   Specifies whether to find the first match, the last match or any
williamr@2
  6123
               match, as defined by one of the TArrayFindMode enum values.
williamr@2
  6124
williamr@2
  6125
@return KErrNotFound, if there is no matching element, otherwise the array
williamr@2
  6126
        index of a matching element -  what the index refers to depends on the
williamr@2
  6127
        value of aMode:
williamr@2
  6128
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  6129
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  6130
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  6131
        the last matching element - if the last matching element is also the last element
williamr@2
  6132
        of the array, then the index value is the same as the total number of elements in
williamr@2
  6133
        the array.
williamr@2
  6134
williamr@2
  6135
@see TArrayFindMode         
williamr@2
  6136
*/
williamr@2
  6137
	{ return RPointerArrayBase::FindIsqSigned(anEntry,aMode); }
williamr@2
  6138
williamr@2
  6139
williamr@2
  6140
williamr@2
  6141
williamr@2
  6142
inline TInt RArray<TInt>::SpecificFindInOrder(TInt anEntry, TInt& anIndex, TInt aMode) const
williamr@2
  6143
/**
williamr@2
  6144
Finds the signed integer in the array that matches the specified signed integer
williamr@2
  6145
using a binary search technique.
williamr@2
  6146
williamr@2
  6147
Where there is more than one matching element, it finds the first, last or any 
williamr@2
  6148
matching element  as specified by the value of aMode.
williamr@2
  6149
williamr@2
  6150
The function assumes that the array is in signed integer order.
williamr@2
  6151
	
williamr@2
  6152
@param anEntry The signed integer to be found.
williamr@2
  6153
@param anIndex A TInt type supplied by the caller. On return, it contains an index
williamr@2
  6154
               value depending on whether a match is found and on the value of aMode.
williamr@2
  6155
               If there is no matching element in the array, then this is the  index of
williamr@2
  6156
               the first element in the array that is bigger than the element being
williamr@2
  6157
               searched for - if no elements in the array are bigger, then the index
williamr@2
  6158
               value is the same as the total number of elements in the array.
williamr@2
  6159
               If there is a matching element, then what the index refers to depends
williamr@2
  6160
               on the value of aMode:
williamr@2
  6161
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  6162
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  6163
               if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  6164
               the last matching element - if the last matching element is also the last element
williamr@2
  6165
               of the array, then the index value is the same as the total number of elements in the array.
williamr@2
  6166
               
williamr@2
  6167
@param	aMode  Specifies whether to find the first match, the last match or any match,
williamr@2
  6168
               as defined by one of the TArrayFindMode enum values.
williamr@2
  6169
               
williamr@2
  6170
@return KErrNone, if a matching element is found; 
williamr@2
  6171
        KErrNotFound, if no suitable element can be found.               
williamr@2
  6172
        
williamr@2
  6173
@see TArrayFindMode
williamr@2
  6174
*/
williamr@2
  6175
	{ return RPointerArrayBase::BinarySearchSigned(anEntry,anIndex,aMode); }
williamr@2
  6176
williamr@2
  6177
williamr@2
  6178
williamr@2
  6179
williamr@2
  6180
inline TInt RArray<TInt>::InsertInOrder(TInt anEntry)
williamr@2
  6181
/**
williamr@2
  6182
Inserts a signed integer into the array in signed integer order.
williamr@2
  6183
	
williamr@2
  6184
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  6185
an attempt to insert a duplicate entry.
williamr@2
  6186
	
williamr@2
  6187
The function assumes that existing entries within the array are in signed 
williamr@2
  6188
integer order.
williamr@2
  6189
	
williamr@2
  6190
@param anEntry The signed integer to be inserted
williamr@2
  6191
williamr@2
  6192
@return KErrNone, if the insertion is successful;
williamr@2
  6193
        KErrAlreadyExists, if an attempt is being made
williamr@2
  6194
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  6195
        error codes.
williamr@2
  6196
*/
williamr@2
  6197
	{ return RPointerArrayBase::InsertIsqSigned(anEntry,EFalse); }
williamr@2
  6198
williamr@2
  6199
williamr@2
  6200
williamr@2
  6201
williamr@2
  6202
inline TInt RArray<TInt>::InsertInOrderAllowRepeats(TInt anEntry)
williamr@2
  6203
/**
williamr@2
  6204
Inserts a signed integer into the array in signed integer order,
williamr@2
  6205
allowing duplicates.
williamr@2
  6206
	
williamr@2
  6207
If anEntry is a duplicate of an existing entry in the array, then the new 
williamr@2
  6208
signed integer is inserted after the existing one. If more than one duplicate 
williamr@2
  6209
entry already exists in the array, then any new duplicate signed integer is 
williamr@2
  6210
inserted after the last one.
williamr@2
  6211
	
williamr@2
  6212
The function assumes that existing entries within the array are in signed 
williamr@2
  6213
integer order.
williamr@2
  6214
	
williamr@2
  6215
@param anEntry The signed integer to be inserted.
williamr@2
  6216
williamr@2
  6217
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  6218
        wide error codes.
williamr@2
  6219
*/
williamr@2
  6220
	{ return RPointerArrayBase::InsertIsqSigned(anEntry,ETrue); }
williamr@2
  6221
williamr@2
  6222
williamr@2
  6223
williamr@2
  6224
williamr@2
  6225
#ifndef __KERNEL_MODE__
williamr@2
  6226
inline RArray<TInt>::RArray(TInt* aEntries, TInt aCount)
williamr@2
  6227
	: RPointerArrayBase((TAny**)aEntries, aCount)
williamr@2
  6228
/**
williamr@2
  6229
C++ constructor with a pointer to the first array entry in a 
williamr@2
  6230
pre-existing array, and the number of entries in that array.
williamr@2
  6231
williamr@2
  6232
This constructor takes a pointer to a pre-existing set of entries of type 
williamr@2
  6233
TInt objects. Ownership of the set of entries does not transfer to
williamr@2
  6234
this RArray object.
williamr@2
  6235
williamr@2
  6236
The purpose of constructing an array in this way is to allow sorting and
williamr@2
  6237
finding operations to be done without further allocation of memory.
williamr@2
  6238
williamr@2
  6239
@param aEntries   A pointer to the first entry of type class TInt in the set of 
williamr@2
  6240
                  entries belonging to the existing array.
williamr@2
  6241
@param aCount     The number of entries in the existing array.
williamr@2
  6242
*/
williamr@2
  6243
	{}
williamr@2
  6244
williamr@2
  6245
inline void RArray<TInt>::GranularCompress()
williamr@2
  6246
/**
williamr@2
  6247
Compresses the array down to a granular boundary.
williamr@2
  6248
	
williamr@2
  6249
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  6250
for its contained entries. Adding new signed integers to the array does not 
williamr@2
  6251
result in a re-allocation of memory until the total number of entries reaches 
williamr@2
  6252
a multiple of the granularity.
williamr@2
  6253
*/
williamr@2
  6254
	{RPointerArrayBase::GranularCompress();}
williamr@2
  6255
williamr@2
  6256
williamr@2
  6257
williamr@2
  6258
williamr@2
  6259
inline TInt RArray<TInt>::Reserve(TInt aCount)
williamr@2
  6260
/**
williamr@2
  6261
Reserves space for the specified number of elements.
williamr@2
  6262
williamr@2
  6263
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  6264
to hold the number of integers specified. Adding new integers to the array 
williamr@2
  6265
does not result in a re-allocation of memory until the the total number of 
williamr@2
  6266
integers exceeds the specified count.
williamr@2
  6267
williamr@2
  6268
@param	aCount	The number of integers for which space should be reserved
williamr@2
  6269
@return	KErrNone		If the operation completed successfully
williamr@2
  6270
@return KErrNoMemory	If the requested amount of memory could not be allocated
williamr@2
  6271
*/
williamr@2
  6272
	{ return RPointerArrayBase::DoReserve(aCount); }
williamr@2
  6273
williamr@2
  6274
williamr@2
  6275
williamr@2
  6276
williamr@2
  6277
inline void RArray<TInt>::Sort()
williamr@2
  6278
/**
williamr@2
  6279
Sorts the array entries into signed integer order.
williamr@2
  6280
*/
williamr@2
  6281
	{ HeapSortSigned(); }
williamr@2
  6282
williamr@2
  6283
williamr@2
  6284
williamr@2
  6285
williamr@2
  6286
inline TArray<TInt> RArray<TInt>::Array() const
williamr@2
  6287
/**
williamr@2
  6288
Constructs and returns a generic array.
williamr@2
  6289
	
williamr@2
  6290
@return A generic array representing this array.
williamr@2
  6291
williamr@2
  6292
@see TArray
williamr@2
  6293
*/
williamr@2
  6294
	{ return TArray<TInt>(GetCount,GetElementPtr,(const CBase*)this); }
williamr@2
  6295
#endif
williamr@2
  6296
williamr@2
  6297
williamr@2
  6298
williamr@2
  6299
inline RArray<TUint>::RArray()
williamr@2
  6300
	: RPointerArrayBase()
williamr@2
  6301
/**
williamr@2
  6302
Default C++ constructor.
williamr@2
  6303
williamr@2
  6304
This constructs an array object for an array of unsigned 
williamr@2
  6305
integers with default granularity.
williamr@2
  6306
williamr@2
  6307
The default granularity of the array is 8.
williamr@2
  6308
*/
williamr@2
  6309
	{}
williamr@2
  6310
williamr@2
  6311
williamr@2
  6312
williamr@2
  6313
williamr@2
  6314
inline RArray<TUint>::RArray(TInt aGranularity)
williamr@2
  6315
	: RPointerArrayBase(aGranularity)
williamr@2
  6316
/**
williamr@2
  6317
Constructs an array object for an array of unsigned integers with the specified 
williamr@2
  6318
granularity.
williamr@2
  6319
	
williamr@2
  6320
@param aGranularity The granularity of the array.
williamr@2
  6321
williamr@2
  6322
@panic USER 127, if aGranularity is not positive or is greater than or
williamr@2
  6323
       equal to 0x10000000.
williamr@2
  6324
*/
williamr@2
  6325
	{}
williamr@2
  6326
williamr@2
  6327
williamr@2
  6328
williamr@2
  6329
williamr@2
  6330
/**
williamr@2
  6331
C++ constructor with minimum growth step and exponential growth factor.
williamr@2
  6332
williamr@2
  6333
This constructs an array object for an array of unsigned integers with the
williamr@2
  6334
specified minimum growth step and exponential growth factor.
williamr@2
  6335
williamr@2
  6336
@param aMinGrowBy	The minimum growth step of the array. Must be between 1 and
williamr@2
  6337
					65535 inclusive.
williamr@2
  6338
@param aFactor		The factor by which the array grows, multiplied by 256.
williamr@2
  6339
					For example 512 specifies a factor of 2. Must be between 257
williamr@2
  6340
					and 32767 inclusive.
williamr@2
  6341
williamr@2
  6342
@panic USER 192, if aMinGrowBy<=0 or aMinGrowBy>65535.
williamr@2
  6343
@panic USER 193, if aFactor<=257 or aFactor>32767.
williamr@2
  6344
*/
williamr@2
  6345
inline RArray<TUint>::RArray(TInt aMinGrowBy, TInt aFactor)
williamr@2
  6346
	: RPointerArrayBase(aMinGrowBy, aFactor)
williamr@2
  6347
	{}
williamr@2
  6348
williamr@2
  6349
williamr@2
  6350
williamr@2
  6351
williamr@2
  6352
inline void RArray<TUint>::Close()
williamr@2
  6353
/**
williamr@2
  6354
Closes the array and frees all memory allocated to the array.
williamr@2
  6355
	
williamr@2
  6356
The function must be called before this array object goes out of scope.
williamr@2
  6357
*/
williamr@2
  6358
	{RPointerArrayBase::Close();}
williamr@2
  6359
williamr@2
  6360
williamr@2
  6361
williamr@2
  6362
williamr@2
  6363
inline TInt RArray<TUint>::Count() const
williamr@2
  6364
/**
williamr@2
  6365
Gets the number of unsigned integers in the array.
williamr@2
  6366
williamr@2
  6367
@return The number of unsigned integers in the array.
williamr@2
  6368
*/
williamr@2
  6369
	{return RPointerArrayBase::Count(); }
williamr@2
  6370
williamr@2
  6371
williamr@2
  6372
williamr@2
  6373
williamr@2
  6374
inline const TUint& RArray<TUint>::operator[](TInt anIndex) const
williamr@2
  6375
/**
williamr@2
  6376
Gets a reference to the unsigned integer located at the specified position 
williamr@2
  6377
within the array.
williamr@2
  6378
	
williamr@2
  6379
The compiler uses this variant if the returned reference is used in an
williamr@2
  6380
expression where the reference cannot be modified.
williamr@2
  6381
	
williamr@2
  6382
@param anIndex The position of the unsigned integer within the array, relative 
williamr@2
  6383
	           to zero, i.e. zero implies the entry at the beginning of
williamr@2
  6384
			   the array.
williamr@2
  6385
williamr@2
  6386
@return A reference to the const unsigned integer at position anIndex within 
williamr@2
  6387
        the array.
williamr@2
  6388
williamr@2
  6389
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  6390
       entries currently in the array.
williamr@2
  6391
*/
williamr@2
  6392
	{return (const TUint&)At(anIndex);}
williamr@2
  6393
williamr@2
  6394
williamr@2
  6395
williamr@2
  6396
williamr@2
  6397
inline TUint& RArray<TUint>::operator[](TInt anIndex)
williamr@2
  6398
/**
williamr@2
  6399
Gets a reference to the unsigned integer located at the specified position 
williamr@2
  6400
within the array.
williamr@2
  6401
	
williamr@2
  6402
The compiler uses this variant if the returned reference is used in an
williamr@2
  6403
expression where the reference can be modified.
williamr@2
  6404
	
williamr@2
  6405
@param anIndex The position of the unsigned integer within the array, relative 
williamr@2
  6406
	           to zero, i.e. zero implies the entry at the beginning of
williamr@2
  6407
			   the array.
williamr@2
  6408
williamr@2
  6409
@return A reference to the non-const unsigned integer at position anIndex
williamr@2
  6410
        within the array.
williamr@2
  6411
williamr@2
  6412
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  6413
       entries currently in the array.
williamr@2
  6414
*/
williamr@2
  6415
	{return (TUint&)At(anIndex);}
williamr@2
  6416
williamr@2
  6417
williamr@2
  6418
williamr@2
  6419
williamr@2
  6420
inline TInt RArray<TUint>::Append(TUint anEntry)
williamr@2
  6421
/**
williamr@2
  6422
Appends an unsigned integer onto the array.
williamr@2
  6423
	
williamr@2
  6424
@param anEntry The unsigned integer to be appended.
williamr@2
  6425
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  6426
        wide error codes.
williamr@2
  6427
*/
williamr@2
  6428
	{ return RPointerArrayBase::Append((const TAny*)anEntry); }
williamr@2
  6429
williamr@2
  6430
williamr@2
  6431
williamr@2
  6432
williamr@2
  6433
inline TInt RArray<TUint>::Insert(TUint anEntry, TInt aPos)
williamr@2
  6434
/**
williamr@2
  6435
Inserts an unsigned integer into the array at the specified position.
williamr@2
  6436
	
williamr@2
  6437
@param anEntry  The unsigned integer to be inserted.
williamr@2
  6438
@param aPos     The position within the array where the unsigned integer is to 
williamr@2
  6439
	            be inserted. The position is relative to zero, i.e. zero
williamr@2
  6440
				implies that an entry is inserted at the beginning of
williamr@2
  6441
				the array.
williamr@2
  6442
			
williamr@2
  6443
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  6444
        wide error codes.
williamr@2
  6445
williamr@2
  6446
@panic USER 131, if aPos is negative, or is greater than the number of entries
williamr@2
  6447
       currently in the array.
williamr@2
  6448
*/
williamr@2
  6449
	{ return RPointerArrayBase::Insert((const TAny*)anEntry,aPos); }
williamr@2
  6450
williamr@2
  6451
williamr@2
  6452
williamr@2
  6453
williamr@2
  6454
inline void RArray<TUint>::Remove(TInt anIndex)
williamr@2
  6455
/**
williamr@2
  6456
Removes the unsigned integer at the specified position from the array.
williamr@2
  6457
	
williamr@2
  6458
@param anIndex The position within the array from where the unsigned integer 
williamr@2
  6459
               is to be removed. The position is relative to zero, i.e. zero
williamr@2
  6460
			   implies that an entry at the beginning of the array is to be
williamr@2
  6461
			   removed. 
williamr@2
  6462
			   
williamr@2
  6463
				 
williamr@2
  6464
@panic USER 130, if anIndex is negative, or is greater than the number of
williamr@2
  6465
       entries currently in the array.
williamr@2
  6466
*/
williamr@2
  6467
	{RPointerArrayBase::Remove(anIndex);}
williamr@2
  6468
williamr@2
  6469
williamr@2
  6470
williamr@2
  6471
williamr@2
  6472
inline void RArray<TUint>::Compress()
williamr@2
  6473
/**
williamr@2
  6474
Compresses the array down to a minimum.
williamr@2
  6475
	
williamr@2
  6476
After a call to this function, the memory allocated to the array is just
williamr@2
  6477
sufficient for its entries. Subsequently adding a new unsigned integer to the
williamr@2
  6478
array always results in a re-allocation of memory.
williamr@2
  6479
*/
williamr@2
  6480
	{RPointerArrayBase::Compress();}
williamr@2
  6481
williamr@2
  6482
williamr@2
  6483
williamr@2
  6484
williamr@2
  6485
inline void RArray<TUint>::Reset()
williamr@2
  6486
/**
williamr@2
  6487
Empties the array.
williamr@2
  6488
williamr@2
  6489
It frees all memory allocated to the array and resets the 
williamr@2
  6490
internal state so that it is ready to be reused.
williamr@2
  6491
	
williamr@2
  6492
This array object can be allowed to go out of scope after a call to
williamr@2
  6493
this function.
williamr@2
  6494
*/
williamr@2
  6495
	{RPointerArrayBase::Reset();}
williamr@2
  6496
williamr@2
  6497
williamr@2
  6498
williamr@2
  6499
williamr@2
  6500
inline TInt RArray<TUint>::Find(TUint anEntry) const
williamr@2
  6501
/**
williamr@2
  6502
Finds the first unsigned integer in the array which matches the specified
williamr@2
  6503
value, using a sequential search.
williamr@2
  6504
	
williamr@2
  6505
The find operation always starts at the low index end of the array. There 
williamr@2
  6506
is no assumption about the order of entries in the array.
williamr@2
  6507
	
williamr@2
  6508
@param anEntry The unsigned integer to be found.
williamr@2
  6509
williamr@2
  6510
@return The index of the first matching unsigned integer within the array.
williamr@2
  6511
        KErrNotFound, if no matching entry can be found.
williamr@2
  6512
*/
williamr@2
  6513
	{ return RPointerArrayBase::Find((const TAny*)anEntry); }
williamr@2
  6514
williamr@2
  6515
williamr@2
  6516
williamr@2
  6517
williamr@2
  6518
inline TInt RArray<TUint>::FindReverse(TUint anEntry) const
williamr@2
  6519
/**
williamr@2
  6520
Finds the last unsigned integer in the array which matches the specified
williamr@2
  6521
value, using a sequential search.
williamr@2
  6522
	
williamr@2
  6523
The find operation always starts at the high index end of the array. There 
williamr@2
  6524
is no assumption about the order of entries in the array.
williamr@2
  6525
	
williamr@2
  6526
@param anEntry The unsigned integer to be found.
williamr@2
  6527
williamr@2
  6528
@return The index of the last matching unsigned integer within the array.
williamr@2
  6529
        KErrNotFound, if no matching entry can be found.
williamr@2
  6530
*/
williamr@2
  6531
	{ return RPointerArrayBase::FindReverse((const TAny*)anEntry); }
williamr@2
  6532
williamr@2
  6533
williamr@2
  6534
williamr@2
  6535
williamr@2
  6536
inline TInt RArray<TUint>::FindInOrder(TUint anEntry) const
williamr@2
  6537
/**
williamr@2
  6538
Finds the unsigned integer in the array which matches the specified value, 
williamr@2
  6539
using a binary search technique.
williamr@2
  6540
	
williamr@2
  6541
The functions assume that existing entries within the array are in unsigned 
williamr@2
  6542
integer order.
williamr@2
  6543
	
williamr@2
  6544
@param anEntry The unsigned integer to be found.
williamr@2
  6545
williamr@2
  6546
@return This is either: the index of the matching unsigned integer within the 
williamr@2
  6547
     	array;
williamr@2
  6548
		KErrNotFound, if no suitable entry can be found.
williamr@2
  6549
*/
williamr@2
  6550
	{ return RPointerArrayBase::FindIsqUnsigned(anEntry); }
williamr@2
  6551
williamr@2
  6552
williamr@2
  6553
williamr@2
  6554
williamr@2
  6555
inline TInt RArray<TUint>::FindInOrder(TUint anEntry, TInt& anIndex) const
williamr@2
  6556
/**
williamr@2
  6557
Finds the unsigned integer in the array which matches the specified value, 
williamr@2
  6558
using a binary search technique.
williamr@2
  6559
williamr@2
  6560
If the index cannot be found, the function returns the index of the last
williamr@2
  6561
unsigned integer within the array which logically precedes anEntry.
williamr@2
  6562
	
williamr@2
  6563
The functions assume that existing entries within the array are in unsigned 
williamr@2
  6564
integer order.
williamr@2
  6565
	
williamr@2
  6566
@param anEntry The unsigned integer to be found.
williamr@2
  6567
@param anIndex A TInt supplied by the caller. On return, contains an index
williamr@2
  6568
               value.
williamr@2
  6569
               If the function returns KErrNone, this is the index of the
williamr@2
  6570
               matching unsigned integer within the array.               
williamr@2
  6571
               If the function returns KErrNotFound, this is the index of the
williamr@2
  6572
               first unsigned integer within the array that is bigger than the
williamr@2
  6573
               unsigned integer being searched for - if no unsigned integers within
williamr@2
  6574
               the array are bigger, then the index value is the same as the
williamr@2
  6575
               total number of unsigned integers within the array.
williamr@2
  6576
@return KErrNone, if a matching unsigned integer is found. 
williamr@2
  6577
        KErrNotFound, if no suitable entry can be found.
williamr@2
  6578
*/
williamr@2
  6579
	{ return RPointerArrayBase::BinarySearchUnsigned(anEntry,anIndex); }
williamr@2
  6580
williamr@2
  6581
williamr@2
  6582
williamr@2
  6583
williamr@2
  6584
inline TInt RArray<TUint>::SpecificFindInOrder(TUint anEntry, TInt aMode) const
williamr@2
  6585
/**
williamr@2
  6586
Finds the unsigned integer in the array that matches the specified unsigned integer 
williamr@2
  6587
using a binary search technique.
williamr@2
  6588
williamr@2
  6589
In the case that there is more than one matching element, finds the first, last
williamr@2
  6590
or any match as specified by the value of aMode.
williamr@2
  6591
	
williamr@2
  6592
The function assumes that the array is in unsigned integer order.
williamr@2
  6593
	
williamr@2
  6594
@param anEntry The unsigned integer to be found..
williamr@2
  6595
@param aMode   Specifies whether to find the first match, the last match or any match,
williamr@2
  6596
               as defined by one of the TArrayFindMode enum values.
williamr@2
  6597
williamr@2
  6598
@return KErrNotFound, if there is no matching element, otherwise the array index of
williamr@2
  6599
        a matching element - what the index refers to depends on the value of
williamr@2
  6600
        aMode:
williamr@2
  6601
        if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  6602
        if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  6603
        if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  6604
        the last matching element - if the last matching element is also the last element of
williamr@2
  6605
        the array, then the index value is the same as the total number of elements in the array.
williamr@2
  6606
        
williamr@2
  6607
@see TArrayFindMode
williamr@2
  6608
*/
williamr@2
  6609
	{ return RPointerArrayBase::FindIsqUnsigned(anEntry,aMode); }
williamr@2
  6610
williamr@2
  6611
williamr@2
  6612
williamr@2
  6613
williamr@2
  6614
inline TInt RArray<TUint>::SpecificFindInOrder(TUint anEntry, TInt& anIndex, TInt aMode) const
williamr@2
  6615
/**
williamr@2
  6616
Finds the unsigned integer in the array that matches the specified unsigned integer
williamr@2
  6617
using a binary search technique.
williamr@2
  6618
williamr@2
  6619
In the case that there is more than one matching element, finds the first, last or any match as specified.
williamr@2
  6620
williamr@2
  6621
The function assumes that the array is in unsigned integer order.
williamr@2
  6622
	
williamr@2
  6623
@param anEntry The unsigned integer to be found.
williamr@2
  6624
@param anIndex A TInt type supplied by the caller. On return, it contains an index
williamr@2
  6625
               value depending on whether a match is found and on the value of aMode.
williamr@2
  6626
               If there is no matching element in the array, then this is the  index
williamr@2
  6627
               of the first element in the array that is bigger than the element being
williamr@2
  6628
               searched for - if no elements in the array are bigger, then the index
williamr@2
  6629
               value is the same as the total number of elements in the array.
williamr@2
  6630
               If there is a matching element, then what the index refers to depends
williamr@2
  6631
               on the value of aMode:
williamr@2
  6632
               if this is EArrayFindMode_First, then the index refers to the first matching element;
williamr@2
  6633
               if this is EArrayFindMode_Any, then the index can refer to any of the matching elements;
williamr@2
  6634
               if this is EArrayFindMode_Last, then the index refers to first element that follows
williamr@2
  6635
               the last matching element - if the last matching element is also the last element of the array,
williamr@2
  6636
               then the index value is the same as the total number of elements in the array.
williamr@2
  6637
@param	aMode  Specifies whether to find the first match, the last match or any match, as defined by one
williamr@2
  6638
               of the TArrayFindMode enum values.
williamr@2
  6639
               
williamr@2
  6640
@return	KErrNone, if a matching entry is found; KErrNotFound, if no matching entry exists.
williamr@2
  6641
williamr@2
  6642
@see TArrayFindMode
williamr@2
  6643
*/
williamr@2
  6644
	{ return RPointerArrayBase::BinarySearchUnsigned(anEntry,anIndex,aMode); }
williamr@2
  6645
williamr@2
  6646
williamr@2
  6647
williamr@2
  6648
williamr@2
  6649
inline TInt RArray<TUint>::InsertInOrder(TUint anEntry)
williamr@2
  6650
/**
williamr@2
  6651
Inserts an unsigned integer into the array in unsigned integer order.
williamr@2
  6652
	
williamr@2
  6653
No duplicate entries are permitted. The array remains unchanged following
williamr@2
  6654
an attempt to insert a duplicate entry.
williamr@2
  6655
	
williamr@2
  6656
The function assumes that existing entries within the array are in unsigned 
williamr@2
  6657
integer order.
williamr@2
  6658
	
williamr@2
  6659
@param anEntry The unsigned integer to be inserted.
williamr@2
  6660
williamr@2
  6661
@return KErrNone, if the insertion is successful;
williamr@2
  6662
        KErrAlreadyExists, if an attempt is being made
williamr@2
  6663
        to insert a duplicate entry; otherwise one of the other system wide
williamr@2
  6664
        error codes.
williamr@2
  6665
*/
williamr@2
  6666
	{ return RPointerArrayBase::InsertIsqUnsigned(anEntry,EFalse); }
williamr@2
  6667
williamr@2
  6668
williamr@2
  6669
williamr@2
  6670
williamr@2
  6671
inline TInt RArray<TUint>::InsertInOrderAllowRepeats(TUint anEntry)
williamr@2
  6672
/**
williamr@2
  6673
Inserts an unsigned integer into the array in unsigned integer order, allowing 
williamr@2
  6674
duplicates.
williamr@2
  6675
	
williamr@2
  6676
If the new integer is a duplicate of an existing entry in the array, then 
williamr@2
  6677
the new unsigned integer is inserted after the existing one. If more than 
williamr@2
  6678
one duplicate entry already exists in the array, then any new duplicate
williamr@2
  6679
unsigned integer is inserted after the last one.
williamr@2
  6680
	
williamr@2
  6681
The function assumes that existing entries within the array are in unsigned 
williamr@2
  6682
integer order.
williamr@2
  6683
	
williamr@2
  6684
@param anEntry The unsigned integer to be inserted.
williamr@2
  6685
williamr@2
  6686
@return KErrNone, if the insertion is successful, otherwise one of the system 
williamr@2
  6687
        wide error codes.
williamr@2
  6688
*/
williamr@2
  6689
	{ return RPointerArrayBase::InsertIsqUnsigned(anEntry,ETrue); }
williamr@2
  6690
williamr@2
  6691
williamr@2
  6692
williamr@2
  6693
williamr@2
  6694
#ifndef __KERNEL_MODE__
williamr@2
  6695
inline RArray<TUint>::RArray(TUint* aEntries, TInt aCount)
williamr@2
  6696
	: RPointerArrayBase((TAny**)aEntries, aCount)
williamr@2
  6697
/**
williamr@2
  6698
C++ constructor with a pointer to the first array entry in a 
williamr@2
  6699
pre-existing array, and the number of entries in that array.
williamr@2
  6700
williamr@2
  6701
This constructor takes a pointer to a pre-existing set of entries of type 
williamr@2
  6702
TUint objects. Ownership of the set of entries does not transfer to
williamr@2
  6703
this RArray object.
williamr@2
  6704
williamr@2
  6705
The purpose of constructing an array in this way is to allow sorting and
williamr@2
  6706
finding operations to be done without further allocation of memory.
williamr@2
  6707
williamr@2
  6708
@param aEntries   A pointer to the first entry of type class TUint in the set of 
williamr@2
  6709
                  entries belonging to the existing array.
williamr@2
  6710
@param aCount     The number of entries in the existing array.
williamr@2
  6711
*/
williamr@2
  6712
	{}
williamr@2
  6713
williamr@2
  6714
williamr@2
  6715
williamr@2
  6716
inline void RArray<TUint>::GranularCompress()
williamr@2
  6717
/**
williamr@2
  6718
Compresses the array down to a granular boundary.
williamr@2
  6719
	
williamr@2
  6720
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  6721
for its contained entries. Adding new unsigned integers to the array does not 
williamr@2
  6722
result in a re-allocation of memory until the total number of entries reaches 
williamr@2
  6723
a multiple of the granularity.
williamr@2
  6724
*/
williamr@2
  6725
	{RPointerArrayBase::GranularCompress();}
williamr@2
  6726
williamr@2
  6727
williamr@2
  6728
williamr@2
  6729
williamr@2
  6730
inline TInt RArray<TUint>::Reserve(TInt aCount)
williamr@2
  6731
/**
williamr@2
  6732
Reserves space for the specified number of elements.
williamr@2
  6733
williamr@2
  6734
After a call to this function, the memory allocated to the array is sufficient 
williamr@2
  6735
to hold the number of integers specified. Adding new integers to the array 
williamr@2
  6736
does not result in a re-allocation of memory until the the total number of 
williamr@2
  6737
integers exceeds the specified count.
williamr@2
  6738
williamr@2
  6739
@param	aCount	The number of integers for which space should be reserved
williamr@2
  6740
@return	KErrNone		If the operation completed successfully
williamr@2
  6741
@return KErrNoMemory	If the requested amount of memory could not be allocated
williamr@2
  6742
*/
williamr@2
  6743
	{ return RPointerArrayBase::DoReserve(aCount); }
williamr@2
  6744
williamr@2
  6745
williamr@2
  6746
williamr@2
  6747
williamr@2
  6748
inline void RArray<TUint>::Sort()
williamr@2
  6749
/**
williamr@2
  6750
Sorts the array entries into unsigned integer order.
williamr@2
  6751
*/
williamr@2
  6752
	{ HeapSortUnsigned(); }
williamr@2
  6753
williamr@2
  6754
williamr@2
  6755
williamr@2
  6756
williamr@2
  6757
inline TArray<TUint> RArray<TUint>::Array() const
williamr@2
  6758
/**
williamr@2
  6759
Constructs and returns a generic array.
williamr@2
  6760
	
williamr@2
  6761
@return A generic array representing this array.
williamr@2
  6762
williamr@2
  6763
@see TArray
williamr@2
  6764
*/
williamr@2
  6765
	{ return TArray<TUint>(GetCount,GetElementPtr,(const CBase*)this); }
williamr@2
  6766
#endif
williamr@2
  6767
williamr@2
  6768
williamr@2
  6769
williamr@2
  6770
williamr@2
  6771
/**
williamr@2
  6772
Sets an argument to default value and type.
williamr@2
  6773
*/
williamr@2
  6774
inline void TIpcArgs::Set(TInt,TNothing)
williamr@2
  6775
	{}
williamr@2
  6776
williamr@2
  6777
williamr@2
  6778
williamr@2
  6779
williamr@2
  6780
/**
williamr@2
  6781
Sets an argument value of TInt type.
williamr@2
  6782
williamr@2
  6783
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6784
              into which the argument value is to be placed.
williamr@2
  6785
              This must be a value in the range 0 to 3.
williamr@2
  6786
@param aValue The argument value.              
williamr@2
  6787
*/
williamr@2
  6788
inline void TIpcArgs::Set(TInt aIndex,TInt aValue)
williamr@2
  6789
	{
williamr@2
  6790
	iArgs[aIndex] = aValue;
williamr@2
  6791
	iFlags |= EUnspecified<<(aIndex*KBitsPerType);
williamr@2
  6792
	}
williamr@2
  6793
williamr@2
  6794
williamr@2
  6795
williamr@2
  6796
williamr@2
  6797
/**
williamr@2
  6798
Sets an argument value of TAny* type.
williamr@2
  6799
williamr@2
  6800
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6801
              into which the argument value is to be placed.
williamr@2
  6802
              This must be a value in the range 0 to 3.
williamr@2
  6803
@param aValue The argument value.              
williamr@2
  6804
*/
williamr@2
  6805
inline void TIpcArgs::Set(TInt aIndex,const TAny* aValue)
williamr@2
  6806
	{
williamr@2
  6807
	iArgs[aIndex] = (TInt)aValue;
williamr@2
  6808
	iFlags |= EUnspecified<<(aIndex*KBitsPerType);
williamr@2
  6809
	}
williamr@2
  6810
williamr@2
  6811
williamr@2
  6812
williamr@2
  6813
williamr@2
  6814
/**
williamr@2
  6815
Sets an argument value of RHandleBase type.
williamr@2
  6816
williamr@2
  6817
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6818
              into which the argument value is to be placed.
williamr@2
  6819
              This must be a value in the range 0 to 3.
williamr@2
  6820
@param aValue The argument value.              
williamr@2
  6821
*/
williamr@2
  6822
inline void TIpcArgs::Set(TInt aIndex,RHandleBase aValue)
williamr@2
  6823
	{
williamr@2
  6824
	iArgs[aIndex] = (TInt)aValue.Handle();
williamr@2
  6825
	iFlags |= EHandle<<(aIndex*KBitsPerType);
williamr@2
  6826
	}
williamr@2
  6827
williamr@2
  6828
williamr@2
  6829
williamr@2
  6830
williamr@2
  6831
/**
williamr@2
  6832
Sets an argument value TDesC8* type.
williamr@2
  6833
williamr@2
  6834
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6835
              into which the argument value is to be placed.
williamr@2
  6836
              This must be a value in the range 0 to 3.
williamr@2
  6837
@param aValue The argument value.              
williamr@2
  6838
*/
williamr@2
  6839
inline void TIpcArgs::Set(TInt aIndex,const TDesC8* aValue)
williamr@2
  6840
	{
williamr@2
  6841
	iArgs[aIndex] = (TInt)aValue;
williamr@2
  6842
	iFlags |= EDesC8<<(aIndex*KBitsPerType);
williamr@2
  6843
	}
williamr@2
  6844
williamr@2
  6845
williamr@2
  6846
williamr@2
  6847
williamr@2
  6848
#ifndef __KERNEL_MODE__
williamr@2
  6849
williamr@2
  6850
/**
williamr@2
  6851
Sets an argument value of TDesC16* type.
williamr@2
  6852
williamr@2
  6853
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6854
              into which the argument value is to be placed.
williamr@2
  6855
              This must be a value in the range 0 to 3.
williamr@2
  6856
@param aValue The argument value.              
williamr@2
  6857
*/
williamr@2
  6858
inline void TIpcArgs::Set(TInt aIndex,const TDesC16* aValue)
williamr@2
  6859
	{
williamr@2
  6860
	iArgs[aIndex] = (TInt)aValue;
williamr@2
  6861
	iFlags |= EDesC16<<(aIndex*KBitsPerType);
williamr@2
  6862
	}
williamr@2
  6863
williamr@2
  6864
#endif
williamr@2
  6865
williamr@2
  6866
williamr@2
  6867
williamr@2
  6868
williamr@2
  6869
/**
williamr@2
  6870
Sets an argument value of TDes8* type.
williamr@2
  6871
williamr@2
  6872
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6873
              into which the argument value is to be placed.
williamr@2
  6874
              This must be a value in the range 0 to 3.
williamr@2
  6875
@param aValue The argument value.              
williamr@2
  6876
*/
williamr@2
  6877
inline void TIpcArgs::Set(TInt aIndex,TDes8* aValue)
williamr@2
  6878
	{
williamr@2
  6879
	iArgs[aIndex] = (TInt)aValue;
williamr@2
  6880
	iFlags |= EDes8<<(aIndex*KBitsPerType);
williamr@2
  6881
	}
williamr@2
  6882
williamr@2
  6883
williamr@2
  6884
williamr@2
  6885
williamr@2
  6886
#ifndef __KERNEL_MODE__
williamr@2
  6887
williamr@2
  6888
/**
williamr@2
  6889
Sets an argument value of TDes16* type.
williamr@2
  6890
williamr@2
  6891
@param aIndex An index value that identifies the slot in the array of arguments
williamr@2
  6892
              into which the argument value is to be placed.
williamr@2
  6893
              This must be a value in the range 0 to 3.
williamr@2
  6894
@param aValue The argument value.              
williamr@2
  6895
*/
williamr@2
  6896
inline void TIpcArgs::Set(TInt aIndex,TDes16* aValue)
williamr@2
  6897
	{
williamr@2
  6898
	iArgs[aIndex] = (TInt)aValue;
williamr@2
  6899
	iFlags |= EDes16<<(aIndex*KBitsPerType);
williamr@2
  6900
	}
williamr@2
  6901
williamr@2
  6902
#endif
williamr@2
  6903
williamr@2
  6904
williamr@4
  6905
/**
williamr@4
  6906
Allows the client to specify whether each argument of the TIpcArgs object will
williamr@4
  6907
be pinned before being sent to the server.
williamr@4
  6908
williamr@4
  6909
To pin all the arguments in the TIpcArgs object pass no parameters to this
williamr@4
  6910
method.
williamr@4
  6911
williamr@4
  6912
@return A reference to this TIpcArgs object that can be passed as a parameter to
williamr@4
  6913
		one of the overloads the DSession::Send() and DSession::SendReceive() methods.
williamr@4
  6914
*/
williamr@4
  6915
inline TIpcArgs& TIpcArgs::PinArgs(TBool aPinArg0, TBool aPinArg1, TBool aPinArg2, TBool aPinArg3)
williamr@4
  6916
	{
williamr@4
  6917
	__ASSERT_COMPILE(!((1 << ((KBitsPerType*KMaxMessageArguments)-1)) & KPinMask));
williamr@4
  6918
	if (aPinArg0)
williamr@4
  6919
		iFlags |= KPinArg0;
williamr@4
  6920
	if (aPinArg1)
williamr@4
  6921
		iFlags |= KPinArg1;
williamr@4
  6922
	if (aPinArg2)
williamr@4
  6923
		iFlags |= KPinArg2;
williamr@4
  6924
	if (aPinArg3)
williamr@4
  6925
		iFlags |= KPinArg3;
williamr@4
  6926
	return *this;
williamr@4
  6927
	}
williamr@2
  6928
williamr@2
  6929
williamr@2
  6930
inline TIpcArgs::TArgType TIpcArgs::Type(TNothing)
williamr@2
  6931
	{ return EUnspecified; }
williamr@2
  6932
inline TIpcArgs::TArgType TIpcArgs::Type(TInt)
williamr@2
  6933
	{ return EUnspecified; }
williamr@2
  6934
inline TIpcArgs::TArgType TIpcArgs::Type(const TAny*)
williamr@2
  6935
	{ return EUnspecified; }
williamr@2
  6936
inline TIpcArgs::TArgType TIpcArgs::Type(RHandleBase)
williamr@2
  6937
	{ return EHandle; }
williamr@2
  6938
inline TIpcArgs::TArgType TIpcArgs::Type(const TDesC8*)
williamr@2
  6939
	{ return EDesC8; }
williamr@2
  6940
#ifndef __KERNEL_MODE__
williamr@2
  6941
inline TIpcArgs::TArgType TIpcArgs::Type(const TDesC16*)
williamr@2
  6942
	{ return EDesC16; }
williamr@2
  6943
#endif
williamr@2
  6944
inline TIpcArgs::TArgType TIpcArgs::Type(TDes8*)
williamr@2
  6945
	{ return EDes8; }
williamr@2
  6946
#ifndef __KERNEL_MODE__
williamr@2
  6947
inline TIpcArgs::TArgType TIpcArgs::Type(TDes16*)
williamr@2
  6948
	{ return EDes16; }
williamr@2
  6949
#endif
williamr@2
  6950
inline void TIpcArgs::Assign(TInt&,TIpcArgs::TNothing)
williamr@2
  6951
	{}
williamr@2
  6952
inline void TIpcArgs::Assign(TInt& aArg,TInt aValue)
williamr@2
  6953
	{ aArg = aValue; }
williamr@2
  6954
inline void TIpcArgs::Assign(TInt& aArg,const TAny* aValue)
williamr@2
  6955
	{ aArg = (TInt)aValue; }
williamr@2
  6956
inline void TIpcArgs::Assign(TInt& aArg,RHandleBase aValue)
williamr@2
  6957
	{ aArg = (TInt)aValue.Handle(); }
williamr@2
  6958
inline void TIpcArgs::Assign(TInt& aArg,const TDesC8* aValue)
williamr@2
  6959
	{ aArg = (TInt)aValue; }
williamr@2
  6960
#ifndef __KERNEL_MODE__
williamr@2
  6961
inline void TIpcArgs::Assign(TInt& aArg,const TDesC16* aValue)
williamr@2
  6962
	{ aArg = (TInt)aValue; }
williamr@2
  6963
#endif
williamr@2
  6964
inline void TIpcArgs::Assign(TInt& aArg,TDes8* aValue)
williamr@2
  6965
	{ aArg = (TInt)aValue; }
williamr@2
  6966
#ifndef __KERNEL_MODE__
williamr@2
  6967
inline void TIpcArgs::Assign(TInt& aArg,TDes16* aValue)
williamr@2
  6968
	{ aArg = (TInt)aValue; }
williamr@2
  6969
#endif
williamr@2
  6970
williamr@2
  6971
williamr@2
  6972
williamr@2
  6973
// Structures for passing 64 bit integers and doubles across GCC/EABI boundaries
williamr@2
  6974
williamr@2
  6975
inline SInt64::SInt64()
williamr@2
  6976
	{}
williamr@2
  6977
williamr@2
  6978
inline SInt64::SInt64(Int64 a)
williamr@2
  6979
	{
williamr@2
  6980
	iData[0] = (TUint32)((Uint64)a);
williamr@2
  6981
	iData[1] = (TUint32)(((Uint64)a)>>32);
williamr@2
  6982
	}
williamr@2
  6983
williamr@2
  6984
inline SInt64& SInt64::operator=(Int64 a)
williamr@2
  6985
	{
williamr@2
  6986
	iData[0] = (TUint32)((Uint64)a);
williamr@2
  6987
	iData[1] = (TUint32)(((Uint64)a)>>32);
williamr@2
  6988
	return *this;
williamr@2
  6989
	}
williamr@2
  6990
williamr@2
  6991
inline SInt64::operator Int64() const
williamr@2
  6992
	{
williamr@2
  6993
	Int64 x;
williamr@2
  6994
	TUint32* px = (TUint32*)&x;
williamr@2
  6995
	px[0] = iData[0];
williamr@2
  6996
	px[1] = iData[1];
williamr@2
  6997
	return x;
williamr@2
  6998
	}
williamr@2
  6999
williamr@2
  7000
inline SUint64::SUint64()
williamr@2
  7001
	{}
williamr@2
  7002
williamr@2
  7003
inline SUint64::SUint64(Uint64 a)
williamr@2
  7004
	{
williamr@2
  7005
	iData[0] = (TUint32)a;
williamr@2
  7006
	iData[1] = (TUint32)(a>>32);
williamr@2
  7007
	}
williamr@2
  7008
williamr@2
  7009
inline SUint64& SUint64::operator=(Uint64 a)
williamr@2
  7010
	{
williamr@2
  7011
	iData[0] = (TUint32)a;
williamr@2
  7012
	iData[1] = (TUint32)(a>>32);
williamr@2
  7013
	return *this;
williamr@2
  7014
	}
williamr@2
  7015
williamr@2
  7016
inline SUint64::operator Uint64() const
williamr@2
  7017
	{
williamr@2
  7018
	Uint64 x;
williamr@2
  7019
	TUint32* px = (TUint32*)&x;
williamr@2
  7020
	px[0] = iData[0];
williamr@2
  7021
	px[1] = iData[1];
williamr@2
  7022
	return x;
williamr@2
  7023
	}
williamr@2
  7024
williamr@2
  7025
inline SDouble::SDouble()
williamr@2
  7026
	{}
williamr@2
  7027
williamr@2
  7028
inline SDouble::SDouble(TReal a)
williamr@2
  7029
	{
williamr@2
  7030
	const TUint32* pa = (const TUint32*)&a;
williamr@2
  7031
#ifdef __DOUBLE_WORDS_SWAPPED__
williamr@2
  7032
	iData[0] = pa[1];
williamr@2
  7033
	iData[1] = pa[0];	// compiler puts MS word of double first
williamr@2
  7034
#else
williamr@2
  7035
	iData[0] = pa[0];
williamr@2
  7036
	iData[1] = pa[1];	// compiler puts MS word of double second
williamr@2
  7037
#endif
williamr@2
  7038
	}
williamr@2
  7039
williamr@2
  7040
inline SDouble& SDouble::operator=(TReal a)
williamr@2
  7041
	{
williamr@2
  7042
	new (this) SDouble(a);
williamr@2
  7043
	return *this;
williamr@2
  7044
	}
williamr@2
  7045
williamr@2
  7046
inline SDouble::operator TReal() const
williamr@2
  7047
	{
williamr@2
  7048
	TReal x;
williamr@2
  7049
	TUint32* px = (TUint32*)&x;
williamr@2
  7050
#ifdef __DOUBLE_WORDS_SWAPPED__
williamr@2
  7051
	px[1] = iData[0];
williamr@2
  7052
	px[0] = iData[1];	// compiler puts MS word of double first
williamr@2
  7053
#else
williamr@2
  7054
	px[0] = iData[0];
williamr@2
  7055
	px[1] = iData[1];	// compiler puts MS word of double second
williamr@2
  7056
#endif
williamr@2
  7057
	return x;
williamr@2
  7058
	}
williamr@2
  7059
williamr@2
  7060
//
williamr@2
  7061
// TSecureId
williamr@2
  7062
//
williamr@2
  7063
williamr@2
  7064
/** Default constructor. This leaves the object in an undefined state */
williamr@2
  7065
inline TSecureId::TSecureId()
williamr@2
  7066
	{}
williamr@2
  7067
williamr@2
  7068
/** Construct 'this' using a TUint32
williamr@2
  7069
@param aId The value for the ID */
williamr@2
  7070
inline TSecureId::TSecureId(TUint32 aId)
williamr@2
  7071
	: iId(aId) {}
williamr@2
  7072
williamr@2
  7073
/** Convert 'this' into a TUint32
williamr@2
  7074
*/
williamr@2
  7075
inline TSecureId::operator TUint32() const
williamr@2
  7076
	{ return iId; }
williamr@2
  7077
williamr@2
  7078
/** Construct 'this' using a TUid
williamr@2
  7079
@param aId The value for the ID */
williamr@2
  7080
inline TSecureId::TSecureId(TUid aId)
williamr@2
  7081
	: iId(aId.iUid) {}
williamr@2
  7082
williamr@2
  7083
/** Convert 'this' into a TUid
williamr@2
  7084
*/
williamr@2
  7085
inline TSecureId::operator TUid() const
williamr@2
  7086
	{ return (TUid&)iId; }
williamr@2
  7087
williamr@2
  7088
//
williamr@2
  7089
// SSecureId
williamr@2
  7090
//
williamr@2
  7091
inline const TSecureId* SSecureId::operator&() const
williamr@2
  7092
	{ return (const TSecureId*)this; }
williamr@2
  7093
inline SSecureId::operator const TSecureId&() const
williamr@4
  7094
	{ /* coverity[return_local_addr] */ return (const TSecureId&)iId; }
williamr@2
  7095
inline SSecureId::operator TUint32() const
williamr@2
  7096
	{ return iId; }
williamr@2
  7097
inline SSecureId::operator TUid() const
williamr@2
  7098
	{ return (TUid&)iId; }
williamr@2
  7099
williamr@2
  7100
//
williamr@2
  7101
// TVendorId
williamr@2
  7102
//
williamr@2
  7103
williamr@2
  7104
/** Default constructor which leaves the object in an undefined state */
williamr@2
  7105
inline TVendorId::TVendorId()
williamr@2
  7106
	{}
williamr@2
  7107
williamr@2
  7108
/** Construct 'this' using a TUint32
williamr@2
  7109
@param aId The value for the ID */
williamr@2
  7110
inline TVendorId::TVendorId(TUint32 aId)
williamr@2
  7111
	: iId(aId) {}
williamr@2
  7112
williamr@2
  7113
/** Convert 'this' into a TUint32
williamr@2
  7114
*/
williamr@2
  7115
inline TVendorId::operator TUint32() const
williamr@2
  7116
	{ return iId; }
williamr@2
  7117
williamr@2
  7118
/** Construct 'this' using a TUid
williamr@2
  7119
@param aId The value for the ID */
williamr@2
  7120
inline TVendorId::TVendorId(TUid aId)
williamr@2
  7121
	: iId(aId.iUid) {}
williamr@2
  7122
williamr@2
  7123
/** Convert 'this' into a TUid
williamr@2
  7124
*/
williamr@2
  7125
inline TVendorId::operator TUid() const
williamr@2
  7126
	{ return (TUid&)iId; }
williamr@2
  7127
williamr@2
  7128
//
williamr@2
  7129
// SSecureId
williamr@2
  7130
//
williamr@2
  7131
inline const TVendorId* SVendorId::operator&() const
williamr@2
  7132
	{ return (const TVendorId*)this; }
williamr@2
  7133
inline SVendorId::operator const TVendorId&() const
williamr@4
  7134
	{ /* coverity[return_local_addr] */ return (const TVendorId&)iId; }
williamr@2
  7135
inline SVendorId::operator TUint32() const
williamr@2
  7136
	{ return iId; }
williamr@2
  7137
inline SVendorId::operator TUid() const
williamr@2
  7138
	{ return (TUid&)iId; }
williamr@2
  7139
williamr@2
  7140
//
williamr@2
  7141
// TSharedChunkBufConfigBase
williamr@2
  7142
// 
williamr@2
  7143
inline TSharedChunkBufConfigBase::TSharedChunkBufConfigBase()
williamr@2
  7144
	{memset(this,0,sizeof(TSharedChunkBufConfigBase));}
williamr@2
  7145
williamr@2
  7146
/**
williamr@2
  7147
Default constructor. This leaves the set in an undefned state.
williamr@2
  7148
*/
williamr@2
  7149
inline TCapabilitySet::TCapabilitySet()
williamr@2
  7150
	{}
williamr@2
  7151
williamr@2
  7152
/**
williamr@2
  7153
Construct a set consisting of a single capability.
williamr@2
  7154
@param aCapability The single capability
williamr@2
  7155
*/
williamr@2
  7156
inline TCapabilitySet::TCapabilitySet(TCapability aCapability)
williamr@2
  7157
	{ new (this) TCapabilitySet(aCapability, aCapability); }
williamr@2
  7158
williamr@2
  7159
/**
williamr@2
  7160
Make this set consist of a single capability.
williamr@2
  7161
@param aCapability The single capability.
williamr@2
  7162
*/
williamr@2
  7163
inline void TCapabilitySet::Set(TCapability aCapability)
williamr@2
  7164
	{ new (this) TCapabilitySet(aCapability, aCapability); }
williamr@2
  7165
williamr@2
  7166
/**
williamr@2
  7167
Make this set consist of two capabilities.
williamr@2
  7168
@param aCapability1 The first capability.
williamr@2
  7169
@param aCapability2 The second capability.
williamr@2
  7170
*/
williamr@2
  7171
inline void TCapabilitySet::Set(TCapability aCapability1, TCapability aCapability2)
williamr@2
  7172
	{ new (this) TCapabilitySet(aCapability1, aCapability2); }
williamr@2
  7173
williamr@2
  7174
williamr@2
  7175
/**
williamr@2
  7176
Default constructor. This leaves the object in an undefned state.
williamr@2
  7177
*/
williamr@2
  7178
inline TSecurityInfo::TSecurityInfo()
williamr@2
  7179
	{}
williamr@2
  7180
williamr@2
  7181
/** Constructs a TSecurityPolicy that will always fail, irrespective of the
williamr@2
  7182
checked object's attributes.
williamr@2
  7183
*/
williamr@2
  7184
inline TSecurityPolicy::TSecurityPolicy()
williamr@2
  7185
	{ new (this) TSecurityPolicy(EAlwaysFail); }
williamr@2
  7186
williamr@2
  7187
/**
williamr@2
  7188
'Address of' operator which generates a TSecurityPolicy*
williamr@2
  7189
@return A pointer of type TSecurityPolicy which refers to this object
williamr@2
  7190
*/
williamr@2
  7191
inline const TSecurityPolicy* TStaticSecurityPolicy::operator&() const
williamr@2
  7192
	{ return (const TSecurityPolicy*)this; }
williamr@2
  7193
williamr@2
  7194
/**
williamr@2
  7195
'Reference of' operator which generates a TSecurityPolicy&
williamr@2
  7196
@return A reference of type TSecurityPolicy which refers to this object
williamr@2
  7197
*/
williamr@2
  7198
inline TStaticSecurityPolicy::operator const TSecurityPolicy&() const
williamr@2
  7199
	{ return *(const TSecurityPolicy*)this; }
williamr@2
  7200
williamr@2
  7201
/**
williamr@2
  7202
A method to explicity generate a TSecurityPolicy reference.
williamr@2
  7203
@return A reference of type TSecurityPolicy which refers to this object
williamr@2
  7204
*/
williamr@2
  7205
inline const TSecurityPolicy& TStaticSecurityPolicy::operator()() const
williamr@2
  7206
	{ return *(const TSecurityPolicy*)this; }
williamr@2
  7207
williamr@2
  7208
#ifdef __KERNEL_MODE__
williamr@2
  7209
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
williamr@2
  7210
williamr@2
  7211
/** Checks this policy against the platform security attributes of aProcess.
williamr@2
  7212
williamr@2
  7213
	When a check fails the action taken is determined by the system wide Platform Security
williamr@2
  7214
	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
williamr@2
  7215
	If PlatSecEnforcement is OFF, then this function will return ETrue even though the
williamr@2
  7216
	check failed.
williamr@2
  7217
williamr@2
  7218
@param aProcess The DProcess object to check against this TSecurityPolicy.
williamr@2
  7219
@param aDiagnostic A string that will be emitted along with any diagnostic message
williamr@2
  7220
							that may be issued if the policy check fails.
williamr@2
  7221
							This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
williamr@2
  7222
							which enables it to be easily removed from the system.
williamr@2
  7223
@return ETrue if all the requirements of this TSecurityPolicy are met by the
williamr@2
  7224
platform security attributes of aProcess, EFalse otherwise.
williamr@2
  7225
@panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object
williamr@2
  7226
*/
williamr@2
  7227
inline TBool TSecurityPolicy::CheckPolicy(DProcess* aProcess, const char* aDiagnostic) const
williamr@2
  7228
	{
williamr@2
  7229
	return DoCheckPolicy(aProcess, aDiagnostic);
williamr@2
  7230
	}
williamr@2
  7231
williamr@2
  7232
/** Checks this policy against the platform security attributes of the process
williamr@2
  7233
owning aThread.
williamr@2
  7234
williamr@2
  7235
	When a check fails the action taken is determined by the system wide Platform Security
williamr@2
  7236
	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
williamr@2
  7237
	If PlatSecEnforcement is OFF, then this function will return ETrue even though the
williamr@2
  7238
	check failed.
williamr@2
  7239
williamr@2
  7240
@param aThread The thread whose owning process' platform security attributes
williamr@2
  7241
are to be checked against this TSecurityPolicy.
williamr@2
  7242
@param aDiagnostic A string that will be emitted along with any diagnostic message
williamr@2
  7243
							that may be issued if the policy check fails.
williamr@2
  7244
							This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
williamr@2
  7245
							which enables it to be easily removed from the system.
williamr@2
  7246
@return ETrue if all the requirements of this TSecurityPolicy are met by the
williamr@2
  7247
platform security parameters of the owning process of aThread, EFalse otherwise.
williamr@2
  7248
@panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object
williamr@2
  7249
*/
williamr@2
  7250
inline TBool TSecurityPolicy::CheckPolicy(DThread* aThread, const char* aDiagnostic) const
williamr@2
  7251
	{
williamr@2
  7252
	return DoCheckPolicy(aThread, aDiagnostic);
williamr@2
  7253
	}
williamr@2
  7254
williamr@2
  7255
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
williamr@2
  7256
williamr@2
  7257
/** Checks this policy against the platform security attributes of aProcess.
williamr@2
  7258
williamr@2
  7259
	When a check fails the action taken is determined by the system wide Platform Security
williamr@2
  7260
	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
williamr@2
  7261
	If PlatSecEnforcement is OFF, then this function will return ETrue even though the
williamr@2
  7262
	check failed.
williamr@2
  7263
williamr@2
  7264
@param aProcess The DProcess object to check against this TSecurityPolicy.
williamr@2
  7265
@param aDiagnostic A string that will be emitted along with any diagnostic message
williamr@2
  7266
							that may be issued if the policy check fails.
williamr@2
  7267
							This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
williamr@2
  7268
							which enables it to be easily removed from the system.
williamr@2
  7269
@return ETrue if all the requirements of this TSecurityPolicy are met by the
williamr@2
  7270
platform security attributes of aProcess, EFalse otherwise.
williamr@2
  7271
@panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object
williamr@2
  7272
*/
williamr@2
  7273
inline TBool TSecurityPolicy::CheckPolicy(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/) const
williamr@2
  7274
	{
williamr@2
  7275
	return DoCheckPolicy(aProcess);
williamr@2
  7276
	}
williamr@2
  7277
williamr@2
  7278
/** Checks this policy against the platform security attributes of the process
williamr@2
  7279
owning aThread.
williamr@2
  7280
williamr@2
  7281
	When a check fails the action taken is determined by the system wide Platform Security
williamr@2
  7282
	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
williamr@2
  7283
	If PlatSecEnforcement is OFF, then this function will return ETrue even though the
williamr@2
  7284
	check failed.
williamr@2
  7285
williamr@2
  7286
@param aThread The thread whose owning process' platform security attributes
williamr@2
  7287
are to be checked against this TSecurityPolicy.
williamr@2
  7288
@param aDiagnostic A string that will be emitted along with any diagnostic message
williamr@2
  7289
							that may be issued if the policy check fails.
williamr@2
  7290
							This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
williamr@2
  7291
							which enables it to be easily removed from the system.
williamr@2
  7292
@return ETrue if all the requirements of this TSecurityPolicy are met by the
williamr@2
  7293
platform security parameters of the owning process of aThread, EFalse otherwise.
williamr@2
  7294
@panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object
williamr@2
  7295
*/
williamr@2
  7296
inline TBool TSecurityPolicy::CheckPolicy(DThread* aThread, OnlyCreateWithNull /*aDiagnostic*/) const
williamr@2
  7297
	{
williamr@2
  7298
	return DoCheckPolicy(aThread);
williamr@2
  7299
	}
williamr@2
  7300
williamr@2
  7301
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
williamr@2
  7302
#endif // __KERNEL_MODE__