os/kernelhwsrv/kernel/eka/include/e32cmn.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32\include\e32cmn.h
    15 // 
    16 //
    17 
    18 #ifndef __E32CMN_H__
    19 #define __E32CMN_H__
    20 #include <e32const.h>
    21 
    22 extern "C" {
    23 /**
    24 @publishedAll
    25 @released
    26 
    27 A Nanokernel utility function that compares two memory buffers for equality.
    28 
    29 The two buffers are considered equal only if:
    30 
    31 1. the buffers have the same length
    32 
    33 and
    34  
    35 2. the binary content of both buffers is the same.
    36 
    37 @param aLeft     The start address of the first buffer in the comparison.
    38 @param aLeftLen  The length of the first buffer in the comparison.
    39 @param aRight    The start address of the second buffer in the comparison.
    40 @param aRightLen The length of the second buffer in the comparison.
    41 
    42 @return Zero if both buffers are equal; non-zero, otherwise.
    43 
    44 @panic USER 88        In debug mode only, if aLeftL is negative, 
    45                       and the function is called on the user side.
    46 @panic KERN-COMMON 88 In debug mode only, if aLeftL is negative,
    47                       and the function is called on the kernel side.
    48 @panic USER 89        In debug mode only, if aRightL is negative, 
    49                       and the function is called on the user side.
    50 @panic KERN-COMMON 89 In debug mode only, if aRightL is negative,
    51                       and the function is called on the kernel side.
    52 */
    53 IMPORT_C TInt memcompare(const TUint8* aLeft, TInt aLeftLen, const TUint8* aRight, TInt aRightLen);
    54 
    55 
    56 
    57 
    58 /**
    59 @publishedAll
    60 @released
    61 
    62 A Nanokernel utility function that moves (copies) bytes in memory.
    63 
    64 The function assumes that the addresses are aligned on word boundaries,
    65 and that the length value is a multiple of 4.
    66 
    67 @param aTrg    The target address.
    68 @param aSrc    The source address.
    69 @param aLength The number of bytes to be moved.
    70 
    71 @return The target address.
    72 
    73 @panic USER 91        In debug mode only, if aLength is not a multiple of 4,
    74                       and the function is called on the user side.
    75 @panic KERN-COMMON 91 In debug mode only, if aLength is not a multiple of 4,
    76                       and the function is called on the kernel side.
    77 @panic USER 92        In debug mode only, if aSrc is not aligned on a word boundary,
    78                       and the function is called on the user side.
    79 @panic KERN-COMMON 92 In debug mode only, if aSrc is not aligned on a word boundary,
    80                       and the function is called on the kernel side.
    81 @panic USER 93        In debug mode only, if aTrg is not aligned on a word boundary,
    82                       and the function is called on the user side.
    83 @panic KERN-COMMON 93 In debug mode only, if aTrg is not aligned on a word boundary,
    84                       and the function is called on the kernel side.
    85 */
    86 IMPORT_C TAny* wordmove(TAny* aTrg, const TAny* aSrc, unsigned int aLength);
    87 
    88 
    89 
    90 
    91 /**
    92 @publishedAll
    93 @released
    94 
    95 A Nanokernel utility function that sets the specified number of bytes
    96 to binary zero.
    97 
    98 @param aTrg    The start address.
    99 @param aLength The number of bytes to be set.
   100 
   101 @return The target address.
   102 */
   103 IMPORT_C TAny* memclr(TAny* aTrg, unsigned int aLength);
   104 }
   105 
   106 
   107 
   108 
   109 #ifndef __TOOLS__
   110 extern "C" {
   111 /**
   112 @publishedAll
   113 @released
   114 
   115 A Nanokernel utility function that sets all of the specified number of bytes to
   116 the specified fill value.
   117 
   118 @param aTrg    The start address.
   119 @param aValue  The fill value (the first or junior byte).
   120 @param aLength The number of bytes to be set.
   121 
   122 @return The target address.
   123 */
   124 	IMPORT_C TAny* memset(TAny* aTrg, TInt aValue, unsigned int aLength);
   125 
   126 
   127 
   128 
   129 /**
   130 @publishedAll
   131 @released
   132 
   133 A Nanokernel utility function that copies bytes in memory.
   134 
   135 @param aTrg    The target address.
   136 @param aSrc    The source address.
   137 @param aLength The number of bytes to be moved.
   138 
   139 @return The target address.
   140 */
   141 	IMPORT_C TAny* memcpy(TAny* aTrg, const TAny* aSrc, unsigned int aLength);
   142 
   143 
   144 
   145 
   146 /**
   147 @publishedAll
   148 @released
   149 
   150 A Nanokernel utility function that moves (copies) bytes in memory.
   151 
   152 @param aTrg    The target address.
   153 @param aSrc    The source address.
   154 @param aLength The number of bytes to be moved.
   155 
   156 @return The target address.
   157 */
   158 	IMPORT_C TAny* memmove(TAny* aTrg, const TAny* aSrc, unsigned int aLength);
   159 }
   160 #else
   161 #include <string.h>
   162 #endif
   163 
   164 
   165 
   166 
   167 /** 
   168 @publishedAll
   169 @released
   170 
   171 Tests whether the specified value is less than or equal to the
   172 specified upper limit.
   173 
   174 @param aVal   The value to be tested.
   175 @param aLimit The upper limit.
   176 
   177 @return True, if the value is less than or equal to the specified upper limit;
   178         false, otherwise.
   179 */
   180 inline TInt Lim(TInt aVal,TUint aLimit)
   181 	{return(((TUint)aVal)<=aLimit);}
   182 
   183 
   184 
   185 
   186 /** 
   187 @publishedAll
   188 @released
   189 
   190 Tests whether the specified value is strictly less than the
   191 specified upper limit.
   192 
   193 @param aVal   The value to be tested.
   194 @param aLimit The upper limit.
   195 
   196 @return True, if the value is strictly less than the specified upper limit;
   197         false, otherwise.
   198 */
   199 inline TInt LimX(TInt aVal,TUint aLimit)
   200 	{return(((TUint)aVal)<aLimit);}
   201 
   202 
   203 
   204 
   205 /** 
   206 @publishedAll
   207 @released
   208 
   209 Returns the smaller of two values.
   210 
   211 @param aLeft  The first value to be compared.
   212 @param aRight The second value to be compared.
   213 
   214 @return The smaller value.
   215 */
   216 template <class T>
   217 inline T Min(T aLeft,T aRight)
   218 	{return(aLeft<aRight ? aLeft : aRight);}
   219 
   220 
   221 
   222 
   223 /**
   224 @publishedAll
   225 @released
   226 
   227 Returns the smaller of two objects, where the right hand object is a treated
   228 as a TInt for the  purpose of comparison.
   229 
   230 @param aLeft  The first value to be compared.
   231 @param aRight The second value to be compared.
   232 
   233 @return The smaller value.
   234 */
   235 template <class T>
   236 inline T Min(T aLeft,TUint aRight)
   237 	{return(aLeft<(TInt)aRight ? aLeft : (T)aRight);}
   238 
   239 
   240 
   241 
   242 /** 
   243 @publishedAll
   244 @released
   245 
   246 Returns the larger of two values.
   247 
   248 @param aLeft  The first value to be compared.
   249 @param aRight The second value to be compared.
   250 
   251 @return The larger value.
   252 */
   253 template <class T>
   254 inline T Max(T aLeft,T aRight)
   255 	{return(aLeft<aRight ? aRight : aLeft);}
   256 
   257 
   258 
   259 
   260 /**
   261 @publishedAll
   262 @released
   263 
   264 Returns the larger of two objects, where the right hand object is a treated
   265 as a TInt for the  purpose of comparison.
   266 
   267 @param aLeft  The first value to be compared.
   268 @param aRight The second value to be compared.
   269 
   270 @return The larger value.
   271 */
   272 template <class T>
   273 inline T Max(T aLeft,TUint aRight)
   274 	{return(aLeft<(TInt)aRight ? (TInt)aRight : aLeft);}
   275 
   276 
   277 
   278 
   279 /**
   280 @publishedAll
   281 @released
   282 
   283 Returns an absolute value.
   284 
   285 @param aVal The source value.
   286 
   287 @return The absolute value
   288 */
   289 template <class T>
   290 inline T Abs(T aVal)
   291 	{return(aVal<0 ? -aVal : aVal);}
   292 
   293 
   294 
   295 
   296 /** 
   297 @publishedAll
   298 @released
   299 
   300 Determines whether a specified value lies within a defined range of values.
   301 
   302 @param aMin The lower value of the range.
   303 @param aVal The value to be compared.
   304 @param aMax The higher value of the range.
   305 
   306 @return True, if the specified value lies within the range; false, otherwise.
   307 */
   308 template <class T>
   309 inline TBool Rng(T aMin,T aVal,T aMax)
   310 	{return(aVal>=aMin && aVal<=aMax);}
   311 
   312 
   313 
   314 
   315 /**
   316 @publishedAll
   317 @released
   318 
   319 Adds a value to a pointer.
   320 
   321 @param aPtr Pointer to an object of type T.
   322 @param aVal The value to be added.
   323 
   324 @return The resulting pointer value, as a pointer to a type T.
   325 */
   326 template <class T,class S>
   327 inline T* PtrAdd(T* aPtr,S aVal)
   328 	{return((T*)(((TUint8*)aPtr)+aVal));}
   329 
   330 
   331 
   332 
   333 /**
   334 @publishedAll
   335 @released
   336 
   337 Subtracts a value from a pointer.
   338 
   339 @param aPtr Pointer to an object of type T.
   340 @param aVal The value to be added.
   341 
   342 @return The resulting pointer value, as a pointer to a type T.
   343 */
   344 template <class T,class S>
   345 inline T* PtrSub(T* aPtr,S aVal)
   346 	{return((T*)(((TUint8*)aPtr)-aVal));}
   347 
   348 
   349 
   350 
   351 /**
   352 @publishedAll
   353 @released
   354 
   355 Aligns the specified value onto a 2-byte boundary.
   356 
   357 @param aValue The value to be aligned.
   358 
   359 @return The aligned value. 
   360 */
   361 template <class T>
   362 inline T Align2(T aValue)
   363 	{return((T)((((TUint)aValue)+sizeof(TUint16)-1)&~(sizeof(TUint16)-1)));}
   364 
   365 
   366 
   367 
   368 /**
   369 @publishedAll
   370 @released
   371 
   372 Aligns the specified value onto a 4-byte boundary.
   373 
   374 @param aValue The value to be aligned.
   375 
   376 @return The aligned value. 
   377 */
   378 template <class T>
   379 inline T Align4(T aValue)
   380 	{return((T)((((TUint)aValue)+sizeof(TUint32)-1)&~(sizeof(TUint32)-1)));}
   381 
   382 
   383 
   384 
   385 /**
   386 @publishedAll
   387 @released
   388 
   389 A templated class which encapsulates a reference to an object within a wrapper.
   390 
   391 The wrapper object can be passed to a function as a value type. This allows 
   392 a reference to be passed to a function as a value type.
   393 
   394 This wrapper object is commonly termed a value reference.
   395 */
   396 template <class T>
   397 class TRefByValue
   398 	{
   399 public:
   400 	inline TRefByValue(T& aRef);
   401 	inline operator T&();
   402 private:
   403 	TRefByValue& operator=(TRefByValue aRef);
   404 private:
   405 	T &iRef;
   406 	};
   407 
   408 
   409 
   410 
   411 #if !defined (__KERNEL_MODE__)
   412 class TDesC16;	// forward declaration for TChar member functions
   413 class TPtrC16;	// forward declaration for TChar member functions
   414 #endif
   415 
   416 
   417 
   418 
   419 /**
   420 @publishedAll
   421 @released
   422 
   423 Holds a character value and provides a number of utility functions to
   424 manipulate it and test its properties.
   425 
   426 For example, there are functions to convert the character 
   427 to uppercase and test whether or not it is a control character.
   428 
   429 The character value is stored as a 32-bit unsigned integer. The shorthand 
   430 "TChar value" is used to describe the character value wrapped by a TChar 
   431 object.
   432 
   433 TChar can be used to represent Unicode values outside plane 0 (that is, the 
   434 extended Unicode range from 0x10000 to 0xFFFFF). This differentiates it from 
   435 TText which can only be used for 16-bit Unicode character values.
   436 
   437 @see TText
   438 */
   439 class TChar
   440 	{
   441 public:
   442 
   443 	
   444     /**
   445     General Unicode character category.
   446 
   447     The high nibble encodes the major category (Mark, Number, etc.) and a low 
   448     nibble encodes the subdivisions of that category.
   449 
   450     The category codes can be used in three ways:
   451     
   452     (i) as unique constants: there is one for each Unicode category, with a
   453     name of the form
   454     @code
   455     E<XX>Category
   456     @endcode
   457     where
   458     @code
   459     <XX>
   460     @endcode
   461     is the category name given by
   462     the Unicode database (e.g., the constant ELuCategory is used for lowercase
   463     letters, category Lu);
   464     
   465     (ii) as numbers in certain ranges: letter categories are all <= EMaxLetterCategory;
   466     
   467     (iii) as codes in which the upper nibble gives the category group
   468     (e.g., punctuation categories all yield TRUE for
   469     the test (category & 0xF0) ==EPunctuationGroup).
   470     */
   471 	enum TCategory
   472 		{
   473         /**
   474         Alphabetic letters.
   475 	
   476         Includes ELuCategory, ELlCategory and ELtCategory.
   477         */
   478 		EAlphaGroup = 0x00,								
   479         
   480         
   481         /**
   482         Other letters.
   483 	
   484         Includes ELoCategory.
   485         */
   486 		ELetterOtherGroup = 0x10,						
   487         
   488         
   489         /**
   490         Letter modifiers.
   491 	
   492         Includes ELmCategory.
   493         */
   494 		ELetterModifierGroup = 0x20,					
   495         
   496         
   497         /**
   498         Marks group.
   499 	
   500         Includes EMnCategory, EMcCategory and EMeCategory.
   501         */
   502 		EMarkGroup = 0x30,
   503         
   504         
   505         /**
   506         Numbers group.
   507 	
   508 	    Includes ENdCategory, ENlCategory and ENoCategory.
   509 	    */
   510 		ENumberGroup = 0x40,
   511         
   512         
   513         /**
   514         Punctuation group.
   515 	
   516 	    IncludesEPcCategory, PdCategory, EpeCategory, EPsCategory and EPoCategory.
   517 	    */
   518 		EPunctuationGroup = 0x50,
   519         
   520         
   521         /**
   522         Symbols group.
   523 	
   524         Includes ESmCategory, EScCategory, ESkCategory and ESoCategory.
   525         */
   526 		ESymbolGroup = 0x60,
   527         
   528         
   529         /**
   530         Separators group.
   531 	
   532         Includes EZsCategory, EZlCategory and EZlpCategory.
   533         */
   534 		ESeparatorGroup = 0x70,
   535         
   536         
   537         /**
   538         Control, format, private use, unassigned.
   539 	
   540      	Includes ECcCategory, ECtCategory, ECsCategory,
   541      	ECoCategory and ECnCategory.
   542      	*/
   543 		EControlGroup = 0x80,
   544 	    
   545 	    
   546 	    /**
   547 	    The highest possible groups category.
   548 	    */
   549 		EMaxAssignedGroup = 0xE0,
   550         
   551         
   552         /**
   553         Unassigned to any other group.
   554         */
   555 		EUnassignedGroup = 0xF0,
   556 
   557 
   558         /**
   559         Letter, Uppercase.
   560         */
   561 		ELuCategory = EAlphaGroup | 0,					
   562         
   563         
   564         /**
   565         Letter, Lowercase.
   566         */
   567 		ELlCategory = EAlphaGroup | 1,					
   568 	    
   569 	    
   570 	    /**
   571 	    Letter, Titlecase.
   572 	    */
   573 		ELtCategory = EAlphaGroup | 2,					
   574      	
   575      	
   576      	/**
   577      	Letter, Other.
   578      	*/
   579 		ELoCategory = ELetterOtherGroup | 0,			
   580 	    
   581 	    
   582 	    /**
   583 	    The highest possible (non-modifier) letter category.
   584 	    */
   585 		EMaxLetterCategory = ELetterOtherGroup | 0x0F,	
   586 
   587 	    /**
   588 	    Letter, Modifier.
   589 	    */
   590 		ELmCategory = ELetterModifierGroup | 0,			
   591 	    
   592 	    
   593 	    /**
   594 	    The highest possible letter category.
   595 	    */
   596 		EMaxLetterOrLetterModifierCategory = ELetterModifierGroup | 0x0F, 
   597 
   598 	    /**
   599 	    Mark, Non-Spacing
   600 	    */
   601 		EMnCategory = EMarkGroup | 0,					
   602         
   603         
   604         /**
   605         Mark, Combining.
   606         */
   607 		EMcCategory = EMarkGroup | 1,					
   608         
   609         
   610         /**
   611         Mark, Enclosing.
   612         */
   613 		EMeCategory = EMarkGroup | 2,					
   614         
   615         
   616         /**
   617         Number, Decimal Digit.
   618         */
   619 		ENdCategory = ENumberGroup | 0,					
   620         
   621         
   622         /**
   623         Number, Letter.
   624         */
   625 		ENlCategory = ENumberGroup | 1,					
   626         
   627         
   628         /**
   629         Number, Other.
   630         */
   631 		ENoCategory = ENumberGroup | 2,					
   632         
   633         
   634         /**
   635         Punctuation, Connector.
   636         */
   637 		EPcCategory = EPunctuationGroup | 0,			
   638         
   639         
   640         /**
   641         Punctuation, Dash.
   642         */
   643 		EPdCategory = EPunctuationGroup | 1,			
   644         
   645         
   646         /**
   647         Punctuation, Open.
   648         */
   649 		EPsCategory = EPunctuationGroup | 2,			
   650         
   651         
   652         /**
   653         Punctuation, Close.
   654         */
   655 		EPeCategory = EPunctuationGroup | 3,
   656 		
   657 		
   658 		/**
   659 		Punctuation, Initial Quote
   660 		*/			
   661 		EPiCategory = EPunctuationGroup | 4,			
   662 		
   663 		
   664 		/**
   665 		Punctuation, Final Quote
   666 		*/
   667 		EPfCategory = EPunctuationGroup | 5,			
   668         
   669         
   670         /**
   671         Punctuation, Other.
   672         */
   673 		EPoCategory = EPunctuationGroup | 6,			
   674         
   675         
   676         /**
   677         Symbol, Math.
   678         */
   679 		ESmCategory = ESymbolGroup | 0,					
   680         
   681         
   682         /**
   683         Symbol, Currency.
   684         */
   685 		EScCategory = ESymbolGroup | 1,					
   686         
   687         
   688         /**
   689         Symbol, Modifier.
   690         */
   691 		ESkCategory = ESymbolGroup | 2,					
   692         
   693         
   694         /**
   695         Symbol, Other.
   696         */
   697 		ESoCategory = ESymbolGroup | 3,					
   698         
   699         
   700         /**
   701         The highest possible graphic character category.
   702         */
   703 		EMaxGraphicCategory = ESymbolGroup | 0x0F,		
   704 
   705 
   706         /**
   707         Separator, Space.
   708         */
   709 		EZsCategory = ESeparatorGroup | 0,				
   710 
   711 
   712         /**
   713         The highest possible printable character category.
   714         */
   715 		EMaxPrintableCategory = EZsCategory,			
   716 
   717 
   718         /**
   719         Separator, Line.
   720         */
   721 		EZlCategory = ESeparatorGroup | 1,				
   722 
   723 
   724         /**
   725         Separator, Paragraph.
   726         */
   727 		EZpCategory = ESeparatorGroup | 2,				
   728 
   729 
   730         /**
   731         Other, Control.
   732         */
   733 		ECcCategory = EControlGroup | 0,				
   734 
   735 
   736         /**
   737         Other, Format.
   738         */
   739 		ECfCategory = EControlGroup | 1,				
   740 
   741 
   742         /**
   743         The highest possible category for assigned 16-bit characters; does not
   744         include surrogates, which are interpreted as pairs and have no meaning
   745         on their own.
   746         */
   747 		EMaxAssignedCategory = EMaxAssignedGroup | 0x0F,
   748 														
   749 
   750         /**
   751         Other, Surrogate.
   752         */
   753 		ECsCategory = EUnassignedGroup | 0,				
   754         
   755         
   756         /**
   757         Other, Private Use.
   758         */
   759 		ECoCategory = EUnassignedGroup | 1,				
   760         
   761         
   762         /**
   763         Other, Not Assigned.
   764         */
   765 		ECnCategory = EUnassignedGroup | 2				
   766 		};
   767 
   768 	
   769     /**
   770     The bi-directional Unicode character category.
   771 
   772     For more information on the bi-directional algorithm, see Unicode Technical 
   773     Report No. 9 available at: http://www.unicode.org/unicode/reports/tr9.
   774     */
   775 	enum TBdCategory
   776 		{
   777 	    /**
   778 	    Left to right.
   779 	    */
   780 		ELeftToRight,				// L Left-to-Right 
   781 	   
   782 	   
   783 	    /**
   784 	    Left to right embedding.
   785 	    */
   786 		ELeftToRightEmbedding,		// LRE Left-to-Right Embedding 
   787 	   
   788 	   
   789 	    /**
   790 	    Left-to-Right Override.
   791 	    */
   792 		ELeftToRightOverride,		// LRO Left-to-Right Override 
   793 	   
   794 	   
   795 	    /**
   796 	    Right to left.
   797 	    */
   798 		ERightToLeft,				// R Right-to-Left 
   799 	   
   800 	   
   801 	    /**
   802 	    Right to left Arabic.
   803 	    */
   804 		ERightToLeftArabic,			// AL Right-to-Left Arabic 
   805 	   
   806 	   
   807 	    /**
   808 	    Right to left embedding.
   809 	    */
   810 		ERightToLeftEmbedding,		// RLE Right-to-Left Embedding 
   811 	   
   812 	   
   813 	    /**
   814 	    Right-to-Left Override.
   815 	    */
   816 		ERightToLeftOverride,		// RLO Right-to-Left Override 
   817 	   
   818 	   
   819 	    /**
   820 	    Pop Directional Format.
   821 	    */
   822 		EPopDirectionalFormat,		// PDF Pop Directional Format 
   823 	   
   824 	   
   825 	    /**
   826 	    European number.
   827 	    */
   828 		EEuropeanNumber,			// EN European Number 
   829 	   
   830 	   
   831 	    /**
   832 	    European number separator.
   833 	    */
   834 		EEuropeanNumberSeparator,	// ES European Number Separator 
   835 	   
   836 	   
   837 	    /**
   838 	    European number terminator.
   839 	    */
   840 		EEuropeanNumberTerminator,	// ET European Number Terminator 
   841 	   
   842 	   
   843 	    /**
   844 	    Arabic number.
   845 	    */
   846 		EArabicNumber,				// AN Arabic Number 
   847 	   
   848 	   
   849 	    /**
   850 	    Common number separator.
   851 	    */
   852 		ECommonNumberSeparator,		// CS Common Number Separator 
   853 	   
   854 	   
   855 	    /**
   856 	    Non Spacing Mark.
   857 	    */
   858 		ENonSpacingMark,			// NSM Non-Spacing Mark 
   859 	   
   860 	   
   861 	    /**
   862 	    Boundary Neutral.
   863 	    */
   864 		EBoundaryNeutral,			// BN Boundary Neutral 
   865 	   
   866 	   
   867 	    /**
   868 	    Paragraph Separator.
   869 	    */
   870 		EParagraphSeparator,		// B Paragraph Separator 
   871 	   
   872 	   
   873 	    /**
   874 	    Segment separator.
   875 	    */
   876 		ESegmentSeparator,			// S Segment Separator 
   877 
   878 		
   879 		/**
   880 		Whitespace
   881 		*/
   882 		EWhitespace,				// WS Whitespace 
   883 
   884 
   885 	    /**
   886 	    Other neutrals; all other characters: punctuation, symbols.
   887 	    */
   888 		EOtherNeutral				// ON Other Neutrals 
   889 		};
   890 
   891 
   892 	/**
   893     Notional character width as known to East Asian (Chinese, Japanese,
   894     Korean (CJK)) coding systems.
   895     */
   896 	enum TCjkWidth
   897 		{
   898 	    /**
   899 	    Includes 'ambiguous width' defined in Unicode Technical Report 11: East Asian Width
   900 	    */
   901 		ENeutralWidth,			
   902 	    
   903 	    
   904 	    /**
   905 	    Character which occupies a single cell.
   906 	    */
   907 		EHalfWidth,				// other categories are as defined in the report
   908         
   909         
   910         /**
   911         Character which occupies 2 cells.
   912         */
   913 		EFullWidth,
   914         
   915         
   916         /**
   917         Characters that are always narrow and have explicit full-width
   918         counterparts. All of ASCII is an example of East Asian Narrow
   919         characters.
   920         */
   921 		ENarrow,
   922 	    
   923 	    /**
   924 	    Characters that are always wide. This category includes characters that
   925 	    have explicit half-width counterparts.
   926 	    */
   927 		EWide
   928 		};
   929 
   930 
   931 	/**
   932 	@deprecated
   933     
   934     Encoding systems used by the translation functions.
   935     */
   936   	enum TEncoding
   937   		{
   938   		/**
   939   		The Unicode encoding.
   940   		*/
   941   		EUnicode,
   942         
   943         
   944         /**
   945         The shift-JIS encoding (used in Japan).
   946         */
   947   		EShiftJIS		
   948   		};
   949 
   950 
   951 	/**
   952 	Flags defining operations to be performed using TChar::Fold().
   953 	
   954 	The flag values are passed to the Fold() funtion.
   955 
   956 	@see TChar::Fold
   957 	*/
   958 	enum
   959 		{
   960 		/**
   961 		Convert characters to their lower case form if any.
   962 		*/
   963 		EFoldCase = 1,			
   964 
   965 
   966 		/**
   967 		Strip accents
   968      	*/
   969 		EFoldAccents = 2,		
   970 
   971 
   972 		/**
   973 		Convert digits representing values 0..9 to characters '0'..'9'
   974      	*/
   975 		EFoldDigits = 4,		
   976 
   977 
   978 		/**
   979 		Convert all spaces (ordinary, fixed-width, ideographic, etc.) to ' '
   980      	*/
   981 		EFoldSpaces = 8,		
   982 
   983 
   984 		/**
   985 		Convert hiragana to katakana.
   986      	*/
   987 		EFoldKana = 16,			
   988 
   989 
   990 		/**
   991 	    Fold fullwidth and halfwidth variants to their standard forms
   992      	*/
   993 		EFoldWidth = 32,		
   994 
   995 
   996 		/**
   997 		Perform standard folding operations, i.e.those done by Fold() with no argument
   998      	*/
   999 		EFoldStandard = EFoldCase | EFoldAccents | EFoldDigits | EFoldSpaces,
  1000 
  1001 
  1002         /**
  1003         Perform all possible folding operations
  1004         */
  1005 		EFoldAll = -1	
  1006 		};
  1007 
  1008 
  1009 	struct TCharInfo
  1010     /**
  1011     A structure to hold information about a Unicode character.
  1012     
  1013     An object of this type is passed to TChar::GetInfo().
  1014  
  1015     @see TChar::GetInfo
  1016     */
  1017 		{
  1018 	    /**
  1019 	    General category.
  1020 	    */
  1021 		TCategory iCategory;				
  1022         
  1023         
  1024         /**
  1025         Bi-directional category.
  1026         */
  1027 		TBdCategory iBdCategory;			
  1028         
  1029         
  1030         /**
  1031         Combining class: number (currently) in the range 0..234
  1032         */
  1033 		TInt iCombiningClass;				
  1034         
  1035         
  1036         /**
  1037         Lower case form.
  1038         */
  1039 		TUint iLowerCase;					
  1040         
  1041         
  1042         /**
  1043         Upper case form.
  1044         */
  1045 		TUint iUpperCase;					
  1046         
  1047         
  1048         /**
  1049         Title case form.
  1050         */
  1051 		TUint iTitleCase;					
  1052         
  1053         
  1054         /**
  1055         True, if the character is mirrored.
  1056         */
  1057 		TBool iMirrored;					
  1058         
  1059         
  1060         /**
  1061         Integer numeric value: -1 if none, -2 if a fraction.
  1062         */
  1063 		TInt iNumericValue;					
  1064 		};
  1065 
  1066 	inline TChar();
  1067 	inline TChar(TUint aChar);
  1068 	inline TChar& operator-=(TUint aChar);
  1069 	inline TChar& operator+=(TUint aChar);
  1070 	inline TChar operator-(TUint aChar);
  1071 	inline TChar operator+(TUint aChar);
  1072 	inline operator TUint() const;
  1073 #ifndef __KERNEL_MODE__
  1074 	inline void Fold();
  1075 	inline void LowerCase();
  1076 	inline void UpperCase();
  1077 	inline TBool Eos() const;
  1078 	IMPORT_C TUint GetUpperCase() const;
  1079 	IMPORT_C TUint GetLowerCase() const;
  1080 	IMPORT_C TBool IsLower() const;
  1081 	IMPORT_C TBool IsUpper() const;
  1082 	IMPORT_C TBool IsAlpha() const;
  1083 	IMPORT_C TBool IsDigit() const;
  1084 	IMPORT_C TBool IsAlphaDigit() const;
  1085 	IMPORT_C TBool IsHexDigit() const;
  1086 	IMPORT_C TBool IsSpace() const;
  1087 	IMPORT_C TBool IsPunctuation() const;
  1088 	IMPORT_C TBool IsGraph() const;
  1089 	IMPORT_C TBool IsPrint() const;
  1090 	IMPORT_C TBool IsControl() const;
  1091 	inline void Fold(TInt aFlags);
  1092 	inline void TitleCase();
  1093 	IMPORT_C TUint GetTitleCase() const;
  1094 	IMPORT_C TBool IsTitle() const;
  1095 	IMPORT_C TBool IsAssigned() const;
  1096 	IMPORT_C void GetInfo(TCharInfo& aInfo) const;
  1097 	IMPORT_C TCategory GetCategory() const;
  1098 	IMPORT_C TBdCategory GetBdCategory() const;
  1099 	IMPORT_C TInt GetCombiningClass() const;
  1100 	IMPORT_C TBool IsMirrored() const;
  1101 	IMPORT_C TInt GetNumericValue() const;
  1102 	IMPORT_C TCjkWidth GetCjkWidth() const;
  1103 	IMPORT_C static TBool Compose(TUint& aResult,const TDesC16& aSource);
  1104 	IMPORT_C TBool Decompose(TPtrC16& aResult) const;
  1105 
  1106 protected:
  1107 	inline void SetChar(TUint aChar);
  1108 #endif
  1109 private:
  1110 	TUint iChar;
  1111 	__DECLARE_TEST;
  1112 	};
  1113 
  1114 #include <e32des8.h>
  1115 #ifndef __KERNEL_MODE__
  1116 #include <e32des16.h>
  1117 #endif
  1118 
  1119 
  1120 
  1121 
  1122 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
  1123 #define __Size (sizeof(TUint)/sizeof(TUint16))
  1124 /**
  1125 @publishedAll
  1126 @released
  1127 
  1128 Defines a build-independent non-modifiable descriptor.
  1129 
  1130 A 16-bit build variant is generated for a Unicode, non-kernel
  1131 mode build.
  1132 
  1133 A build-independent type should always be used unless an explicit 8-bit 
  1134 or 16-bit type is required.
  1135 
  1136 @see TDesC8
  1137 @see TDesC16
  1138 */
  1139 typedef TDesC16 TDesC;
  1140 
  1141 
  1142 
  1143 
  1144 /**
  1145 @publishedAll
  1146 @released
  1147 
  1148 Defines a build-independent non-modifiable pointer descriptor.
  1149 
  1150 A 16-bit build variant is generated for a Unicode, non-kernel
  1151 mode build.
  1152 
  1153 A build-independent type should always be used unless an explicit 8-bit 
  1154 or 16-bit type is required.
  1155 
  1156 @see TPtrC8
  1157 @see TPtrC16
  1158 */
  1159 typedef TPtrC16 TPtrC;
  1160 
  1161 
  1162 
  1163 
  1164 /**
  1165 @publishedAll
  1166 @released
  1167 
  1168 Defines a build-independent modifiable descriptor.
  1169 
  1170 A 16-bit build variant is generated for a Unicode, non-kernel
  1171 mode build.
  1172 
  1173 A build-independent type should always be used unless an explicit 8-bit 
  1174 or 16-bit type is required.
  1175 
  1176 @see TDes8
  1177 @see TDes16
  1178 */
  1179 typedef TDes16 TDes;
  1180 
  1181 
  1182 
  1183 
  1184 /**
  1185 @publishedAll
  1186 @released
  1187 
  1188 Defines a build-independent modifiable pointer descriptor.
  1189 
  1190 A 16-bit build variant is generated for a Unicode, non-kernel
  1191 mode build.
  1192 
  1193 A build-independent type should always be used unless an explicit 8-bit 
  1194 or 16-bit type is required.
  1195 
  1196 @see TPtr8
  1197 @see TPtr16
  1198 */
  1199 typedef TPtr16 TPtr;
  1200 
  1201 
  1202 
  1203 
  1204 #ifndef __KERNEL_MODE__
  1205 /**
  1206 @publishedAll
  1207 @released
  1208 
  1209 Defines a build-independent heap descriptor. 
  1210 
  1211 A 16-bit build variant is generated for a Unicode, non-kernel
  1212 mode build.
  1213 
  1214 A build-independent type should always be used unless an explicit 8-bit 
  1215 or 16-bit type is required.
  1216 
  1217 @see HBufC8
  1218 @see HBufC16
  1219 */
  1220 typedef HBufC16 HBufC;
  1221 
  1222 
  1223 
  1224 
  1225 /** 
  1226 @publishedAll
  1227 @released
  1228 
  1229 Defines a build-independent descriptor overflow handler.
  1230 
  1231 A 16-bit build variant is generated for a Unicode, non-kernel
  1232 mode build.
  1233 
  1234 A build-independent type should always be used unless an explicit 8-bit 
  1235 or 16-bit type is required.
  1236 
  1237 @see TDes8Overflow
  1238 @see TDes16Overflow
  1239 */
  1240 typedef TDes16Overflow TDesOverflow;
  1241 
  1242 
  1243 /** 
  1244 @publishedAll
  1245 @released
  1246 
  1247 Defines a build-independent resizable buffer descriptor.
  1248 
  1249 A 16-bit build variant is generated for a Unicode, non-kernel mode build.
  1250 
  1251 A build-independent type should always be used unless an explicit 8-bit 
  1252 or 16-bit type is required.
  1253 
  1254 @see RBuf8
  1255 @see RBuf16
  1256 */
  1257 typedef RBuf16 RBuf;
  1258 
  1259 #endif
  1260 #else
  1261 #define __Size (sizeof(TUint)/sizeof(TUint8))
  1262 
  1263 
  1264 
  1265 
  1266 /**
  1267 @publishedAll
  1268 @released
  1269 
  1270 Defines a build-independent non-modifiable descriptor.
  1271 
  1272 An 8-bit build variant is generated for a non-Unicode build.
  1273 
  1274 This build-independent type should always be used unless an explicit 8-bit 
  1275 or 16-bit build variant is required.
  1276 
  1277 @see TDesC8
  1278 @see TDesC16
  1279 */
  1280 typedef TDesC8 TDesC;
  1281 
  1282 
  1283 
  1284 
  1285 /**
  1286 @publishedAll
  1287 @released
  1288 
  1289 Defines a build-independent non-modifiable pointer descriptor.
  1290 
  1291 An 8-bit build variant is generated for a non-Unicode build.
  1292 
  1293 This build-independent type should always be used unless an explicit 8-bit 
  1294 or 16-bit build variant is required.
  1295 
  1296 @see TPtrC8
  1297 @see TPtrC16
  1298 */
  1299 typedef TPtrC8 TPtrC;
  1300 
  1301 
  1302 
  1303 
  1304 /**
  1305 @publishedAll
  1306 @released
  1307 
  1308 Defines a build-independent modifiable descriptor.
  1309 
  1310 An 8-bit build variant is generated for a non-Unicode build.
  1311 
  1312 This build-independent type should always be used unless an explicit 8-bit 
  1313 or 16-bit build variant is required.
  1314 
  1315 @see TDes8
  1316 @see TDes16
  1317 */
  1318 typedef TDes8 TDes;
  1319 
  1320 
  1321 
  1322 
  1323 /**
  1324 @publishedAll
  1325 @released
  1326 
  1327 Defines a build-independent modifiable pointer descriptor.
  1328 
  1329 An 8-bit build variant is generated for a non-Unicode build.
  1330 
  1331 This build-independent type should always be used unless an explicit 8-bit 
  1332 or 16-bit build variant is required.
  1333 
  1334 @see TPtr8
  1335 @see TPtr16
  1336 */
  1337 typedef TPtr8 TPtr;
  1338 #ifndef __KERNEL_MODE__
  1339 
  1340 
  1341 
  1342 
  1343 /**
  1344 @publishedAll
  1345 @released
  1346 
  1347 Defines a build-independent heap descriptor.
  1348 
  1349 An 8-bit build variant is generated for a non-Unicode, non-kernel
  1350 mode build.
  1351 
  1352 This build-independent type should always be used unless an explicit 8-bit 
  1353 or 16-bit build variant is required.
  1354 
  1355 @see HBufC8
  1356 @see HBufC16
  1357 */
  1358 typedef HBufC8 HBufC;
  1359 
  1360 
  1361 
  1362 
  1363 /**
  1364 @publishedAll
  1365 @released
  1366 
  1367 Defines a build-independent descriptor overflow handler. 
  1368 
  1369 An 8-bit build variant is generated for a non-Unicode, non-kernel
  1370 mode build.
  1371 
  1372 This build-independent type should always be used unless an explicit 8-bit 
  1373 or 16-bit build variant is required.
  1374 
  1375 @see TDes8Overflow
  1376 @see TDes16Overflow
  1377 */
  1378 typedef TDes8Overflow TDesOverflow;
  1379 
  1380 
  1381 /**
  1382 @publishedAll
  1383 @released
  1384 
  1385 Defines a build-independent resizable buffer descriptor.
  1386 
  1387 An 8-bit build variant is generated for a non-Unicode, non-kernel mode build.
  1388 
  1389 This build-independent type should always be used unless an explicit 8-bit 
  1390 or 16-bit build variant is required.
  1391 
  1392 @see RBuf8
  1393 @see RBuf16
  1394 */
  1395 typedef RBuf8 RBuf;
  1396 
  1397 #endif
  1398 #endif
  1399 
  1400 
  1401 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
  1402 typedef TBufCBase16 TBufCBase;
  1403 #else
  1404 typedef TBufCBase8 TBufCBase;
  1405 #endif
  1406 
  1407 /**
  1408 @publishedAll
  1409 @released
  1410 
  1411 A build-independent non-modifiable buffer descriptor.
  1412 
  1413 This is a descriptor class which provides a buffer of fixed length for
  1414 containing and accessing TUint16 or TUint8 data, depending on the build.
  1415 
  1416 The class intended for instantiation. The data that the descriptor represents 
  1417 is part of the descriptor object itself.
  1418 
  1419 The class is templated, based on an integer value which defines the size of 
  1420 the descriptor's data area.
  1421 
  1422 The data is intended to be accessed, but not modified; however, it can be 
  1423 completely replaced using the assignment operators of this class. The base 
  1424 class provides the functions through which the data is accessed.
  1425 
  1426 This class derives from TBufCBase16 for a Unicode, non-kernel build, but
  1427 derives from TBufCBase8 for a non-Unicode build.
  1428 
  1429 @see TDesC
  1430 @see TDesC8
  1431 @see TDesC16
  1432 @see TPtr
  1433 @see TPtr8
  1434 @see TPtr16
  1435 @see TBufC8
  1436 @see TBufC16
  1437 */
  1438 template <TInt S>
  1439 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
  1440 class TBufC : public TBufCBase16
  1441 #else
  1442 class TBufC : public TBufCBase8
  1443 #endif
  1444 	{
  1445 public:
  1446 	inline TBufC();
  1447 	inline TBufC(const TText* aString);
  1448 	inline TBufC(const TDesC& aDes);
  1449 	inline TBufC<S>& operator=(const TText* aString);
  1450 	inline TBufC<S>& operator=(const TDesC& aDes);
  1451 	inline TPtr Des();
  1452 private:
  1453 	TText iBuf[__Align(S)];
  1454 	};
  1455 
  1456 
  1457 
  1458 /**
  1459 @publishedAll
  1460 @released
  1461 
  1462 A build-independent modifiable buffer descriptor.
  1463 
  1464 This is a descriptor class which provides a buffer of fixed length for
  1465 containing, accessing and manipulating TUint16 or TUint8 data, depending
  1466 on the build.
  1467 
  1468 The class is intended for instantiation. The data that the descriptor represents 
  1469 is part of the descriptor object itself.
  1470 
  1471 The class is templated, based on an integer value which determines the size 
  1472 of the data area created as part of the buffer descriptor object; this is 
  1473 also the maximum length of the descriptor.
  1474 
  1475 The data is intended to be both accessed and modified. The base classes provide 
  1476 the functions through which the data is accessed.
  1477 
  1478 This class derives from TBufCBase16 for a Unicode, non-kernel build, but
  1479 derives from TBufCBase8 for a non-Unicode build.
  1480 
  1481 @see TDesC
  1482 @see TDesC8
  1483 @see TDesC16
  1484 @see TDes
  1485 @see TDes8
  1486 @see TDes16
  1487 @see TPtr
  1488 @see TPtr8
  1489 @see TPtr16
  1490 */
  1491 template <TInt S>
  1492 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
  1493 class TBuf : public TBufBase16
  1494 #else
  1495 class TBuf : public TBufBase8
  1496 #endif
  1497 	{
  1498 public:
  1499 	inline TBuf();
  1500 	inline explicit TBuf(TInt aLength);
  1501 	inline TBuf(const TText* aString);
  1502 	inline TBuf(const TDesC& aDes);
  1503 	inline TBuf<S>& operator=(const TText* aString);
  1504 	inline TBuf<S>& operator=(const TDesC& aDes);
  1505 	inline TBuf<S>& operator=(const TBuf<S>& aBuf);
  1506 private:
  1507 	TText iBuf[__Align(S)];
  1508 	};
  1509 
  1510 
  1511 
  1512 
  1513 /**
  1514 @publishedAll
  1515 @released
  1516 
  1517 Value reference used in operator TLitC::__TRefDesC().
  1518 
  1519 @see TRefByValue
  1520 */
  1521 typedef TRefByValue<const TDesC> __TRefDesC;
  1522 
  1523 
  1524 
  1525 
  1526 /**
  1527 @publishedAll
  1528 @released
  1529 
  1530 Encapsulates literal text.
  1531 
  1532 This is always constructed using an _LIT macro.
  1533 
  1534 This class is build independent; i.e. for a non-Unicode build, an 8-bit build
  1535 variant is generated; for a Unicode build, a 16 bit build variant is generated.
  1536 
  1537 The class has no explicit constructors. See the _LIT macro definition.
  1538 */
  1539 template <TInt S>
  1540 class TLitC
  1541 	{
  1542 public:
  1543     /**
  1544     @internalComponent
  1545     */
  1546 	enum {BufferSize=S-1};
  1547 	inline const TDesC* operator&() const;
  1548 	inline operator const TDesC&() const;
  1549 	inline const TDesC& operator()() const;
  1550 	inline operator const __TRefDesC() const;
  1551 public:
  1552 #if !defined(_UNICODE) || defined(__KERNEL_MODE__)
  1553 
  1554     /**
  1555     @internalComponent
  1556     */
  1557 	typedef TUint8 __TText;
  1558 #elif defined(__GCC32__)
  1559 
  1560     /**
  1561     @internalComponent
  1562     */
  1563 	typedef wchar_t __TText;
  1564 #elif defined(__VC32__)
  1565 
  1566 	/**
  1567     @internalComponent
  1568     */
  1569 	typedef wchar_t __TText;
  1570 
  1571 #elif defined(__CW32__)
  1572 
  1573     /**
  1574     @internalComponent
  1575     */
  1576 	typedef TUint16 __TText;
  1577 #elif !defined(__TText_defined)
  1578 #error  no typedef for __TText
  1579 #endif
  1580 public:
  1581     /**
  1582     @internalComponent
  1583     */
  1584 	TUint iTypeLength;
  1585 
  1586     /**
  1587     @internalComponent
  1588     */
  1589 	__TText iBuf[__Align(S)];
  1590 	};
  1591 
  1592 
  1593 /**
  1594 @publishedAll
  1595 @released
  1596 
  1597 Defines an empty or null literal descriptor.
  1598 
  1599 This is the build independent form.
  1600 An 8 bit build variant is generated for a non-Unicode build;
  1601 a 16 bit build variant is generated for a Unicode build.
  1602 */
  1603 _LIT(KNullDesC,"");
  1604 
  1605 
  1606 
  1607 /**
  1608 @publishedAll
  1609 @released
  1610 
  1611 Defines an empty or null literal descriptor for use with 8-bit descriptors.
  1612 */
  1613 _LIT8(KNullDesC8,"");
  1614 #ifndef __KERNEL_MODE__
  1615 
  1616 
  1617 
  1618 /**
  1619 @publishedAll
  1620 @released
  1621 
  1622 Defines an empty or null literal descriptor for use with 16-bit descriptors
  1623 */
  1624 _LIT16(KNullDesC16,"");
  1625 #endif
  1626 
  1627 
  1628 
  1629 
  1630 /**
  1631 @publishedAll
  1632 @released
  1633 
  1634 Packages a non-modifiable pointer descriptor which represents an object of 
  1635 specific type.
  1636 
  1637 The template parameter defines the type of object.
  1638 
  1639 The object represented by the packaged pointer descriptor is accessible through 
  1640 the package but cannot be changed. */
  1641 template <class T>
  1642 class TPckgC : public TPtrC8
  1643 	{
  1644 public:
  1645 	inline TPckgC(const T& aRef);
  1646 	inline const T& operator()() const;
  1647 private:
  1648 	TPckgC<T>& operator=(const TPckgC<T>& aRef);
  1649 	};
  1650 
  1651 
  1652 
  1653 
  1654 /**
  1655 @publishedAll
  1656 @released
  1657 
  1658 Packages a modifiable pointer descriptor which represents an object of specific 
  1659 type.
  1660 
  1661 The template parameter defines the type of object.
  1662 
  1663 The object represented by the packaged pointer descriptor is accessible through 
  1664 the package.
  1665 */
  1666 template <class T>
  1667 class TPckg : public TPtr8
  1668 	{
  1669 public:
  1670 	inline TPckg(const T& aRef);
  1671 	inline T& operator()();
  1672 private:
  1673 	TPckg<T>& operator=(const TPckg<T>& aRef);
  1674 	};
  1675 
  1676 
  1677 
  1678 
  1679 /**
  1680 @publishedAll
  1681 @released
  1682 
  1683 Packages an object into a modifiable buffer descriptor.
  1684 
  1685 The template parameter defines the type of object to be packaged.
  1686 
  1687 The package provides a type safe way of transferring an object or data structure 
  1688 which is contained within a modifiable buffer descriptor. Typically, a package 
  1689 is used for passing data via inter thread communication.
  1690 
  1691 The contained object is accessible through the package.
  1692 */
  1693 template <class T>
  1694 class TPckgBuf : public TAlignedBuf8<sizeof(T)>
  1695 	{
  1696 public:
  1697 	inline TPckgBuf();
  1698 	inline TPckgBuf(const T& aRef);
  1699 	inline TPckgBuf& operator=(const TPckgBuf<T>& aRef);
  1700 	inline T& operator=(const T& aRef);
  1701 	inline T& operator()();
  1702 	inline const T& operator()() const;
  1703 	};
  1704 
  1705 
  1706 
  1707 
  1708 /**
  1709 @publishedAll
  1710 @released
  1711 
  1712 Defines a modifiable buffer descriptor that can contain the name of a reference 
  1713 counting object.
  1714 
  1715 @see TBuf
  1716 @see CObject
  1717 */
  1718 typedef TBuf<KMaxName> TName;
  1719 
  1720 
  1721 /**
  1722 @publishedAll
  1723 @released
  1724 
  1725 Defines a modifiable buffer descriptor that can contain the full name of a 
  1726 reference counting object.
  1727 
  1728 @see TBuf
  1729 @see CObject
  1730 */
  1731 typedef TBuf<KMaxFullName> TFullName;
  1732 
  1733 
  1734 
  1735 /**
  1736 @publishedAll
  1737 @released
  1738 
  1739 Defines a modifiable buffer descriptor to contain the category name identifying
  1740 the cause of thread or process termination. The buffer takes a maximum length
  1741 of KMaxExitCategoryName.
  1742 
  1743 @see RThread::ExitCategory
  1744 @see RThread::ExitCategory
  1745 */
  1746 typedef TBuf<KMaxExitCategoryName> TExitCategoryName;
  1747 
  1748 
  1749 
  1750 /**
  1751 @publishedAll
  1752 @released
  1753 
  1754 A buffer that can contain the name of a file.
  1755 The name can have a maximum length of KMaxFileName
  1756 (currently 256 but check the definition of KMaxFileName).
  1757 
  1758 @see KMaxFileName
  1759 */
  1760 typedef TBuf<KMaxFileName> TFileName;
  1761 
  1762 
  1763 
  1764 /**
  1765 @publishedAll
  1766 @released
  1767 
  1768 A buffer that can contain the name of a path.
  1769 The name can have a maximum length of KMaxPath
  1770 (currently 256 but check the definition of KMaxPath).
  1771 
  1772 @see KMaxPath
  1773 */
  1774 typedef TBuf<KMaxPath> TPath;
  1775 
  1776 
  1777 
  1778 
  1779 /**
  1780 @publishedAll
  1781 @released
  1782 
  1783 Version name type.
  1784 
  1785 This is a buffer descriptor with a maximum length of KMaxVersionName.
  1786 A TVersion object returns the formatted character representation of its version
  1787 information in a descriptor of this type.
  1788 
  1789 @see TVersion
  1790 */
  1791 typedef TBuf<KMaxVersionName> TVersionName;
  1792 
  1793 
  1794 
  1795 
  1796 /**
  1797 @publishedAll
  1798 @released
  1799 
  1800 Defines a modifiable buffer descriptor for the text form of the UID.
  1801 The descriptor has a maximum length of KMaxUidName and is used to contain
  1802 the standard text format returned by the function TUid::Name().
  1803 
  1804 @see TUid::Name
  1805 */
  1806 typedef TBuf<KMaxUidName> TUidName;
  1807 
  1808 
  1809 
  1810 
  1811 /**
  1812 @publishedAll
  1813 @released
  1814 
  1815 Defines a null UID
  1816 */
  1817 #define KNullUid TUid::Null()
  1818 
  1819 
  1820 
  1821 
  1822 /**
  1823 @publishedAll
  1824 @released
  1825 
  1826 A globally unique 32-bit number.
  1827 */
  1828 class TUid
  1829 	{
  1830 public:
  1831 #ifndef __KERNEL_MODE__
  1832 	IMPORT_C TBool operator==(const TUid& aUid) const;
  1833 	IMPORT_C TBool operator!=(const TUid& aUid) const;
  1834 	IMPORT_C TUidName Name() const;
  1835 #endif
  1836 	static inline TUid Uid(TInt aUid);
  1837 	static inline TUid Null();
  1838 public:
  1839 	/**
  1840 	The 32-bit integer UID value.
  1841 	*/
  1842 	TInt32 iUid;
  1843 	};
  1844 
  1845 
  1846 
  1847 
  1848 /**
  1849 @publishedAll
  1850 @released
  1851 
  1852 Encapsulates a set of three unique identifiers (UIDs) which, in combination, 
  1853 identify a system object such as a GUI application or a DLL. The three
  1854 component UIDs are referred to as UID1, UID2 and UID3.
  1855 
  1856 An object of this type is referred to as a compound identifier or a UID type.
  1857 */
  1858 class TUidType
  1859 	{
  1860 public:
  1861 #ifndef __KERNEL_MODE__
  1862 	IMPORT_C TUidType();
  1863 	IMPORT_C TUidType(TUid aUid1);
  1864 	IMPORT_C TUidType(TUid aUid1,TUid aUid2);
  1865 	IMPORT_C TUidType(TUid aUid1,TUid aUid2,TUid aUid3);
  1866 	IMPORT_C TBool operator==(const TUidType& aUidType) const;
  1867 	IMPORT_C TBool operator!=(const TUidType& aUidType) const;
  1868 	IMPORT_C const TUid& operator[](TInt anIndex) const;
  1869 	IMPORT_C TUid MostDerived() const;
  1870 	IMPORT_C TBool IsPresent(TUid aUid) const;
  1871 	IMPORT_C TBool IsValid() const;
  1872 private:
  1873 #endif
  1874 	TUid iUid[KMaxCheckedUid];
  1875 	};
  1876 
  1877 
  1878 
  1879 
  1880 /**
  1881 A class used to represent the Secure ID of a process or executable image.
  1882 
  1883 Constructors and conversion operators are provided to enable conversion
  1884 of this class to and from both TUint32 and TUid objects.
  1885 
  1886 Because this class has non-default constructors, compilers will not initialise
  1887 this objects at compile time, instead code will be generated to construct the object
  1888 at run-time. This is wastefull, and Symbian OS DLLs are not permitted to have
  1889 such uninitialised data. To overcome these problems a macro is provided to construct
  1890 a const object which behaves like a TSecureId. This is _LIT_SECURE_ID.
  1891 This macro should be used where it is desirable to define const TSecureId objects,
  1892 like in header files. E.g. Instead of writing:
  1893 @code
  1894 	const TSecureId MyId=0x1234567
  1895 @endcode
  1896 use
  1897 @code
  1898 	_LIT_SECURE_ID(MyId,0x1234567)
  1899 @endcode
  1900 
  1901 @publishedAll
  1902 @released
  1903 
  1904 @see _LIT_SECURE_ID
  1905 */
  1906 class TSecureId
  1907 	{
  1908 public:
  1909 	inline TSecureId();
  1910 	inline TSecureId(TUint32 aId);
  1911 	inline operator TUint32() const;
  1912 	inline TSecureId(TUid aId);
  1913 	inline operator TUid() const;
  1914 public:
  1915 	TUint32 iId;
  1916 	};
  1917 
  1918 
  1919 
  1920 
  1921 /**
  1922 A class used to represent the Vendor ID of a process or executable image
  1923 
  1924 Constructors and conversion operators are provided to enable conversion
  1925 of this class to and from both TUint32 and TUid objects.
  1926 
  1927 Because this class has non-default constructors, compilers will not initialise
  1928 this objects at compile time, instead code will be generated to construct the object
  1929 at run-time. This is wastefull, and Symbian OS DLLs are not permitted to have
  1930 such uninitialised data. To overcome these problems a macro is provided to construct
  1931 a const object which behaves like a TSecureId. This is _LIT_VENDOR_ID.
  1932 This macro should be used where it is desirable to define const TSecureId objects,
  1933 like in header files. E.g. Instead of writing:
  1934 @code
  1935 	const TVendorId MyId=0x1234567
  1936 @endcode
  1937 use
  1938 @code
  1939 	_LIT_VENDOR_ID(MyId,0x1234567)
  1940 @endcode
  1941 
  1942 @publishedAll
  1943 @released
  1944 
  1945 @see _LIT_VENDOR_ID
  1946 */
  1947 class TVendorId
  1948 	{
  1949 public:
  1950 	inline TVendorId();
  1951 	inline TVendorId(TUint32 aId);
  1952 	inline operator TUint32() const;
  1953 	inline TVendorId(TUid aId);
  1954 	inline operator TUid() const;
  1955 public:
  1956 	TUint32 iId;
  1957 	};
  1958 
  1959 
  1960 
  1961 /**
  1962 Structure for compile-time definition of a secure ID
  1963 @internalComponent
  1964 */
  1965 class SSecureId
  1966 	{
  1967 public:
  1968 	inline const TSecureId* operator&() const;
  1969 	inline operator const TSecureId&() const;
  1970 	inline operator TUint32() const;
  1971 	inline operator TUid() const;
  1972 public:
  1973 	TUint32 iId;
  1974 	};
  1975 
  1976 
  1977 	
  1978 	
  1979 /**
  1980 Structure for compile-time definition of a vendor ID
  1981 @internalComponent
  1982 */
  1983 class SVendorId
  1984 	{
  1985 public:
  1986 	inline const TVendorId* operator&() const;
  1987 	inline operator const TVendorId&() const;
  1988 	inline operator TUint32() const;
  1989 	inline operator TUid() const;
  1990 public:
  1991 	TUint32 iId;
  1992 	};
  1993 
  1994 
  1995 
  1996 
  1997 /**
  1998 Macro for compile-time definition of a secure ID
  1999 @param name Name to use for secure ID
  2000 @param value Value of secure ID
  2001 @publishedAll
  2002 @released
  2003 */
  2004 #define _LIT_SECURE_ID(name,value) const SSecureId name={value}
  2005 
  2006 
  2007 
  2008 
  2009 /**
  2010 Macro for compile-time definition of a vendor ID
  2011 @param name Name to use for vendor ID
  2012 @param value Value of vendor ID
  2013 @publishedAll
  2014 @released
  2015 */
  2016 #define _LIT_VENDOR_ID(name,value) const SVendorId name={value}
  2017 
  2018 
  2019 
  2020 
  2021 /**
  2022 @publishedAll
  2023 @released
  2024 
  2025 Contains version information.
  2026 
  2027 A version is defined by a set of three numbers:
  2028 
  2029 1. the major version number, ranging from 0 to 127, inclusive
  2030 
  2031 2. the minor version number, ranging from 0 to 99 inclusive
  2032 
  2033 3. the build number, ranging from 0 to 32767 inclusive.
  2034 
  2035 The class provides a constructor for setting all three numbers.
  2036 It also provides a member function to build a character representation of
  2037 this information in a TVersionName descriptor.
  2038 
  2039 @see TVersionName
  2040 */
  2041 class TVersion
  2042 	{
  2043 public:
  2044 	IMPORT_C TVersion();
  2045 	IMPORT_C TVersion(TInt aMajor,TInt aMinor,TInt aBuild);
  2046 	IMPORT_C TVersionName Name() const;
  2047 public:
  2048     /**
  2049     The major version number.
  2050     */
  2051 	TInt8 iMajor;
  2052 
  2053 
  2054     /**
  2055     The minor version number.
  2056     */
  2057 	TInt8 iMinor;
  2058 
  2059 	
  2060 	/**
  2061 	The build number.
  2062 	*/
  2063 	TInt16 iBuild;
  2064 	};
  2065 
  2066 
  2067 
  2068 
  2069 /**
  2070 @publishedAll
  2071 @released
  2072 
  2073 Indicates the completion status of a request made to a service provider.
  2074 
  2075 When a thread makes a request, it passes a request status as a parameter. 
  2076 On completion, the provider signals the requesting thread's request semaphore 
  2077 and stores a completion code in the request status. Typically, this is KErrNone 
  2078 or one of the other system-wide error codes.
  2079 
  2080 This class is not intended for user derivation.
  2081 */
  2082 class TRequestStatus
  2083 	{
  2084 public:
  2085 	inline TRequestStatus();
  2086 	inline TRequestStatus(TInt aVal);
  2087 	inline TInt operator=(TInt aVal);
  2088 	inline TBool operator==(TInt aVal) const;
  2089 	inline TBool operator!=(TInt aVal) const;
  2090 	inline TBool operator>=(TInt aVal) const;
  2091 	inline TBool operator<=(TInt aVal) const;
  2092 	inline TBool operator>(TInt aVal) const;
  2093 	inline TBool operator<(TInt aVal) const;
  2094 	inline TInt Int() const;
  2095 private:
  2096 	enum
  2097 		{
  2098 		EActive				= 1,  //bit0
  2099 		ERequestPending		= 2,  //bit1
  2100 		};
  2101 	TInt iStatus;
  2102 	TUint iFlags;
  2103 	friend class CActive;
  2104 	friend class CActiveScheduler;
  2105 	friend class CServer2;
  2106    //SL: Added this so that upon request completion a thread can set iStatus without touching iFlag
  2107    //That stuff is usually probably handled by some exec call accessing the memory directly (just a guess)
  2108    //@see RThread::RequestComplete
  2109    friend class RThread;
  2110 	};
  2111 
  2112 
  2113 
  2114 
  2115 class TSize;
  2116 /**
  2117 @publishedAll
  2118 @released
  2119 
  2120 Stores a two-dimensional point in Cartesian co-ordinates.
  2121 
  2122 Its data members (iX and iY) are public and can be manipulated directly, or 
  2123 by means of the functions provided. Functions are provided to set and manipulate 
  2124 the point, and to compare points for equality.
  2125 */
  2126 class TPoint
  2127 	{
  2128 public:
  2129 #ifndef __KERNEL_MODE__
  2130 	enum TUninitialized { EUninitialized };
  2131 	/**
  2132 	Constructs default point, initialising its iX and iY members to zero.
  2133 	*/
  2134 	TPoint(TUninitialized) {}
  2135 	inline TPoint();
  2136 	inline TPoint(TInt aX,TInt aY);
  2137 	IMPORT_C TBool operator==(const TPoint& aPoint) const;
  2138 	IMPORT_C TBool operator!=(const TPoint& aPoint) const;
  2139 	IMPORT_C TPoint& operator-=(const TPoint& aPoint);
  2140 	IMPORT_C TPoint& operator+=(const TPoint& aPoint);
  2141 	IMPORT_C TPoint& operator-=(const TSize& aSize);
  2142 	IMPORT_C TPoint& operator+=(const TSize& aSize);
  2143 	IMPORT_C TPoint operator-(const TPoint& aPoint) const;
  2144 	IMPORT_C TPoint operator+(const TPoint& aPoint) const;
  2145 	IMPORT_C TPoint operator-(const TSize& aSize) const;
  2146 	IMPORT_C TPoint operator+(const TSize& aSize) const;
  2147 	IMPORT_C TPoint operator-() const;
  2148 	IMPORT_C void SetXY(TInt aX,TInt aY);
  2149 	IMPORT_C TSize AsSize() const;
  2150 #endif
  2151 public:
  2152 	/**
  2153 	The x co-ordinate.
  2154 	*/
  2155 	TInt iX;
  2156 	/**
  2157 	The y co-ordinate.
  2158 	*/
  2159 	TInt iY;
  2160 	};
  2161 
  2162 
  2163 
  2164 
  2165 /**
  2166 @publishedAll
  2167 @prototype
  2168 
  2169 Stores a three-dimensional point in Cartesian or polar co-ordinates.
  2170 Its data members (iX, iY and iZ) are public and can be manipulated directly.
  2171 
  2172 */
  2173 class TPoint3D
  2174 	{
  2175 public:
  2176 #ifndef __KERNEL_MODE__
  2177 	enum TUninitialized { EUninitialized };
  2178 
  2179 	/**
  2180 	TUninitialized Constructor
  2181 	*/
  2182 	TPoint3D(TUninitialized) {}
  2183 	/**
  2184 	Constructs default TPoint3D, initialising its iX , iY and iZ members to zero.
  2185 	*/
  2186 	inline TPoint3D();
  2187 	/**
  2188 	Constructs  TPoint3D with the specified x,y  and z co-ordinates.
  2189 	*/
  2190 	inline TPoint3D(TInt aX,TInt aY,TInt aZ);
  2191 	/** 
  2192 	Copy Construct from TPoint , initialises Z co-ordinate to  Zero
  2193 	*/
  2194 	inline TPoint3D(const  TPoint& aPoint);
  2195 
  2196 	IMPORT_C TBool operator==(const TPoint3D& aPoint3D) const;
  2197 	IMPORT_C TBool operator!=(const TPoint3D& aPoint3D) const;
  2198 
  2199 	IMPORT_C TPoint3D& operator-=(const TPoint3D& aPoint3D);
  2200 	IMPORT_C TPoint3D& operator-=(const TPoint& aPoint);
  2201 
  2202 	IMPORT_C TPoint3D& operator+=(const TPoint3D& aPoint3D);	
  2203 	IMPORT_C TPoint3D& operator+=(const TPoint& aPoint);
  2204 
  2205 	IMPORT_C TPoint3D operator-(const TPoint3D& aPoint3D) const;
  2206 	IMPORT_C TPoint3D operator-(const TPoint& aPoint) const;	
  2207 
  2208 	IMPORT_C TPoint3D operator+(const TPoint3D& aPoint3D) const;
  2209 	IMPORT_C TPoint3D operator+(const TPoint& aPoint) const;
  2210 	/**
  2211     Unary minus operator. The operator returns the negation of this Point3D 
  2212 	*/
  2213 	IMPORT_C TPoint3D operator-() const;
  2214 	
  2215 	/**
  2216 	Set Method to set the xyz co-ordinates of TPoint3D
  2217 	*/
  2218 	IMPORT_C void SetXYZ(TInt aX,TInt aY,TInt aZ);
  2219 	
  2220 	/**
  2221 	TPoint3D from TPoint, sets the Z co-ordinate to  Zero
  2222 	*/
  2223 	IMPORT_C void SetPoint(const TPoint& aPoint);
  2224 
  2225 	/**
  2226 	Returns TPoint from TPoint3D
  2227 	*/
  2228 	IMPORT_C TPoint AsPoint() const;
  2229 #endif
  2230 public:
  2231 	/**
  2232 	The x co-ordinate.
  2233 	*/
  2234 	TInt iX;
  2235 	/**
  2236 	The y co-ordinate.
  2237 	*/
  2238 	TInt iY;
  2239 	/**
  2240 	The z co-ordinate.
  2241 	*/
  2242 	TInt iZ;
  2243 	};
  2244 
  2245 
  2246 
  2247 /**
  2248 @internalTechnology
  2249 @prototype For now, only intended to be used by TRwEvent and the Windows Server
  2250 
  2251 Stores the angular spherical coordinates (Phi,Theta) of a three-dimensional point.
  2252 
  2253 Its data members (iPhi, iTheta) are public and can be manipulated directly.
  2254 */
  2255 class TAngle3D
  2256 	{
  2257 public:
  2258 	/**
  2259 	The Phi co-ordinate (angle between X-axis and the line that links the projection of the point on the X-Y plane and the origin).
  2260 	*/
  2261 	TInt iPhi;
  2262 	/**
  2263 	The Theta co-ordinate (angle between the Z-axis and the line that links the point and the origin).
  2264 	*/
  2265 	TInt iTheta;
  2266 	};
  2267 
  2268 	
  2269 /**
  2270 @publishedAll
  2271 @released
  2272 
  2273 Stores a two-dimensional size as a width and a height value.
  2274 
  2275 Its data members are public and can be manipulated directly, or by means of 
  2276 the functions provided.
  2277 */
  2278 class TSize
  2279 	{
  2280 public:
  2281 #ifndef __KERNEL_MODE__
  2282 	enum TUninitialized { EUninitialized };
  2283 	/**
  2284 	Constructs the size object with its iWidth and iHeight members set to zero.
  2285 	*/
  2286 	TSize(TUninitialized) {}
  2287 	inline TSize();
  2288 	inline TSize(TInt aWidth,TInt aHeight);
  2289 	IMPORT_C TBool operator==(const TSize& aSize) const;
  2290 	IMPORT_C TBool operator!=(const TSize& aSize) const;
  2291 	IMPORT_C TSize& operator-=(const TSize& aSize);
  2292 	IMPORT_C TSize& operator-=(const TPoint& aPoint);
  2293 	IMPORT_C TSize& operator+=(const TSize& aSize);
  2294 	IMPORT_C TSize& operator+=(const TPoint& aPoint);
  2295 	IMPORT_C TSize operator-(const TSize& aSize) const;
  2296 	IMPORT_C TSize operator-(const TPoint& aPoint) const;
  2297 	IMPORT_C TSize operator+(const TSize& aSize) const;
  2298 	IMPORT_C TSize operator+(const TPoint& aPoint) const;
  2299 	IMPORT_C TSize operator-() const;
  2300 	IMPORT_C void SetSize(TInt aWidth,TInt aHeight);
  2301 	IMPORT_C TPoint AsPoint() const;
  2302 #endif
  2303 public:
  2304 	/**
  2305 	The width of this TSize object.
  2306 	*/
  2307 	TInt iWidth;
  2308 	/**
  2309 	The height of this TSize object.
  2310 	*/
  2311 	TInt iHeight;
  2312 	};
  2313 
  2314 
  2315 
  2316 
  2317 /**
  2318 @publishedAll
  2319 @released
  2320 
  2321 Information about a kernel object.
  2322 
  2323 This type of object is passed to RHandleBase::HandleInfo(). The function 
  2324 fetches information on the usage of the kernel object associated with that 
  2325 handle and stores the information in the THandleInfo object.
  2326 
  2327 The class contains four data members and no explicitly defined function
  2328 members.
  2329 */
  2330 class THandleInfo
  2331 	{
  2332 public:
  2333 	/**
  2334 	The number of times that the kernel object is open in the current process.
  2335 	*/
  2336 	TInt iNumOpenInProcess;
  2337 	
  2338 	/**
  2339 	The number of times that the kernel object is open in the current thread.
  2340 	*/
  2341 	TInt iNumOpenInThread;
  2342 	
  2343 	/**
  2344 	The number of processes which have a handle on the kernel object.
  2345 	*/
  2346 	TInt iNumProcesses;
  2347 	
  2348 	/**
  2349 	The number of threads which have a handle on the kernel object.
  2350 	*/
  2351 	TInt iNumThreads;
  2352 	};
  2353 
  2354 
  2355 
  2356 
  2357 /**
  2358 @internalComponent
  2359 */
  2360 class TFindHandle
  2361 	{
  2362 public:
  2363 	inline TFindHandle();
  2364 	inline TInt Handle() const;
  2365 #ifdef __KERNEL_MODE__
  2366 	inline TInt Index() const;
  2367 	inline TInt UniqueID() const;
  2368 	inline TUint64 ObjectID() const;
  2369 	inline void Set(TInt aIndex, TInt aUniqueId, TUint64 aObjectId);
  2370 #else
  2371 protected:
  2372 	inline void Reset();
  2373 #endif
  2374 private:
  2375 	TInt iHandle;
  2376 	TInt iSpare1;
  2377 	TInt iObjectIdLow;
  2378 	TInt iObjectIdHigh;
  2379 	};
  2380 
  2381 
  2382 
  2383 class RThread;
  2384 class TFindHandleBase;
  2385 class TFindSemaphore;
  2386 /**
  2387 @publishedAll
  2388 @released
  2389 
  2390 A handle to an object.
  2391 
  2392 The class encapsulates the basic behaviour of a handle, hiding the
  2393 handle-number which identifies the object which the handle represents.
  2394 
  2395 The class is abstract in the sense that a RHandleBase object is never
  2396 explicitly instantiated. It is always a base class to a concrete handle class;
  2397 for example, RSemaphore, RThread, RProcess, RCriticalSection etc.
  2398 */
  2399 class RHandleBase
  2400 	{
  2401 public:
  2402     /**
  2403     @publishedAll
  2404     @released
  2405 
  2406 	Read/Write attributes for the handle.
  2407     */
  2408     enum TAttributes
  2409 		{
  2410 		EReadAccess=0x1,
  2411 		EWriteAccess=0x2,
  2412 		EDirectReadAccess=0x4,
  2413 		EDirectWriteAccess=0x8,
  2414 		};
  2415 public:
  2416 	inline RHandleBase();
  2417 	inline TInt Handle() const;
  2418 	inline void SetHandle(TInt aHandle);
  2419 	inline TInt SetReturnedHandle(TInt aHandleOrError);	
  2420 	static void DoExtendedClose();
  2421 #ifndef __KERNEL_MODE__
  2422 	IMPORT_C void Close();
  2423 	IMPORT_C TName Name() const;
  2424 	IMPORT_C TFullName FullName() const;
  2425 	IMPORT_C void FullName(TDes& aName) const;
  2426 	IMPORT_C void SetHandleNC(TInt aHandle);
  2427 	IMPORT_C TInt Duplicate(const RThread& aSrc,TOwnerType aType=EOwnerProcess);
  2428 	IMPORT_C void HandleInfo(THandleInfo* anInfo);
  2429 	IMPORT_C TUint Attributes() const;
  2430 	IMPORT_C TInt BTraceId() const;
  2431 	IMPORT_C void NotifyDestruction(TRequestStatus& aStatus);	/**< @internalTechnology */
  2432 protected:
  2433 	inline RHandleBase(TInt aHandle);
  2434 	IMPORT_C TInt Open(const TFindHandleBase& aHandle,TOwnerType aType);
  2435 	static TInt SetReturnedHandle(TInt aHandleOrError,RHandleBase& aHandle);
  2436 	TInt OpenByName(const TDesC &aName,TOwnerType aOwnerType,TInt aObjectType);
  2437 #endif
  2438 private:
  2439 	static void DoExtendedCloseL();
  2440 protected:
  2441 	TInt iHandle;
  2442 	};
  2443 
  2444 
  2445 
  2446 
  2447 class RMessagePtr2;
  2448 /**
  2449 @publishedAll
  2450 @released
  2451 
  2452 A handle to a semaphore.
  2453 
  2454 The semaphore itself is a Kernel side object.
  2455 
  2456 As with all handles, they should be closed after use. RHandleBase provides 
  2457 the necessary Close() function, which should be called when the handle is 
  2458 no longer required.
  2459 
  2460 @see RHandleBase::Close
  2461 */
  2462 class RSemaphore : public RHandleBase
  2463 	{
  2464 public:
  2465 #ifndef __KERNEL_MODE__
  2466 	inline TInt Open(const TFindSemaphore& aFind,TOwnerType aType=EOwnerProcess);
  2467 	IMPORT_C TInt CreateLocal(TInt aCount,TOwnerType aType=EOwnerProcess);
  2468 	IMPORT_C TInt CreateGlobal(const TDesC& aName,TInt aCount,TOwnerType aType=EOwnerProcess);
  2469 	IMPORT_C TInt OpenGlobal(const TDesC& aName,TOwnerType aType=EOwnerProcess);
  2470 	IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess);
  2471 	IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
  2472 	IMPORT_C void Wait();
  2473 	IMPORT_C TInt Wait(TInt aTimeout);	// timeout in microseconds
  2474 	IMPORT_C void Signal();
  2475 	IMPORT_C void Signal(TInt aCount);
  2476 #endif
  2477 	};
  2478 
  2479 
  2480 
  2481 
  2482 /**
  2483 @publishedAll
  2484 @released
  2485 
  2486 A fast semaphore.
  2487 
  2488 This is a layer over a standard semaphore, and only calls into the kernel side
  2489 if there is contention.
  2490 */
  2491 class RFastLock : public RSemaphore
  2492 	{
  2493 public:
  2494 	inline RFastLock();
  2495 	IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess);
  2496 	IMPORT_C void Wait();
  2497 	IMPORT_C void Signal();
  2498 private:
  2499 	TInt iCount;
  2500 	};
  2501 
  2502 
  2503 
  2504 
  2505 /**
  2506 @publishedAll
  2507 @released
  2508 
  2509 A read-write lock.
  2510 
  2511 This is a lock for co-ordinating readers and writers to shared resources.
  2512 It is designed to allow multiple concurrent readers.
  2513 It is not a kernel side object and so does not inherit from RHandleBase.
  2514 */
  2515 class RReadWriteLock
  2516 	{
  2517 public:
  2518 	enum TReadWriteLockPriority
  2519 		{
  2520 		/** Pending writers always get the lock before pending readers */
  2521 		EWriterPriority,
  2522 		/** Lock is given alternately to pending readers and writers */
  2523 		EAlternatePriority,
  2524 		/** Pending readers always get the lock before pending writers - beware writer starvation! */
  2525 		EReaderPriority,
  2526 		};
  2527 	enum TReadWriteLockClientCategoryLimit
  2528 		{
  2529 		/** Maximum number of clients in each category: read locked, read lock pending, write lock pending */
  2530 		EReadWriteLockClientCategoryLimit = KMaxTUint16
  2531 		};
  2532 
  2533 public:
  2534 	inline RReadWriteLock();
  2535 	IMPORT_C TInt CreateLocal(TReadWriteLockPriority aPriority = EWriterPriority);
  2536 	IMPORT_C void Close();
  2537 
  2538 	IMPORT_C void ReadLock();
  2539 	IMPORT_C void WriteLock();
  2540 	IMPORT_C TBool TryReadLock();
  2541 	IMPORT_C TBool TryWriteLock();
  2542 	IMPORT_C TBool TryUpgradeReadLock();
  2543 	IMPORT_C void DowngradeWriteLock();
  2544 	IMPORT_C void Unlock();
  2545 
  2546 private:
  2547 	RReadWriteLock(const RReadWriteLock& aLock);
  2548 	RReadWriteLock& operator=(const RReadWriteLock& aLock);
  2549 
  2550 	TInt UnlockWriter();
  2551 	TInt UnlockAlternate();
  2552 	TInt UnlockReader();
  2553 
  2554 private:
  2555 	volatile TUint64 iValues; // Bits 0-15: readers; bit 16: writer; bits 32-47: readersPending; bits 48-63: writersPending
  2556 	TReadWriteLockPriority iPriority;
  2557 	RSemaphore iReaderSem;
  2558 	RSemaphore iWriterSem;
  2559 	TUint32 iSpare[4]; // Reserved for future development
  2560 	};
  2561 
  2562 
  2563 
  2564 
  2565 /**
  2566 @publishedAll
  2567 @released
  2568 
  2569 The user-side handle to a logical channel.
  2570 
  2571 The class provides functions that are used to open a channel
  2572 to a device driver, and to make requests. A device driver provides
  2573 a derived class to give the user-side a tailored interface to the driver.
  2574 */
  2575 class RBusLogicalChannel : public RHandleBase
  2576 	{
  2577 public:
  2578 	IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess);
  2579 	IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess);
  2580 protected:
  2581 	inline TInt DoCreate(const TDesC& aDevice, const TVersion& aVer, TInt aUnit, const TDesC* aDriver, const TDesC8* anInfo, TOwnerType aType=EOwnerProcess, TBool aProtected=EFalse);
  2582 	IMPORT_C void DoCancel(TUint aReqMask);
  2583 	IMPORT_C void DoRequest(TInt aReqNo,TRequestStatus& aStatus);
  2584 	IMPORT_C void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TAny* a1);
  2585 	IMPORT_C void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TAny* a1,TAny* a2);
  2586 	IMPORT_C TInt DoControl(TInt aFunction);
  2587 	IMPORT_C TInt DoControl(TInt aFunction,TAny* a1);
  2588 	IMPORT_C TInt DoControl(TInt aFunction,TAny* a1,TAny* a2);
  2589 	inline TInt DoSvControl(TInt aFunction) { return DoControl(aFunction); }
  2590 	inline TInt DoSvControl(TInt aFunction,TAny* a1) { return DoControl(aFunction, a1); }
  2591 	inline TInt DoSvControl(TInt aFunction,TAny* a1,TAny* a2) { return DoControl(aFunction, a1, a2); }
  2592 private:
  2593 	IMPORT_C TInt DoCreate(const TDesC& aDevice, const TVersion& aVer, TInt aUnit, const TDesC* aDriver, const TDesC8* aInfo, TInt aType);
  2594 private:
  2595 	// Padding for Binary Compatibility purposes
  2596 	TInt iPadding1;
  2597 	TInt iPadding2;
  2598 	};
  2599 
  2600 
  2601 
  2602 
  2603 /**
  2604 @internalComponent
  2605 
  2606 Base class for memory allocators.
  2607 */
  2608 // Put pure virtual functions into a separate base class so that vptr is at same
  2609 // place in both GCC98r2 and EABI builds.
  2610 class MAllocator
  2611 	{
  2612 public:
  2613 	virtual TAny* Alloc(TInt aSize)=0;
  2614 	virtual void Free(TAny* aPtr)=0;
  2615 	virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0)=0;
  2616 	virtual TInt AllocLen(const TAny* aCell) const =0;
  2617 	virtual TInt Compress()=0;
  2618 	virtual void Reset()=0;
  2619 	virtual TInt AllocSize(TInt& aTotalAllocSize) const =0;
  2620 	virtual TInt Available(TInt& aBiggestBlock) const =0;
  2621 	virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL)=0;
  2622 	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)=0;
  2623 	};
  2624 
  2625 
  2626 
  2627 
  2628 /**
  2629 @publishedAll
  2630 @released
  2631 
  2632 Base class for heaps.
  2633 */
  2634 class RAllocator : public MAllocator
  2635 	{
  2636 public:
  2637 
  2638 
  2639     /**
  2640     A set of heap allocation failure flags.
  2641     
  2642     This enumeration indicates how to simulate heap allocation failure.
  2643 
  2644     @see RAllocator::__DbgSetAllocFail()
  2645     */
  2646 	enum TAllocFail {
  2647                     /**
  2648                     Attempts to allocate from this heap fail at a random rate;
  2649                     however, the interval pattern between failures is the same
  2650                     every time simulation is started.
  2651                     */
  2652 	                ERandom,
  2653 	                
  2654 	                
  2655                   	/**
  2656                   	Attempts to allocate from this heap fail at a random rate.
  2657                   	The interval pattern between failures may be different every
  2658                   	time the simulation is started.
  2659                   	*/
  2660 	                ETrueRandom,
  2661 	                
  2662 	                
  2663                     /**
  2664                     Attempts to allocate from this heap fail at a rate aRate;
  2665                     for example, if aRate is 3, allocation fails at every
  2666                     third attempt.
  2667                     */
  2668 	                EDeterministic,
  2669 
  2670 	                
  2671 	                /**
  2672 	                Cancels simulated heap allocation failure.
  2673 	                */
  2674 	                ENone,
  2675 	                
  2676 	                
  2677 	                /**
  2678 	                An allocation from this heap will fail after the next aRate - 1 
  2679 					allocation attempts. For example, if aRate = 1 then the next 
  2680 					attempt to allocate from this heap will fail.
  2681 	                */
  2682 	                EFailNext,
  2683 	                
  2684 	                /**
  2685 	                Cancels simulated heap allocation failure, and sets
  2686 	                the nesting level for all allocated cells to zero.
  2687 	                */
  2688 	                EReset,
  2689 
  2690                     /**
  2691                     aBurst allocations from this heap fail at a random rate;
  2692                     however, the interval pattern between failures is the same
  2693                     every time the simulation is started.
  2694                     */
  2695 	                EBurstRandom,
  2696 	                
  2697 	                
  2698                   	/**
  2699                   	aBurst allocations from this heap fail at a random rate.
  2700                   	The interval pattern between failures may be different every
  2701                   	time the simulation is started.
  2702                   	*/
  2703 	                EBurstTrueRandom,
  2704 	                
  2705 	                
  2706                     /**
  2707                     aBurst allocations from this heap fail at a rate aRate.
  2708                     For example, if aRate is 10 and aBurst is 2, then 2 allocations
  2709 					will fail at every tenth attempt.
  2710                     */
  2711 	                EBurstDeterministic,
  2712 
  2713 	                /**
  2714 	                aBurst allocations from this heap will fail after the next aRate - 1 
  2715 					allocation attempts have occurred. For example, if aRate = 1 and 
  2716 					aBurst = 3 then the next 3 attempts to allocate from this heap will fail.
  2717 	                */
  2718 	                EBurstFailNext,
  2719 
  2720 					/**
  2721 					Use this to determine how many times the current debug 
  2722 					failure mode has failed so far.
  2723 					@see RAllocator::__DbgCheckFailure()
  2724 					*/
  2725 					ECheckFailure,
  2726 	                };
  2727 	                
  2728 	                
  2729     /**
  2730     Heap debug checking type flag.
  2731     */
  2732 	enum TDbgHeapType {
  2733                       /**
  2734                       The heap is a user heap.
  2735                       */
  2736 	                  EUser,
  2737 	                  
  2738                       /**
  2739                       The heap is the Kernel heap.
  2740                       */	                  
  2741 	                  EKernel
  2742 	                  };
  2743 	                  
  2744 	                  
  2745 	enum TAllocDebugOp {ECount, EMarkStart, EMarkEnd, ECheck, ESetFail, ECopyDebugInfo, ESetBurstFail};
  2746 	
  2747 	
  2748 	/**
  2749 	Flags controlling reallocation.
  2750 	*/
  2751 	enum TReAllocMode {
  2752 	                  /**
  2753 	                  A reallocation of a cell must not change
  2754 	                  the start address of the cell.
  2755 	                  */
  2756 	                  ENeverMove=1,
  2757 	                  
  2758 	                  /**
  2759 	                  Allows the start address of the cell to change
  2760 	                  if the cell shrinks in size.
  2761 	                  */
  2762 	                  EAllowMoveOnShrink=2
  2763 	                  };
  2764 	                  
  2765 	                  
  2766 	enum TFlags {ESingleThreaded=1, EFixedSize=2, ETraceAllocs=4, EMonitorMemory=8,};
  2767 	struct SCheckInfo {TBool iAll; TInt iCount; const TDesC8* iFileName; TInt iLineNum;};
  2768 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
  2769 	struct SRAllocatorBurstFail {TInt iBurst; TInt iRate; TInt iUnused[2];};
  2770 #endif
  2771 	enum {EMaxHandles=32};
  2772 
  2773 public:
  2774 	inline RAllocator();
  2775 #ifndef __KERNEL_MODE__
  2776 	IMPORT_C TInt Open();
  2777 	IMPORT_C void Close();
  2778 	IMPORT_C TAny* AllocZ(TInt aSize);
  2779 	IMPORT_C TAny* AllocZL(TInt aSize);
  2780 	IMPORT_C TAny* AllocL(TInt aSize);
  2781 	IMPORT_C TAny* AllocLC(TInt aSize);
  2782 	IMPORT_C void FreeZ(TAny*& aCell);
  2783 	IMPORT_C TAny* ReAllocL(TAny* aCell, TInt aSize, TInt aMode=0);
  2784 	IMPORT_C TInt Count() const;
  2785 	IMPORT_C TInt Count(TInt& aFreeCount) const;
  2786 #endif
  2787 	UIMPORT_C void Check() const;
  2788 	UIMPORT_C void __DbgMarkStart();
  2789 	UIMPORT_C TUint32 __DbgMarkEnd(TInt aCount);
  2790 	UIMPORT_C TInt __DbgMarkCheck(TBool aCountAll, TInt aCount, const TDesC8& aFileName, TInt aLineNum);
  2791 	inline void __DbgMarkCheck(TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum);
  2792 	UIMPORT_C void __DbgSetAllocFail(TAllocFail aType, TInt aRate);
  2793 	UIMPORT_C void __DbgSetBurstAllocFail(TAllocFail aType, TUint aRate, TUint aBurst);
  2794 	UIMPORT_C TUint __DbgCheckFailure();
  2795 protected:
  2796 	UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
  2797 #ifndef __KERNEL_MODE__
  2798 	IMPORT_C virtual void DoClose();
  2799 #endif
  2800 protected:
  2801 	TInt iAccessCount;
  2802 	TInt iHandleCount;
  2803 	TInt* iHandles;
  2804 	TUint32 iFlags;
  2805 	TInt iCellCount;
  2806 	TInt iTotalAllocSize;
  2807 	};
  2808 
  2809 
  2810 
  2811 
  2812 class UserHeap;
  2813 /**
  2814 @publishedAll
  2815 @released
  2816 
  2817 Represents the default implementation for a heap.
  2818 
  2819 The default implementation uses an address-ordered first fit type algorithm.
  2820 
  2821 The heap itself is contained in a chunk and may be the only occupant of the 
  2822 chunk or may share the chunk with the program stack.
  2823 
  2824 The class contains member functions for allocating, adjusting, freeing individual 
  2825 cells and generally managing the heap.
  2826 
  2827 The class is not a handle in the same sense that RChunk is a handle; i.e. 
  2828 there is no Kernel object which corresponds to the heap.
  2829 */
  2830 class RHeap : public RAllocator
  2831 	{
  2832 public:
  2833     /**
  2834     The structure of a heap cell header for a heap cell on the free list.
  2835     */
  2836 	struct SCell {
  2837 	             /**
  2838 	             The length of the cell, which includes the length of
  2839 	             this header.
  2840 	             */
  2841 	             TInt len; 
  2842 	             
  2843 	             
  2844 	             /**
  2845 	             A pointer to the next cell in the free list.
  2846 	             */
  2847 	             SCell* next;
  2848 	             };
  2849 
  2850 
  2851 	/**
  2852     The structure of a heap cell header for an allocated heap cell in a debug build.
  2853     */             
  2854 	struct SDebugCell {
  2855 	                  /**
  2856 	                  The length of the cell, which includes the length of
  2857                       this header.
  2858 	                  */
  2859 	                  TInt len;
  2860 	                  
  2861 	                  
  2862 	                  /**
  2863 	                  The nested level.
  2864 	                  */
  2865 	                  TInt nestingLevel;
  2866 	                  
  2867 	                  
  2868 	                  /**
  2869 	                  The cumulative number of allocated cells
  2870 	                  */
  2871 	                  TInt allocCount;
  2872 	                  };
  2873 
  2874 	/**
  2875     @internalComponent
  2876     */
  2877 	struct SHeapCellInfo { RHeap* iHeap; TInt iTotalAlloc;	TInt iTotalAllocSize; TInt iTotalFree; TInt iLevelAlloc; SDebugCell* iStranded; };
  2878 
  2879 	/**
  2880 	@internalComponent
  2881 	*/
  2882 	struct _s_align {char c; double d;};
  2883 
  2884 	/** 
  2885 	The default cell alignment.
  2886 	*/
  2887 	enum {ECellAlignment = sizeof(_s_align)-sizeof(double)};
  2888 	
  2889 	/**
  2890 	Size of a free cell header.
  2891 	*/
  2892 	enum {EFreeCellSize = sizeof(SCell)};
  2893 
  2894 
  2895 #ifdef _DEBUG
  2896     /**
  2897     Size of an allocated cell header in a debug build.
  2898     */
  2899 	enum {EAllocCellSize = sizeof(SDebugCell)};
  2900 #else
  2901     /**
  2902     Size of an allocated cell header in a release build.
  2903     */
  2904 	enum {EAllocCellSize = sizeof(SCell*)};
  2905 #endif
  2906 
  2907 
  2908     /**
  2909     @internalComponent
  2910     */
  2911 	enum TDebugOp {EWalk=128};
  2912 	
  2913 	
  2914     /**
  2915     @internalComponent
  2916     */
  2917 	enum TCellType
  2918 		{EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress,
  2919 		EBadFreeCellAddress, EBadFreeCellSize};
  2920 
  2921 		
  2922     /**
  2923     @internalComponent
  2924     */
  2925 	enum TDebugHeapId {EUser=0, EKernel=1};
  2926     
  2927     /**
  2928     @internalComponent
  2929     */
  2930     enum TDefaultShrinkRatios {EShrinkRatio1=256, EShrinkRatioDflt=512};
  2931 
  2932 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
  2933 	/**
  2934     @internalComponent
  2935     */
  2936 #else
  2937 private:
  2938 #endif
  2939     typedef void (*TWalkFunc)(TAny*, TCellType, TAny*, TInt);
  2940 
  2941 public:
  2942 	UIMPORT_C virtual TAny* Alloc(TInt aSize);
  2943 	UIMPORT_C virtual void Free(TAny* aPtr);
  2944 	UIMPORT_C virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0);
  2945 	UIMPORT_C virtual TInt AllocLen(const TAny* aCell) const;
  2946 #ifndef __KERNEL_MODE__
  2947 	UIMPORT_C virtual TInt Compress();
  2948 	UIMPORT_C virtual void Reset();
  2949 	UIMPORT_C virtual TInt AllocSize(TInt& aTotalAllocSize) const;
  2950 	UIMPORT_C virtual TInt Available(TInt& aBiggestBlock) const;
  2951 #endif
  2952 	UIMPORT_C virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL);
  2953 protected:
  2954 	UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
  2955 public:
  2956 	UIMPORT_C RHeap(TInt aMaxLength, TInt aAlign=0, TBool aSingleThread=ETrue);
  2957 	UIMPORT_C RHeap(TInt aChunkHandle, TInt aOffset, TInt aMinLength, TInt aMaxLength, TInt aGrowBy, TInt aAlign=0, TBool aSingleThread=EFalse);
  2958 	UIMPORT_C TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW;
  2959 	inline void operator delete(TAny* aPtr, TAny* aBase);
  2960 	inline TUint8* Base() const;
  2961 	inline TInt Size() const;
  2962 	inline TInt MaxLength() const;
  2963 	inline TInt Align(TInt a) const;
  2964 	inline const TAny* Align(const TAny* a) const;
  2965 	inline TBool IsLastCell(const SCell* aCell) const;
  2966 	inline void Lock() const;
  2967 	inline void Unlock() const;
  2968 	inline TInt ChunkHandle() const;
  2969 protected:
  2970 	inline RHeap();
  2971 	void Initialise();
  2972 	SCell* DoAlloc(TInt aSize, SCell*& aLastFree);
  2973 	void DoFree(SCell* pC);
  2974 	TInt TryToGrowHeap(TInt aSize, SCell* aLastFree);
  2975 	inline void FindFollowingFreeCell(SCell* aCell, SCell*& pPrev, SCell*& aNext);
  2976 	TInt TryToGrowCell(SCell* pC, SCell* pP, SCell* pE, TInt aSize);
  2977 	TInt Reduce(SCell* aCell);
  2978 	UIMPORT_C SCell* GetAddress(const TAny* aCell) const;
  2979 	void CheckCell(const SCell* aCell) const;
  2980 	void Walk(TWalkFunc aFunc, TAny* aPtr);
  2981 	static void WalkCheckCell(TAny* aPtr, TCellType aType, TAny* aCell, TInt aLen);
  2982 	TInt DoCountAllocFree(TInt& aFree);
  2983 	TInt DoCheckHeap(SCheckInfo* aInfo);
  2984 	void DoMarkStart();
  2985 	TUint32 DoMarkEnd(TInt aExpected);
  2986 	void DoSetAllocFail(TAllocFail aType, TInt aRate);
  2987 	TBool CheckForSimulatedAllocFail();
  2988 	inline TInt SetBrk(TInt aBrk);
  2989 	inline TAny* ReAllocImpl(TAny* aPtr, TInt aSize, TInt aMode);
  2990 	void DoSetAllocFail(TAllocFail aType, TInt aRate, TUint aBurst);
  2991 protected:
  2992 	TInt iMinLength;
  2993 	TInt iMaxLength;
  2994 	TInt iOffset;
  2995 	TInt iGrowBy;
  2996 	TInt iChunkHandle;
  2997 	RFastLock iLock;
  2998 	TUint8* iBase;
  2999 	TUint8* iTop;
  3000 	TInt iAlign;
  3001 	TInt iMinCell;
  3002 	TInt iPageSize;
  3003 	SCell iFree;
  3004 protected:
  3005 	TInt iNestingLevel;
  3006 	TInt iAllocCount;
  3007 	TAllocFail iFailType;
  3008 	TInt iFailRate;
  3009 	TBool iFailed;
  3010 	TInt iFailAllocCount;
  3011 	TInt iRand;
  3012 	TAny* iTestData;
  3013 
  3014 	friend class UserHeap;
  3015 	};
  3016 
  3017 
  3018 
  3019 
  3020 
  3021 class OnlyCreateWithNull;
  3022 
  3023 /** @internalTechnology */
  3024 typedef void (OnlyCreateWithNull::* __NullPMF)();
  3025 
  3026 /** @internalTechnology */
  3027 class OnlyCreateWithNull
  3028 	{
  3029 public:
  3030 	inline OnlyCreateWithNull(__NullPMF /*aPointerToNull*/) {}
  3031 	};
  3032 
  3033 /**
  3034 @publishedAll
  3035 @released
  3036 
  3037 A handle to a message sent by the client to the server.
  3038 
  3039 A server's interaction with its clients is channelled through an RMessagePtr2
  3040 object, which acts as a handle to a message sent by the client.
  3041 The details of the original message are kept by the kernel allowing it enforce
  3042 correct usage of the member functions of this class.
  3043 
  3044 @see RMessage2
  3045 */
  3046 class RMessagePtr2
  3047 	{
  3048 public:
  3049 	inline RMessagePtr2();
  3050 	inline TBool IsNull() const;
  3051 	inline TInt Handle() const;
  3052 #ifndef __KERNEL_MODE__
  3053 	IMPORT_C void Complete(TInt aReason) const;
  3054 	IMPORT_C void Complete(RHandleBase aHandle) const;
  3055 	IMPORT_C TInt GetDesLength(TInt aParam) const;
  3056 	IMPORT_C TInt GetDesLengthL(TInt aParam) const;
  3057 	IMPORT_C TInt GetDesMaxLength(TInt aParam) const;
  3058 	IMPORT_C TInt GetDesMaxLengthL(TInt aParam) const;
  3059 	IMPORT_C void ReadL(TInt aParam,TDes8& aDes,TInt aOffset=0) const;
  3060 	IMPORT_C void ReadL(TInt aParam,TDes16 &aDes,TInt aOffset=0) const;
  3061 	IMPORT_C void WriteL(TInt aParam,const TDesC8& aDes,TInt aOffset=0) const;
  3062 	IMPORT_C void WriteL(TInt aParam,const TDesC16& aDes,TInt aOffset=0) const;
  3063 	IMPORT_C TInt Read(TInt aParam,TDes8& aDes,TInt aOffset=0) const;
  3064 	IMPORT_C TInt Read(TInt aParam,TDes16 &aDes,TInt aOffset=0) const;
  3065 	IMPORT_C TInt Write(TInt aParam,const TDesC8& aDes,TInt aOffset=0) const;
  3066 	IMPORT_C TInt Write(TInt aParam,const TDesC16& aDes,TInt aOffset=0) const;
  3067 	IMPORT_C void Panic(const TDesC& aCategory,TInt aReason) const;
  3068 	IMPORT_C void Kill(TInt aReason) const;
  3069 	IMPORT_C void Terminate(TInt aReason) const;
  3070 	IMPORT_C TInt SetProcessPriority(TProcessPriority aPriority) const;
  3071 	inline   void SetProcessPriorityL(TProcessPriority aPriority) const;
  3072 	IMPORT_C TInt Client(RThread& aClient, TOwnerType aOwnerType=EOwnerProcess) const;
  3073 	inline   void ClientL(RThread& aClient, TOwnerType aOwnerType=EOwnerProcess) const;
  3074 	IMPORT_C TUint ClientProcessFlags() const;
  3075 	IMPORT_C const TRequestStatus* ClientStatus() const;
  3076 	IMPORT_C TBool ClientIsRealtime() const;
  3077 	
  3078 	/**
  3079 	Return the Secure ID of the process which sent this message.
  3080 
  3081 	If an intended use of this method is to check that the Secure ID is
  3082 	a given value, then the use of a TSecurityPolicy object should be
  3083 	considered. E.g. Instead of something like:
  3084 
  3085 	@code
  3086 		RMessagePtr2& message;
  3087 		TInt error = message.SecureId()==KRequiredSecureId ? KErrNone : KErrPermissionDenied;
  3088 	@endcode
  3089 
  3090 	this could be used;
  3091 
  3092 	@code
  3093 		RMessagePtr2& message;
  3094 		static _LIT_SECURITY_POLICY_S0(mySidPolicy, KRequiredSecureId);
  3095 		TBool pass = mySidPolicy().CheckPolicy(message);
  3096 	@endcode
  3097 
  3098 	This has the benefit that the TSecurityPolicy::CheckPolicy methods are
  3099 	configured by the system wide Platform Security configuration. I.e. are
  3100 	capable of emitting diagnostic messages when a check fails and/or the
  3101 	check can be forced to always pass.
  3102 
  3103 	@see TSecurityPolicy::CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const
  3104 	@see _LIT_SECURITY_POLICY_S0
  3105 
  3106 	@return The Secure ID.
  3107 
  3108 	@publishedAll
  3109 	@released
  3110 	*/
  3111 	IMPORT_C TSecureId SecureId() const;
  3112 
  3113 	/**
  3114 	Return the Vendor ID of the process which sent this message.
  3115 
  3116 	If an intended use of this method is to check that the Vendor ID is
  3117 	a given value, then the use of a TSecurityPolicy object should be
  3118 	considered. E.g. Instead of something like:
  3119 
  3120 	@code
  3121 		RMessagePtr2& message;
  3122 		TInt error = message.VendorId()==KRequiredVendorId ? KErrNone : KErrPermissionDenied;
  3123 	@endcode
  3124 
  3125 	this could be used;
  3126 
  3127 	@code
  3128 		RMessagePtr2& message;
  3129 		static _LIT_SECURITY_POLICY_V0(myVidPolicy, KRequiredVendorId);
  3130 		TBool pass = myVidPolicy().CheckPolicy(message);
  3131 	@endcode
  3132 
  3133 	This has the benefit that the TSecurityPolicy::CheckPolicy methods are
  3134 	configured by the system wide Platform Security configuration. I.e. are
  3135 	capable of emitting diagnostic messages when a check fails and/or the
  3136 	check can be forced to always pass.
  3137 
  3138 	@see TSecurityPolicy::CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const
  3139 	@see _LIT_SECURITY_POLICY_V0
  3140 
  3141 	@return The Vendor ID.
  3142 	@publishedAll
  3143 	@released
  3144 	*/
  3145 	IMPORT_C TVendorId VendorId() const;
  3146 
  3147 	/**
  3148 	Check if the process which sent this message has a given capability.
  3149 
  3150 	When a check fails the action taken is determined by the system wide Platform Security
  3151 	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
  3152 	If PlatSecEnforcement is OFF, then this function will return ETrue even though the
  3153 	check failed.
  3154 
  3155 	@param aCapability The capability to test.
  3156 	@param aDiagnostic A string that will be emitted along with any diagnostic message
  3157 								that may be issued if the test finds the capability is not present.
  3158 								This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
  3159 								which enables it to be easily removed from the system.
  3160 	@return ETrue if process which sent this message has the capability, EFalse otherwise.
  3161 	@publishedAll
  3162 	@released
  3163 	*/
  3164 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3165 	inline TBool HasCapability(TCapability aCapability, const char* aDiagnostic=0) const;
  3166 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3167 	// Only available to NULL arguments
  3168 	inline TBool HasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic=NULL) const;
  3169 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3170 	// For things using KSuppressPlatSecDiagnostic
  3171 	inline TBool HasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3172 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  3173 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3174 
  3175  	/**
  3176 	Check if the process which sent this message has a given capability.
  3177 
  3178 	When a check fails the action taken is determined by the system wide Platform Security
  3179 	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
  3180 	If PlatSecEnforcement is OFF, then this function will not leave even though the
  3181 	check failed.
  3182 
  3183  	@param aCapability The capability to test.
  3184  	@param aDiagnosticMessage A string that will be emitted along with any diagnostic message
  3185  								that may be issued if the test finds the capability is not present.
  3186  								This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
  3187  								which enables it to be easily removed from the system.
  3188  	@leave KErrPermissionDenied, if the process does not have the capability.
  3189  	@publishedAll
  3190  	@released
  3191  	*/
  3192 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3193  	inline void HasCapabilityL(TCapability aCapability, const char* aDiagnosticMessage=0) const;
  3194 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3195 	// Only available to NULL arguments
  3196  	inline void HasCapabilityL(TCapability aCapability, OnlyCreateWithNull aDiagnosticMessage=NULL) const;
  3197 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3198 	// For things using KSuppressPlatSecDiagnostic
  3199 	inline void HasCapabilityL(TCapability aCapability, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3200 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  3201 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3202 
  3203 	/**
  3204 	Check if the process which sent this message has both of the given capabilities.
  3205 
  3206 	When a check fails the action taken is determined by the system wide Platform Security
  3207 	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
  3208 	If PlatSecEnforcement is OFF, then this function will return ETrue even though the
  3209 	check failed.
  3210 
  3211 	@param aCapability1 The first capability to test.
  3212 	@param aCapability2 The second capability to test.
  3213 	@param aDiagnostic A string that will be emitted along with any diagnostic message
  3214 								that may be issued if the test finds a capability is not present.
  3215 								This string should be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
  3216 								which enables it to be easily removed from the system.
  3217 	@return ETrue if the process which sent this message has both the capabilities, EFalse otherwise.
  3218 	@publishedAll
  3219 	@released
  3220 	*/
  3221 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3222 	inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic=0) const;
  3223 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3224 	// Only available to NULL arguments
  3225 	inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic=NULL) const;
  3226 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3227 	// For things using KSuppressPlatSecDiagnostic
  3228 	inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3229 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  3230 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3231 
  3232  	/**
  3233 	Check if the process which sent this message has both of the given capabilities.
  3234 
  3235 	When a check fails the action taken is determined by the system wide Platform Security
  3236 	configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted.
  3237 	If PlatSecEnforcement is OFF, then this function will not leave even though the
  3238 	check failed.
  3239 
  3240  	@param aCapability1 The first capability to test.
  3241  	@param aCapability2 The second capability to test.
  3242  	@param aDiagnosticMessage A string that will be emitted along with any diagnostic message
  3243  								that may be issued if the test finds a capability is not present.
  3244  								This string should be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro
  3245  								which enables it to be easily removed from the system.
  3246  	@leave KErrPermissionDenied, if the process does not have the capabilities.
  3247  	@publishedAll
  3248  	@released
  3249  	*/
  3250 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3251 	inline void HasCapabilityL(TCapability aCapability1, TCapability aCapability2, const char* aDiagnosticMessage=0) const;
  3252 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3253 	// Only available to NULL arguments
  3254 	inline void HasCapabilityL(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnosticMessage=NULL) const;
  3255 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3256 	// For things using KSuppressPlatSecDiagnostic
  3257 	inline void HasCapabilityL(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3258 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  3259 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3260 
  3261 	/**
  3262 	@deprecated Use SecureId()
  3263 	*/
  3264 	inline TUid Identity() const { return SecureId(); }
  3265 #endif
  3266 
  3267 private:
  3268 	// Implementations of functions with diagnostics
  3269 	IMPORT_C TBool DoHasCapability(TCapability aCapability, const char* aDiagnostic) const;
  3270 	IMPORT_C TBool DoHasCapability(TCapability aCapability) const;
  3271 	IMPORT_C TBool DoHasCapability(TCapability aCapability, TCapability aCapability2, const char* aDiagnostic) const;
  3272 	IMPORT_C TBool DoHasCapability(TCapability aCapability, TCapability aCapability2) const;
  3273 
  3274 protected:
  3275 	TInt iHandle;
  3276 	};
  3277 inline TBool operator==(RMessagePtr2 aLeft,RMessagePtr2 aRight);
  3278 inline TBool operator!=(RMessagePtr2 aLeft,RMessagePtr2 aRight);
  3279 
  3280 class CSession2;
  3281 
  3282 #define __IPC_V2_PRESENT__
  3283 
  3284 /**
  3285 @publishedAll
  3286 @released
  3287 
  3288 An object that encapsulates the details of a client request.
  3289 */
  3290 class RMessage2 : public RMessagePtr2
  3291 	{
  3292 	friend class CServer2;
  3293 public:
  3294 
  3295     /**
  3296     Defines internal message types.
  3297     */
  3298 	enum TSessionMessages {
  3299 	                      /**
  3300 	                      A message type used internally that means connect.
  3301 	                      */
  3302 	                      EConnect=-1,
  3303 	                      
  3304 	                      /**
  3305                           A message type used internally that means disconnect.
  3306 	                      */
  3307 	                      EDisConnect=-2
  3308 	                      };
  3309 public:
  3310 	inline RMessage2();
  3311 #ifndef __KERNEL_MODE__
  3312 	IMPORT_C explicit RMessage2(const RMessagePtr2& aPtr);
  3313 	void SetAuthorised() const; 
  3314 	void ClearAuthorised() const;
  3315 	TBool Authorised() const;
  3316 #endif
  3317 	inline TInt Function() const;
  3318 	inline TInt Int0() const;
  3319 	inline TInt Int1() const;
  3320 	inline TInt Int2() const;
  3321 	inline TInt Int3() const;
  3322 	inline const TAny* Ptr0() const;
  3323 	inline const TAny* Ptr1() const;
  3324 	inline const TAny* Ptr2() const;
  3325 	inline const TAny* Ptr3() const;
  3326 	inline CSession2* Session() const;
  3327 protected:
  3328     
  3329     /**
  3330     The request type.
  3331     */
  3332 	TInt iFunction;
  3333 	
  3334 	/**
  3335 	A copy of the message arguments.
  3336 	*/
  3337 	TInt iArgs[KMaxMessageArguments];
  3338 private:
  3339 	TInt iSpare1;
  3340 protected:
  3341     /**
  3342     @internalComponent
  3343     */
  3344 	const TAny* iSessionPtr;
  3345 private:
  3346 	mutable TInt iFlags;// Currently only used for *Authorised above
  3347 	TInt iSpare3;		// Reserved for future use
  3348 
  3349 	friend class RMessage;
  3350 	};
  3351 
  3352 
  3353 
  3354 
  3355 /**
  3356 @publishedAll
  3357 @released
  3358 
  3359 Defines an 8-bit modifiable buffer descriptor to contain passwords when dealing
  3360 with password security support in a file server session.
  3361 
  3362 The descriptor takes a maximum length of KMaxMediaPassword.
  3363 
  3364 @see KMaxMediaPassword
  3365 */
  3366 typedef TBuf8<KMaxMediaPassword> TMediaPassword;	// 128 bit
  3367 
  3368 
  3369 
  3370 /**
  3371 @publishedPartner
  3372 @prototype
  3373 A configuration flag for the shared chunk buffer configuration class (used by the multimedia device drivers). This being
  3374 set signifies that a buffer offset list follows the buffer configuration class. This list holds the offset of each buffer.
  3375 */
  3376 const TUint KScFlagBufOffsetListInUse=0x00000001;
  3377 
  3378 /**
  3379 @publishedPartner
  3380 @prototype
  3381 A configuration flag for the shared chunk buffer configuration class (used by the multimedia device drivers). This being
  3382 set is a suggestion that the shared chunk should be configured leaving guard pages around each buffers.
  3383 */
  3384 const TUint KScFlagUseGuardPages=0x00000002;
  3385 
  3386 /**
  3387 @publishedPartner
  3388 @prototype
  3389 The shared chunk buffer configuration class (used by the multimedia device drivers). This is used to hold information
  3390 on the current buffer configuration within a shared chunk.
  3391 */
  3392 class TSharedChunkBufConfigBase
  3393 	{
  3394 public:	
  3395 	inline TSharedChunkBufConfigBase();
  3396 public:
  3397 	/** The number of buffers. */
  3398 	TInt iNumBuffers;
  3399 	/** The size of each buffer in bytes. */
  3400 	TInt iBufferSizeInBytes;
  3401 	/** Reserved field. */
  3402 	TInt iReserved1;
  3403 	/** Shared chunk buffer flag settings. */
  3404 	TUint iFlags;
  3405 	};
  3406 
  3407 
  3408 /** Maximum size of capability set
  3409 
  3410 @internalTechnology
  3411 */
  3412 const TInt KCapabilitySetMaxSize = (((TInt)ECapability_HardLimit + 7)>>3);
  3413 
  3414 /** Maximum size of any future extension to TSecurityPolicy
  3415 
  3416 @internalTechnology
  3417 */
  3418 const TInt KMaxSecurityPolicySize = KCapabilitySetMaxSize + 3*sizeof(TUint32);
  3419 
  3420 
  3421 /** Class representing an arbitrary set of capabilities.
  3422 
  3423 This class can only contain capabilities supported by the current OS version.
  3424 
  3425 @publishedAll
  3426 @released
  3427 */
  3428 class TCapabilitySet
  3429 	{
  3430 public:
  3431 	inline TCapabilitySet();
  3432 	inline TCapabilitySet(TCapability aCapability);
  3433 	IMPORT_C TCapabilitySet(TCapability aCapability1, TCapability aCapability2);
  3434 	IMPORT_C void SetEmpty();
  3435 	inline void Set(TCapability aCapability);
  3436 	inline void Set(TCapability aCapability1, TCapability aCapability2);
  3437 	IMPORT_C void SetAllSupported();
  3438 	IMPORT_C void AddCapability(TCapability aCapability);
  3439 	IMPORT_C void RemoveCapability(TCapability aCapability);
  3440 	IMPORT_C void Union(const TCapabilitySet&  aCapabilities);
  3441 	IMPORT_C void Intersection(const TCapabilitySet& aCapabilities);
  3442 	IMPORT_C void Remove(const TCapabilitySet& aCapabilities);
  3443 	IMPORT_C TBool HasCapability(TCapability aCapability) const;
  3444 	IMPORT_C TBool HasCapabilities(const TCapabilitySet& aCapabilities) const;
  3445 
  3446 	/**
  3447 	Make this set consist of the capabilities which are disabled on this platform.
  3448 	@internalTechnology
  3449 	*/
  3450 	IMPORT_C void SetDisabled();
  3451 	/**
  3452 	@internalComponent
  3453 	*/
  3454 	TBool NotEmpty() const;
  3455 
  3456 private:
  3457 	TUint32 iCaps[KCapabilitySetMaxSize / sizeof(TUint32)];
  3458 	};
  3459 
  3460 #ifndef __SECURITY_INFO_DEFINED__
  3461 #define __SECURITY_INFO_DEFINED__
  3462 /**
  3463 @internalTechnology
  3464  */
  3465 struct SCapabilitySet
  3466 	{
  3467 	enum {ENCapW=2};
  3468 
  3469 	inline void AddCapability(TCapability aCap1) {((TCapabilitySet*)this)->AddCapability(aCap1);}
  3470 	inline void Remove(const SCapabilitySet& aCaps) {((TCapabilitySet*)this)->Remove(*((TCapabilitySet*)&aCaps));}
  3471 	inline TBool NotEmpty() const {return ((TCapabilitySet*)this)->NotEmpty();}
  3472 
  3473 	inline const TUint32& operator[] (TInt aIndex) const { return iCaps[aIndex]; }
  3474 	inline TUint32& operator[] (TInt aIndex) { return iCaps[aIndex]; }
  3475 
  3476 	TUint32 iCaps[ENCapW];
  3477 	};
  3478 
  3479 /**
  3480 @internalTechnology
  3481  */
  3482 struct SSecurityInfo
  3483 	{
  3484 	TUint32	iSecureId;
  3485 	TUint32	iVendorId;
  3486 	SCapabilitySet iCaps;	// Capabilities re. platform security
  3487 	};
  3488 
  3489 #endif
  3490 
  3491 /** Define this macro to reference the set of all capabilities.
  3492 	@internalTechnology
  3493 */
  3494 #ifdef __REFERENCE_ALL_SUPPORTED_CAPABILITIES__
  3495 
  3496 extern const SCapabilitySet AllSupportedCapabilities;
  3497 
  3498 #endif	//__REFERENCE_ALL_SUPPORTED_CAPABILITIES__
  3499 
  3500 /** Define this macro to include the set of all capabilities.
  3501 	@internalTechnology
  3502 */
  3503 #ifdef __INCLUDE_ALL_SUPPORTED_CAPABILITIES__
  3504 
  3505 /** The set of all capabilities.
  3506 	@internalTechnology
  3507 */
  3508 const SCapabilitySet AllSupportedCapabilities = {
  3509 		{
  3510 		ECapability_Limit<32  ? (TUint32)((1u<<(ECapability_Limit&31))-1u) : 0xffffffffu
  3511 		,
  3512 		ECapability_Limit>=32 ? (TUint32)((1u<<(ECapability_Limit&31))-1u) : 0u
  3513 		}
  3514 	};
  3515 
  3516 #endif	// __INCLUDE_ALL_SUPPORTED_CAPABILITIES__
  3517 
  3518 #ifndef __KERNEL_MODE__
  3519 class RProcess;
  3520 class RThread;
  3521 class RMessagePtr2;
  3522 class RSessionBase;
  3523 #else
  3524 class DProcess;
  3525 class DThread;
  3526 #endif
  3527 
  3528 /** Class representing all security attributes of a process or DLL.
  3529 	These comprise a set of capabilities, a Secure ID and a Vendor ID.
  3530 
  3531 @publishedAll
  3532 @released
  3533 */
  3534 class TSecurityInfo
  3535 	{
  3536 public:
  3537 	inline TSecurityInfo();
  3538 #ifdef __KERNEL_MODE__
  3539 	IMPORT_C TSecurityInfo(DProcess* aProcess);
  3540 	IMPORT_C TSecurityInfo(DThread* aThread);
  3541 #else
  3542 	IMPORT_C TSecurityInfo(RProcess aProcess);
  3543 	IMPORT_C TSecurityInfo(RThread aThread);
  3544 	IMPORT_C TSecurityInfo(RMessagePtr2 aMesPtr);
  3545 	inline void Set(RProcess aProcess);
  3546 	inline void Set(RThread aThread);
  3547 	inline void Set(RMessagePtr2 aMsgPtr);
  3548 	TInt Set(RSessionBase aSession); /**< @internalComponent */
  3549 	inline void SetToCurrentInfo();
  3550 	IMPORT_C void SetToCreatorInfo();
  3551 #endif //__KERNEL_MODE__
  3552 public:
  3553 	TSecureId		iSecureId;	/**< Secure ID */
  3554 	TVendorId		iVendorId;	/**< Vendor ID */
  3555 	TCapabilitySet	iCaps;		/**< Capability Set */
  3556 	};
  3557 
  3558 
  3559 /** Class representing a generic security policy
  3560 
  3561 This class can specify a security policy consisting of either:
  3562 
  3563 -#	A check for between 0 and 7 capabilities
  3564 -#	A check for a given Secure ID along with 0-3 capabilities
  3565 -#	A check for a given Vendor ID along with 0-3 capabilities
  3566 
  3567 If multiple capabilities are specified, all of them must be present for the
  3568 security check to succeed ('AND' relation).
  3569 
  3570 The envisaged use case for this class is to specify access rights to an object
  3571 managed either by the kernel or by a server but in principle owned by a client
  3572 and usable in a limited way by other clients. For example
  3573 - Publish and Subscribe properties
  3574 - DBMS databases
  3575 
  3576 In these cases the owning client would pass one (or more) of these objects to
  3577 the server to specify which security checks should be done on other clients
  3578 before allowing access to the object.
  3579 
  3580 To pass a TSecurityPolicy object via IPC, a client should obtain a descriptor
  3581 for the object using Package() and send this. When a server receives this descriptor
  3582 it should read the descriptor contents into a TSecurityPolicyBuf and then
  3583 Set() should be used to create a policy object from this.
  3584 
  3585 Because this class has non-default constructors, compilers will not initialise
  3586 this object at compile time, instead code will be generated to construct the object
  3587 at run-time. This is wasteful - and Symbian OS DLLs are not permitted to have
  3588 such uninitialised data. To overcome these problems a set of macros are provided to
  3589 construct a const object which behaves like a TSecurityPolicy. These are:
  3590 
  3591 _LIT_SECURITY_POLICY_C1 through _LIT_SECURITY_POLICY_C7,
  3592 _LIT_SECURITY_POLICY_S0 through _LIT_SECURITY_POLICY_S3 and
  3593 _LIT_SECURITY_POLICY_V0 through _LIT_SECURITY_POLICY_V3.
  3594 
  3595 Also, the macros _LIT_SECURITY_POLICY_PASS and _LIT_SECURITY_POLICY_FAIL are provided
  3596 in order to allow easy construction of a const object which can be used as a
  3597 TSecuityPolicy which always passes or always fails, respectively.
  3598 
  3599 If a security policy object is needed to be embedded in another class then the
  3600 TStaticSecurityPolicy structure can be used. This behaves in the same way as a
  3601 TSecurityPolicy object but may be initialised at compile time.
  3602 
  3603 @see TStaticSecurityPolicy
  3604 @see TSecurityPolicyBuf
  3605 @see _LIT_SECURITY_POLICY_PASS
  3606 @see _LIT_SECURITY_POLICY_FAIL
  3607 @see _LIT_SECURITY_POLICY_C1
  3608 @see _LIT_SECURITY_POLICY_C2 
  3609 @see _LIT_SECURITY_POLICY_C3 
  3610 @see _LIT_SECURITY_POLICY_C4 
  3611 @see _LIT_SECURITY_POLICY_C5 
  3612 @see _LIT_SECURITY_POLICY_C6 
  3613 @see _LIT_SECURITY_POLICY_C7 
  3614 @see _LIT_SECURITY_POLICY_S0 
  3615 @see _LIT_SECURITY_POLICY_S1 
  3616 @see _LIT_SECURITY_POLICY_S2 
  3617 @see _LIT_SECURITY_POLICY_S3 
  3618 @see _LIT_SECURITY_POLICY_V0 
  3619 @see _LIT_SECURITY_POLICY_V1 
  3620 @see _LIT_SECURITY_POLICY_V2 
  3621 @see _LIT_SECURITY_POLICY_V3 
  3622 
  3623 @publishedAll
  3624 @released
  3625 */
  3626 class TSecurityPolicy
  3627 	{
  3628 public:
  3629 	enum TSecPolicyType 
  3630 		{
  3631 		EAlwaysFail=0,
  3632 		EAlwaysPass=1,
  3633 		};
  3634 		
  3635 public:
  3636 	inline TSecurityPolicy();
  3637 	IMPORT_C TSecurityPolicy(TSecPolicyType aType);
  3638 	IMPORT_C TSecurityPolicy(TCapability aCap1, TCapability aCap2 = ECapability_None, TCapability aCap3 = ECapability_None);
  3639 	IMPORT_C TSecurityPolicy(TCapability aCap1, TCapability aCap2, TCapability aCap3, TCapability aCap4, TCapability aCap5 = ECapability_None, TCapability aCap6 = ECapability_None, TCapability aCap7 = ECapability_None);
  3640 	IMPORT_C TSecurityPolicy(TSecureId aSecureId, TCapability aCap1 = ECapability_None, TCapability aCap2 = ECapability_None, TCapability aCap3 = ECapability_None);
  3641 	IMPORT_C TSecurityPolicy(TVendorId aVendorId, TCapability aCap1 = ECapability_None, TCapability aCap2 = ECapability_None, TCapability aCap3 = ECapability_None);
  3642 	IMPORT_C TInt Set(const TDesC8& aDes);
  3643 	IMPORT_C TPtrC8 Package() const;
  3644 
  3645 #ifdef __KERNEL_MODE__
  3646 
  3647 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3648 	inline TBool CheckPolicy(DProcess* aProcess, const char* aDiagnostic=0) const;
  3649 	inline TBool CheckPolicy(DThread* aThread, const char* aDiagnostic=0) const;
  3650 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3651 	// Only available to NULL arguments
  3652 	inline TBool CheckPolicy(DProcess* aProcess, OnlyCreateWithNull aDiagnostic=NULL) const;
  3653 	inline TBool CheckPolicy(DThread* aThread, OnlyCreateWithNull aDiagnostic=NULL) const;
  3654 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3655 
  3656 #else // !__KERNEL_MODE__
  3657 
  3658 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3659 	inline TBool CheckPolicy(RProcess aProcess, const char* aDiagnostic=0) const;
  3660 	inline TBool CheckPolicy(RThread aThread, const char* aDiagnostic=0) const;
  3661 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic=0) const;
  3662 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic=0) const;
  3663 	inline TBool CheckPolicyCreator(const char* aDiagnostic=0) const;
  3664 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3665 	// Only available to NULL arguments
  3666 	inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic=NULL) const;
  3667 	inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic=NULL) const;
  3668 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic=NULL) const;
  3669 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic=NULL) const;
  3670 	inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic=NULL) const;
  3671 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3672 	// For things using KSuppressPlatSecDiagnostic
  3673 	inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3674 	inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3675 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3676 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3677 	inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3678 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  3679 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3680 	TInt CheckPolicy(RSessionBase aSession) const; /**< @internalComponent */
  3681 
  3682 #endif //__KERNEL_MODE__
  3683 
  3684 	TBool Validate() const;
  3685 
  3686 private:
  3687 #ifdef __KERNEL_MODE__
  3688 	IMPORT_C TBool DoCheckPolicy(DProcess* aProcess, const char* aDiagnostic) const;
  3689 	IMPORT_C TBool DoCheckPolicy(DProcess* aProcess) const;
  3690 	IMPORT_C TBool DoCheckPolicy(DThread* aThread, const char* aDiagnostic) const;
  3691 	IMPORT_C TBool DoCheckPolicy(DThread* aThread) const;
  3692 #else // !__KERNEL_MODE__
  3693 	IMPORT_C TBool DoCheckPolicy(RProcess aProcess, const char* aDiagnostic) const;
  3694 	IMPORT_C TBool DoCheckPolicy(RProcess aProcess) const;
  3695 	IMPORT_C TBool DoCheckPolicy(RThread aThread, const char* aDiagnostic) const;
  3696 	IMPORT_C TBool DoCheckPolicy(RThread aThread) const;
  3697 	IMPORT_C TBool DoCheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const;
  3698 	IMPORT_C TBool DoCheckPolicy(RMessagePtr2 aMsgPtr) const;
  3699 	IMPORT_C TBool DoCheckPolicyCreator(const char* aDiagnostic) const;
  3700 	IMPORT_C TBool DoCheckPolicyCreator() const;
  3701 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3702 	TBool DoCheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic) const;
  3703 #endif //__REMOVE_PLATSEC_DIAGNOSTICS__
  3704 	TBool DoCheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing) const;
  3705 #endif //__KERNEL_MODE__
  3706 
  3707 public:
  3708 	/** Constants to specify the type of TSecurityPolicy objects.
  3709 	*/
  3710 	enum TType
  3711 		{
  3712 		ETypeFail=0,	/**< Always fail*/
  3713 		ETypePass=1,	/**< Always pass*/
  3714 		ETypeC3=2,		/**< Up to 3 capabilities*/
  3715 		ETypeC7=3,		/**< Up to 7 capabilities*/
  3716 		ETypeS3=4,		/**< Secure ID and up to 3 capabilities*/
  3717 		ETypeV3=5,		/**< Vendor ID and up to 3 capabilities*/
  3718 
  3719 		/** The number of possible TSecurityPolicy types
  3720 		This is intended for internal Symbian use only.
  3721 		@internalTechnology
  3722 		*/
  3723 		ETypeLimit
  3724 
  3725 		// other values may be added to indicate expanded policy objects (future extensions)
  3726 		};
  3727 protected:
  3728 	TBool CheckPolicy(const SSecurityInfo& aSecInfo, SSecurityInfo& aMissing) const;
  3729 private:
  3730 	void ConstructAndCheck3(TCapability aCap1, TCapability aCap2, TCapability aCap3);
  3731 private:
  3732 	TUint8 iType;
  3733 	TUint8 iCaps[3];				// missing capabilities are set to 0xff
  3734 	union
  3735 		{
  3736 		TUint32 iSecureId;
  3737 		TUint32 iVendorId;
  3738 		TUint8 iExtraCaps[4];		// missing capabilities are set to 0xff
  3739 		};
  3740 	friend class TCompiledSecurityPolicy;
  3741 	};
  3742 
  3743 /** Provides a TPkcgBuf wrapper for a descriptorised TSecurityPolicy.  This a
  3744 suitable container for passing a security policy across IPC.
  3745 @publishedAll
  3746 @released
  3747 */
  3748 typedef TPckgBuf<TSecurityPolicy> TSecurityPolicyBuf;
  3749 
  3750 
  3751 /** Structure for compile-time initialisation of a security policy.
  3752 
  3753 This structure behaves in the same way as a TSecurityPolicy object but has
  3754 the advantage that it may be initialised at compile time. E.g.
  3755 the following line defines a security policy 'KSecurityPolictReadUserData'
  3756 which checks ReadUserData capability.
  3757 
  3758 @code
  3759 _LIT_SECURITY_POLICY_C1(KSecurityPolictReadUserData,ECapabilityReadUserData)
  3760 @endcode
  3761 
  3762 Or, an array of security policies may be created like this:
  3763 @code
  3764 static const TStaticSecurityPolicy MyPolicies[] = 
  3765 	{
  3766 	_INIT_SECURITY_POLICY_C1(ECapabilityReadUserData),
  3767 	_INIT_SECURITY_POLICY_PASS(),
  3768 	_INIT_SECURITY_POLICY_S0(0x1234567)
  3769 	}
  3770 @endcode
  3771 
  3772 This class should not be initialised directly, instead one of the following
  3773 macros should be used:
  3774 
  3775 -	_INIT_SECURITY_POLICY_PASS
  3776 -	_INIT_SECURITY_POLICY_FAIL
  3777 -	_INIT_SECURITY_POLICY_C1
  3778 -	_INIT_SECURITY_POLICY_C2
  3779 -	_INIT_SECURITY_POLICY_C3
  3780 -	_INIT_SECURITY_POLICY_C4
  3781 -	_INIT_SECURITY_POLICY_C5
  3782 -	_INIT_SECURITY_POLICY_C6
  3783 -	_INIT_SECURITY_POLICY_C7
  3784 -	_INIT_SECURITY_POLICY_S0
  3785 -	_INIT_SECURITY_POLICY_S1
  3786 -	_INIT_SECURITY_POLICY_S2
  3787 -	_INIT_SECURITY_POLICY_S3
  3788 -	_INIT_SECURITY_POLICY_V0
  3789 -	_INIT_SECURITY_POLICY_V1
  3790 -	_INIT_SECURITY_POLICY_V2
  3791 -	_INIT_SECURITY_POLICY_V3
  3792 -	_LIT_SECURITY_POLICY_PASS
  3793 -	_LIT_SECURITY_POLICY_FAIL
  3794 -	_LIT_SECURITY_POLICY_C1
  3795 -	_LIT_SECURITY_POLICY_C2
  3796 -	_LIT_SECURITY_POLICY_C3
  3797 -	_LIT_SECURITY_POLICY_C4
  3798 -	_LIT_SECURITY_POLICY_C5
  3799 -	_LIT_SECURITY_POLICY_C6
  3800 -	_LIT_SECURITY_POLICY_C7
  3801 -	_LIT_SECURITY_POLICY_S0
  3802 -	_LIT_SECURITY_POLICY_S1
  3803 -	_LIT_SECURITY_POLICY_S2
  3804 -	_LIT_SECURITY_POLICY_S3
  3805 -	_LIT_SECURITY_POLICY_V0
  3806 -	_LIT_SECURITY_POLICY_V1
  3807 -	_LIT_SECURITY_POLICY_V2
  3808 -	_LIT_SECURITY_POLICY_V3
  3809 
  3810 @see TSecurityPolicy
  3811 @publishedAll
  3812 @released
  3813 */
  3814 struct TStaticSecurityPolicy
  3815 	{
  3816 	inline const TSecurityPolicy* operator&() const;
  3817 	inline operator const TSecurityPolicy&() const;
  3818 	inline const TSecurityPolicy& operator()() const;
  3819 
  3820 #ifndef __KERNEL_MODE__
  3821 #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3822 	inline TBool CheckPolicy(RProcess aProcess, const char* aDiagnostic=0) const;
  3823 	inline TBool CheckPolicy(RThread aThread, const char* aDiagnostic=0) const;
  3824 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic=0) const;
  3825 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic=0) const;
  3826 	inline TBool CheckPolicyCreator(const char* aDiagnostic=0) const;
  3827 #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3828 	// Only available to NULL arguments
  3829 	inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic=NULL) const;
  3830 	inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic=NULL) const;
  3831 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic=NULL) const;
  3832 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic=NULL) const;
  3833 	inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic=NULL) const;
  3834 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  3835 	// For things using KSuppressPlatSecDiagnostic
  3836 	inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3837 	inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3838 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3839 	inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3840 	inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const;
  3841 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  3842 #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__
  3843 #endif // !__KERNEL_MODE__
  3844 
  3845 	TUint32 iA;	/**< @internalComponent */
  3846 	TUint32 iB;	/**< @internalComponent */
  3847 	};
  3848 
  3849 	
  3850 /**
  3851 A dummy enum for use by the CAPABILITY_AS_TUINT8 macro
  3852 @internalComponent
  3853 */
  3854 enum __invalid_capability_value {};
  3855 
  3856 /**
  3857 A macro to cast a TCapability to a TUint8.
  3858 
  3859 If an invlid capability value is specified then, dependant on the compiler,
  3860 a compile time error or warning will be produced which includes the label
  3861 "__invalid_capability_value"
  3862 
  3863 @param cap The capability value
  3864 @internalComponent
  3865 */
  3866 #define CAPABILITY_AS_TUINT8(cap)											\
  3867 	((TUint8)(int)(															\
  3868 		(cap)==ECapability_None												\
  3869 		? (__invalid_capability_value(*)[1])(ECapability_None)								\
  3870 		: (__invalid_capability_value(*)[((TUint)(cap+1)<=(TUint)ECapability_Limit)?1:2])(cap)	\
  3871 	))
  3872 
  3873 
  3874 /**
  3875 A macro to construct a TUint32 from four TUint8s.  The TUint32 is in BigEndian
  3876 ordering useful for class layout rather than number generation.
  3877 
  3878 @param i1 The first TUint8
  3879 @param i2 The second TUint8
  3880 @param i3 The third TUint8
  3881 @param i4 The fourth TUint8
  3882 @internalComponent
  3883 */
  3884 #define FOUR_TUINT8(i1,i2,i3,i4) \
  3885 	(TUint32)(				\
  3886 		(TUint8)i1 		 | 	\
  3887 		(TUint8)i2 << 8  | 	\
  3888 		(TUint8)i3 << 16 | 	\
  3889 		(TUint8)i4 << 24	\
  3890 	)
  3891 
  3892 
  3893 /** Macro for compile-time initialisation of a security policy object that
  3894 always fails.  That is, checks against this policy will always fail,
  3895 irrespective of the security attributes of the item being checked.
  3896 
  3897 The object declared has an implicit conversion to const TSecurityPolicy&.
  3898 Taking the address of the object will return a const TSecurityPolicy*.
  3899 Explicit conversion to const TSecurityPolicy& may be effected by using the
  3900 function call operator n().
  3901 @publishedAll
  3902 @released
  3903 */
  3904 #define _INIT_SECURITY_POLICY_FAIL \
  3905 	{ 																		\
  3906 	FOUR_TUINT8(															\
  3907 		(TUint8)TSecurityPolicy::ETypeFail,									\
  3908 		(TUint8)0xff,														\
  3909 		(TUint8)0xff,														\
  3910 		(TUint8)0xff														\
  3911 	),																		\
  3912 	(TUint32)0xffffffff														\
  3913 	}
  3914 
  3915 
  3916 /** Macro for compile-time definition of a security policy object that always
  3917 fails.  That is, checks against this policy will always fail, irrespective of
  3918 the security attributes of the item being checked.
  3919 
  3920 The object declared has an implicit conversion to const TSecurityPolicy&.
  3921 Taking the address of the object will return a const TSecurityPolicy*.
  3922 Explicit conversion to const TSecurityPolicy& may be effected by using the
  3923 function call operator n().
  3924 @param	n	Name to use for policy object
  3925 @publishedAll
  3926 @released
  3927 */
  3928 #define	_LIT_SECURITY_POLICY_FAIL(n) const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_FAIL
  3929 
  3930 
  3931 /** Macro for compile-time initialisation of a security policy object that 
  3932 always passes.  That is, checks against this policy will always pass,
  3933 irrespective of the security attributes of the item being checked.
  3934 
  3935 The object declared has an implicit conversion to const TSecurityPolicy&.
  3936 Taking the address of the object will return a const TSecurityPolicy*.
  3937 Explicit conversion to const TSecurityPolicy& may be effected by using the
  3938 function call operator n().
  3939 @publishedAll
  3940 @released
  3941 */
  3942 #define _INIT_SECURITY_POLICY_PASS \
  3943 	{ 																		\
  3944 	FOUR_TUINT8(															\
  3945 		(TUint8)TSecurityPolicy::ETypePass,									\
  3946 		(TUint8)0xff,														\
  3947 		(TUint8)0xff,														\
  3948 		(TUint8)0xff														\
  3949 	),																		\
  3950 	(TUint32)0xffffffff														\
  3951 	}
  3952 
  3953 
  3954 /** Macro for compile-time definition of a security policy object that always
  3955 passes.  That is, checks against this policy will always pass, irrespective of
  3956 the security attributes of the item being checked.
  3957 
  3958 The object declared has an implicit conversion to const TSecurityPolicy&.
  3959 Taking the address of the object will return a const TSecurityPolicy*.
  3960 Explicit conversion to const TSecurityPolicy& may be effected by using the
  3961 function call operator n().
  3962 @param	n	Name to use for policy object
  3963 @publishedAll
  3964 @released
  3965 */
  3966 #define	_LIT_SECURITY_POLICY_PASS(n) const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_PASS
  3967 
  3968 
  3969 /** Macro for compile-time initialisation of a security policy object
  3970 The policy will check for seven capabilities.
  3971 
  3972 The object declared has an implicit conversion to const TSecurityPolicy&.
  3973 Taking the address of the object will return a const TSecurityPolicy*.
  3974 Explicit conversion to const TSecurityPolicy& may be effected by using the
  3975 function call operator n().
  3976 
  3977 If an invlid capability value is specified then, dependant on the compiler,
  3978 a compile time error or warning will be produced which includes the label
  3979 "__invalid_capability_value"
  3980 
  3981 @param	c1	The first capability to check (enumerator of TCapability)
  3982 @param	c2	The second capability to check (enumerator of TCapability)
  3983 @param	c3	The third capability to check (enumerator of TCapability)
  3984 @param	c4	The fourth capability to check (enumerator of TCapability)
  3985 @param	c5	The fifth capability to check (enumerator of TCapability)
  3986 @param	c6	The sixth capability to check (enumerator of TCapability)
  3987 @param	c7	The seventh capability to check (enumerator of TCapability)
  3988 
  3989 @publishedAll
  3990 @released
  3991 */
  3992 #define _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,c6,c7) \
  3993 	{ 																		\
  3994 	FOUR_TUINT8(															\
  3995 		(TUint8)TSecurityPolicy::ETypeC7,									\
  3996 		CAPABILITY_AS_TUINT8(c1),											\
  3997 		CAPABILITY_AS_TUINT8(c2),											\
  3998 		CAPABILITY_AS_TUINT8(c3)											\
  3999 	),																		\
  4000 	FOUR_TUINT8(															\
  4001 		CAPABILITY_AS_TUINT8(c4),											\
  4002 		CAPABILITY_AS_TUINT8(c5),											\
  4003 		CAPABILITY_AS_TUINT8(c6),											\
  4004 		CAPABILITY_AS_TUINT8(c7)											\
  4005 	)																		\
  4006 	}
  4007 
  4008 
  4009 /** Macro for compile-time definition of a security policy object
  4010 The policy will check for seven capabilities.
  4011 
  4012 The object declared has an implicit conversion to const TSecurityPolicy&.
  4013 Taking the address of the object will return a const TSecurityPolicy*.
  4014 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4015 function call operator n().
  4016 
  4017 If an invlid capability value is specified then, dependant on the compiler,
  4018 a compile time error or warning will be produced which includes the label
  4019 "__invalid_capability_value"
  4020 
  4021 @param	n	Name to use for policy object
  4022 @param	c1	The first capability to check (enumerator of TCapability)
  4023 @param	c2	The second capability to check (enumerator of TCapability)
  4024 @param	c3	The third capability to check (enumerator of TCapability)
  4025 @param	c4	The fourth capability to check (enumerator of TCapability)
  4026 @param	c5	The fifth capability to check (enumerator of TCapability)
  4027 @param	c6	The sixth capability to check (enumerator of TCapability)
  4028 @param	c7	The seventh capability to check (enumerator of TCapability)
  4029 
  4030 @publishedAll
  4031 @released
  4032 */
  4033 #define	_LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,c5,c6,c7)						\
  4034 	const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,c6,c7)
  4035 
  4036 
  4037 /** Macro for compile-time initialisation of a security policy object
  4038 The policy will check for six capabilities.
  4039 
  4040 The object declared has an implicit conversion to const TSecurityPolicy&.
  4041 Taking the address of the object will return a const TSecurityPolicy*.
  4042 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4043 function call operator n().
  4044 
  4045 If an invlid capability value is specified then, dependant on the compiler,
  4046 a compile time error or warning will be produced which includes the label
  4047 "__invalid_capability_value"
  4048 
  4049 @param	c1	The first capability to check (enumerator of TCapability)
  4050 @param	c2	The second capability to check (enumerator of TCapability)
  4051 @param	c3	The third capability to check (enumerator of TCapability)
  4052 @param	c4	The fourth capability to check (enumerator of TCapability)
  4053 @param	c5	The fifth capability to check (enumerator of TCapability)
  4054 @param	c6	The sixth capability to check (enumerator of TCapability)
  4055 
  4056 @publishedAll
  4057 @released
  4058 */
  4059 #define _INIT_SECURITY_POLICY_C6(c1,c2,c3,c4,c5,c6)  \
  4060 	_INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,c6,ECapability_None)
  4061 
  4062 
  4063 /** Macro for compile-time definition of a security policy object
  4064 The policy will check for six capabilities.
  4065 
  4066 The object declared has an implicit conversion to const TSecurityPolicy&.
  4067 Taking the address of the object will return a const TSecurityPolicy*.
  4068 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4069 function call operator n().
  4070 
  4071 If an invlid capability value is specified then, dependant on the compiler,
  4072 a compile time error or warning will be produced which includes the label
  4073 "__invalid_capability_value"
  4074 
  4075 @param	n	Name to use for policy object
  4076 @param	c1	The first capability to check (enumerator of TCapability)
  4077 @param	c2	The second capability to check (enumerator of TCapability)
  4078 @param	c3	The third capability to check (enumerator of TCapability)
  4079 @param	c4	The fourth capability to check (enumerator of TCapability)
  4080 @param	c5	The fifth capability to check (enumerator of TCapability)
  4081 @param	c6	The sixth capability to check (enumerator of TCapability)
  4082 
  4083 @publishedAll
  4084 @released
  4085 */
  4086 #define	_LIT_SECURITY_POLICY_C6(n,c1,c2,c3,c4,c5,c6)  \
  4087 	_LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,c5,c6,ECapability_None)
  4088 
  4089 
  4090 /** Macro for compile-time initialisation of a security policy object
  4091 The policy will check for five capabilities.
  4092 
  4093 The object declared has an implicit conversion to const TSecurityPolicy&.
  4094 Taking the address of the object will return a const TSecurityPolicy*.
  4095 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4096 function call operator n().
  4097 
  4098 If an invlid capability value is specified then, dependant on the compiler,
  4099 a compile time error or warning will be produced which includes the label
  4100 "__invalid_capability_value"
  4101 
  4102 @param	c1	The first capability to check (enumerator of TCapability)
  4103 @param	c2	The second capability to check (enumerator of TCapability)
  4104 @param	c3	The third capability to check (enumerator of TCapability)
  4105 @param	c4	The fourth capability to check (enumerator of TCapability)
  4106 @param	c5	The fifth capability to check (enumerator of TCapability)
  4107 
  4108 @publishedAll
  4109 @released
  4110 */
  4111 #define _INIT_SECURITY_POLICY_C5(c1,c2,c3,c4,c5)  \
  4112 	_INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,ECapability_None,ECapability_None)
  4113 
  4114 
  4115 /** Macro for compile-time definition of a security policy object
  4116 The policy will check for five capabilities.
  4117 
  4118 The object declared has an implicit conversion to const TSecurityPolicy&.
  4119 Taking the address of the object will return a const TSecurityPolicy*.
  4120 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4121 function call operator n().
  4122 
  4123 If an invlid capability value is specified then, dependant on the compiler,
  4124 a compile time error or warning will be produced which includes the label
  4125 "__invalid_capability_value"
  4126 
  4127 @param	n	Name to use for policy object
  4128 @param	c1	The first capability to check (enumerator of TCapability)
  4129 @param	c2	The second capability to check (enumerator of TCapability)
  4130 @param	c3	The third capability to check (enumerator of TCapability)
  4131 @param	c4	The fourth capability to check (enumerator of TCapability)
  4132 @param	c5	The fifth capability to check (enumerator of TCapability)
  4133 
  4134 @publishedAll
  4135 @released
  4136 */
  4137 #define	_LIT_SECURITY_POLICY_C5(n,c1,c2,c3,c4,c5)  \
  4138 	_LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,c5,ECapability_None,ECapability_None)
  4139 
  4140 
  4141 /** Macro for compile-time initialisation of a security policy object
  4142 The policy will check for four capabilities.
  4143 
  4144 The object declared has an implicit conversion to const TSecurityPolicy&.
  4145 Taking the address of the object will return a const TSecurityPolicy*.
  4146 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4147 function call operator n().
  4148 
  4149 If an invlid capability value is specified then, dependant on the compiler,
  4150 a compile time error or warning will be produced which includes the label
  4151 "__invalid_capability_value"
  4152 
  4153 @param	c1	The first capability to check (enumerator of TCapability)
  4154 @param	c2	The second capability to check (enumerator of TCapability)
  4155 @param	c3	The third capability to check (enumerator of TCapability)
  4156 @param	c4	The fourth capability to check (enumerator of TCapability)
  4157 
  4158 @publishedAll
  4159 @released
  4160 */
  4161 #define _INIT_SECURITY_POLICY_C4(c1,c2,c3,c4)  \
  4162 	_INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,ECapability_None,ECapability_None,ECapability_None)
  4163 
  4164 
  4165 /** Macro for compile-time definition of a security policy object
  4166 The policy will check for four capabilities.
  4167 
  4168 The object declared has an implicit conversion to const TSecurityPolicy&.
  4169 Taking the address of the object will return a const TSecurityPolicy*.
  4170 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4171 function call operator n().
  4172 
  4173 If an invlid capability value is specified then, dependant on the compiler,
  4174 a compile time error or warning will be produced which includes the label
  4175 "__invalid_capability_value"
  4176 
  4177 @param	n	Name to use for policy object
  4178 @param	c1	The first capability to check (enumerator of TCapability)
  4179 @param	c2	The second capability to check (enumerator of TCapability)
  4180 @param	c3	The third capability to check (enumerator of TCapability)
  4181 @param	c4	The fourth capability to check (enumerator of TCapability)
  4182 
  4183 @publishedAll
  4184 @released
  4185 */
  4186 #define	_LIT_SECURITY_POLICY_C4(n,c1,c2,c3,c4)  \
  4187 	_LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,ECapability_None,ECapability_None,ECapability_None)
  4188 
  4189 
  4190 /** Macro for compile-time initialisation of a security policy object
  4191 The policy will check for three capabilities.
  4192 
  4193 The object declared has an implicit conversion to const TSecurityPolicy&.
  4194 Taking the address of the object will return a const TSecurityPolicy*.
  4195 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4196 function call operator n().
  4197 
  4198 If an invlid capability value is specified then, dependant on the compiler,
  4199 a compile time error or warning will be produced which includes the label
  4200 "__invalid_capability_value"
  4201 
  4202 @param	c1	The first capability to check (enumerator of TCapability)
  4203 @param	c2	The second capability to check (enumerator of TCapability)
  4204 @param	c3	The third capability to check (enumerator of TCapability)
  4205 
  4206 @publishedAll
  4207 @released
  4208 */
  4209 #define _INIT_SECURITY_POLICY_C3(c1,c2,c3)									\
  4210 	{ 																		\
  4211 	FOUR_TUINT8(															\
  4212 		(TUint8)TSecurityPolicy::ETypeC3,									\
  4213 		CAPABILITY_AS_TUINT8(c1),											\
  4214 		CAPABILITY_AS_TUINT8(c2),											\
  4215 		CAPABILITY_AS_TUINT8(c3)											\
  4216 	),																		\
  4217 	(TUint32)0xffffffff														\
  4218 	}
  4219 
  4220 
  4221 /** Macro for compile-time definition of a security policy object
  4222 The policy will check for three capabilities.
  4223 
  4224 The object declared has an implicit conversion to const TSecurityPolicy&.
  4225 Taking the address of the object will return a const TSecurityPolicy*.
  4226 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4227 function call operator n().
  4228 
  4229 If an invlid capability value is specified then, dependant on the compiler,
  4230 a compile time error or warning will be produced which includes the label
  4231 "__invalid_capability_value"
  4232 
  4233 @param	n	Name to use for policy object
  4234 @param	c1	The first capability to check (enumerator of TCapability)
  4235 @param	c2	The second capability to check (enumerator of TCapability)
  4236 @param	c3	The third capability to check (enumerator of TCapability)
  4237 
  4238 @publishedAll
  4239 @released
  4240 */
  4241 #define	_LIT_SECURITY_POLICY_C3(n,c1,c2,c3)									\
  4242 	const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_C3(c1,c2,c3)
  4243 
  4244 
  4245 /** Macro for compile-time initialisation of a security policy object
  4246 The policy will check for two capabilities.
  4247 
  4248 The object declared has an implicit conversion to const TSecurityPolicy&.
  4249 Taking the address of the object will return a const TSecurityPolicy*.
  4250 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4251 function call operator n().
  4252 
  4253 If an invlid capability value is specified then, dependant on the compiler,
  4254 a compile time error or warning will be produced which includes the label
  4255 "__invalid_capability_value"
  4256 
  4257 @param	c1	The first capability to check (enumerator of TCapability)
  4258 @param	c2	The second capability to check (enumerator of TCapability)
  4259 
  4260 @publishedAll
  4261 @released
  4262 */
  4263 #define _INIT_SECURITY_POLICY_C2(c1,c2)  \
  4264 	_INIT_SECURITY_POLICY_C3(c1,c2,ECapability_None)
  4265 
  4266 
  4267 /** Macro for compile-time definition of a security policy object
  4268 The policy will check for two capabilities.
  4269 
  4270 The object declared has an implicit conversion to const TSecurityPolicy&.
  4271 Taking the address of the object will return a const TSecurityPolicy*.
  4272 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4273 function call operator n().
  4274 
  4275 If an invlid capability value is specified then, dependant on the compiler,
  4276 a compile time error or warning will be produced which includes the label
  4277 "__invalid_capability_value"
  4278 
  4279 @param	n	Name to use for policy object
  4280 @param	c1	The first capability to check (enumerator of TCapability)
  4281 @param	c2	The second capability to check (enumerator of TCapability)
  4282 
  4283 @publishedAll
  4284 @released
  4285 */
  4286 #define	_LIT_SECURITY_POLICY_C2(n,c1,c2)  \
  4287 	_LIT_SECURITY_POLICY_C3(n,c1,c2,ECapability_None)
  4288 
  4289 
  4290 /** Macro for compile-time initialisation of a security policy object
  4291 The policy will check for one capability.
  4292 
  4293 The object declared has an implicit conversion to const TSecurityPolicy&.
  4294 Taking the address of the object will return a const TSecurityPolicy*.
  4295 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4296 function call operator n().
  4297 
  4298 If an invlid capability value is specified then, dependant on the compiler,
  4299 a compile time error or warning will be produced which includes the label
  4300 "__invalid_capability_value"
  4301 
  4302 @param	c1	The first capability to check (enumerator of TCapability)
  4303 
  4304 
  4305 @publishedAll
  4306 @released
  4307 */
  4308 #define _INIT_SECURITY_POLICY_C1(c1)  \
  4309 	_INIT_SECURITY_POLICY_C3(c1,ECapability_None,ECapability_None)
  4310 
  4311 
  4312 /** Macro for compile-time definition of a security policy object
  4313 The policy will check for one capability.
  4314 
  4315 The object declared has an implicit conversion to const TSecurityPolicy&.
  4316 Taking the address of the object will return a const TSecurityPolicy*.
  4317 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4318 function call operator n().
  4319 
  4320 If an invlid capability value is specified then, dependant on the compiler,
  4321 a compile time error or warning will be produced which includes the label
  4322 "__invalid_capability_value"
  4323 
  4324 @param	n	Name to use for policy object
  4325 @param	c1	The first capability to check (enumerator of TCapability)
  4326 
  4327 @publishedAll
  4328 @released
  4329 */
  4330 #define	_LIT_SECURITY_POLICY_C1(n,c1)  \
  4331 	_LIT_SECURITY_POLICY_C3(n,c1,ECapability_None,ECapability_None)
  4332 
  4333 
  4334 /** Macro for compile-time initialisation of a security policy object
  4335 The policy will check for a secure ID and three capabilities.
  4336 
  4337 The object declared has an implicit conversion to const TSecurityPolicy&.
  4338 Taking the address of the object will return a const TSecurityPolicy*.
  4339 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4340 function call operator n().
  4341 
  4342 If an invlid capability value is specified then, dependant on the compiler,
  4343 a compile time error or warning be produced which includes the label
  4344 "__invalid_capability_value"
  4345 
  4346 @param	sid	The SID value to check for
  4347 @param	c1	The first capability to check (enumerator of TCapability)
  4348 @param	c2	The second capability to check (enumerator of TCapability)
  4349 @param	c3	The third capability to check (enumerator of TCapability)
  4350 
  4351 @publishedAll
  4352 @released
  4353 */
  4354 #define _INIT_SECURITY_POLICY_S3(sid,c1,c2,c3)								\
  4355 	{																		\
  4356 	FOUR_TUINT8(															\
  4357 		(TUint8)TSecurityPolicy::ETypeS3,									\
  4358 		CAPABILITY_AS_TUINT8(c1),											\
  4359 		CAPABILITY_AS_TUINT8(c2),											\
  4360 		CAPABILITY_AS_TUINT8(c3)											\
  4361 	),																		\
  4362 	(TUint32)(sid)															\
  4363 	}
  4364 
  4365 
  4366 /** Macro for compile-time definition of a security policy object
  4367 The policy will check for a secure ID and three capabilities.
  4368 
  4369 The object declared has an implicit conversion to const TSecurityPolicy&.
  4370 Taking the address of the object will return a const TSecurityPolicy*.
  4371 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4372 function call operator n().
  4373 
  4374 If an invlid capability value is specified then, dependant on the compiler,
  4375 a compile time error or warning be produced which includes the label
  4376 "__invalid_capability_value"
  4377 
  4378 @param	n	Name to use for policy object
  4379 @param	sid	The SID value to check for
  4380 @param	c1	The first capability to check (enumerator of TCapability)
  4381 @param	c2	The second capability to check (enumerator of TCapability)
  4382 @param	c3	The third capability to check (enumerator of TCapability)
  4383 
  4384 @publishedAll
  4385 @released
  4386 */
  4387 #define	_LIT_SECURITY_POLICY_S3(n,sid,c1,c2,c3)								\
  4388 	const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_S3(sid,c1,c2,c3)
  4389 
  4390 
  4391 /** Macro for compile-time initialisation of a security policy object
  4392 The policy will check for a secure ID and two capabilities.
  4393 
  4394 The object declared has an implicit conversion to const TSecurityPolicy&.
  4395 Taking the address of the object will return a const TSecurityPolicy*.
  4396 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4397 function call operator n().
  4398 
  4399 If an invlid capability value is specified then, dependant on the compiler,
  4400 a compile time error or warning be produced which includes the label
  4401 "__invalid_capability_value"
  4402 
  4403 @param	sid	The SID value to check for
  4404 @param	c1	The first capability to check (enumerator of TCapability)
  4405 @param	c2	The second capability to check (enumerator of TCapability)
  4406 
  4407 @publishedAll
  4408 @released
  4409 */
  4410 #define _INIT_SECURITY_POLICY_S2(sid,c1,c2)  \
  4411 	_INIT_SECURITY_POLICY_S3(sid,c1,c2,ECapability_None)
  4412 
  4413 
  4414 /** Macro for compile-time definition of a security policy object
  4415 The policy will check for a secure ID and two capabilities.
  4416 
  4417 The object declared has an implicit conversion to const TSecurityPolicy&.
  4418 Taking the address of the object will return a const TSecurityPolicy*.
  4419 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4420 function call operator n().
  4421 
  4422 If an invlid capability value is specified then, dependant on the compiler,
  4423 a compile time error or warning be produced which includes the label
  4424 "__invalid_capability_value"
  4425 
  4426 @param	n	Name to use for policy object
  4427 @param	sid	The SID value to check for
  4428 @param	c1	The first capability to check (enumerator of TCapability)
  4429 @param	c2	The second capability to check (enumerator of TCapability)
  4430 
  4431 @publishedAll
  4432 @released
  4433 */
  4434 #define	_LIT_SECURITY_POLICY_S2(n,sid,c1,c2)  \
  4435 	_LIT_SECURITY_POLICY_S3(n,sid,c1,c2,ECapability_None)
  4436 
  4437 
  4438 /** Macro for compile-time initialisation of a security policy object
  4439 The policy will check for a secure ID and one capability.
  4440 
  4441 The object declared has an implicit conversion to const TSecurityPolicy&.
  4442 Taking the address of the object will return a const TSecurityPolicy*.
  4443 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4444 function call operator n().
  4445 
  4446 If an invlid capability value is specified then, dependant on the compiler,
  4447 a compile time error or warning be produced which includes the label
  4448 "__invalid_capability_value"
  4449 
  4450 @param	sid	The SID value to check for
  4451 @param	c1	The first capability to check (enumerator of TCapability)
  4452 
  4453 @publishedAll
  4454 @released
  4455 */
  4456 #define _INIT_SECURITY_POLICY_S1(sid,c1)  \
  4457 	_INIT_SECURITY_POLICY_S3(sid,c1,ECapability_None,ECapability_None)
  4458 
  4459 
  4460 /** Macro for compile-time definition of a security policy object
  4461 The policy will check for a secure ID and one capability.
  4462 
  4463 The object declared has an implicit conversion to const TSecurityPolicy&.
  4464 Taking the address of the object will return a const TSecurityPolicy*.
  4465 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4466 function call operator n().
  4467 
  4468 If an invlid capability value is specified then, dependant on the compiler,
  4469 a compile time error or warning be produced which includes the label
  4470 "__invalid_capability_value"
  4471 
  4472 @param	n	Name to use for policy object
  4473 @param	sid	The SID value to check for
  4474 @param	c1	The first capability to check (enumerator of TCapability)
  4475 
  4476 @publishedAll
  4477 @released
  4478 */
  4479 #define	_LIT_SECURITY_POLICY_S1(n,sid,c1)  \
  4480 	_LIT_SECURITY_POLICY_S3(n,sid,c1,ECapability_None,ECapability_None)
  4481 
  4482 
  4483 /** Macro for compile-time initialisation of a security policy object
  4484 The policy will check for a secure ID.
  4485 
  4486 The object declared has an implicit conversion to const TSecurityPolicy&.
  4487 Taking the address of the object will return a const TSecurityPolicy*.
  4488 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4489 function call operator n().
  4490 
  4491 @param	sid	The SID value to check for
  4492 
  4493 @publishedAll
  4494 @released
  4495 */
  4496 #define _INIT_SECURITY_POLICY_S0(sid)  \
  4497 	_INIT_SECURITY_POLICY_S3(sid,ECapability_None,ECapability_None,ECapability_None)
  4498 
  4499 
  4500 /** Macro for compile-time definition of a security policy object
  4501 The policy will check for a secure ID.
  4502 
  4503 The object declared has an implicit conversion to const TSecurityPolicy&.
  4504 Taking the address of the object will return a const TSecurityPolicy*.
  4505 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4506 function call operator n().
  4507 
  4508 @param	n	Name to use for policy object
  4509 @param	sid	The SID value to check for
  4510 
  4511 @publishedAll
  4512 @released
  4513 */
  4514 #define	_LIT_SECURITY_POLICY_S0(n,sid)  \
  4515 	_LIT_SECURITY_POLICY_S3(n,sid,ECapability_None,ECapability_None,ECapability_None)
  4516 
  4517 
  4518 /** Macro for compile-time initialisation of a security policy object
  4519 The policy will check for a vendor ID and three capabilities.
  4520 
  4521 The object declared has an implicit conversion to const TSecurityPolicy&.
  4522 Taking the address of the object will return a const TSecurityPolicy*.
  4523 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4524 function call operator n().
  4525 
  4526 If an invlid capability value is specified then, dependant on the compiler,
  4527 a compile time error or warning be produced which includes the label
  4528 "__invalid_capability_value"
  4529 
  4530 @param	vid	The VID value to check for
  4531 @param	c1	The first capability to check (enumerator of TCapability)
  4532 @param	c2	The second capability to check (enumerator of TCapability)
  4533 @param	c3	The third capability to check (enumerator of TCapability)
  4534 
  4535 @publishedAll
  4536 @released
  4537 */
  4538 #define _INIT_SECURITY_POLICY_V3(vid,c1,c2,c3)								\
  4539 	{																		\
  4540 	FOUR_TUINT8(															\
  4541 		(TUint8)TSecurityPolicy::ETypeV3,									\
  4542 		CAPABILITY_AS_TUINT8(c1),											\
  4543 		CAPABILITY_AS_TUINT8(c2),											\
  4544 		CAPABILITY_AS_TUINT8(c3)											\
  4545 	),																		\
  4546 	(TUint32)(vid)															\
  4547 	}
  4548 
  4549 
  4550 /** Macro for compile-time definition of a security policy object
  4551 The policy will check for a vendor ID and three capabilities.
  4552 
  4553 The object declared has an implicit conversion to const TSecurityPolicy&.
  4554 Taking the address of the object will return a const TSecurityPolicy*.
  4555 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4556 function call operator n().
  4557 
  4558 If an invlid capability value is specified then, dependant on the compiler,
  4559 a compile time error or warning be produced which includes the label
  4560 "__invalid_capability_value"
  4561 
  4562 @param	n	Name to use for policy object
  4563 @param	vid	The VID value to check for
  4564 @param	c1	The first capability to check (enumerator of TCapability)
  4565 @param	c2	The second capability to check (enumerator of TCapability)
  4566 @param	c3	The third capability to check (enumerator of TCapability)
  4567 
  4568 @publishedAll
  4569 @released
  4570 */
  4571 #define	_LIT_SECURITY_POLICY_V3(n,vid,c1,c2,c3)								\
  4572 	const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_V3(vid,c1,c2,c3)
  4573 
  4574 
  4575 /** Macro for compile-time initialisation of a security policy object
  4576 The policy will check for a vendor ID and two capabilities.
  4577 
  4578 The object declared has an implicit conversion to const TSecurityPolicy&.
  4579 Taking the address of the object will return a const TSecurityPolicy*.
  4580 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4581 function call operator n().
  4582 
  4583 If an invlid capability value is specified then, dependant on the compiler,
  4584 a compile time error or warning be produced which includes the label
  4585 "__invalid_capability_value"
  4586 
  4587 @param	vid	The VID value to check for
  4588 @param	c1	The first capability to check (enumerator of TCapability)
  4589 @param	c2	The second capability to check (enumerator of TCapability)
  4590 
  4591 @publishedAll
  4592 @released
  4593 */
  4594 #define _INIT_SECURITY_POLICY_V2(vid,c1,c2)  \
  4595 	_INIT_SECURITY_POLICY_V3(vid,c1,c2,ECapability_None)
  4596 
  4597 
  4598 /** Macro for compile-time definition of a security policy object
  4599 The policy will check for a vendor ID and two capabilities.
  4600 
  4601 The object declared has an implicit conversion to const TSecurityPolicy&.
  4602 Taking the address of the object will return a const TSecurityPolicy*.
  4603 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4604 function call operator n().
  4605 
  4606 If an invlid capability value is specified then, dependant on the compiler,
  4607 a compile time error or warning be produced which includes the label
  4608 "__invalid_capability_value"
  4609 
  4610 @param	n	Name to use for policy object
  4611 @param	vid	The VID value to check for
  4612 @param	c1	The first capability to check (enumerator of TCapability)
  4613 @param	c2	The second capability to check (enumerator of TCapability)
  4614 
  4615 @publishedAll
  4616 @released
  4617 */
  4618 #define	_LIT_SECURITY_POLICY_V2(n,vid,c1,c2)  \
  4619 	_LIT_SECURITY_POLICY_V3(n,vid,c1,c2,ECapability_None)
  4620 
  4621 
  4622 /** Macro for compile-time initialisation of a security policy object
  4623 The policy will check for a vendor ID and one capability.
  4624 
  4625 The object declared has an implicit conversion to const TSecurityPolicy&.
  4626 Taking the address of the object will return a const TSecurityPolicy*.
  4627 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4628 function call operator n().
  4629 
  4630 If an invlid capability value is specified then, dependant on the compiler,
  4631 a compile time error or warning be produced which includes the label
  4632 "__invalid_capability_value"
  4633 
  4634 @param	vid	The VID value to check for
  4635 @param	c1	The first capability to check (enumerator of TCapability)
  4636 
  4637 @publishedAll
  4638 @released
  4639 */
  4640 #define _INIT_SECURITY_POLICY_V1(vid,c1)  \
  4641 	_INIT_SECURITY_POLICY_V3(vid,c1,ECapability_None,ECapability_None)
  4642 
  4643 
  4644 /** Macro for compile-time definition of a security policy object
  4645 The policy will check for a vendor ID and one capability.
  4646 
  4647 The object declared has an implicit conversion to const TSecurityPolicy&.
  4648 Taking the address of the object will return a const TSecurityPolicy*.
  4649 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4650 function call operator n().
  4651 
  4652 If an invlid capability value is specified then, dependant on the compiler,
  4653 a compile time error or warning be produced which includes the label
  4654 "__invalid_capability_value"
  4655 
  4656 @param	n	Name to use for policy object
  4657 @param	vid	The VID value to check for
  4658 @param	c1	The first capability to check (enumerator of TCapability)
  4659 
  4660 @publishedAll
  4661 @released
  4662 */
  4663 #define	_LIT_SECURITY_POLICY_V1(n,vid,c1)  \
  4664 	_LIT_SECURITY_POLICY_V3(n,vid,c1,ECapability_None,ECapability_None)
  4665 
  4666 
  4667 /** Macro for compile-time initialisation of a security policy object
  4668 The policy will check for a vendor ID.
  4669 
  4670 The object declared has an implicit conversion to const TSecurityPolicy&.
  4671 Taking the address of the object will return a const TSecurityPolicy*.
  4672 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4673 function call operator n().
  4674 
  4675 @param	vid	The VID value to check for
  4676 
  4677 @publishedAll
  4678 @released
  4679 */
  4680 #define _INIT_SECURITY_POLICY_V0(vid)  \
  4681 	_INIT_SECURITY_POLICY_V3(vid,ECapability_None,ECapability_None,ECapability_None)
  4682 
  4683 
  4684 /** Macro for compile-time definition of a security policy object
  4685 The policy will check for a vendor ID.
  4686 
  4687 The object declared has an implicit conversion to const TSecurityPolicy&.
  4688 Taking the address of the object will return a const TSecurityPolicy*.
  4689 Explicit conversion to const TSecurityPolicy& may be effected by using the
  4690 function call operator n().
  4691 
  4692 @param	n	Name to use for policy object
  4693 @param	vid	The VID value to check for
  4694 
  4695 @publishedAll
  4696 @released
  4697 */
  4698 #define	_LIT_SECURITY_POLICY_V0(n,vid)  \
  4699 	_LIT_SECURITY_POLICY_V3(n,vid,ECapability_None,ECapability_None,ECapability_None)
  4700 
  4701 
  4702 
  4703 #ifdef __KERNEL_MODE__
  4704 class DThread;
  4705 class RMessageK;
  4706 #endif
  4707 class TPlatSecDiagnostic;
  4708 
  4709 /**
  4710 Class containing Platform Security related methods
  4711 @internalTechnology
  4712 */
  4713 class PlatSec
  4714 	{
  4715 #ifndef __KERNEL_MODE__
  4716 public:
  4717 	/**
  4718 	Tests whether a given Platform Security capability is enforced by the system.
  4719 
  4720 	Capabilities may not be enforced for several reasons:
  4721 	-#	The capability has been explicitly disabled on this system
  4722 		by use of the PlatSecDisabledCaps configuration parameter
  4723 	-#	Platform Security checks have been globally disabled
  4724 		by use of the EPlatSecEnforcement configuration parameter	     
  4725 	-#	The capability value is unknown. I.e. Is not part of the set of supported
  4726 		capabilities. See TCapabilitySet::SetAllSupported().
  4727 
  4728 	@param aCapability The capability to test
  4729 	@return A non-zero value if the capability is enforced, zero if it is not.
  4730 
  4731 	@publishedAll
  4732 	@released
  4733 	*/
  4734 	IMPORT_C static TBool IsCapabilityEnforced(TCapability aCapability);
  4735 
  4736 	/**
  4737 	An enumeration used with PlatSecSetting()
  4738 	@see PlatSecSetting()
  4739 	@publishedAll
  4740 	@test
  4741 	*/
  4742 	enum TConfigSetting
  4743 		{
  4744 		EPlatSecEnforcement, /**< Used to request the value of the PlatSecEnforcement setting */
  4745 		EPlatSecDiagnotics,  /**< Used to request the value of the PlatSecDiagnotics setting */
  4746 		EPlatSecProcessIsolation,  /**< Used to request the value of the PlatSecProcessIsolation setting */
  4747 		EPlatSecEnforceSysBin,  /**< Used to request the value of the PlatSecEnforceSysBin setting */
  4748 		EPlatSecLocked,  /**< Used to request the value of the PlatSecLocked setting */
  4749 		};
  4750 
  4751 	/**
  4752 	A test function to return the state of a given Platform Security configuration setting.
  4753 	@param aSetting An enumerated value representing the required setting
  4754 	@return A value representing the setting. 0 represents 'OFF', 1 represents 'ON'
  4755 			Other values may be returned for some settings, these exceptions are documented
  4756 			in the description for individual enumerations of TConfigSetting.
  4757 	@see TConfigSetting
  4758 	@publishedAll
  4759 	@test
  4760 	*/
  4761 	IMPORT_C static TInt ConfigSetting(TConfigSetting aSetting);
  4762 
  4763 #endif // Not __KERNEL_MODE__
  4764 
  4765 	//
  4766 	// All methods below here are internalTechnology
  4767 	//
  4768 
  4769 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
  4770 public:
  4771 	/** @internalTechnology */
  4772 	static inline TInt LoaderCapabilityViolation(const TDesC8& aImporterName, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps);
  4773 #ifdef __KERNEL_MODE__
  4774 	/** @internalTechnology */
  4775 	static inline TInt CapabilityCheckFail(const DProcess* aViolatingProcess, TCapability aCapability, const char* aContextText);
  4776 	/** @internalTechnology */
  4777 	static inline TInt CapabilityCheckFail(const DThread* aViolatingThread, TCapability aCapability, const char* aContextText);
  4778 	/** @internalTechnology */
  4779 	static inline TInt SecureIdCheckFail(const DProcess* aViolatingProcess, TSecureId aSid, const char* aContextText);
  4780 	/** @internalTechnology */
  4781 	static inline TInt PolicyCheckFail(const DProcess* aProcess, const SSecurityInfo& aMissing, const char* aContextText);
  4782 	/** @internalTechnology */
  4783 	static inline TInt PolicyCheckFail(const DThread* aProcess, const SSecurityInfo& aMissing, const char* aContextText);
  4784 	/** @internalTechnology */
  4785 	static inline TInt ProcessIsolationFail(const char* aContextText);
  4786 	/** @internalTechnology */
  4787 	static inline TInt ProcessIsolationIPCFail(RMessageK* aMessage, const char* aContextText);
  4788 #else // !__KERNEL_MODE__
  4789 	/** @internalTechnology */
  4790 	static inline TInt LoaderCapabilityViolation(RProcess aLoadingProcess, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps);
  4791 	/** @internalTechnology */
  4792 	static inline TInt CreatorCapabilityCheckFail(TCapability aCapability, const char* aContextText);
  4793 	/** @internalTechnology */
  4794 	static inline TInt CreatorCapabilityCheckFail(const TCapabilitySet& aMissingCaps, const char* aContextText);
  4795 	/** @internalTechnology */
  4796 	static inline TInt CapabilityCheckFail(TInt aHandle, TCapability aCapability, const char* aContextText);
  4797 	/** @internalTechnology */
  4798 	static inline TInt CapabilityCheckFail(TInt aHandle, const TCapabilitySet& aMissingCaps, const char* aContextText);
  4799 	/** @internalTechnology */
  4800 	static inline TInt PolicyCheckFail(TInt aHandle, const SSecurityInfo& aMissing, const char* aContextText);
  4801 	/** @internalTechnology */
  4802 	static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, TCapability aCapability, const char* aContextText);
  4803 	/** @internalTechnology */
  4804 	static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, const TCapabilitySet& aMissingCaps, const char* aContextText);
  4805 	/** @internalTechnology */
  4806 	static inline TInt PolicyCheckFail(RMessagePtr2 aMessage, const SSecurityInfo& aMissingCaps, const char* aContextText);
  4807 	/** @internalTechnology */
  4808 	static inline TInt PolicyCheckFail(RSessionBase aSession, const SSecurityInfo& aMissingCaps, const char* aContextText);
  4809 	/** @internalTechnology */
  4810 	static inline TInt CreatorPolicyCheckFail(const SSecurityInfo& aMissingCaps, const char* aContextText);
  4811 	/** @internalTechnology */
  4812 	static inline TInt CreatorCapabilityCheckFail(TCapability aCapability);
  4813 	/** @internalTechnology */
  4814 	static inline TInt CreatorCapabilityCheckFail(const TCapabilitySet& aMissingCaps);
  4815 	/** @internalTechnology */
  4816 	static inline TInt CapabilityCheckFail(TInt aHandle, TCapability aCapability);
  4817 	/** @internalTechnology */
  4818 	static inline TInt CapabilityCheckFail(TInt aHandle, const TCapabilitySet& aMissingCaps);
  4819 	/** @internalTechnology */
  4820 	static inline TInt PolicyCheckFail(TInt aHandle, const SSecurityInfo& aMissing);
  4821 	/** @internalTechnology */
  4822 	static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, TCapability aCapability);
  4823 	/** @internalTechnology */
  4824 	static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, const TCapabilitySet& aMissingCaps);
  4825 	/** @internalTechnology */
  4826 	static inline TInt PolicyCheckFail(RMessagePtr2 aMessage, const SSecurityInfo& aMissingCaps);
  4827 	/** @internalTechnology */
  4828 	static inline TInt CreatorPolicyCheckFail(const SSecurityInfo& aMissingCaps);
  4829 #endif //__KERNEL_MODE__
  4830 
  4831 private:
  4832 	UIMPORT_C static TInt EmitDiagnostic(TPlatSecDiagnostic& aDiagnostic, const char* aContextText);
  4833 #else //__REMOVE_PLATSEC_DIAGNOSTICS__
  4834 #ifndef __KERNEL_MODE__
  4835 private:
  4836 	IMPORT_C static TInt EmitDiagnostic(TPlatSecDiagnostic& aDiagnostic, const char* aContextText);
  4837 #endif // !__KERNEL_MODE__
  4838 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
  4839 
  4840 public:
  4841 	/** @internalTechnology */
  4842 	UIMPORT_C static TInt EmitDiagnostic();
  4843 	};
  4844 
  4845 
  4846 #define KMaxSerialNumLength 64
  4847 typedef TBuf8<KMaxSerialNumLength> TMediaSerialNumber;
  4848 
  4849 
  4850 /**
  4851 @publishedAll
  4852 @released
  4853 
  4854 Contains information about the code and data sections belonging to a process.
  4855 
  4856 @see RProcess::GetMemoryInfo
  4857 */
  4858 class TProcessMemoryInfo
  4859 	{
  4860 public:
  4861     /**
  4862     The code base address (.text).
  4863     */
  4864 	TUint32 iCodeBase;
  4865 
  4866 	
  4867     /**
  4868     The size of the code section (.text).
  4869     */
  4870 	TUint32 iCodeSize;
  4871 	
  4872 	
  4873     /**
  4874     The base address of the constant data section (.radata).
  4875     */
  4876 	TUint32 iConstDataBase;
  4877 	
  4878 	
  4879     /**
  4880     The size of the constant data section (.radata).
  4881     */
  4882 
  4883 	TUint32 iConstDataSize;
  4884 	
  4885 	
  4886     /**
  4887     The base address of the initialised data section (.data).
  4888     */
  4889 	TUint32 iInitialisedDataBase;
  4890 	
  4891 	
  4892     /**
  4893     The size of the initialised data section (.data).
  4894     */
  4895 	TUint32 iInitialisedDataSize;
  4896 
  4897 	
  4898     /**
  4899     The base address of the uninitialised data section (.bss).
  4900     */
  4901 	TUint32 iUninitialisedDataBase;
  4902 
  4903 	
  4904     /**
  4905     The size of the uninitialised data section (.bss).
  4906     */
  4907 	TUint32 iUninitialisedDataSize;
  4908 	};
  4909 
  4910 
  4911 
  4912 
  4913 /**
  4914 @publishedAll
  4915 @released
  4916 
  4917 Defines a more useful synonym for TProcessMemoryInfo.
  4918 */
  4919 typedef TProcessMemoryInfo TModuleMemoryInfo;	// more accurate name - remove old one later
  4920 
  4921 
  4922 
  4923 
  4924 #ifndef __KERNEL_MODE__
  4925 class CBase;
  4926 /**
  4927 @publishedAll
  4928 @released
  4929 
  4930 Generic array.
  4931 
  4932 This class defines a generic array which can be constructed by any of the
  4933 following templated concrete arrays:
  4934 
  4935 1. CArrayFixFlat<class T>
  4936 
  4937 2. CArrayFixSeg<class T>
  4938 
  4939 3. CArrayVarFlat<class T>
  4940 
  4941 4. CArrayVarSeg<class T>
  4942 
  4943 5. CArrayPakFlat<class T>
  4944 
  4945 6. RArray<class T>
  4946 
  4947 7. RPointerArray<class T>
  4948 
  4949 and also by the following template specialisation classes:
  4950 
  4951 1. RArray<TInt>
  4952 
  4953 2. RArray<TUint>
  4954 
  4955 It allows a degree of polymorphism amongst the array classes. It permits the 
  4956 operator[] and the Count() member functions of an array to be invoked without 
  4957 knowing which array class has been used to construct that array.
  4958 
  4959 TArray allows access to elements of an array but does not permit changes to 
  4960 those elements. 
  4961 
  4962 Use the Array() member function of an array to construct and return
  4963 a TArray<class T> object for that array.
  4964 
  4965 A TArray<class T> type object is not intended to be constructed explicitly 
  4966 by user code.
  4967 
  4968 @see CArrayFixFlat
  4969 @see CArrayFixSeg
  4970 @see CArrayVarFlat
  4971 @see CArrayVarSeg
  4972 @see CArrayPakFlat
  4973 @see RArray
  4974 @see RPointerArray
  4975 @see RArray<TInt>
  4976 @see RArray<TUint>
  4977 */
  4978 template <class T>
  4979 class TArray
  4980 	{
  4981 public:
  4982 	inline TArray(TInt (*aCount)(const CBase* aPtr),const TAny*(*anAt)(const CBase* aPtr,TInt anIndex),const CBase* aPtr);
  4983 	inline TInt Count() const;
  4984 	inline const T& operator[](TInt anIndex) const;
  4985 private:
  4986 	const CBase* iPtr;
  4987 	TInt (*iCount)(const CBase* aPtr);
  4988 	const TAny*(*iAt)(const CBase* aPtr,TInt anIndex);
  4989 	};
  4990 #endif
  4991 
  4992 
  4993 
  4994 
  4995 /**
  4996 @publishedAll
  4997 @released
  4998 
  4999 Defines a function type used by a TIdentityRelation object. 
  5000 
  5001 A function of this type implements an algorithm for determining whether
  5002 two objects match.
  5003 
  5004 @see TIdentityRelation
  5005 */
  5006 typedef TBool (*TGeneralIdentityRelation)(const TAny*, const TAny*);
  5007 
  5008 
  5009 
  5010 
  5011 /**
  5012 @publishedAll
  5013 @released
  5014 
  5015 Defines a function type used by a TLinearOrder object
  5016 
  5017 A function of this type implements an algorithm that determines
  5018 the order of two objects.
  5019 
  5020 @see TLinearOrder
  5021 */
  5022 typedef TInt (*TGeneralLinearOrder)(const TAny*, const TAny*);
  5023 
  5024 
  5025 
  5026 
  5027 /**
  5028 @publishedAll
  5029 @released
  5030 
  5031 A templated class which packages a function that determines whether two
  5032 objects of a given class type match. During linear search operations the search
  5033 term is always passed as the first argument and the second argument is an
  5034 element of the array being searched.
  5035 
  5036 A TIdentityRelation<T> object is constructed and passed as a parameter to 
  5037 member functions of the array classes RArray<T> and RPointerArray<T>.
  5038 
  5039 @see RArray
  5040 @see RPointerArray
  5041 */
  5042 template <class T>
  5043 class TIdentityRelation
  5044 	{
  5045 public:
  5046 	inline TIdentityRelation();
  5047 	inline TIdentityRelation( TBool (*anIdentity)(const T&, const T&) );
  5048 	inline operator TGeneralIdentityRelation() const;
  5049 private:
  5050 	inline static TBool EqualityOperatorCompare(const T& aLeft, const T& aRight);
  5051 private:
  5052 	TGeneralIdentityRelation iIdentity;
  5053 	};
  5054 
  5055 
  5056 
  5057 /**
  5058 @publishedAll
  5059 @released
  5060 
  5061 A set of common identity relations for frequently occurring types.
  5062 
  5063 @see RArray
  5064 @see RPointerArray
  5065 @see RHashSet
  5066 @see RPtrHashSet
  5067 @see RHashMap
  5068 @see RPtrHashMap
  5069 */
  5070 class DefaultIdentity
  5071 	{
  5072 public:
  5073 	IMPORT_C static TBool Integer(const TInt&, const TInt&);
  5074 	IMPORT_C static TBool Des8(const TDesC8&, const TDesC8&);
  5075 	IMPORT_C static TBool Des16(const TDesC16&, const TDesC16&);
  5076 	IMPORT_C static TBool IntegerPtr(TInt* const&, TInt* const&);
  5077 	IMPORT_C static TBool Des8Ptr(TDesC8* const&, TDesC8* const&);
  5078 	IMPORT_C static TBool Des16Ptr(TDesC16* const&, TDesC16* const&);
  5079 	};
  5080 
  5081 
  5082 
  5083 
  5084 /**
  5085 @publishedAll
  5086 @released
  5087 
  5088 A templated class which packages a function that determines the order of two 
  5089 objects of a given class type. During binary search operations the search term
  5090 is always passed as the first argument and the second argument is an element
  5091 of the array being searched.
  5092 
  5093 A TLinearOrder<T> object is constructed and passed as a parameter to member 
  5094 functions of the array classes RArray<T> and RPointerArray<T>.
  5095 
  5096 @see RArray
  5097 @see RPointerArray
  5098 */
  5099 template <class T>
  5100 class TLinearOrder
  5101 	{
  5102 public:
  5103 	inline TLinearOrder( TInt(*anOrder)(const T&, const T&) );
  5104 	inline operator TGeneralLinearOrder() const;
  5105 private:
  5106 	TGeneralLinearOrder iOrder;
  5107 	};
  5108 
  5109 
  5110 /*
  5111 @publishedAll
  5112 @released
  5113 
  5114 A set of values that tell array search functions which array element is to be
  5115 returned when there are duplicate elements in the array.
  5116 
  5117 These values are used by RArray, RPointerArray, RArray<TInt>,
  5118 and RArray<TUint> search functions. 
  5119 
  5120 Examples of functions that take
  5121 these enum values are: RPointerArray::SpecificFindInOrderL(),
  5122 and RArray::SpecificFindInSignedKeyOrder().
  5123 
  5124 @see RArray
  5125 @see RPointerArray
  5126 @see RArray<TInt>
  5127 @see RArray<TUint>
  5128 */
  5129 enum TArrayFindMode
  5130 	{
  5131 	/**
  5132 	Indicates that any element in a block of duplicate elements can be
  5133 	returned by a search function.
  5134 	
  5135 	Note that using this mode, there can be no guarantee that the element
  5136 	returned by the search functions will be the same if the size of the array
  5137 	changes between successive calls to those functions.
  5138 	*/
  5139 	EArrayFindMode_Any = 0,
  5140 	
  5141 	/**
  5142 	Indicates that the first element in a block of duplicate elements
  5143 	is returned.
  5144 	*/
  5145 	EArrayFindMode_First = 1,
  5146 
  5147 	/**
  5148 	Indicates that the first element after the last element in a block
  5149 	of duplicate elements is returned.
  5150 	*/
  5151 	EArrayFindMode_Last = 2,
  5152     
  5153     /**
  5154     @internalTechnology
  5155     */
  5156 	EArrayFindMode_Limit = 3
  5157 	};
  5158 
  5159 
  5160 /**
  5161 @internalComponent
  5162 
  5163 Base class used in the derivation of RPointerArray, RArray<TInt>,
  5164 and RArray<TUint>. 
  5165 
  5166 The base class is inherited privately.
  5167 
  5168 The class is internal and is not intended for use.
  5169 */
  5170 class RPointerArrayBase
  5171 	{
  5172 protected:
  5173 	IMPORT_C RPointerArrayBase();
  5174 	IMPORT_C RPointerArrayBase(TInt aGranularity);
  5175 	IMPORT_C RPointerArrayBase(TInt aMinGrowBy, TInt aFactor);
  5176 	IMPORT_C void Close();
  5177 	IMPORT_C TInt Count() const;
  5178 	inline void ZeroCount() {iCount=0;}
  5179 	inline TAny** Entries() {return iEntries;}
  5180 	IMPORT_C TAny*& At(TInt anIndex) const;
  5181 	IMPORT_C TInt Append(const TAny* anEntry);
  5182 	IMPORT_C TInt Insert(const TAny* anEntry, TInt aPos);
  5183 	IMPORT_C void Remove(TInt anIndex);
  5184 	IMPORT_C void Compress();
  5185 	IMPORT_C void Reset();
  5186 	IMPORT_C TInt Find(const TAny* anEntry) const;
  5187 	IMPORT_C TInt Find(const TAny* anEntry, TGeneralIdentityRelation anIdentity) const;
  5188 	IMPORT_C TInt FindReverse(const TAny* aEntry) const;
  5189 	IMPORT_C TInt FindReverse(const TAny* aEntry, TGeneralIdentityRelation aIdentity) const;
  5190 	IMPORT_C TInt FindIsqSigned(TInt anEntry) const;
  5191 	IMPORT_C TInt FindIsqUnsigned(TUint anEntry) const;
  5192 	IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const;
  5193 	IMPORT_C TInt FindIsqSigned(TInt anEntry, TInt aMode) const;
  5194 	IMPORT_C TInt FindIsqUnsigned(TUint anEntry, TInt aMode) const;
  5195 	IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TInt aMode) const;
  5196 	IMPORT_C TInt InsertIsqSigned(TInt anEntry, TBool aAllowRepeats);
  5197 	IMPORT_C TInt InsertIsqUnsigned(TUint anEntry, TBool aAllowRepeats);
  5198 	IMPORT_C TInt InsertIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TBool aAllowRepeats);
  5199 	IMPORT_C TInt BinarySearchSigned(TInt anEntry, TInt& anIndex) const;
  5200 	IMPORT_C TInt BinarySearchUnsigned(TUint anEntry, TInt& anIndex) const;
  5201 	IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder) const;
  5202 	IMPORT_C TInt BinarySearchSigned(TInt anEntry, TInt& anIndex, TInt aMode) const;
  5203 	IMPORT_C TInt BinarySearchUnsigned(TUint anEntry, TInt& anIndex, TInt aMode) const;
  5204 	IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder, TInt aMode) const;
  5205 #ifndef __KERNEL_MODE__
  5206 	IMPORT_C RPointerArrayBase(TAny** aEntries, TInt aCount);
  5207 	IMPORT_C void GranularCompress();
  5208 	IMPORT_C TInt DoReserve(TInt aCount);
  5209 	IMPORT_C void HeapSortSigned();
  5210 	IMPORT_C void HeapSortUnsigned();
  5211 	IMPORT_C void HeapSort(TGeneralLinearOrder anOrder);
  5212 	IMPORT_C static TInt GetCount(const CBase* aPtr);
  5213 	IMPORT_C static const TAny* GetElementPtr(const CBase* aPtr, TInt aIndex);
  5214 #endif
  5215 private:
  5216 	TInt Grow();
  5217 private:
  5218 	TInt iCount;
  5219 	TAny** iEntries;
  5220 	TInt iAllocated;
  5221 	TInt iGranularity;	// positive means linear, negative means exponential growth
  5222 	TInt iSpare1;
  5223 	TInt iSpare2;
  5224 	};
  5225 
  5226 
  5227 
  5228 
  5229 /**
  5230 @publishedAll
  5231 @released
  5232 
  5233 A simple and efficient array of pointers to objects.
  5234 
  5235 The elements of the array are pointers to instances of a class; this class
  5236 is specified as the template parameter T.
  5237 
  5238 The class offers standard array behaviour which includes insertion, appending 
  5239 and sorting of pointers.
  5240 
  5241 Derivation from RPointerArrayBase is private.
  5242 */
  5243 template <class T>
  5244 class RPointerArray : private RPointerArrayBase
  5245 	{
  5246 public:
  5247 	inline RPointerArray();
  5248 	inline explicit RPointerArray(TInt aGranularity);
  5249 	inline RPointerArray(TInt aMinGrowBy, TInt aFactor);
  5250 	inline void Close();
  5251 	inline TInt Count() const;
  5252 	inline T* const& operator[](TInt anIndex) const;
  5253 	inline T*& operator[](TInt anIndex);
  5254 	inline TInt Append(const T* anEntry);
  5255 	inline TInt Insert(const T* anEntry, TInt aPos);
  5256 	inline void Remove(TInt anIndex);
  5257 	inline void Compress();
  5258 	inline void Reset();
  5259 	void ResetAndDestroy();
  5260 	inline TInt Find(const T* anEntry) const;
  5261 	inline TInt Find(const T* anEntry, TIdentityRelation<T> anIdentity) const;
  5262 	template <class K>
  5263 	inline TInt Find(const K& aKey, TBool (*apfnCompare)(const K* k, const T& t)) const
  5264 	/**
  5265 	Finds the first object pointer in the array which matches aKey using
  5266 	the comparison algorithm provided by apfnCompare.
  5267 	
  5268 	The find operation always starts at the low index end of the array. There 
  5269 	is no assumption about the order of objects in the array.
  5270 
  5271 	@param aKey The key of type K to be compared with the elements of the array using apfnCompare.
  5272 	@param apfnCompare A function defining the identity relation between the
  5273 			object pointers in the array, and their keys of type K.  The
  5274 			function returns true if k and t match based on this relationship.
  5275 	
  5276 	@return The index of the first matching object pointer within the array.
  5277 			KErrNotFound, if no suitable object pointer can be found.
  5278 	*/
  5279 		{ return RPointerArrayBase::Find((T*)&aKey,*(TIdentityRelation<T>*)&apfnCompare); }		
  5280 	inline TInt FindReverse(const T* anEntry) const;
  5281 	inline TInt FindReverse(const T* anEntry, TIdentityRelation<T> anIdentity) const;
  5282 	template <class K>
  5283 	inline TInt FindReverse(const K& aKey, TInt (*apfnMatch)(const K* k, const T& t)) const
  5284 	/**
  5285 	Finds the first object pointer in the array which matches aKey using
  5286 	the comparison algorithm provided by apfnCompare.
  5287 	
  5288 	The find operation always starts at the high index end of the array. There 
  5289 	is no assumption about the order of objects in the array.
  5290 
  5291 	@param aKey The key of type K to be compared with the elements of the array using apfnMatch.
  5292 	@param apfnMatch A function defining the identity relation between the
  5293 			object pointers in the array, and their keys of type K.  The
  5294 			function returns true if k and t match based on this relationship.
  5295 	
  5296 	@return The index of the first matching object pointer within the array.
  5297 			KErrNotFound, if no suitable object pointer can be found.
  5298 	*/
  5299 
  5300 		{ return RPointerArrayBase::FindReverse((T*)&aKey,*(TIdentityRelation<T>*)&apfnMatch); } 				
  5301 	inline TInt FindInAddressOrder(const T* anEntry) const;
  5302 	inline TInt FindInOrder(const T* anEntry, TLinearOrder<T> anOrder) const;
  5303 	inline TInt FindInAddressOrder(const T* anEntry, TInt& anIndex) const;
  5304 	inline TInt FindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const;
  5305 	template <class K>
  5306 	inline TInt FindInOrder(const K& aKey, TInt (*apfnCompare)(const K* k, const T& t)) const
  5307 	/**
  5308 	Finds the object pointer in the array whose object matches the specified
  5309 	key, (Using the relationship defined within apfnCompare) using a binary search
  5310 	technique and an ordering algorithm.
  5311 
  5312 	The function assumes that existing object pointers in the array are ordered 
  5313 	so that the objects themselves are in object order as determined by an algorithm 
  5314 	supplied by the caller and packaged as a TLinearOrder<T>.
  5315 
  5316 	@param aKey The key of type K to be compared with the elements of the array using apfnCompare.
  5317 	@param apfnCompare A function which defines the order that the array was sorted,
  5318 		 where in it aKey (via the defined relationship) should fit, and if the key is present. 
  5319 	
  5320 	@return The index of the matching object pointer within the array.
  5321 			KErrNotFound, if no suitable object pointer can be found.
  5322 	*/	
  5323 		{ return RPointerArrayBase::FindIsq((T*)&aKey,*(TLinearOrder<T>*)&apfnCompare); }
  5324 	inline TInt SpecificFindInAddressOrder(const T* anEntry, TInt aMode) const;
  5325 	inline TInt SpecificFindInOrder(const T* anEntry, TLinearOrder<T> anOrder, TInt aMode) const;
  5326 	inline TInt SpecificFindInAddressOrder(const T* anEntry, TInt& anIndex, TInt aMode) const;
  5327 	inline TInt SpecificFindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder<T> anOrder, TInt aMode) const;
  5328 	inline TInt InsertInAddressOrder(const T* anEntry);
  5329 	inline TInt InsertInOrder(const T* anEntry, TLinearOrder<T> anOrder);
  5330 	inline TInt InsertInAddressOrderAllowRepeats(const T* anEntry);
  5331 	inline TInt InsertInOrderAllowRepeats(const T* anEntry, TLinearOrder<T> anOrder);
  5332 #ifndef __KERNEL_MODE__
  5333 	inline void AppendL(const T* anEntry);
  5334 	inline void InsertL(const T* anEntry, TInt aPos);
  5335 	inline TInt FindL(const T* anEntry) const;
  5336 	inline TInt FindL(const T* anEntry, TIdentityRelation<T> anIdentity) const;
  5337 	inline TInt FindReverseL(const T* anEntry) const;
  5338 	inline TInt FindReverseL(const T* anEntry, TIdentityRelation<T> anIdentity) const;
  5339 	inline TInt FindInAddressOrderL(const T* anEntry) const;
  5340 	inline TInt FindInOrderL(const T* anEntry, TLinearOrder<T> anOrder) const;
  5341 	inline void FindInAddressOrderL(const T* anEntry, TInt& anIndex) const;
  5342 	inline void FindInOrderL(const T* anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const;
  5343 	inline TInt SpecificFindInAddressOrderL(const T* anEntry, TInt aMode) const;
  5344 	inline TInt SpecificFindInOrderL(const T* anEntry, TLinearOrder<T> anOrder, TInt aMode) const;
  5345 	inline void SpecificFindInAddressOrderL(const T* anEntry, TInt& anIndex, TInt aMode) const;
  5346 	inline void SpecificFindInOrderL(const T* anEntry, TInt& anIndex, TLinearOrder<T> anOrder, TInt aMode) const;
  5347 	inline void InsertInAddressOrderL(const T* anEntry);
  5348 	inline void InsertInOrderL(const T* anEntry, TLinearOrder<T> anOrder);
  5349 	inline void InsertInAddressOrderAllowRepeatsL(const T* anEntry);
  5350 	inline void InsertInOrderAllowRepeatsL(const T* anEntry, TLinearOrder<T> anOrder);
  5351 
  5352 	inline RPointerArray(T** aEntries, TInt aCount);
  5353 	inline void GranularCompress();
  5354 	inline TInt Reserve(TInt aCount);
  5355 	inline void ReserveL(TInt aCount);
  5356 	inline void SortIntoAddressOrder();
  5357 	inline void Sort(TLinearOrder<T> anOrder);
  5358 	inline TArray<T*> Array() const;
  5359 #endif
  5360 	};
  5361 
  5362 
  5363 
  5364 /**
  5365 @publishedAll
  5366 @released
  5367 
  5368 Array of raw pointers.
  5369 
  5370 The array is a simple and efficient specialized array of TAny pointers offering
  5371 standard array behaviour.
  5372 
  5373 The derivation from RPointerArrayBase is private.
  5374 */
  5375 TEMPLATE_SPECIALIZATION class RPointerArray<TAny> : private RPointerArrayBase
  5376 	{
  5377 public:
  5378 	inline RPointerArray();
  5379 	inline explicit RPointerArray(TInt aGranularity);
  5380 	inline RPointerArray(TInt aMinGrowBy, TInt aFactor);
  5381 	inline void Close();
  5382 	inline TInt Count() const;
  5383 	inline TAny* const& operator[](TInt anIndex) const;
  5384 	inline TAny*& operator[](TInt anIndex);
  5385 	inline TInt Append(const TAny* anEntry);
  5386 	inline TInt Insert(const TAny* anEntry, TInt aPos);
  5387 	inline void Remove(TInt anIndex);
  5388 	inline void Compress();
  5389 	inline void Reset();
  5390 	inline TInt Find(const TAny* anEntry) const;
  5391 	inline TInt FindReverse(const TAny* anEntry) const;
  5392 	inline TInt FindInAddressOrder(const TAny* anEntry) const;
  5393 	inline TInt FindInAddressOrder(const TAny* anEntry, TInt& anIndex) const;
  5394 	inline TInt SpecificFindInAddressOrder(const TAny* anEntry, TInt aMode) const;
  5395 	inline TInt SpecificFindInAddressOrder(const TAny* anEntry, TInt& anIndex, TInt aMode) const;
  5396 	inline TInt InsertInAddressOrder(const TAny* anEntry);
  5397 	inline TInt InsertInAddressOrderAllowRepeats(const TAny* anEntry);
  5398 #ifndef __KERNEL_MODE__
  5399 	inline void AppendL(const TAny* anEntry);
  5400 	inline void InsertL(const TAny* anEntry, TInt aPos);
  5401 	inline TInt FindL(const TAny* anEntry) const;
  5402 	inline TInt FindReverseL(const TAny* anEntry) const;
  5403 	inline TInt FindInAddressOrderL(const TAny* anEntry) const;
  5404 	inline void FindInAddressOrderL(const TAny* anEntry, TInt& anIndex) const;
  5405 	inline TInt SpecificFindInAddressOrderL(const TAny* anEntry, TInt aMode) const;
  5406 	inline void SpecificFindInAddressOrderL(const TAny* anEntry, TInt& anIndex, TInt aMode) const;
  5407 	inline void InsertInAddressOrderL(const TAny* anEntry);
  5408 	inline void InsertInAddressOrderAllowRepeatsL(const TAny* anEntry);
  5409 
  5410 	inline RPointerArray(TAny** aEntries, TInt aCount);
  5411 	inline void GranularCompress();
  5412 	inline void SortIntoAddressOrder();
  5413 	inline TArray<TAny*> Array() const;
  5414 #endif
  5415 	};
  5416 
  5417 
  5418 
  5419 /**
  5420 @internalComponent
  5421 
  5422 Base class used in the derivation of RArray.
  5423 
  5424 The base class is inherited privately.
  5425 
  5426 The class is internal and is not intended for use.
  5427 */
  5428 class RArrayBase
  5429 	{
  5430 protected:
  5431 	IMPORT_C RArrayBase(TInt anEntrySize);
  5432 	IMPORT_C RArrayBase(TInt anEntrySize, TInt aGranularity);
  5433 	IMPORT_C RArrayBase(TInt anEntrySize, TInt aGranularity, TInt aKeyOffset);
  5434 	IMPORT_C RArrayBase(TInt anEntrySize, TInt aMinGrowBy, TInt aKeyOffset, TInt aFactor);
  5435 	IMPORT_C RArrayBase(TInt aEntrySize,TAny* aEntries, TInt aCount);
  5436 	IMPORT_C void Close();
  5437 	IMPORT_C TInt Count() const;
  5438 	IMPORT_C TAny* At(TInt anIndex) const;
  5439 	IMPORT_C TInt Append(const TAny* anEntry);
  5440 	IMPORT_C TInt Insert(const TAny* anEntry, TInt aPos);
  5441 	IMPORT_C void Remove(TInt anIndex);
  5442 	IMPORT_C void Compress();
  5443 	IMPORT_C void Reset();
  5444 	IMPORT_C TInt Find(const TAny* anEntry) const;
  5445 	IMPORT_C TInt Find(const TAny* anEntry, TGeneralIdentityRelation anIdentity) const;
  5446 	IMPORT_C TInt FindReverse(const TAny* aEntry) const;
  5447 	IMPORT_C TInt FindReverse(const TAny* aEntry, TGeneralIdentityRelation aIdentity) const;
  5448 	IMPORT_C TInt FindIsqSigned(const TAny* anEntry) const;
  5449 	IMPORT_C TInt FindIsqUnsigned(const TAny* anEntry) const;
  5450 	IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const;
  5451 	IMPORT_C TInt FindIsqSigned(const TAny* anEntry, TInt aMode) const;
  5452 	IMPORT_C TInt FindIsqUnsigned(const TAny* anEntry, TInt aMode) const;
  5453 	IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TInt aMode) const;
  5454 	IMPORT_C TInt InsertIsqSigned(const TAny* anEntry, TBool aAllowRepeats);
  5455 	IMPORT_C TInt InsertIsqUnsigned(const TAny* anEntry, TBool aAllowRepeats);
  5456 	IMPORT_C TInt InsertIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TBool aAllowRepeats);
  5457 	IMPORT_C TInt BinarySearchSigned(const TAny* anEntry, TInt& anIndex) const;
  5458 	IMPORT_C TInt BinarySearchUnsigned(const TAny* anEntry, TInt& anIndex) const;
  5459 	IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder) const;
  5460 	IMPORT_C TInt BinarySearchSigned(const TAny* anEntry, TInt& anIndex, TInt aMode) const;
  5461 	IMPORT_C TInt BinarySearchUnsigned(const TAny* anEntry, TInt& anIndex, TInt aMode) const;
  5462 	IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder, TInt aMode) const;
  5463 #ifndef __KERNEL_MODE__
  5464 	IMPORT_C void GranularCompress();
  5465 	IMPORT_C TInt DoReserve(TInt aCount);
  5466 	IMPORT_C void HeapSortSigned();
  5467 	IMPORT_C void HeapSortUnsigned();
  5468 	IMPORT_C void HeapSort(TGeneralLinearOrder anOrder);
  5469 	IMPORT_C static TInt GetCount(const CBase* aPtr);
  5470 	IMPORT_C static const TAny* GetElementPtr(const CBase* aPtr, TInt aIndex);
  5471 #endif
  5472 private:
  5473 	TInt Grow();
  5474 private:
  5475 	TInt iCount;
  5476 	TAny* iEntries;
  5477 	TInt iEntrySize;
  5478 	TInt iKeyOffset;
  5479 	TInt iAllocated;
  5480 	TInt iGranularity;	// positive means linear, negative means exponential growth
  5481 	TInt iSpare1;
  5482 	TInt iSpare2;
  5483 	};
  5484 
  5485 
  5486 
  5487 
  5488 /**
  5489 @publishedAll
  5490 @released
  5491 
  5492 A simple and efficient array of fixed length objects.
  5493 
  5494 The elements of the array are instances of a class; this class is specified
  5495 as the template parameter T.
  5496 
  5497 The array offers standard array behaviour which includes insertion, appending 
  5498 and sorting of elements.
  5499 
  5500 Note:
  5501 
  5502 1. where possible, this class should be used in preference to
  5503    CArrayFixFlat<classT>.
  5504 
  5505 2. the derivation from RArrayBase is private.
  5506 
  5507 3. for performance reasons, RArray stores objects in the array as
  5508    word (4 byte) aligned quantities. This means that some member functions
  5509    do not work when RArray is instantiated for classes of less than 4 bytes
  5510    in size, or when the class's alignment requirement is not 4.
  5511    Be aware that it is possible to get an unhandled exception on hardware
  5512    that enforces strict alignment.
  5513    
  5514    The affected functions are:
  5515    
  5516    3.1 the constructor: RArray(TInt, T*, TInt)
  5517    
  5518    3.2 Append(const T&)
  5519    
  5520    3.3 Insert(const T&, TInt)
  5521    
  5522    3.4 the [] operator, and then using the pointer to iterate through
  5523        the array as you would with a C array.
  5524 */
  5525 template <class T>
  5526 class RArray : private RArrayBase
  5527 	{
  5528 public:
  5529 	inline RArray();
  5530 	inline explicit RArray(TInt aGranularity);
  5531 	inline RArray(TInt aGranularity, TInt aKeyOffset);
  5532 	inline RArray(TInt aMinGrowBy, TInt aKeyOffset, TInt aFactor);
  5533 	inline RArray(TInt aEntrySize,T* aEntries, TInt aCount);
  5534 	inline void Close();
  5535 	inline TInt Count() const;
  5536 	inline const T& operator[](TInt anIndex) const;
  5537 	inline T& operator[](TInt anIndex);
  5538 	inline TInt Append(const T& anEntry);
  5539 	inline TInt Insert(const T& anEntry, TInt aPos);
  5540 	inline void Remove(TInt anIndex);
  5541 	inline void Compress();
  5542 	inline void Reset();
  5543 	inline TInt Find(const T& anEntry) const;
  5544 	inline TInt Find(const T& anEntry, TIdentityRelation<T> anIdentity) const;
  5545 	template <class K>
  5546 	inline TInt Find(const K& aKey, TBool (*apfnCompare)(const K* k, const T& t)) const
  5547 	/**
  5548 	Finds the first object in the array which matches aKey using
  5549 	the comparison algorithm provided by apfnCompare.
  5550 	
  5551 	The find operation always starts at the low index end of the array. There 
  5552 	is no assumption about the order of objects in the array.
  5553 
  5554 	@param aKey The key of type K to be compared with the elements of the array using apfnCompare.
  5555 	@param apfnCompare A function defining the identity relation between the
  5556 			object in the array, and their keys of type K.  The function
  5557 			returns true if k and t match based on this relationship.
  5558 	
  5559 	@return The index of the first matching object within the array.
  5560 			KErrNotFound, if no suitable object can be found.
  5561 	*/
  5562 		{ return RArrayBase::Find((T*)&aKey,*(TIdentityRelation<T>*)&apfnCompare); }
  5563 	inline TInt FindReverse(const T& anEntry) const;
  5564 	inline TInt FindReverse(const T& anEntry, TIdentityRelation<T> anIdentity) const;
  5565 	template <class K>
  5566 	inline TInt FindReverse(const K& aKey, TInt (*apfnMatch)(const K* k, const T& t)) const 
  5567 	/**
  5568 	Finds the first object in the array which matches aKey using the comparison
  5569 	algorithm provided by apfnCompare.
  5570 	
  5571 	The find operation always starts at the high index end of the array. There 
  5572 	is no assumption about the order of objects in the array.
  5573 
  5574 	@param aKey The key of type K to be compared with the elements of the array using apfnMatch.
  5575 	@param apfnMatch A function defining the identity relation between the
  5576 			object in the array, and their keys of type K.  The	function
  5577 			returns true if k and t match based on this relationship.
  5578 	
  5579 	@return The index of the first matching object within the array.
  5580 			KErrNotFound, if no suitable object can be found.
  5581 	*/	
  5582 		{ return RArrayBase::FindReverse((T*)&aKey,*(TIdentityRelation<T>*)&apfnMatch); }		
  5583 	inline TInt FindInSignedKeyOrder(const T& anEntry) const;
  5584 	inline TInt FindInUnsignedKeyOrder(const T& anEntry) const;
  5585 	inline TInt FindInOrder(const T& anEntry, TLinearOrder<T> anOrder) const;
  5586 	inline TInt FindInSignedKeyOrder(const T& anEntry, TInt& anIndex) const;
  5587 	inline TInt FindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex) const;
  5588 	inline TInt FindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const;
  5589 	template <class K>
  5590 	inline TInt FindInOrder(const K& aKey, TInt (*apfnCompare)(const K* k, const T& t)) const
  5591 	/**
  5592 	Finds the object in the array whose object matches the specified
  5593 	key, (Using the relationship defined within apfnCompare) using a binary search
  5594 	technique and an ordering algorithm.
  5595 
  5596 	The function assumes that existing objects in the array are ordered so
  5597 	that the objects themselves are in object order as determined by an algorithm 
  5598 	supplied by the caller and packaged as a TLinearOrder<T>.
  5599 
  5600 	@param aKey The key of type K to be compared with the elements of the array using apfnCompare.
  5601 	@param apfnCompare A function which defines the order that the array was sorted,
  5602 		 where in it aKey (via the defined relationship) should fit, and if the key is present. 
  5603 	
  5604 	@return The index of the matching object within the array.
  5605 			KErrNotFound, if no suitable object can be found.
  5606 	*/	
  5607 
  5608 		{ return RArrayBase::FindIsq((T*)&aKey,*(TLinearOrder<T>*)&apfnCompare); }
  5609 	inline TInt SpecificFindInSignedKeyOrder(const T& anEntry, TInt aMode) const;
  5610 	inline TInt SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt aMode) const;
  5611 	inline TInt SpecificFindInOrder(const T& anEntry, TLinearOrder<T> anOrder, TInt aMode) const;
  5612 	inline TInt SpecificFindInSignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const;
  5613 	inline TInt SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const;
  5614 	inline TInt SpecificFindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder, TInt aMode) const;
  5615 	inline TInt InsertInSignedKeyOrder(const T& anEntry);
  5616 	inline TInt InsertInUnsignedKeyOrder(const T& anEntry);
  5617 	inline TInt InsertInOrder(const T& anEntry, TLinearOrder<T> anOrder);
  5618 	inline TInt InsertInSignedKeyOrderAllowRepeats(const T& anEntry);
  5619 	inline TInt InsertInUnsignedKeyOrderAllowRepeats(const T& anEntry);
  5620 	inline TInt InsertInOrderAllowRepeats(const T& anEntry, TLinearOrder<T> anOrder);
  5621 #ifndef __KERNEL_MODE__
  5622 	inline void AppendL(const T& anEntry);
  5623 	inline void InsertL(const T& anEntry, TInt aPos);
  5624 	inline TInt FindL(const T& anEntry) const;
  5625 	inline TInt FindL(const T& anEntry, TIdentityRelation<T> anIdentity) const;
  5626 	inline TInt FindReverseL(const T& anEntry) const;
  5627 	inline TInt FindReverseL(const T& anEntry, TIdentityRelation<T> anIdentity) const;
  5628 	inline TInt FindInSignedKeyOrderL(const T& anEntry) const;
  5629 	inline TInt FindInUnsignedKeyOrderL(const T& anEntry) const;
  5630 	inline TInt FindInOrderL(const T& anEntry, TLinearOrder<T> anOrder) const;
  5631 	inline void FindInSignedKeyOrderL(const T& anEntry, TInt& anIndex) const;
  5632 	inline void FindInUnsignedKeyOrderL(const T& anEntry, TInt& anIndex) const;
  5633 	inline void FindInOrderL(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder) const;
  5634 	inline TInt SpecificFindInSignedKeyOrderL(const T& anEntry, TInt aMode) const;
  5635 	inline TInt SpecificFindInUnsignedKeyOrderL(const T& anEntry, TInt aMode) const;
  5636 	inline TInt SpecificFindInOrderL(const T& anEntry, TLinearOrder<T> anOrder, TInt aMode) const;
  5637 	inline void SpecificFindInSignedKeyOrderL(const T& anEntry, TInt& anIndex, TInt aMode) const;
  5638 	inline void SpecificFindInUnsignedKeyOrderL(const T& anEntry, TInt& anIndex, TInt aMode) const;
  5639 	inline void SpecificFindInOrderL(const T& anEntry, TInt& anIndex, TLinearOrder<T> anOrder, TInt aMode) const;
  5640 	inline void InsertInSignedKeyOrderL(const T& anEntry);
  5641 	inline void InsertInUnsignedKeyOrderL(const T& anEntry);
  5642 	inline void InsertInOrderL(const T& anEntry, TLinearOrder<T> anOrder);
  5643 	inline void InsertInSignedKeyOrderAllowRepeatsL(const T& anEntry);
  5644 	inline void InsertInUnsignedKeyOrderAllowRepeatsL(const T& anEntry);
  5645 	inline void InsertInOrderAllowRepeatsL(const T& anEntry, TLinearOrder<T> anOrder);
  5646 
  5647 	inline void GranularCompress();
  5648 	inline TInt Reserve(TInt aCount);
  5649 	inline void ReserveL(TInt aCount);
  5650 	inline void SortSigned();
  5651 	inline void SortUnsigned();
  5652 	inline void Sort(TLinearOrder<T> anOrder);
  5653 	inline TArray<T> Array() const;
  5654 #endif
  5655 	};
  5656 
  5657 
  5658 
  5659 
  5660 /**
  5661 @publishedAll
  5662 @released
  5663 
  5664 A simple and efficient specialized array of signed integers offering standard 
  5665 array behaviour.
  5666 
  5667 Note that derivation from RPointerArrayBase is private.
  5668 */
  5669 TEMPLATE_SPECIALIZATION class RArray<TInt> : private RPointerArrayBase
  5670 	{
  5671 public:
  5672 	inline RArray();
  5673 	inline explicit RArray(TInt aGranularity);
  5674 	inline RArray(TInt aMinGrowBy, TInt aFactor);
  5675 	inline void Close();
  5676 	inline TInt Count() const;
  5677 	inline const TInt& operator[](TInt anIndex) const;
  5678 	inline TInt& operator[](TInt anIndex);
  5679 	inline TInt Append(TInt anEntry);
  5680 	inline TInt Insert(TInt anEntry, TInt aPos);
  5681 	inline void Remove(TInt anIndex);
  5682 	inline void Compress();
  5683 	inline void Reset();
  5684 	inline TInt Find(TInt anEntry) const;
  5685 	inline TInt FindReverse(TInt anEntry) const;
  5686 	inline TInt FindInOrder(TInt anEntry) const;
  5687 	inline TInt FindInOrder(TInt anEntry, TInt& anIndex) const;
  5688 	inline TInt SpecificFindInOrder(TInt anEntry, TInt aMode) const;
  5689 	inline TInt SpecificFindInOrder(TInt anEntry, TInt& anIndex, TInt aMode) const;
  5690 	inline TInt InsertInOrder(TInt anEntry);
  5691 	inline TInt InsertInOrderAllowRepeats(TInt anEntry);
  5692 #ifndef __KERNEL_MODE__
  5693 	inline void AppendL(TInt anEntry);
  5694 	inline void InsertL(TInt anEntry, TInt aPos);
  5695 	inline TInt FindL(TInt anEntry) const;
  5696 	inline TInt FindReverseL(TInt anEntry) const;
  5697 	inline TInt FindInOrderL(TInt anEntry) const;
  5698 	inline void FindInOrderL(TInt anEntry, TInt& anIndex) const;
  5699 	inline TInt SpecificFindInOrderL(TInt anEntry, TInt aMode) const;
  5700 	inline void SpecificFindInOrderL(TInt anEntry, TInt& anIndex, TInt aMode) const;
  5701 	inline void InsertInOrderL(TInt anEntry);
  5702 	inline void InsertInOrderAllowRepeatsL(TInt anEntry);
  5703 
  5704 	inline RArray(TInt* aEntries, TInt aCount);
  5705 	inline void GranularCompress();
  5706 	inline TInt Reserve(TInt aCount);
  5707 	inline void ReserveL(TInt aCount);
  5708 	inline void Sort();
  5709 	inline TArray<TInt> Array() const;
  5710 #endif
  5711 	};
  5712 
  5713 
  5714 
  5715 
  5716 /**
  5717 @publishedAll
  5718 @released
  5719 
  5720 Array of unsigned integers.
  5721 
  5722 The array is a simple and efficient specialized array of unsigned integers 
  5723 offering standard array behaviour.
  5724 
  5725 The derivation from RPointerArrayBase is private.
  5726 */
  5727 TEMPLATE_SPECIALIZATION class RArray<TUint> : private RPointerArrayBase
  5728 	{
  5729 public:
  5730 	inline RArray();
  5731 	inline explicit RArray(TInt aGranularity);
  5732 	inline RArray(TInt aMinGrowBy, TInt aFactor);
  5733 	inline void Close();
  5734 	inline TInt Count() const;
  5735 	inline const TUint& operator[](TInt anIndex) const;
  5736 	inline TUint& operator[](TInt anIndex);
  5737 	inline TInt Append(TUint anEntry);
  5738 	inline TInt Insert(TUint anEntry, TInt aPos);
  5739 	inline void Remove(TInt anIndex);
  5740 	inline void Compress();
  5741 	inline void Reset();
  5742 	inline TInt Find(TUint anEntry) const;
  5743 	inline TInt FindReverse(TUint anEntry) const;
  5744 	inline TInt FindInOrder(TUint anEntry) const;
  5745 	inline TInt FindInOrder(TUint anEntry, TInt& anIndex) const;
  5746 	inline TInt SpecificFindInOrder(TUint anEntry, TInt aMode) const;
  5747 	inline TInt SpecificFindInOrder(TUint anEntry, TInt& anIndex, TInt aMode) const;
  5748 	inline TInt InsertInOrder(TUint anEntry);
  5749 	inline TInt InsertInOrderAllowRepeats(TUint anEntry);
  5750 #ifndef __KERNEL_MODE__
  5751 	inline void AppendL(TUint anEntry);
  5752 	inline void InsertL(TUint anEntry, TInt aPos);
  5753 	inline TInt FindL(TUint anEntry) const;
  5754 	inline TInt FindReverseL(TUint anEntry) const;
  5755 	inline TInt FindInOrderL(TUint anEntry) const;
  5756 	inline void FindInOrderL(TUint anEntry, TInt& anIndex) const;
  5757 	inline TInt SpecificFindInOrderL(TUint anEntry, TInt aMode) const;
  5758 	inline void SpecificFindInOrderL(TUint anEntry, TInt& anIndex, TInt aMode) const;
  5759 	inline void InsertInOrderL(TUint anEntry);
  5760 	inline void InsertInOrderAllowRepeatsL(TUint anEntry);
  5761 
  5762 	inline RArray(TUint* aEntries, TInt aCount);
  5763 	inline void GranularCompress();
  5764 	inline TInt Reserve(TInt aCount);
  5765 	inline void ReserveL(TInt aCount);
  5766 	inline void Sort();
  5767 	inline TArray<TUint> Array() const;
  5768 #endif
  5769 	};
  5770 
  5771 #ifndef __LEAVE_EQUALS_THROW__
  5772 
  5773 class TTrapHandler;
  5774 
  5775 /**
  5776 @internalComponent
  5777 */
  5778 class TTrap
  5779 	{
  5780 public:
  5781 #ifndef __KERNEL_MODE__
  5782 	IMPORT_C TInt Trap(TInt& aResult);
  5783 	IMPORT_C static void UnTrap();
  5784 #endif
  5785 public:
  5786 	enum {EMaxState=0x10};
  5787 public:
  5788 	TInt iState[EMaxState];
  5789 	TTrap* iNext;
  5790 	TInt* iResult;
  5791 	TTrapHandler* iHandler;
  5792 	};
  5793 
  5794 
  5795 
  5796 /**
  5797 @publishedAll
  5798 @released
  5799 
  5800 Executes the set of C++ statements _s under a trap harness.
  5801 
  5802 Use this macro as a C++ statement.
  5803 
  5804 _r must be a TInt which has already been declared; if any of the
  5805 C++ statements _s leaves, then the leave code is returned in _r,
  5806 otherwise _r is set to KErrNone.
  5807 
  5808 _s can consist of multiple C++ statements; in theory, _s can consist
  5809 of any legal C++ code but in practice, such statements consist of simple
  5810 function calls, e.g. Foo() or an assignment of some value to the result of
  5811 a function call, e.g. functionValue=GetFoo().
  5812 
  5813 A cleanup stack is constructed for the set of C++ statements _s.
  5814 If any function in _s leaves, objects pushed to the cleanup stack are
  5815 cleaned-up. In addition, if any of the C++ statements in _s leaves,
  5816 then remaining C++ code in _s is not executed and any variables which
  5817 are assigned within that remaining code are not defined.
  5818 
  5819 @param _r An lvalue, convertible to TInt&, which will receive the result of
  5820           any User::Leave() executed within _s or, if no leave occurred,
  5821           it will be set to KErrNone. The value of _r on entry is not used.
  5822 
  5823 @param _s C++ statements which will be executed under a trap harness.
  5824 
  5825 @see TRAPD
  5826 */
  5827 #define TRAP(_r,_s) {TTrap __t;if (__t.Trap(_r)==0){_s;TTrap::UnTrap();}}
  5828 
  5829 /**
  5830 @publishedAll
  5831 @released
  5832 
  5833 Executes the set of C++ statements _s under a trap harness.
  5834 
  5835 Use this macro in the same way as you would TRAP, except that the
  5836 variable _r is defined as part of the macro (and is therefore valid for the
  5837 rest of the block in which the macro occurs). Often, this saves a line of code.
  5838 
  5839 @param _r A name, which will be declared as a TInt, and will receive the result
  5840           of any User::Leave() executed within _s or, if no leave occurred, it
  5841           will be set to KErrNone. After the macro, _r remains in scope until
  5842           the end of its enclosing block.
  5843 
  5844 @param _s C++ statements which will be executed under a trap harness.
  5845 
  5846 @see TRAP
  5847 */
  5848 #define TRAPD(_r,_s) TInt _r;{TTrap __t;if (__t.Trap(_r)==0){_s;TTrap::UnTrap();}}
  5849 
  5850 /**
  5851 @publishedAll
  5852 @released
  5853 
  5854 Executes the set of C++ statements _s under a trap harness.
  5855 Any leave code generated is ignored.
  5856 
  5857 Use this macro as a C++ statement.
  5858 
  5859 This macro is functionally equivalent to:
  5860 @code
  5861 	TInt x;
  5862 	TRAP(x,_s)
  5863 @endcode
  5864 or
  5865 @code
  5866 	TRAPD(x,_s)
  5867 @endcode
  5868 where the value in 'x' is not used by any subsequent code.
  5869 
  5870 _s can consist of multiple C++ statements; in theory, _s can consist
  5871 of any legal C++ code but in practice, such statements consist of simple
  5872 function calls, e.g. Foo() or an assignment of some value to the result of
  5873 a function call, e.g. functionValue=GetFoo().
  5874 
  5875 A cleanup stack is constructed for the set of C++ statements _s.
  5876 If any function in _s leaves, objects pushed to the cleanup stack are
  5877 cleaned-up. In addition, if any of the C++ statements in _s leaves,
  5878 then remaining C++ code in _s is not executed and any variables which
  5879 are assigned within that remaining code are not defined.
  5880 
  5881 @param _s C++ statements which will be executed under a trap harness.
  5882 
  5883 @see TRAPD
  5884 @see TRAP
  5885 */
  5886 #define TRAP_IGNORE(_s) {TInt _ignore;TTrap __t;if (__t.Trap(_ignore)==0){_s;TTrap::UnTrap();}}
  5887 
  5888 
  5889 #else //__LEAVE_EQUALS_THROW__
  5890 
  5891 #if defined(__WINS__) && !defined(__SYMC__)
  5892 /** @internalComponent */
  5893 #define __WIN32SEHTRAP		TWin32SEHTrap __trap; __trap.Trap();
  5894 /** @internalComponent */
  5895 #define __WIN32SEHUNTRAP	__trap.UnTrap();
  5896 IMPORT_C void EmptyFunction();
  5897 #define __CALL_EMPTY_FUNCTION	EmptyFunction();   
  5898 #else // !__WINS__
  5899 #define __WIN32SEHTRAP
  5900 #define __WIN32SEHUNTRAP
  5901 #define __CALL_EMPTY_FUNCTION
  5902 #endif //__WINS__
  5903 
  5904 /** 
  5905 This macro is used by the TRAP and TRAPD macros and provides a means
  5906 of inserting code into uses of these.
  5907 
  5908 This macro is invoked before any 'trapped' code is called, and it should be
  5909 redefined to do whatever task is required. E.g. this code:
  5910 
  5911 @code
  5912     #undef TRAP_INSTRUMENTATION_START
  5913     #define TRAP_INSTRUMENTATION_START DoMyLoging(__LINE__)
  5914 @endcode
  5915 
  5916 Will cause all subsequent uses of the TRAP macros to behave in an
  5917 equivalent way to:
  5918 
  5919 @code
  5920     DoMyLoging(__LINE__)
  5921     TRAP(r,SomeCodeL());
  5922 @endcode
  5923 
  5924 
  5925 @publishedPartner
  5926 @released
  5927 
  5928 @see TRAP
  5929 @see TRAPD
  5930 */
  5931 #define TRAP_INSTRUMENTATION_START
  5932 
  5933 
  5934 
  5935 /** 
  5936 This macro is used by the TRAP and TRAPD macros and provides a means
  5937 of inserting code into uses of these.
  5938 
  5939 This macro is invoked if the 'trapped' code did not Leave.
  5940 E.g. this code:
  5941 
  5942 @code
  5943     #undef TRAP_INSTRUMENTATION_NOLEAVE
  5944     #define TRAP_INSTRUMENTATION_NOLEAVE DoMyLoging(__LINE__)
  5945 @endcode
  5946 
  5947 Will cause all subsequent uses of the TRAP macros to behave in an
  5948 equivalent way to:
  5949 
  5950 @code
  5951     TRAP(r,SomeCodeL());
  5952     if(r==KErrNone) DoMyLoging(__LINE__);
  5953 @endcode
  5954 
  5955 
  5956 @param aLine The line number in the C++ source file where the TRAP or TRAPD
  5957              macro was used.
  5958 
  5959 @publishedPartner
  5960 @released
  5961 
  5962 @see TRAP
  5963 @see TRAPD
  5964 */
  5965 #define TRAP_INSTRUMENTATION_NOLEAVE
  5966 
  5967 
  5968 /** 
  5969 This macro is used by the TRAP and TRAPD macros and provides a means
  5970 of inserting code into uses of these.
  5971 
  5972 This macro is invoked if the 'trapped' code did Leave. E.g. this code:
  5973 
  5974 @code
  5975     #undef TRAP_INSTRUMENTATION_LEAVE
  5976     #define TRAP_INSTRUMENTATION_LEAVE(aResult) DoMyLoging(aResult,__LINE__)
  5977 @endcode
  5978 
  5979 Will cause all subsequent uses of the TRAP macros to behave in an
  5980 equivalent way to:
  5981 
  5982 @code
  5983     TRAP(r,SomeCodeL());
  5984     if(r!=KErrNone) DoMyLoging(r,__LINE__);
  5985 @endcode
  5986 
  5987 
  5988 @param aResult  A reference to the result value used in the TRAP macro.
  5989 
  5990 
  5991 @publishedPartner
  5992 @released
  5993 
  5994 @see TRAP
  5995 @see TRAPD
  5996 */
  5997 #define TRAP_INSTRUMENTATION_LEAVE(aResult)
  5998 
  5999 
  6000 
  6001 /** 
  6002 This macro is used by the TRAP and TRAPD macros and provides a means
  6003 of inserting code into uses of these.
  6004 
  6005 This macro is invoked after the 'trapped' code is called, regardless of whether
  6006 or not it did Leave.  It should be redefined to do whatever task is
  6007 required. E.g. this code:
  6008 
  6009 @code
  6010     #undef TRAP_INSTRUMENTATION_END
  6011     #define TRAP_INSTRUMENTATION_END DoMyLoging(__LINE__)
  6012 @endcode
  6013 
  6014 Will cause all subsequent uses of the TRAP macros to behave in an
  6015 equivalent way to:
  6016 
  6017 @code
  6018     TRAP(r,SomeCodeL());
  6019     DoMyLoging(__LINE__)
  6020 @endcode
  6021 
  6022 
  6023 @publishedPartner
  6024 @released
  6025 
  6026 @see TRAP
  6027 @see TRAPD
  6028 */
  6029 #define TRAP_INSTRUMENTATION_END
  6030 
  6031 
  6032 
  6033 /**
  6034 @publishedAll
  6035 @released
  6036 
  6037 Executes the set of C++ statements _s under a trap harness.
  6038 
  6039 Use this macro as a C++ statement.
  6040 
  6041 _r must be a TInt which has already been declared; if any of the
  6042 C++ statements _s leaves, then the leave code is returned in _r,
  6043 otherwise _r is set to KErrNone.
  6044 
  6045 _s can consist of multiple C++ statements; in theory, _s can consist
  6046 of any legal C++ code but in practice, such statements consist of simple
  6047 function calls, e.g. Foo() or an assignment of some value to the result of
  6048 a function call, e.g. functionValue=GetFoo().
  6049 
  6050 A cleanup stack is constructed for the set of C++ statements _s.
  6051 If any function in _s leaves, objects pushed to the cleanup stack are
  6052 cleaned-up. In addition, if any of the C++ statements in _s leaves,
  6053 then remaining C++ code in _s is not executed and any variables which
  6054 are assigned within that remaining code are not defined.
  6055 
  6056 @param _r An lvalue, convertible to TInt&, which will receive the result of
  6057           any User::Leave() executed within _s or, if no leave occurred,
  6058           it will be set to KErrNone. The value of _r on entry is not used.
  6059 
  6060 @param _s C++ statements which will be executed under a trap harness.
  6061 
  6062 @see TRAPD
  6063 */
  6064 
  6065 /*__CALL_EMPTY_FUNCTION(call to a function with an empty body) was added as a 
  6066 workaround to a compiler bug (mwccsym2 - winscw ) which caused an incorrect 
  6067 trap handler to be invoked when multiple nested TRAP's were present and 
  6068 User::Leave(..) was called. */
  6069 
  6070 #define TRAP(_r, _s)										\
  6071 	{														\
  6072 	TInt& __rref = _r;										\
  6073 	__rref = 0;												\
  6074 	{ TRAP_INSTRUMENTATION_START; }							\
  6075 	try	{													\
  6076 		__WIN32SEHTRAP										\
  6077 		TTrapHandler* ____t = User::MarkCleanupStack();		\
  6078 		_s;													\
  6079 		User::UnMarkCleanupStack(____t);					\
  6080 		{ TRAP_INSTRUMENTATION_NOLEAVE; }					\
  6081 		__WIN32SEHUNTRAP									\
  6082 		}													\
  6083 	catch (XLeaveException& l)								\
  6084 		{													\
  6085 		__rref = l.GetReason();								\
  6086 		{ TRAP_INSTRUMENTATION_LEAVE(__rref); }				\
  6087 		}													\
  6088 	catch (...)												\
  6089 		{													\
  6090 		User::Invariant();									\
  6091 		}													\
  6092 	__CALL_EMPTY_FUNCTION									\
  6093 	{ TRAP_INSTRUMENTATION_END; }							\
  6094 	}
  6095 
  6096 
  6097 /**
  6098 @publishedAll
  6099 @released
  6100 
  6101 Executes the set of C++ statements _s under a trap harness.
  6102 
  6103 Use this macro in the same way as you would TRAP, except that the
  6104 variable _r is defined as part of the macro (and is therefore valid for the
  6105 rest of the block in which the macro occurs). Often, this saves a line of code.
  6106 
  6107 @param _r A name, which will be declared as a TInt, and will receive the result
  6108           of any User::Leave() executed within _s or, if no leave occurred, it
  6109           will be set to KErrNone. After the macro, _r remains in scope until
  6110           the end of its enclosing block.
  6111 
  6112 @param _s C++ statements which will be executed under a trap harness.
  6113 
  6114 @see TRAP
  6115 */
  6116 
  6117 /*__CALL_EMPTY_FUNCTION(call to a function with an empty body) was added as a 
  6118 workaround to a compiler bug (mwccsym2 - winscw ) which caused an incorrect 
  6119 trap handler to be invoked when multiple nested TRAP's were present and 
  6120 User::Leave(..) was called. */
  6121 
  6122 
  6123 #define TRAPD(_r, _s)										\
  6124 	TInt _r;												\
  6125 	{														\
  6126 	_r = 0;													\
  6127 	{ TRAP_INSTRUMENTATION_START; }							\
  6128 	try	{													\
  6129 		__WIN32SEHTRAP										\
  6130 		TTrapHandler* ____t = User::MarkCleanupStack();		\
  6131 		_s;													\
  6132 		User::UnMarkCleanupStack(____t);					\
  6133 		{ TRAP_INSTRUMENTATION_NOLEAVE; }					\
  6134 		__WIN32SEHUNTRAP									\
  6135 		}													\
  6136 	catch (XLeaveException& l)								\
  6137 		{													\
  6138 		_r = l.GetReason();									\
  6139 		{ TRAP_INSTRUMENTATION_LEAVE(_r); }					\
  6140 		}													\
  6141 	catch (...)												\
  6142 		{													\
  6143 		User::Invariant();									\
  6144 		}													\
  6145 	__CALL_EMPTY_FUNCTION									\
  6146 	{ TRAP_INSTRUMENTATION_END; }							\
  6147 	}
  6148 
  6149 /**
  6150 @publishedAll
  6151 @released
  6152 
  6153 Executes the set of C++ statements _s under a trap harness.
  6154 Any leave code generated is ignored.
  6155 
  6156 Use this macro as a C++ statement.
  6157 
  6158 This macro is functionally equivalent to:
  6159 @code
  6160 	TInt x;
  6161 	TRAP(x,_s)
  6162 @endcode
  6163 or
  6164 @code
  6165 	TRAPD(x,_s)
  6166 @endcode
  6167 where the value in 'x' is not used by any subsequent code.
  6168 
  6169 Use this macro as a C++ statement.
  6170 
  6171 _s can consist of multiple C++ statements; in theory, _s can consist
  6172 of any legal C++ code but in practice, such statements consist of simple
  6173 function calls, e.g. Foo() or an assignment of some value to the result of
  6174 a function call, e.g. functionValue=GetFoo().
  6175 
  6176 A cleanup stack is constructed for the set of C++ statements _s.
  6177 If any function in _s leaves, objects pushed to the cleanup stack are
  6178 cleaned-up. In addition, if any of the C++ statements in _s leaves,
  6179 then remaining C++ code in _s is not executed and any variables which
  6180 are assigned within that remaining code are not defined.
  6181 
  6182 @param _s C++ statements which will be executed under a trap harness.
  6183 
  6184 @see TRAPD
  6185 @see TRAP
  6186 */
  6187 
  6188 /*__CALL_EMPTY_FUNCTION(call to a function with an empty body) was added as a 
  6189 workaround to a compiler bug (mwccsym2 - winscw ) which caused an incorrect 
  6190 trap handler to be invoked when multiple nested TRAP's were present and 
  6191 User::Leave(..) was called. */
  6192 
  6193 #define TRAP_IGNORE(_s)										\
  6194 	{														\
  6195 	{ TRAP_INSTRUMENTATION_START; }							\
  6196 	try	{													\
  6197 		__WIN32SEHTRAP										\
  6198 		TTrapHandler* ____t = User::MarkCleanupStack();		\
  6199 		_s;													\
  6200 		User::UnMarkCleanupStack(____t);					\
  6201 		{ TRAP_INSTRUMENTATION_NOLEAVE; }					\
  6202 		__WIN32SEHUNTRAP									\
  6203 		}													\
  6204 	catch (XLeaveException& l)								\
  6205 		{													\
  6206 		l.GetReason();										\
  6207 		{ TRAP_INSTRUMENTATION_LEAVE(l.Reason()); }			\
  6208 		}													\
  6209 	catch (...)												\
  6210 		{													\
  6211 		User::Invariant();									\
  6212 		}													\
  6213 	__CALL_EMPTY_FUNCTION									\
  6214 	{ TRAP_INSTRUMENTATION_END; }							\
  6215 	}
  6216 
  6217 
  6218 #endif //__LEAVE_EQUALS_THROW__
  6219 
  6220 /* The macro __SYMBIAN_STDCPP_SUPPORT__ is defined when building a StdC++ target.
  6221  * In this case, operator new and operator delete below should not be declared
  6222  * to avoid clashing with StdC++ declarations.
  6223  */ 
  6224 
  6225 #ifndef __SYMBIAN_STDCPP_SUPPORT__
  6226 
  6227 #ifndef __OPERATOR_NEW_DECLARED__
  6228 
  6229 /* Some operator new and operator delete overloads may be declared in compiler
  6230  * pre-include files.
  6231  *
  6232  * __OPERATOR_NEW_DECLARED__ is #defined if they are, so that we can avoid
  6233  * re-declaring them here.
  6234  */
  6235 
  6236 #define __OPERATOR_NEW_DECLARED__
  6237 
  6238 /**
  6239 @publishedAll
  6240 @released
  6241 */
  6242 GLREF_C TAny* operator new(TUint aSize) __NO_THROW;
  6243 
  6244 /**
  6245 @publishedAll
  6246 @released
  6247 */
  6248 GLREF_C TAny* operator new(TUint aSize,TUint anExtraSize) __NO_THROW;
  6249 
  6250 /**
  6251 @publishedAll
  6252 @released
  6253 */
  6254 GLREF_C void operator delete(TAny* aPtr) __NO_THROW;
  6255 
  6256 #ifndef __OMIT_VEC_OPERATOR_NEW_DECL__
  6257 /**
  6258 @publishedAll
  6259 @released
  6260 */
  6261 GLREF_C TAny* operator new[](TUint aSize) __NO_THROW;
  6262 
  6263 /**
  6264 @publishedAll
  6265 @released
  6266 */
  6267 GLREF_C void operator delete[](TAny* aPtr) __NO_THROW;
  6268 #endif // !__OMIT_VEC_OPERATOR_NEW_DECL__
  6269 
  6270 #endif // !__OPERATOR_NEW_DECLARED__
  6271 
  6272 #endif // !__SYMBIAN_STDCPP_SUPPORT__
  6273 
  6274 /**
  6275 @publishedAll
  6276 @released
  6277 */
  6278 inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW;
  6279 
  6280 /**
  6281 @publishedAll
  6282 @released
  6283 */
  6284 inline void operator delete(TAny* aPtr, TAny* aBase) __NO_THROW;
  6285 
  6286 #ifndef __PLACEMENT_VEC_NEW_INLINE
  6287 /**
  6288 @publishedAll
  6289 @released
  6290 */
  6291 inline TAny* operator new[](TUint aSize, TAny* aBase) __NO_THROW;
  6292 
  6293 /**
  6294 @publishedAll
  6295 @released
  6296 */
  6297 inline void operator delete[](TAny* aPtr, TAny* aBase) __NO_THROW;
  6298 
  6299 #endif // !__PLACEMENT_VEC_NEW_INLINE
  6300 
  6301 #if !defined(__BOOL_NO_TRUE_TRAP__)
  6302 
  6303 /**
  6304 @publishedAll
  6305 @released
  6306 */
  6307 TBool operator==(TTrue,volatile const TBool);
  6308 
  6309 /**
  6310 @publishedAll
  6311 @released
  6312 */
  6313 TBool operator==(volatile const TBool,TTrue);
  6314 
  6315 /**
  6316 @publishedAll
  6317 @released
  6318 */
  6319 TBool operator!=(TTrue,volatile const TBool);
  6320 
  6321 /**
  6322 @publishedAll
  6323 @released
  6324 */
  6325 TBool operator!=(volatile const TBool,TTrue);
  6326 #endif
  6327 
  6328 
  6329 
  6330 
  6331 /**
  6332 @publishedAll
  6333 @released
  6334 
  6335 A Version 2 client/server class that clients use to package 
  6336 the arguments to be sent to a server.
  6337 
  6338 The object can package up to 4 arguments together with information about each
  6339 argument's type, width and accessibility; it is also possible for
  6340 the package to contain zero arguments. In addition to the default constructor,
  6341 the class has four templated constructors, allowing an object of this type to
  6342 be constructed for 0, 1, 2, 3 or 4 arguments.
  6343 
  6344 Internally, the arguments are stored in a simple TInt array.
  6345 Consecutive arguments in a constructor's parameter list are put into
  6346 consecutive slots in the array. The Set() overloaded functions can be used
  6347 to set argument values into specific slots within this array.
  6348 */
  6349 class TIpcArgs
  6350 	{
  6351 public:
  6352     /**
  6353     @internalComponent
  6354     
  6355     Argument types; some of these may be ORed together to specify
  6356 	type, accessibility, and width.
  6357     */
  6358 	enum TArgType
  6359 		{
  6360 		EUnspecified = 0,                         /**< Type not specified.*/
  6361 		EHandle = 1,                              /**< Handle type.*/
  6362 		EFlagDes = 4,                             /**< Descriptor type.*/
  6363 		EFlagConst = 2,                           /**< Read only type.*/
  6364 		EFlag16Bit = 1,                           /**< 16 bit rather than 8 bit.*/
  6365 		EDes8 = EFlagDes,                         /**< 8 bit read/write descriptor.*/
  6366 		EDes16 = EFlagDes|EFlag16Bit,             /**< 16 bit read/write descriptor.*/
  6367 		EDesC8 = EFlagDes|EFlagConst,             /**< 8 bit read only descriptor.*/
  6368 		EDesC16 = EFlagDes|EFlagConst|EFlag16Bit, /**< 16 bit read only descriptor.*/
  6369 		};
  6370 
  6371 
  6372     /**
  6373     @internalComponent
  6374 	*/
  6375 	enum 
  6376 		{
  6377 		KBitsPerType	= 3, 		/**< Number of bits of type information used for each of the 4 arguments.*/
  6378 		KPinArgShift	= KBitsPerType*KMaxMessageArguments,	/**< Bit number of the start of the pin flags. */
  6379 		KPinArg0		= 1<<(KPinArgShift+0),	/**< Set to pin argument at index 0.*/
  6380 		KPinArg1		= 1<<(KPinArgShift+1),	/**< Set to pin argument at index 1.*/
  6381 		KPinArg2		= 1<<(KPinArgShift+2),	/**< Set to pin argument at index 2.*/
  6382 		KPinArg3		= 1<<(KPinArgShift+3),	/**< Set to pin argument at index 3.*/
  6383 		KPinMask 		= 0xf<<KPinArgShift,	/**< The bits used for the pinning attributes of each argument.*/
  6384 		};
  6385 	
  6386 	
  6387 	/**
  6388 	Indicates a Null argument.
  6389 	*/
  6390 	enum TNothing {
  6391 	              /**
  6392 	              An enum value that can be used to indicate an empty or
  6393 	              unused argument to a server. For example:
  6394 	
  6395                   @code
  6396                   TIpcArgs args(arg1, TIpcArgs::ENothing, arg2);
  6397                   @endcode
  6398     
  6399                   This argument will have an undefined value when the server
  6400                   receives the message.
  6401 	              */
  6402 	              ENothing
  6403 	              };
  6404 public:
  6405     /**
  6406     Default constructor.
  6407     
  6408     An argument package constructed using this constructor has no arguments;
  6409     however, arguments can subsequently be set into this argument package object
  6410     using the Set() member functions.
  6411     */
  6412 	inline TIpcArgs()
  6413 		:iFlags(0)
  6414 		{}
  6415 		
  6416 		
  6417     /**
  6418     A templated constructor that constructs the argument package; it takes
  6419     1 argument.
  6420     
  6421     @param a0 An argument of general class type T0 to be contained by
  6422               this object.
  6423     */		
  6424 	template <class T0>
  6425 	inline explicit TIpcArgs(T0 a0)
  6426 		{
  6427 		Assign(iArgs[0],a0);
  6428 		iFlags=(Type(a0)<<(0*KBitsPerType));
  6429 		}
  6430 		
  6431 		
  6432     /**
  6433     A templated constructor that constructs the argument package; it takes
  6434     2 arguments.
  6435     
  6436     @param a0 An argument of general class type T0 to be contained by
  6437               this object.
  6438     @param a1 An argument of general class type T1 to be contained by
  6439               this object.
  6440     */		
  6441 	template <class T0,class T1>
  6442 	inline TIpcArgs(T0 a0,T1 a1)
  6443 		{
  6444 		Assign(iArgs[0],a0);
  6445 		Assign(iArgs[1],a1);
  6446 		iFlags=(Type(a0)<<(0*KBitsPerType))|(Type(a1)<<(1*KBitsPerType));
  6447 		}
  6448 				
  6449 		
  6450     /**
  6451     A templated constructor that constructs the argument package; it takes
  6452     3 arguments.
  6453     
  6454     @param a0 An argument of general class type T0 to be contained by
  6455               this object.
  6456     @param a1 An argument of general class type T1 to be contained by
  6457               this object.
  6458     @param a2 An argument of general class type T2 to be contained by
  6459               this object.
  6460     */		
  6461 	template <class T0,class T1,class T2>
  6462 	inline TIpcArgs(T0 a0,T1 a1,T2 a2)
  6463 		{
  6464 		Assign(iArgs[0],a0);
  6465 		Assign(iArgs[1],a1);
  6466 		Assign(iArgs[2],a2);
  6467 		iFlags=(Type(a0)<<(0*KBitsPerType))|(Type(a1)<<(1*KBitsPerType))|(Type(a2)<<(2*KBitsPerType));
  6468 		}
  6469 
  6470 
  6471     /**
  6472     A templated constructor that constructs the argument package; it takes
  6473     4 arguments.
  6474     
  6475     @param a0 An argument of general class type T0 to be contained by
  6476               this object.
  6477     @param a1 An argument of general class type T1 to be contained by
  6478               this object.
  6479     @param a2 An argument of general class type T2 to be contained by
  6480               this object.
  6481     @param a3 An argument of general class type T3 to be contained by
  6482               this object.
  6483     */		
  6484 	template <class T0,class T1,class T2,class T3>
  6485 	inline TIpcArgs(T0 a0,T1 a1,T2 a2,T3 a3)
  6486 		{
  6487 		Assign(iArgs[0],a0);
  6488 		Assign(iArgs[1],a1);
  6489 		Assign(iArgs[2],a2);
  6490 		Assign(iArgs[3],a3);
  6491 		iFlags=(Type(a0)<<(0*KBitsPerType))|(Type(a1)<<(1*KBitsPerType))|(Type(a2)<<(2*KBitsPerType))|(Type(a3)<<(3*KBitsPerType));
  6492 		}
  6493 	//
  6494 	inline void Set(TInt aIndex,TNothing);
  6495 	inline void Set(TInt aIndex,TInt aValue);
  6496 	inline void Set(TInt aIndex,const TAny* aValue);
  6497 	inline void Set(TInt aIndex,RHandleBase aValue);
  6498 	inline void Set(TInt aIndex,const TDesC8* aValue);
  6499 #ifndef __KERNEL_MODE__
  6500 	inline void Set(TInt aIndex,const TDesC16* aValue);
  6501 #endif
  6502 	inline void Set(TInt aIndex,TDes8* aValue);
  6503 #ifndef __KERNEL_MODE__
  6504 	inline void Set(TInt aIndex,TDes16* aValue);
  6505 #endif
  6506 
  6507 	inline TIpcArgs& PinArgs(TBool aPinArg0=ETrue, TBool aPinArg1=ETrue, TBool aPinArg2=ETrue, TBool aPinArg3=ETrue);
  6508 private:
  6509 	inline static TArgType Type(TNothing);
  6510 	inline static TArgType Type(TInt);
  6511 	inline static TArgType Type(const TAny*);
  6512 	inline static TArgType Type(RHandleBase aValue);
  6513 	inline static TArgType Type(const TDesC8*);
  6514 #ifndef __KERNEL_MODE__
  6515 	inline static TArgType Type(const TDesC16*);
  6516 #endif
  6517 	inline static TArgType Type(TDes8*);
  6518 #ifndef __KERNEL_MODE__
  6519 	inline static TArgType Type(TDes16*);
  6520 #endif
  6521 	//
  6522 	inline static void Assign(TInt&,TNothing);
  6523 	inline static void Assign(TInt& aArg,TInt aValue);
  6524 	inline static void Assign(TInt& aArg,const TAny* aValue);
  6525 	inline static void Assign(TInt& aArg,RHandleBase aValue);
  6526 	inline static void Assign(TInt& aArg,const TDesC8* aValue);
  6527 #ifndef __KERNEL_MODE__
  6528 	inline static void Assign(TInt& aArg,const TDesC16* aValue);
  6529 #endif
  6530 	inline static void Assign(TInt& aArg,TDes8* aValue);
  6531 #ifndef __KERNEL_MODE__
  6532 	inline static void Assign(TInt& aArg,TDes16* aValue);
  6533 #endif
  6534 public:
  6535     
  6536     /**
  6537     The location where the message arguments are stored.
  6538     
  6539     There is no reason to access this data member directly and it should be
  6540     considered as internal.
  6541     */
  6542 	TInt iArgs[KMaxMessageArguments];
  6543 	
  6544 	/**
  6545 	The location where the flag bits describing the argument types are stored.
  6546 	
  6547 	The symbolic values describing the argument types are internal to Symbian,
  6548 	and there is therefore no reason to access this data member directly.
  6549 	It should be considered as internal.
  6550 	*/
  6551 	TInt iFlags;
  6552 	};
  6553 
  6554 // Structures for passing 64 bit integers and doubles across GCC/EABI boundaries
  6555 
  6556 /**
  6557 @internalComponent
  6558 */
  6559 struct SInt64
  6560 	{
  6561 public:
  6562 	inline SInt64();
  6563 	inline SInt64(Int64 a);
  6564 	inline SInt64& operator=(Int64 a);
  6565 	inline operator Int64() const;
  6566 public:
  6567 	TUint32 iData[2];	// little endian
  6568 	};
  6569 
  6570 /**
  6571 @internalComponent
  6572 */
  6573 struct SUint64
  6574 	{
  6575 public:
  6576 	inline SUint64();
  6577 	inline SUint64(Uint64 a);
  6578 	inline SUint64& operator=(Uint64 a);
  6579 	inline operator Uint64() const;
  6580 public:
  6581 	TUint32 iData[2];	// little endian
  6582 	};
  6583 
  6584 /**
  6585 @internalComponent
  6586 */
  6587 struct SDouble
  6588 	{
  6589 public:
  6590 	inline SDouble();
  6591 	inline SDouble(TReal a);
  6592 	inline SDouble& operator=(TReal a);
  6593 	inline operator TReal() const;
  6594 public:
  6595 	TUint32 iData[2];	// always little endian
  6596 	};
  6597 
  6598 /**
  6599 @publishedAll
  6600 @released
  6601 
  6602 Stores information about a thread's stack.
  6603 
  6604 Note, on the emulator, the memory between iLimit and the thread's current stack pointer
  6605 may not actually be committed.
  6606 
  6607 @see RThread::StackInfo()
  6608 */
  6609 class TThreadStackInfo
  6610 	{
  6611 public:
  6612     /**
  6613     The address which the stack pointer would contain if the stack were empty.
  6614     */
  6615 	TLinAddr iBase;
  6616 	
  6617 	/**
  6618 	The address which the stack pointer would contain if the stack were full,
  6619     (The lowest valid address).
  6620 	*/
  6621 	TLinAddr iLimit;
  6622 	
  6623 	/**
  6624 	The limit value for the stack if it were expanded to its maximum size.
  6625     
  6626     Currently expanding stacks is not supported so iExpandLimit==iLimit
  6627 	*/
  6628 	TLinAddr iExpandLimit;
  6629 	};
  6630 
  6631 
  6632 
  6633 
  6634 #ifdef __SUPPORT_CPP_EXCEPTIONS__
  6635 /**
  6636 @internalComponent
  6637 @released
  6638 
  6639 The class used to implement User::Leave in term of throw and TRAP in terms of catch.
  6640 
  6641 */
  6642 class XLeaveException
  6643 	{
  6644 public:
  6645 	inline XLeaveException() {}
  6646 	inline XLeaveException(TInt aReason) {iR = aReason;}
  6647 	inline TInt Reason() const {return iR;}
  6648 	IMPORT_C TInt GetReason() const;
  6649 private:
  6650 #if __ARMCC_VERSION >= 220000
  6651 	// From rvct 2.2 onwards we want the class impedimenta to be shared, so create a key function.
  6652 	// Unfortunately we can't make this the key function the dtor since this would make it impossible for existing 2.1 
  6653 	// derived binaries to be 'BC' with 2.2 binaries (in the general case (which I wont attempt to describe coz its
  6654 	// too complex) so its best to be safe). As a clue: if 2.1 is used to compile with a key function its not possible 
  6655 	// for catch handlers to work :-( (see the old code).
  6656 	virtual void ForceKeyFunction();	
  6657 #endif
  6658 private:
  6659 #if __ARMCC_VERSION < 220000
  6660 	TAny* iVtable;							// reserve space for vtable
  6661 #endif	
  6662 	TInt iR;
  6663 	};
  6664 
  6665 // The standard header file <exception> defines the following guard macro for EDG and CW, VC++, GCC respectively.
  6666 // The guard below is ugly. It will surely come back and bite us unless we resolve the whole issue of standard headers
  6667 // when we move to supporting Standard C++.
  6668 
  6669 // The macro __SYMBIAN_STDCPP_SUPPORT__ is defined when building a StdC++ target.
  6670 // In this case, we include the StdC++ specification <exception> rather than declaring uncaught_exception.
  6671  
  6672 #ifdef __SYMBIAN_STDCPP_SUPPORT__
  6673 	#include <stdapis/stlportv5/exception>
  6674 #elif !defined(_EXCEPTION) && !defined(_EXCEPTION_) && !defined(__EXCEPTION__)
  6675 // Declare standard C++ functions relating to exceptions here
  6676 namespace std {
  6677 #if defined(__VC32__) || defined(__CW32__)
  6678   bool uncaught_exception();
  6679 #else
  6680   IMPORT_C bool uncaught_exception();
  6681 #endif
  6682   void terminate(void);
  6683   void unexpected(void);
  6684   typedef void (*terminate_handler)();
  6685   terminate_handler set_terminate(terminate_handler h) throw();
  6686   typedef void (*unexpected_handler)();
  6687   unexpected_handler set_unexpected(unexpected_handler h) throw();
  6688 }
  6689 
  6690 #endif
  6691 #endif //__SUPPORT_CPP_EXCEPTIONS__
  6692 
  6693 #ifdef __WINS__
  6694 
  6695 #ifndef __WIN32_SEH_TYPES_KNOWN__
  6696 class __UnknownWindowsType1;
  6697 class __UnknownWindowsType2;
  6698 #endif
  6699 
  6700 class TWin32SEHTrap;
  6701 
  6702 /**
  6703  * Typedef for the SEH handler function
  6704  * @internalComponent
  6705  */
  6706 typedef TUint32 (TWin32SEHExceptionHandler)(__UnknownWindowsType1* aExceptionRecord, TWin32SEHTrap* aRegistrationRecord, __UnknownWindowsType2* aContext);
  6707 
  6708 /**
  6709  * @internalComponent
  6710  */
  6711 class TWin32SEHTrap
  6712 	{
  6713 private:
  6714 	// Prevent copy/assign
  6715     TWin32SEHTrap(TWin32SEHTrap const &);
  6716     TWin32SEHTrap& operator=(TWin32SEHTrap const &);
  6717 
  6718 #ifdef __KERNEL_MODE__
  6719 //
  6720 // Kernel-side functions for nkern exception handler
  6721 //
  6722 public:
  6723 	/** Find final exception handler in SEH chain */
  6724 	static TWin32SEHTrap* IterateForFinal();
  6725 
  6726 	/** Access exception handler */
  6727 	TWin32SEHExceptionHandler* ExceptionHandler();
  6728 
  6729 private:
  6730 
  6731 #else // !__KERNEL_MODE__
  6732 //
  6733 // User-side functions for use in TRAP(...)
  6734 //
  6735 public:
  6736 	UIMPORT_C TWin32SEHTrap();
  6737 
  6738 public:
  6739 	/** Add object to SEH chain */
  6740 	UIMPORT_C void Trap();
  6741 
  6742 	/** Remove object from SEH chain */
  6743 	UIMPORT_C void UnTrap();
  6744 
  6745 #ifndef __IN_SEH_CPP__
  6746 private:
  6747 #endif
  6748 	/** Handle Win32 exceptions */
  6749 	static TUint32 ExceptionHandler(__UnknownWindowsType1* aException, TWin32SEHTrap* aRegistrationRecord, __UnknownWindowsType2* aContext);
  6750 
  6751 #endif //__KERNEL_MODE__
  6752 
  6753 	//
  6754 	// NB: This is really an _EXCEPTION_REGISTRATION_RECORD
  6755 	//
  6756     TWin32SEHTrap*					iPrevExceptionRegistrationRecord;	/** Link to previous SEH record */
  6757 	TWin32SEHExceptionHandler*		iExceptionHandler;					/** SEH handler function */
  6758 
  6759 private:
  6760 	TUint32 iPadding[254];	// discourage the compiler from putting this in reused function parameter space
  6761 	};
  6762 
  6763 #else // !__WINS__
  6764 
  6765 #ifdef __X86__
  6766 /**
  6767  * @internalComponent
  6768  */
  6769 class TWin32SEHTrap
  6770 	{
  6771 public:
  6772 	UIMPORT_C TWin32SEHTrap();
  6773 	UIMPORT_C void Trap();
  6774 	UIMPORT_C void UnTrap();
  6775 	};
  6776 #endif //__X86__
  6777 #endif //__WINS__
  6778 
  6779 /**
  6780 @internalTechnology
  6781  */
  6782 struct TEmulatorImageHeader
  6783 	{
  6784 	TUid iUids[KMaxCheckedUid];
  6785 	TProcessPriority iPriority;
  6786 	SSecurityInfo iS;
  6787 	TUint32 iSpare1;
  6788 	TUint32 iSpare2;
  6789 	TUint32 iModuleVersion;
  6790 	TUint32 iFlags;
  6791 	};
  6792 
  6793 // forward declaration of shareable data buffers pool infomation
  6794 class TShPoolInfo;
  6795 
  6796 #include <e32cmn.inl>
  6797 
  6798 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
  6799 #include <e32cmn_private.h>
  6800 #endif
  6801 
  6802 #endif //__E32CMN_H__
  6803