williamr@2: // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of the License "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // e32\include\e32cmn.h williamr@2: // williamr@2: // williamr@2: williamr@2: #ifndef __E32CMN_H__ williamr@2: #define __E32CMN_H__ williamr@2: #include williamr@2: williamr@2: extern "C" { williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Nanokernel utility function that compares two memory buffers for equality. williamr@2: williamr@2: The two buffers are considered equal only if: williamr@2: williamr@2: 1. the buffers have the same length williamr@2: williamr@2: and williamr@2: williamr@2: 2. the binary content of both buffers is the same. williamr@2: williamr@2: @param aLeft The start address of the first buffer in the comparison. williamr@2: @param aLeftLen The length of the first buffer in the comparison. williamr@2: @param aRight The start address of the second buffer in the comparison. williamr@2: @param aRightLen The length of the second buffer in the comparison. williamr@2: williamr@2: @return Zero if both buffers are equal; non-zero, otherwise. williamr@2: williamr@2: @panic USER 88 In debug mode only, if aLeftL is negative, williamr@2: and the function is called on the user side. williamr@2: @panic KERN-COMMON 88 In debug mode only, if aLeftL is negative, williamr@2: and the function is called on the kernel side. williamr@2: @panic USER 89 In debug mode only, if aRightL is negative, williamr@2: and the function is called on the user side. williamr@2: @panic KERN-COMMON 89 In debug mode only, if aRightL is negative, williamr@2: and the function is called on the kernel side. williamr@2: */ williamr@2: IMPORT_C TInt memcompare(const TUint8* aLeft, TInt aLeftLen, const TUint8* aRight, TInt aRightLen); williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Nanokernel utility function that moves (copies) bytes in memory. williamr@2: williamr@2: The function assumes that the addresses are aligned on word boundaries, williamr@2: and that the length value is a multiple of 4. williamr@2: williamr@2: @param aTrg The target address. williamr@2: @param aSrc The source address. williamr@2: @param aLength The number of bytes to be moved. williamr@2: williamr@2: @return The target address. williamr@2: williamr@2: @panic USER 91 In debug mode only, if aLength is not a multiple of 4, williamr@2: and the function is called on the user side. williamr@2: @panic KERN-COMMON 91 In debug mode only, if aLength is not a multiple of 4, williamr@2: and the function is called on the kernel side. williamr@2: @panic USER 92 In debug mode only, if aSrc is not aligned on a word boundary, williamr@2: and the function is called on the user side. williamr@2: @panic KERN-COMMON 92 In debug mode only, if aSrc is not aligned on a word boundary, williamr@2: and the function is called on the kernel side. williamr@2: @panic USER 93 In debug mode only, if aTrg is not aligned on a word boundary, williamr@2: and the function is called on the user side. williamr@2: @panic KERN-COMMON 93 In debug mode only, if aTrg is not aligned on a word boundary, williamr@2: and the function is called on the kernel side. williamr@2: */ williamr@2: IMPORT_C TAny* wordmove(TAny* aTrg, const TAny* aSrc, unsigned int aLength); williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Nanokernel utility function that sets the specified number of bytes williamr@2: to binary zero. williamr@2: williamr@2: @param aTrg The start address. williamr@2: @param aLength The number of bytes to be set. williamr@2: williamr@2: @return The target address. williamr@2: */ williamr@2: IMPORT_C TAny* memclr(TAny* aTrg, unsigned int aLength); williamr@2: } williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __TOOLS__ williamr@2: extern "C" { williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Nanokernel utility function that sets all of the specified number of bytes to williamr@2: the specified fill value. williamr@2: williamr@2: @param aTrg The start address. williamr@2: @param aValue The fill value (the first or junior byte). williamr@2: @param aLength The number of bytes to be set. williamr@2: williamr@2: @return The target address. williamr@2: */ williamr@2: IMPORT_C TAny* memset(TAny* aTrg, TInt aValue, unsigned int aLength); williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Nanokernel utility function that copies bytes in memory. williamr@2: williamr@2: @param aTrg The target address. williamr@2: @param aSrc The source address. williamr@2: @param aLength The number of bytes to be moved. williamr@2: williamr@2: @return The target address. williamr@2: */ williamr@2: IMPORT_C TAny* memcpy(TAny* aTrg, const TAny* aSrc, unsigned int aLength); williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Nanokernel utility function that moves (copies) bytes in memory. williamr@2: williamr@2: @param aTrg The target address. williamr@2: @param aSrc The source address. williamr@2: @param aLength The number of bytes to be moved. williamr@2: williamr@2: @return The target address. williamr@2: */ williamr@2: IMPORT_C TAny* memmove(TAny* aTrg, const TAny* aSrc, unsigned int aLength); williamr@2: } williamr@2: #else williamr@2: #include williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Tests whether the specified value is less than or equal to the williamr@2: specified upper limit. williamr@2: williamr@2: @param aVal The value to be tested. williamr@2: @param aLimit The upper limit. williamr@2: williamr@2: @return True, if the value is less than or equal to the specified upper limit; williamr@2: false, otherwise. williamr@2: */ williamr@2: inline TInt Lim(TInt aVal,TUint aLimit) williamr@2: {return(((TUint)aVal)<=aLimit);} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Tests whether the specified value is strictly less than the williamr@2: specified upper limit. williamr@2: williamr@2: @param aVal The value to be tested. williamr@2: @param aLimit The upper limit. williamr@2: williamr@2: @return True, if the value is strictly less than the specified upper limit; williamr@2: false, otherwise. williamr@2: */ williamr@2: inline TInt LimX(TInt aVal,TUint aLimit) williamr@2: {return(((TUint)aVal) williamr@2: inline T Min(T aLeft,T aRight) williamr@2: {return(aLeft williamr@2: inline T Min(T aLeft,TUint aRight) williamr@2: {return(aLeft<(TInt)aRight ? aLeft : (T)aRight);} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Returns the larger of two values. williamr@2: williamr@2: @param aLeft The first value to be compared. williamr@2: @param aRight The second value to be compared. williamr@2: williamr@2: @return The larger value. williamr@2: */ williamr@2: template williamr@2: inline T Max(T aLeft,T aRight) williamr@2: {return(aLeft williamr@2: inline T Max(T aLeft,TUint aRight) williamr@2: {return(aLeft<(TInt)aRight ? (TInt)aRight : aLeft);} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Returns an absolute value. williamr@2: williamr@2: @param aVal The source value. williamr@2: williamr@2: @return The absolute value williamr@2: */ williamr@2: template williamr@2: inline T Abs(T aVal) williamr@2: {return(aVal<0 ? -aVal : aVal);} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Determines whether a specified value lies within a defined range of values. williamr@2: williamr@2: @param aMin The lower value of the range. williamr@2: @param aVal The value to be compared. williamr@2: @param aMax The higher value of the range. williamr@2: williamr@2: @return True, if the specified value lies within the range; false, otherwise. williamr@2: */ williamr@2: template williamr@2: inline TBool Rng(T aMin,T aVal,T aMax) williamr@2: {return(aVal>=aMin && aVal<=aMax);} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Adds a value to a pointer. williamr@2: williamr@2: @param aPtr Pointer to an object of type T. williamr@2: @param aVal The value to be added. williamr@2: williamr@2: @return The resulting pointer value, as a pointer to a type T. williamr@2: */ williamr@2: template williamr@2: inline T* PtrAdd(T* aPtr,S aVal) williamr@2: {return((T*)(((TUint8*)aPtr)+aVal));} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Subtracts a value from a pointer. williamr@2: williamr@2: @param aPtr Pointer to an object of type T. williamr@2: @param aVal The value to be added. williamr@2: williamr@2: @return The resulting pointer value, as a pointer to a type T. williamr@2: */ williamr@2: template williamr@2: inline T* PtrSub(T* aPtr,S aVal) williamr@2: {return((T*)(((TUint8*)aPtr)-aVal));} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Aligns the specified value onto a 2-byte boundary. williamr@2: williamr@2: @param aValue The value to be aligned. williamr@2: williamr@2: @return The aligned value. williamr@2: */ williamr@2: template williamr@2: inline T Align2(T aValue) williamr@2: {return((T)((((TUint)aValue)+sizeof(TUint16)-1)&~(sizeof(TUint16)-1)));} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Aligns the specified value onto a 4-byte boundary. williamr@2: williamr@2: @param aValue The value to be aligned. williamr@2: williamr@2: @return The aligned value. williamr@2: */ williamr@2: template williamr@2: inline T Align4(T aValue) williamr@2: {return((T)((((TUint)aValue)+sizeof(TUint32)-1)&~(sizeof(TUint32)-1)));} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A templated class which encapsulates a reference to an object within a wrapper. williamr@2: williamr@2: The wrapper object can be passed to a function as a value type. This allows williamr@2: a reference to be passed to a function as a value type. williamr@2: williamr@2: This wrapper object is commonly termed a value reference. williamr@2: */ williamr@2: template williamr@2: class TRefByValue williamr@2: { williamr@2: public: williamr@2: inline TRefByValue(T& aRef); williamr@2: inline operator T&(); williamr@2: private: williamr@2: TRefByValue& operator=(TRefByValue aRef); williamr@2: private: williamr@2: T &iRef; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #if !defined (__KERNEL_MODE__) williamr@2: class TDesC16; // forward declaration for TChar member functions williamr@2: class TPtrC16; // forward declaration for TChar member functions williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Holds a character value and provides a number of utility functions to williamr@2: manipulate it and test its properties. williamr@2: williamr@2: For example, there are functions to convert the character williamr@2: to uppercase and test whether or not it is a control character. williamr@2: williamr@2: The character value is stored as a 32-bit unsigned integer. The shorthand williamr@2: "TChar value" is used to describe the character value wrapped by a TChar williamr@2: object. williamr@2: williamr@2: TChar can be used to represent Unicode values outside plane 0 (that is, the williamr@2: extended Unicode range from 0x10000 to 0xFFFFF). This differentiates it from williamr@2: TText which can only be used for 16-bit Unicode character values. williamr@2: williamr@2: @see TText williamr@2: */ williamr@2: class TChar williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: /** williamr@2: General Unicode character category. williamr@2: williamr@2: The high nibble encodes the major category (Mark, Number, etc.) and a low williamr@2: nibble encodes the subdivisions of that category. williamr@2: williamr@2: The category codes can be used in three ways: williamr@2: williamr@2: (i) as unique constants: there is one for each Unicode category, with a williamr@2: name of the form williamr@2: @code williamr@2: ECategory williamr@2: @endcode williamr@2: where williamr@2: @code williamr@2: williamr@2: @endcode williamr@2: is the category name given by williamr@2: the Unicode database (e.g., the constant ELuCategory is used for lowercase williamr@2: letters, category Lu); williamr@2: williamr@2: (ii) as numbers in certain ranges: letter categories are all <= EMaxLetterCategory; williamr@2: williamr@2: (iii) as codes in which the upper nibble gives the category group williamr@2: (e.g., punctuation categories all yield TRUE for williamr@2: the test (category & 0xF0) ==EPunctuationGroup). williamr@2: */ williamr@2: enum TCategory williamr@2: { williamr@2: /** williamr@2: Alphabetic letters. williamr@2: williamr@2: Includes ELuCategory, ELlCategory and ELtCategory. williamr@2: */ williamr@2: EAlphaGroup = 0x00, williamr@2: williamr@2: williamr@2: /** williamr@2: Other letters. williamr@2: williamr@2: Includes ELoCategory. williamr@2: */ williamr@2: ELetterOtherGroup = 0x10, williamr@2: williamr@2: williamr@2: /** williamr@2: Letter modifiers. williamr@2: williamr@2: Includes ELmCategory. williamr@2: */ williamr@2: ELetterModifierGroup = 0x20, williamr@2: williamr@2: williamr@2: /** williamr@2: Marks group. williamr@2: williamr@2: Includes EMnCategory, EMcCategory and EMeCategory. williamr@2: */ williamr@2: EMarkGroup = 0x30, williamr@2: williamr@2: williamr@2: /** williamr@2: Numbers group. williamr@2: williamr@2: Includes ENdCategory, ENlCategory and ENoCategory. williamr@2: */ williamr@2: ENumberGroup = 0x40, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation group. williamr@2: williamr@2: IncludesEPcCategory, PdCategory, EpeCategory, EPsCategory and EPoCategory. williamr@2: */ williamr@2: EPunctuationGroup = 0x50, williamr@2: williamr@2: williamr@2: /** williamr@2: Symbols group. williamr@2: williamr@2: Includes ESmCategory, EScCategory, ESkCategory and ESoCategory. williamr@2: */ williamr@2: ESymbolGroup = 0x60, williamr@2: williamr@2: williamr@2: /** williamr@2: Separators group. williamr@2: williamr@2: Includes EZsCategory, EZlCategory and EZlpCategory. williamr@2: */ williamr@2: ESeparatorGroup = 0x70, williamr@2: williamr@2: williamr@2: /** williamr@2: Control, format, private use, unassigned. williamr@2: williamr@2: Includes ECcCategory, ECtCategory, ECsCategory, williamr@2: ECoCategory and ECnCategory. williamr@2: */ williamr@2: EControlGroup = 0x80, williamr@2: williamr@2: williamr@2: /** williamr@2: The highest possible groups category. williamr@2: */ williamr@2: EMaxAssignedGroup = 0xE0, williamr@2: williamr@2: williamr@2: /** williamr@2: Unassigned to any other group. williamr@2: */ williamr@2: EUnassignedGroup = 0xF0, williamr@2: williamr@2: williamr@2: /** williamr@2: Letter, Uppercase. williamr@2: */ williamr@2: ELuCategory = EAlphaGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Letter, Lowercase. williamr@2: */ williamr@2: ELlCategory = EAlphaGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Letter, Titlecase. williamr@2: */ williamr@2: ELtCategory = EAlphaGroup | 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Letter, Other. williamr@2: */ williamr@2: ELoCategory = ELetterOtherGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: The highest possible (non-modifier) letter category. williamr@2: */ williamr@2: EMaxLetterCategory = ELetterOtherGroup | 0x0F, williamr@2: williamr@2: /** williamr@2: Letter, Modifier. williamr@2: */ williamr@2: ELmCategory = ELetterModifierGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: The highest possible letter category. williamr@2: */ williamr@2: EMaxLetterOrLetterModifierCategory = ELetterModifierGroup | 0x0F, williamr@2: williamr@2: /** williamr@2: Mark, Non-Spacing williamr@2: */ williamr@2: EMnCategory = EMarkGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Mark, Combining. williamr@2: */ williamr@2: EMcCategory = EMarkGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Mark, Enclosing. williamr@2: */ williamr@2: EMeCategory = EMarkGroup | 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Number, Decimal Digit. williamr@2: */ williamr@2: ENdCategory = ENumberGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Number, Letter. williamr@2: */ williamr@2: ENlCategory = ENumberGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Number, Other. williamr@2: */ williamr@2: ENoCategory = ENumberGroup | 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Connector. williamr@2: */ williamr@2: EPcCategory = EPunctuationGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Dash. williamr@2: */ williamr@2: EPdCategory = EPunctuationGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Open. williamr@2: */ williamr@2: EPsCategory = EPunctuationGroup | 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Close. williamr@2: */ williamr@2: EPeCategory = EPunctuationGroup | 3, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Initial Quote williamr@2: */ williamr@2: EPiCategory = EPunctuationGroup | 4, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Final Quote williamr@2: */ williamr@2: EPfCategory = EPunctuationGroup | 5, williamr@2: williamr@2: williamr@2: /** williamr@2: Punctuation, Other. williamr@2: */ williamr@2: EPoCategory = EPunctuationGroup | 6, williamr@2: williamr@2: williamr@2: /** williamr@2: Symbol, Math. williamr@2: */ williamr@2: ESmCategory = ESymbolGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Symbol, Currency. williamr@2: */ williamr@2: EScCategory = ESymbolGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Symbol, Modifier. williamr@2: */ williamr@2: ESkCategory = ESymbolGroup | 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Symbol, Other. williamr@2: */ williamr@2: ESoCategory = ESymbolGroup | 3, williamr@2: williamr@2: williamr@2: /** williamr@2: The highest possible graphic character category. williamr@2: */ williamr@2: EMaxGraphicCategory = ESymbolGroup | 0x0F, williamr@2: williamr@2: williamr@2: /** williamr@2: Separator, Space. williamr@2: */ williamr@2: EZsCategory = ESeparatorGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: The highest possible printable character category. williamr@2: */ williamr@2: EMaxPrintableCategory = EZsCategory, williamr@2: williamr@2: williamr@2: /** williamr@2: Separator, Line. williamr@2: */ williamr@2: EZlCategory = ESeparatorGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Separator, Paragraph. williamr@2: */ williamr@2: EZpCategory = ESeparatorGroup | 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Other, Control. williamr@2: */ williamr@2: ECcCategory = EControlGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Other, Format. williamr@2: */ williamr@2: ECfCategory = EControlGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: The highest possible category for assigned 16-bit characters; does not williamr@2: include surrogates, which are interpreted as pairs and have no meaning williamr@2: on their own. williamr@2: */ williamr@2: EMaxAssignedCategory = EMaxAssignedGroup | 0x0F, williamr@2: williamr@2: williamr@2: /** williamr@2: Other, Surrogate. williamr@2: */ williamr@2: ECsCategory = EUnassignedGroup | 0, williamr@2: williamr@2: williamr@2: /** williamr@2: Other, Private Use. williamr@2: */ williamr@2: ECoCategory = EUnassignedGroup | 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Other, Not Assigned. williamr@2: */ williamr@2: ECnCategory = EUnassignedGroup | 2 williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: The bi-directional Unicode character category. williamr@2: williamr@2: For more information on the bi-directional algorithm, see Unicode Technical williamr@2: Report No. 9 available at: http://www.unicode.org/unicode/reports/tr9. williamr@2: */ williamr@2: enum TBdCategory williamr@2: { williamr@2: /** williamr@2: Left to right. williamr@2: */ williamr@2: ELeftToRight, // L Left-to-Right williamr@2: williamr@2: williamr@2: /** williamr@2: Left to right embedding. williamr@2: */ williamr@2: ELeftToRightEmbedding, // LRE Left-to-Right Embedding williamr@2: williamr@2: williamr@2: /** williamr@2: Left-to-Right Override. williamr@2: */ williamr@2: ELeftToRightOverride, // LRO Left-to-Right Override williamr@2: williamr@2: williamr@2: /** williamr@2: Right to left. williamr@2: */ williamr@2: ERightToLeft, // R Right-to-Left williamr@2: williamr@2: williamr@2: /** williamr@2: Right to left Arabic. williamr@2: */ williamr@2: ERightToLeftArabic, // AL Right-to-Left Arabic williamr@2: williamr@2: williamr@2: /** williamr@2: Right to left embedding. williamr@2: */ williamr@2: ERightToLeftEmbedding, // RLE Right-to-Left Embedding williamr@2: williamr@2: williamr@2: /** williamr@2: Right-to-Left Override. williamr@2: */ williamr@2: ERightToLeftOverride, // RLO Right-to-Left Override williamr@2: williamr@2: williamr@2: /** williamr@2: Pop Directional Format. williamr@2: */ williamr@2: EPopDirectionalFormat, // PDF Pop Directional Format williamr@2: williamr@2: williamr@2: /** williamr@2: European number. williamr@2: */ williamr@2: EEuropeanNumber, // EN European Number williamr@2: williamr@2: williamr@2: /** williamr@2: European number separator. williamr@2: */ williamr@2: EEuropeanNumberSeparator, // ES European Number Separator williamr@2: williamr@2: williamr@2: /** williamr@2: European number terminator. williamr@2: */ williamr@2: EEuropeanNumberTerminator, // ET European Number Terminator williamr@2: williamr@2: williamr@2: /** williamr@2: Arabic number. williamr@2: */ williamr@2: EArabicNumber, // AN Arabic Number williamr@2: williamr@2: williamr@2: /** williamr@2: Common number separator. williamr@2: */ williamr@2: ECommonNumberSeparator, // CS Common Number Separator williamr@2: williamr@2: williamr@2: /** williamr@2: Non Spacing Mark. williamr@2: */ williamr@2: ENonSpacingMark, // NSM Non-Spacing Mark williamr@2: williamr@2: williamr@2: /** williamr@2: Boundary Neutral. williamr@2: */ williamr@2: EBoundaryNeutral, // BN Boundary Neutral williamr@2: williamr@2: williamr@2: /** williamr@2: Paragraph Separator. williamr@2: */ williamr@2: EParagraphSeparator, // B Paragraph Separator williamr@2: williamr@2: williamr@2: /** williamr@2: Segment separator. williamr@2: */ williamr@2: ESegmentSeparator, // S Segment Separator williamr@2: williamr@2: williamr@2: /** williamr@2: Whitespace williamr@2: */ williamr@2: EWhitespace, // WS Whitespace williamr@2: williamr@2: williamr@2: /** williamr@2: Other neutrals; all other characters: punctuation, symbols. williamr@2: */ williamr@2: EOtherNeutral // ON Other Neutrals williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Notional character width as known to East Asian (Chinese, Japanese, williamr@2: Korean (CJK)) coding systems. williamr@2: */ williamr@2: enum TCjkWidth williamr@2: { williamr@2: /** williamr@2: Includes 'ambiguous width' defined in Unicode Technical Report 11: East Asian Width williamr@2: */ williamr@2: ENeutralWidth, williamr@2: williamr@2: williamr@2: /** williamr@2: Character which occupies a single cell. williamr@2: */ williamr@2: EHalfWidth, // other categories are as defined in the report williamr@2: williamr@2: williamr@2: /** williamr@2: Character which occupies 2 cells. williamr@2: */ williamr@2: EFullWidth, williamr@2: williamr@2: williamr@2: /** williamr@2: Characters that are always narrow and have explicit full-width williamr@2: counterparts. All of ASCII is an example of East Asian Narrow williamr@2: characters. williamr@2: */ williamr@2: ENarrow, williamr@2: williamr@2: /** williamr@2: Characters that are always wide. This category includes characters that williamr@2: have explicit half-width counterparts. williamr@2: */ williamr@2: EWide williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: @deprecated williamr@2: williamr@2: Encoding systems used by the translation functions. williamr@2: */ williamr@2: enum TEncoding williamr@2: { williamr@2: /** williamr@2: The Unicode encoding. williamr@2: */ williamr@2: EUnicode, williamr@2: williamr@2: williamr@2: /** williamr@2: The shift-JIS encoding (used in Japan). williamr@2: */ williamr@2: EShiftJIS williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Flags defining operations to be performed using TChar::Fold(). williamr@2: williamr@2: The flag values are passed to the Fold() funtion. williamr@2: williamr@2: @see TChar::Fold williamr@2: */ williamr@2: enum williamr@2: { williamr@2: /** williamr@2: Convert characters to their lower case form if any. williamr@2: */ williamr@2: EFoldCase = 1, williamr@2: williamr@2: williamr@2: /** williamr@2: Strip accents williamr@2: */ williamr@2: EFoldAccents = 2, williamr@2: williamr@2: williamr@2: /** williamr@2: Convert digits representing values 0..9 to characters '0'..'9' williamr@2: */ williamr@2: EFoldDigits = 4, williamr@2: williamr@2: williamr@2: /** williamr@2: Convert all spaces (ordinary, fixed-width, ideographic, etc.) to ' ' williamr@2: */ williamr@2: EFoldSpaces = 8, williamr@2: williamr@2: williamr@2: /** williamr@2: Convert hiragana to katakana. williamr@2: */ williamr@2: EFoldKana = 16, williamr@2: williamr@2: williamr@2: /** williamr@2: Fold fullwidth and halfwidth variants to their standard forms williamr@2: */ williamr@2: EFoldWidth = 32, williamr@2: williamr@2: williamr@2: /** williamr@2: Perform standard folding operations, i.e.those done by Fold() with no argument williamr@2: */ williamr@2: EFoldStandard = EFoldCase | EFoldAccents | EFoldDigits | EFoldSpaces, williamr@2: williamr@2: williamr@2: /** williamr@2: Perform all possible folding operations williamr@2: */ williamr@2: EFoldAll = -1 williamr@2: }; williamr@2: williamr@2: williamr@2: struct TCharInfo williamr@2: /** williamr@2: A structure to hold information about a Unicode character. williamr@2: williamr@2: An object of this type is passed to TChar::GetInfo(). williamr@2: williamr@2: @see TChar::GetInfo williamr@2: */ williamr@2: { williamr@2: /** williamr@2: General category. williamr@2: */ williamr@2: TCategory iCategory; williamr@2: williamr@2: williamr@2: /** williamr@2: Bi-directional category. williamr@2: */ williamr@2: TBdCategory iBdCategory; williamr@2: williamr@2: williamr@2: /** williamr@2: Combining class: number (currently) in the range 0..234 williamr@2: */ williamr@2: TInt iCombiningClass; williamr@2: williamr@2: williamr@2: /** williamr@2: Lower case form. williamr@2: */ williamr@2: TUint iLowerCase; williamr@2: williamr@2: williamr@2: /** williamr@2: Upper case form. williamr@2: */ williamr@2: TUint iUpperCase; williamr@2: williamr@2: williamr@2: /** williamr@2: Title case form. williamr@2: */ williamr@2: TUint iTitleCase; williamr@2: williamr@2: williamr@2: /** williamr@2: True, if the character is mirrored. williamr@2: */ williamr@2: TBool iMirrored; williamr@2: williamr@2: williamr@2: /** williamr@2: Integer numeric value: -1 if none, -2 if a fraction. williamr@2: */ williamr@2: TInt iNumericValue; williamr@2: }; williamr@2: williamr@2: inline TChar(); williamr@2: inline TChar(TUint aChar); williamr@2: inline TChar& operator-=(TUint aChar); williamr@2: inline TChar& operator+=(TUint aChar); williamr@2: inline TChar operator-(TUint aChar); williamr@2: inline TChar operator+(TUint aChar); williamr@2: inline operator TUint() const; williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void Fold(); williamr@2: inline void LowerCase(); williamr@2: inline void UpperCase(); williamr@2: inline TBool Eos() const; williamr@2: IMPORT_C TUint GetUpperCase() const; williamr@2: IMPORT_C TUint GetLowerCase() const; williamr@2: IMPORT_C TBool IsLower() const; williamr@2: IMPORT_C TBool IsUpper() const; williamr@2: IMPORT_C TBool IsAlpha() const; williamr@2: IMPORT_C TBool IsDigit() const; williamr@2: IMPORT_C TBool IsAlphaDigit() const; williamr@2: IMPORT_C TBool IsHexDigit() const; williamr@2: IMPORT_C TBool IsSpace() const; williamr@2: IMPORT_C TBool IsPunctuation() const; williamr@2: IMPORT_C TBool IsGraph() const; williamr@2: IMPORT_C TBool IsPrint() const; williamr@2: IMPORT_C TBool IsControl() const; williamr@2: inline void Fold(TInt aFlags); williamr@2: inline void TitleCase(); williamr@2: IMPORT_C TUint GetTitleCase() const; williamr@2: IMPORT_C TBool IsTitle() const; williamr@2: IMPORT_C TBool IsAssigned() const; williamr@2: IMPORT_C void GetInfo(TCharInfo& aInfo) const; williamr@2: IMPORT_C TCategory GetCategory() const; williamr@2: IMPORT_C TBdCategory GetBdCategory() const; williamr@2: IMPORT_C TInt GetCombiningClass() const; williamr@2: IMPORT_C TBool IsMirrored() const; williamr@2: IMPORT_C TInt GetNumericValue() const; williamr@2: IMPORT_C TCjkWidth GetCjkWidth() const; williamr@2: IMPORT_C static TBool Compose(TUint& aResult,const TDesC16& aSource); williamr@2: IMPORT_C TBool Decompose(TPtrC16& aResult) const; williamr@2: williamr@2: protected: williamr@2: inline void SetChar(TUint aChar); williamr@2: #endif williamr@2: private: williamr@2: TUint iChar; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: #include williamr@2: #ifndef __KERNEL_MODE__ williamr@2: #include williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #if defined(_UNICODE) && !defined(__KERNEL_MODE__) williamr@2: #define __Size (sizeof(TUint)/sizeof(TUint16)) williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent non-modifiable descriptor. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see TDesC8 williamr@2: @see TDesC16 williamr@2: */ williamr@2: typedef TDesC16 TDesC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent non-modifiable pointer descriptor. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see TPtrC8 williamr@2: @see TPtrC16 williamr@2: */ williamr@2: typedef TPtrC16 TPtrC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent modifiable descriptor. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see TDes8 williamr@2: @see TDes16 williamr@2: */ williamr@2: typedef TDes16 TDes; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent modifiable pointer descriptor. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see TPtr8 williamr@2: @see TPtr16 williamr@2: */ williamr@2: typedef TPtr16 TPtr; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent heap descriptor. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see HBufC8 williamr@2: @see HBufC16 williamr@2: */ williamr@2: typedef HBufC16 HBufC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent descriptor overflow handler. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see TDes8Overflow williamr@2: @see TDes16Overflow williamr@2: */ williamr@2: typedef TDes16Overflow TDesOverflow; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent resizable buffer descriptor. williamr@2: williamr@2: A 16-bit build variant is generated for a Unicode, non-kernel mode build. williamr@2: williamr@2: A build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit type is required. williamr@2: williamr@2: @see RBuf8 williamr@2: @see RBuf16 williamr@2: */ williamr@2: typedef RBuf16 RBuf; williamr@2: williamr@2: #endif williamr@2: #else williamr@2: #define __Size (sizeof(TUint)/sizeof(TUint8)) williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent non-modifiable descriptor. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see TDesC8 williamr@2: @see TDesC16 williamr@2: */ williamr@2: typedef TDesC8 TDesC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent non-modifiable pointer descriptor. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see TPtrC8 williamr@2: @see TPtrC16 williamr@2: */ williamr@2: typedef TPtrC8 TPtrC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent modifiable descriptor. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see TDes8 williamr@2: @see TDes16 williamr@2: */ williamr@2: typedef TDes8 TDes; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent modifiable pointer descriptor. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see TPtr8 williamr@2: @see TPtr16 williamr@2: */ williamr@2: typedef TPtr8 TPtr; williamr@2: #ifndef __KERNEL_MODE__ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent heap descriptor. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see HBufC8 williamr@2: @see HBufC16 williamr@2: */ williamr@2: typedef HBufC8 HBufC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent descriptor overflow handler. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode, non-kernel williamr@2: mode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see TDes8Overflow williamr@2: @see TDes16Overflow williamr@2: */ williamr@2: typedef TDes8Overflow TDesOverflow; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a build-independent resizable buffer descriptor. williamr@2: williamr@2: An 8-bit build variant is generated for a non-Unicode, non-kernel mode build. williamr@2: williamr@2: This build-independent type should always be used unless an explicit 8-bit williamr@2: or 16-bit build variant is required. williamr@2: williamr@2: @see RBuf8 williamr@2: @see RBuf16 williamr@2: */ williamr@2: typedef RBuf8 RBuf; williamr@2: williamr@2: #endif williamr@2: #endif williamr@2: williamr@2: williamr@2: #if defined(_UNICODE) && !defined(__KERNEL_MODE__) williamr@2: typedef TBufCBase16 TBufCBase; williamr@2: #else williamr@2: typedef TBufCBase8 TBufCBase; williamr@2: #endif williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A build-independent non-modifiable buffer descriptor. williamr@2: williamr@2: This is a descriptor class which provides a buffer of fixed length for williamr@2: containing and accessing TUint16 or TUint8 data, depending on the build. williamr@2: williamr@2: The class intended for instantiation. The data that the descriptor represents williamr@2: is part of the descriptor object itself. williamr@2: williamr@2: The class is templated, based on an integer value which defines the size of williamr@2: the descriptor's data area. williamr@2: williamr@2: The data is intended to be accessed, but not modified; however, it can be williamr@2: completely replaced using the assignment operators of this class. The base williamr@2: class provides the functions through which the data is accessed. williamr@2: williamr@2: This class derives from TBufCBase16 for a Unicode, non-kernel build, but williamr@2: derives from TBufCBase8 for a non-Unicode build. williamr@2: williamr@2: @see TDesC williamr@2: @see TDesC8 williamr@2: @see TDesC16 williamr@2: @see TPtr williamr@2: @see TPtr8 williamr@2: @see TPtr16 williamr@2: @see TBufC8 williamr@2: @see TBufC16 williamr@2: */ williamr@2: template williamr@2: #if defined(_UNICODE) && !defined(__KERNEL_MODE__) williamr@2: class TBufC : public TBufCBase16 williamr@2: #else williamr@2: class TBufC : public TBufCBase8 williamr@2: #endif williamr@2: { williamr@2: public: williamr@2: inline TBufC(); williamr@2: inline TBufC(const TText* aString); williamr@2: inline TBufC(const TDesC& aDes); williamr@2: inline TBufC& operator=(const TText* aString); williamr@2: inline TBufC& operator=(const TDesC& aDes); williamr@2: inline TPtr Des(); williamr@2: private: williamr@2: TText iBuf[__Align(S)]; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A build-independent modifiable buffer descriptor. williamr@2: williamr@2: This is a descriptor class which provides a buffer of fixed length for williamr@2: containing, accessing and manipulating TUint16 or TUint8 data, depending williamr@2: on the build. williamr@2: williamr@2: The class is intended for instantiation. The data that the descriptor represents williamr@2: is part of the descriptor object itself. williamr@2: williamr@2: The class is templated, based on an integer value which determines the size williamr@2: of the data area created as part of the buffer descriptor object; this is williamr@2: also the maximum length of the descriptor. williamr@2: williamr@2: The data is intended to be both accessed and modified. The base classes provide williamr@2: the functions through which the data is accessed. williamr@2: williamr@2: This class derives from TBufCBase16 for a Unicode, non-kernel build, but williamr@2: derives from TBufCBase8 for a non-Unicode build. williamr@2: williamr@2: @see TDesC williamr@2: @see TDesC8 williamr@2: @see TDesC16 williamr@2: @see TDes williamr@2: @see TDes8 williamr@2: @see TDes16 williamr@2: @see TPtr williamr@2: @see TPtr8 williamr@2: @see TPtr16 williamr@2: */ williamr@2: template williamr@2: #if defined(_UNICODE) && !defined(__KERNEL_MODE__) williamr@2: class TBuf : public TBufBase16 williamr@2: #else williamr@2: class TBuf : public TBufBase8 williamr@2: #endif williamr@2: { williamr@2: public: williamr@2: inline TBuf(); williamr@2: inline explicit TBuf(TInt aLength); williamr@2: inline TBuf(const TText* aString); williamr@2: inline TBuf(const TDesC& aDes); williamr@2: inline TBuf& operator=(const TText* aString); williamr@2: inline TBuf& operator=(const TDesC& aDes); williamr@2: inline TBuf& operator=(const TBuf& aBuf); williamr@2: private: williamr@2: TText iBuf[__Align(S)]; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Value reference used in operator TLitC::__TRefDesC(). williamr@2: williamr@2: @see TRefByValue williamr@2: */ williamr@2: typedef TRefByValue __TRefDesC; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Encapsulates literal text. williamr@2: williamr@2: This is always constructed using an _LIT macro. williamr@2: williamr@2: This class is build independent; i.e. for a non-Unicode build, an 8-bit build williamr@2: variant is generated; for a Unicode build, a 16 bit build variant is generated. williamr@2: williamr@2: The class has no explicit constructors. See the _LIT macro definition. williamr@2: */ williamr@2: template williamr@2: class TLitC williamr@2: { williamr@2: public: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: enum {BufferSize=S-1}; williamr@2: inline const TDesC* operator&() const; williamr@2: inline operator const TDesC&() const; williamr@2: inline const TDesC& operator()() const; williamr@2: inline operator const __TRefDesC() const; williamr@2: public: williamr@2: #if !defined(_UNICODE) || defined(__KERNEL_MODE__) williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef TUint8 __TText; williamr@2: #elif defined(__GCC32__) williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef wchar_t __TText; williamr@2: #elif defined(__VC32__) williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef TUint16 __TText; williamr@2: williamr@2: #elif defined(__CW32__) williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef TUint16 __TText; williamr@2: #elif !defined(__TText_defined) williamr@2: #error no typedef for __TText williamr@2: #endif williamr@2: public: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: TUint iTypeLength; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: __TText iBuf[__Align(S)]; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines an empty or null literal descriptor. williamr@2: williamr@2: This is the build independent form. williamr@2: An 8 bit build variant is generated for a non-Unicode build; williamr@2: a 16 bit build variant is generated for a Unicode build. williamr@2: */ williamr@2: _LIT(KNullDesC,""); williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines an empty or null literal descriptor for use with 8-bit descriptors. williamr@2: */ williamr@2: _LIT8(KNullDesC8,""); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines an empty or null literal descriptor for use with 16-bit descriptors williamr@2: */ williamr@2: _LIT16(KNullDesC16,""); williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Packages a non-modifiable pointer descriptor which represents an object of williamr@2: specific type. williamr@2: williamr@2: The template parameter defines the type of object. williamr@2: williamr@2: The object represented by the packaged pointer descriptor is accessible through williamr@2: the package but cannot be changed. */ williamr@2: template williamr@2: class TPckgC : public TPtrC8 williamr@2: { williamr@2: public: williamr@2: inline TPckgC(const T& aRef); williamr@2: inline const T& operator()() const; williamr@2: private: williamr@2: TPckgC& operator=(const TPckgC& aRef); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Packages a modifiable pointer descriptor which represents an object of specific williamr@2: type. williamr@2: williamr@2: The template parameter defines the type of object. williamr@2: williamr@2: The object represented by the packaged pointer descriptor is accessible through williamr@2: the package. williamr@2: */ williamr@2: template williamr@2: class TPckg : public TPtr8 williamr@2: { williamr@2: public: williamr@2: inline TPckg(const T& aRef); williamr@2: inline T& operator()(); williamr@2: private: williamr@2: TPckg& operator=(const TPckg& aRef); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Packages an object into a modifiable buffer descriptor. williamr@2: williamr@2: The template parameter defines the type of object to be packaged. williamr@2: williamr@2: The package provides a type safe way of transferring an object or data structure williamr@2: which is contained within a modifiable buffer descriptor. Typically, a package williamr@2: is used for passing data via inter thread communication. williamr@2: williamr@2: The contained object is accessible through the package. williamr@2: */ williamr@2: template williamr@2: class TPckgBuf : public TAlignedBuf8 williamr@2: { williamr@2: public: williamr@2: inline TPckgBuf(); williamr@2: inline TPckgBuf(const T& aRef); williamr@2: inline TPckgBuf& operator=(const TPckgBuf& aRef); williamr@2: inline T& operator=(const T& aRef); williamr@2: inline T& operator()(); williamr@2: inline const T& operator()() const; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a modifiable buffer descriptor that can contain the name of a reference williamr@2: counting object. williamr@2: williamr@2: @see TBuf williamr@2: @see CObject williamr@2: */ williamr@2: typedef TBuf TName; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a modifiable buffer descriptor that can contain the full name of a williamr@2: reference counting object. williamr@2: williamr@2: @see TBuf williamr@2: @see CObject williamr@2: */ williamr@2: typedef TBuf TFullName; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a modifiable buffer descriptor to contain the category name identifying williamr@2: the cause of thread or process termination. The buffer takes a maximum length williamr@2: of KMaxExitCategoryName. williamr@2: williamr@2: @see RThread::ExitCategory williamr@2: @see RThread::ExitCategory williamr@2: */ williamr@2: typedef TBuf TExitCategoryName; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A buffer that can contain the name of a file. williamr@2: The name can have a maximum length of KMaxFileName williamr@2: (currently 256 but check the definition of KMaxFileName). williamr@2: williamr@2: @see KMaxFileName williamr@2: */ williamr@2: typedef TBuf TFileName; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A buffer that can contain the name of a path. williamr@2: The name can have a maximum length of KMaxPath williamr@2: (currently 256 but check the definition of KMaxPath). williamr@2: williamr@2: @see KMaxPath williamr@2: */ williamr@2: typedef TBuf TPath; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Version name type. williamr@2: williamr@2: This is a buffer descriptor with a maximum length of KMaxVersionName. williamr@2: A TVersion object returns the formatted character representation of its version williamr@2: information in a descriptor of this type. williamr@2: williamr@2: @see TVersion williamr@2: */ williamr@2: typedef TBuf TVersionName; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a modifiable buffer descriptor for the text form of the UID. williamr@2: The descriptor has a maximum length of KMaxUidName and is used to contain williamr@2: the standard text format returned by the function TUid::Name(). williamr@2: williamr@2: @see TUid::Name williamr@2: */ williamr@2: typedef TBuf TUidName; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a null UID williamr@2: */ williamr@2: #define KNullUid TUid::Null() williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A globally unique 32-bit number. williamr@2: */ williamr@2: class TUid williamr@2: { williamr@2: public: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C TBool operator==(const TUid& aUid) const; williamr@2: IMPORT_C TBool operator!=(const TUid& aUid) const; williamr@2: IMPORT_C TUidName Name() const; williamr@2: #endif williamr@2: static inline TUid Uid(TInt aUid); williamr@2: static inline TUid Null(); williamr@2: public: williamr@2: /** williamr@2: The 32-bit integer UID value. williamr@2: */ williamr@2: TInt32 iUid; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Encapsulates a set of three unique identifiers (UIDs) which, in combination, williamr@2: identify a system object such as a GUI application or a DLL. The three williamr@2: component UIDs are referred to as UID1, UID2 and UID3. williamr@2: williamr@2: An object of this type is referred to as a compound identifier or a UID type. williamr@2: */ williamr@2: class TUidType williamr@2: { williamr@2: public: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C TUidType(); williamr@2: IMPORT_C TUidType(TUid aUid1); williamr@2: IMPORT_C TUidType(TUid aUid1,TUid aUid2); williamr@2: IMPORT_C TUidType(TUid aUid1,TUid aUid2,TUid aUid3); williamr@2: IMPORT_C TBool operator==(const TUidType& aUidType) const; williamr@2: IMPORT_C TBool operator!=(const TUidType& aUidType) const; williamr@2: IMPORT_C const TUid& operator[](TInt anIndex) const; williamr@2: IMPORT_C TUid MostDerived() const; williamr@2: IMPORT_C TBool IsPresent(TUid aUid) const; williamr@2: IMPORT_C TBool IsValid() const; williamr@2: private: williamr@2: #endif williamr@2: TUid iUid[KMaxCheckedUid]; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: A class used to represent the Secure ID of a process or executable image. williamr@2: williamr@2: Constructors and conversion operators are provided to enable conversion williamr@2: of this class to and from both TUint32 and TUid objects. williamr@2: williamr@2: Because this class has non-default constructors, compilers will not initialise williamr@2: this objects at compile time, instead code will be generated to construct the object williamr@2: at run-time. This is wastefull, and Symbian OS DLLs are not permitted to have williamr@2: such uninitialised data. To overcome these problems a macro is provided to construct williamr@2: a const object which behaves like a TSecureId. This is _LIT_SECURE_ID. williamr@2: This macro should be used where it is desirable to define const TSecureId objects, williamr@2: like in header files. E.g. Instead of writing: williamr@2: @code williamr@2: const TSecureId MyId=0x1234567 williamr@2: @endcode williamr@2: use williamr@2: @code williamr@2: _LIT_SECURE_ID(MyId,0x1234567) williamr@2: @endcode williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: @see _LIT_SECURE_ID williamr@2: */ williamr@2: class TSecureId williamr@2: { williamr@2: public: williamr@2: inline TSecureId(); williamr@2: inline TSecureId(TUint32 aId); williamr@2: inline operator TUint32() const; williamr@2: inline TSecureId(TUid aId); williamr@2: inline operator TUid() const; williamr@2: public: williamr@2: TUint32 iId; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: A class used to represent the Vendor ID of a process or executable image williamr@2: williamr@2: Constructors and conversion operators are provided to enable conversion williamr@2: of this class to and from both TUint32 and TUid objects. williamr@2: williamr@2: Because this class has non-default constructors, compilers will not initialise williamr@2: this objects at compile time, instead code will be generated to construct the object williamr@2: at run-time. This is wastefull, and Symbian OS DLLs are not permitted to have williamr@2: such uninitialised data. To overcome these problems a macro is provided to construct williamr@2: a const object which behaves like a TSecureId. This is _LIT_VENDOR_ID. williamr@2: This macro should be used where it is desirable to define const TSecureId objects, williamr@2: like in header files. E.g. Instead of writing: williamr@2: @code williamr@2: const TVendorId MyId=0x1234567 williamr@2: @endcode williamr@2: use williamr@2: @code williamr@2: _LIT_VENDOR_ID(MyId,0x1234567) williamr@2: @endcode williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: @see _LIT_VENDOR_ID williamr@2: */ williamr@2: class TVendorId williamr@2: { williamr@2: public: williamr@2: inline TVendorId(); williamr@2: inline TVendorId(TUint32 aId); williamr@2: inline operator TUint32() const; williamr@2: inline TVendorId(TUid aId); williamr@2: inline operator TUid() const; williamr@2: public: williamr@2: TUint32 iId; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Structure for compile-time definition of a secure ID williamr@2: @internalComponent williamr@2: */ williamr@2: class SSecureId williamr@2: { williamr@2: public: williamr@2: inline const TSecureId* operator&() const; williamr@2: inline operator const TSecureId&() const; williamr@2: inline operator TUint32() const; williamr@2: inline operator TUid() const; williamr@2: public: williamr@2: TUint32 iId; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Structure for compile-time definition of a vendor ID williamr@2: @internalComponent williamr@2: */ williamr@2: class SVendorId williamr@2: { williamr@2: public: williamr@2: inline const TVendorId* operator&() const; williamr@2: inline operator const TVendorId&() const; williamr@2: inline operator TUint32() const; williamr@2: inline operator TUid() const; williamr@2: public: williamr@2: TUint32 iId; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Macro for compile-time definition of a secure ID williamr@2: @param name Name to use for secure ID williamr@2: @param value Value of secure ID williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURE_ID(name,value) const SSecureId name={value} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Macro for compile-time definition of a vendor ID williamr@2: @param name Name to use for vendor ID williamr@2: @param value Value of vendor ID williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_VENDOR_ID(name,value) const SVendorId name={value} williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains version information. williamr@2: williamr@2: A version is defined by a set of three numbers: williamr@2: williamr@2: 1. the major version number, ranging from 0 to 127, inclusive williamr@2: williamr@2: 2. the minor version number, ranging from 0 to 99 inclusive williamr@2: williamr@2: 3. the build number, ranging from 0 to 32767 inclusive. williamr@2: williamr@2: The class provides a constructor for setting all three numbers. williamr@2: It also provides a member function to build a character representation of williamr@2: this information in a TVersionName descriptor. williamr@2: williamr@2: @see TVersionName williamr@2: */ williamr@2: class TVersion williamr@2: { williamr@2: public: williamr@2: IMPORT_C TVersion(); williamr@2: IMPORT_C TVersion(TInt aMajor,TInt aMinor,TInt aBuild); williamr@2: IMPORT_C TVersionName Name() const; williamr@2: public: williamr@2: /** williamr@2: The major version number. williamr@2: */ williamr@2: TInt8 iMajor; williamr@2: williamr@2: williamr@2: /** williamr@2: The minor version number. williamr@2: */ williamr@2: TInt8 iMinor; williamr@2: williamr@2: williamr@2: /** williamr@2: The build number. williamr@2: */ williamr@2: TInt16 iBuild; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Indicates the completion status of a request made to a service provider. williamr@2: williamr@2: When a thread makes a request, it passes a request status as a parameter. williamr@2: On completion, the provider signals the requesting thread's request semaphore williamr@2: and stores a completion code in the request status. Typically, this is KErrNone williamr@2: or one of the other system-wide error codes. williamr@2: williamr@2: This class is not intended for user derivation. williamr@2: */ williamr@2: class TRequestStatus williamr@2: { williamr@2: public: williamr@2: inline TRequestStatus(); williamr@2: inline TRequestStatus(TInt aVal); williamr@2: inline TInt operator=(TInt aVal); williamr@2: inline TBool operator==(TInt aVal) const; williamr@2: inline TBool operator!=(TInt aVal) const; williamr@2: inline TBool operator>=(TInt aVal) const; williamr@2: inline TBool operator<=(TInt aVal) const; williamr@2: inline TBool operator>(TInt aVal) const; williamr@2: inline TBool operator<(TInt aVal) const; williamr@2: inline TInt Int() const; williamr@2: private: williamr@2: enum williamr@2: { williamr@2: EActive = 1, //bit0 williamr@2: ERequestPending = 2, //bit1 williamr@2: }; williamr@2: TInt iStatus; williamr@2: TUint iFlags; williamr@2: friend class CActive; williamr@2: friend class CActiveScheduler; williamr@2: friend class CServer2; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class TSize; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Stores a two-dimensional point in Cartesian co-ordinates. williamr@2: williamr@2: Its data members (iX and iY) are public and can be manipulated directly, or williamr@2: by means of the functions provided. Functions are provided to set and manipulate williamr@2: the point, and to compare points for equality. williamr@2: */ williamr@2: class TPoint williamr@2: { williamr@2: public: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: enum TUninitialized { EUninitialized }; williamr@2: /** williamr@2: Constructs default point, initialising its iX and iY members to zero. williamr@2: */ williamr@2: TPoint(TUninitialized) {} williamr@2: inline TPoint(); williamr@2: inline TPoint(TInt aX,TInt aY); williamr@2: IMPORT_C TBool operator==(const TPoint& aPoint) const; williamr@2: IMPORT_C TBool operator!=(const TPoint& aPoint) const; williamr@2: IMPORT_C TPoint& operator-=(const TPoint& aPoint); williamr@2: IMPORT_C TPoint& operator+=(const TPoint& aPoint); williamr@2: IMPORT_C TPoint& operator-=(const TSize& aSize); williamr@2: IMPORT_C TPoint& operator+=(const TSize& aSize); williamr@2: IMPORT_C TPoint operator-(const TPoint& aPoint) const; williamr@2: IMPORT_C TPoint operator+(const TPoint& aPoint) const; williamr@2: IMPORT_C TPoint operator-(const TSize& aSize) const; williamr@2: IMPORT_C TPoint operator+(const TSize& aSize) const; williamr@2: IMPORT_C TPoint operator-() const; williamr@2: IMPORT_C void SetXY(TInt aX,TInt aY); williamr@2: IMPORT_C TSize AsSize() const; williamr@2: #endif williamr@2: public: williamr@2: /** williamr@2: The x co-ordinate. williamr@2: */ williamr@2: TInt iX; williamr@2: /** williamr@2: The y co-ordinate. williamr@2: */ williamr@2: TInt iY; williamr@2: }; williamr@2: williamr@4: williamr@4: williamr@4: williamr@2: /** williamr@4: @publishedAll williamr@4: @prototype williamr@2: williamr@2: Stores a three-dimensional point in Cartesian or polar co-ordinates. williamr@2: Its data members (iX, iY and iZ) are public and can be manipulated directly. williamr@4: williamr@2: */ williamr@2: class TPoint3D williamr@2: { williamr@2: public: williamr@4: #ifndef __KERNEL_MODE__ williamr@4: enum TUninitialized { EUninitialized }; williamr@4: williamr@4: /** williamr@4: TUninitialized Constructor williamr@4: */ williamr@4: TPoint3D(TUninitialized) {} williamr@4: /** williamr@4: Constructs default TPoint3D, initialising its iX , iY and iZ members to zero. williamr@4: */ williamr@4: inline TPoint3D(); williamr@4: /** williamr@4: Constructs TPoint3D with the specified x,y and z co-ordinates. williamr@4: */ williamr@4: inline TPoint3D(TInt aX,TInt aY,TInt aZ); williamr@4: /** williamr@4: Copy Construct from TPoint , initialises Z co-ordinate to Zero williamr@4: */ williamr@4: inline TPoint3D(const TPoint& aPoint); williamr@4: williamr@4: IMPORT_C TBool operator==(const TPoint3D& aPoint3D) const; williamr@4: IMPORT_C TBool operator!=(const TPoint3D& aPoint3D) const; williamr@4: williamr@4: IMPORT_C TPoint3D& operator-=(const TPoint3D& aPoint3D); williamr@4: IMPORT_C TPoint3D& operator-=(const TPoint& aPoint); williamr@4: williamr@4: IMPORT_C TPoint3D& operator+=(const TPoint3D& aPoint3D); williamr@4: IMPORT_C TPoint3D& operator+=(const TPoint& aPoint); williamr@4: williamr@4: IMPORT_C TPoint3D operator-(const TPoint3D& aPoint3D) const; williamr@4: IMPORT_C TPoint3D operator-(const TPoint& aPoint) const; williamr@4: williamr@4: IMPORT_C TPoint3D operator+(const TPoint3D& aPoint3D) const; williamr@4: IMPORT_C TPoint3D operator+(const TPoint& aPoint) const; williamr@4: /** williamr@4: Unary minus operator. The operator returns the negation of this Point3D williamr@4: */ williamr@4: IMPORT_C TPoint3D operator-() const; williamr@4: williamr@4: /** williamr@4: Set Method to set the xyz co-ordinates of TPoint3D williamr@4: */ williamr@4: IMPORT_C void SetXYZ(TInt aX,TInt aY,TInt aZ); williamr@4: williamr@4: /** williamr@4: TPoint3D from TPoint, sets the Z co-ordinate to Zero williamr@4: */ williamr@4: IMPORT_C void SetPoint(const TPoint& aPoint); williamr@4: williamr@4: /** williamr@4: Returns TPoint from TPoint3D williamr@4: */ williamr@4: IMPORT_C TPoint AsPoint() const; williamr@4: #endif williamr@4: public: williamr@2: /** williamr@2: The x co-ordinate. williamr@2: */ williamr@2: TInt iX; williamr@2: /** williamr@2: The y co-ordinate. williamr@2: */ williamr@2: TInt iY; williamr@2: /** williamr@2: The z co-ordinate. williamr@2: */ williamr@2: TInt iZ; williamr@2: }; williamr@2: williamr@4: williamr@4: williamr@2: /** williamr@2: @internalTechnology williamr@2: @prototype For now, only intended to be used by TRwEvent and the Windows Server williamr@2: williamr@2: Stores the angular spherical coordinates (Phi,Theta) of a three-dimensional point. williamr@2: williamr@2: Its data members (iPhi, iTheta) are public and can be manipulated directly. williamr@2: */ williamr@2: class TAngle3D williamr@2: { williamr@2: public: williamr@2: /** williamr@2: 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). williamr@2: */ williamr@2: TInt iPhi; williamr@2: /** williamr@2: The Theta co-ordinate (angle between the Z-axis and the line that links the point and the origin). williamr@2: */ williamr@2: TInt iTheta; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Stores a two-dimensional size as a width and a height value. williamr@2: williamr@2: Its data members are public and can be manipulated directly, or by means of williamr@2: the functions provided. williamr@2: */ williamr@2: class TSize williamr@2: { williamr@2: public: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: enum TUninitialized { EUninitialized }; williamr@2: /** williamr@2: Constructs the size object with its iWidth and iHeight members set to zero. williamr@2: */ williamr@2: TSize(TUninitialized) {} williamr@2: inline TSize(); williamr@2: inline TSize(TInt aWidth,TInt aHeight); williamr@2: IMPORT_C TBool operator==(const TSize& aSize) const; williamr@2: IMPORT_C TBool operator!=(const TSize& aSize) const; williamr@2: IMPORT_C TSize& operator-=(const TSize& aSize); williamr@2: IMPORT_C TSize& operator-=(const TPoint& aPoint); williamr@2: IMPORT_C TSize& operator+=(const TSize& aSize); williamr@2: IMPORT_C TSize& operator+=(const TPoint& aPoint); williamr@2: IMPORT_C TSize operator-(const TSize& aSize) const; williamr@2: IMPORT_C TSize operator-(const TPoint& aPoint) const; williamr@2: IMPORT_C TSize operator+(const TSize& aSize) const; williamr@2: IMPORT_C TSize operator+(const TPoint& aPoint) const; williamr@2: IMPORT_C TSize operator-() const; williamr@2: IMPORT_C void SetSize(TInt aWidth,TInt aHeight); williamr@2: IMPORT_C TPoint AsPoint() const; williamr@2: #endif williamr@2: public: williamr@2: /** williamr@2: The width of this TSize object. williamr@2: */ williamr@2: TInt iWidth; williamr@2: /** williamr@2: The height of this TSize object. williamr@2: */ williamr@2: TInt iHeight; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Information about a kernel object. williamr@2: williamr@2: This type of object is passed to RHandleBase::HandleInfo(). The function williamr@2: fetches information on the usage of the kernel object associated with that williamr@2: handle and stores the information in the THandleInfo object. williamr@2: williamr@2: The class contains four data members and no explicitly defined function williamr@2: members. williamr@2: */ williamr@2: class THandleInfo williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The number of times that the kernel object is open in the current process. williamr@2: */ williamr@2: TInt iNumOpenInProcess; williamr@2: williamr@2: /** williamr@2: The number of times that the kernel object is open in the current thread. williamr@2: */ williamr@2: TInt iNumOpenInThread; williamr@2: williamr@2: /** williamr@2: The number of processes which have a handle on the kernel object. williamr@2: */ williamr@2: TInt iNumProcesses; williamr@2: williamr@2: /** williamr@2: The number of threads which have a handle on the kernel object. williamr@2: */ williamr@2: TInt iNumThreads; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: class TFindHandle williamr@2: { williamr@2: public: williamr@2: inline TFindHandle(); williamr@2: inline TInt Handle() const; williamr@2: #ifdef __KERNEL_MODE__ williamr@2: inline TInt Index() const; williamr@2: inline TInt UniqueID() const; williamr@2: inline TUint64 ObjectID() const; williamr@2: inline void Set(TInt aIndex, TInt aUniqueId, TUint64 aObjectId); williamr@2: #else williamr@2: protected: williamr@2: inline void Reset(); williamr@2: #endif williamr@2: private: williamr@2: TInt iHandle; williamr@2: TInt iSpare1; williamr@2: TInt iObjectIdLow; williamr@2: TInt iObjectIdHigh; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: class RThread; williamr@2: class TFindHandleBase; williamr@2: class TFindSemaphore; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to an object. williamr@2: williamr@2: The class encapsulates the basic behaviour of a handle, hiding the williamr@2: handle-number which identifies the object which the handle represents. williamr@2: williamr@2: The class is abstract in the sense that a RHandleBase object is never williamr@2: explicitly instantiated. It is always a base class to a concrete handle class; williamr@2: for example, RSemaphore, RThread, RProcess, RCriticalSection etc. williamr@2: */ williamr@2: class RHandleBase williamr@2: { williamr@2: public: williamr@2: /** williamr@4: @publishedAll williamr@4: @released williamr@4: williamr@4: Read/Write attributes for the handle. williamr@2: */ williamr@4: enum TAttributes williamr@2: { williamr@2: EReadAccess=0x1, williamr@2: EWriteAccess=0x2, williamr@2: EDirectReadAccess=0x4, williamr@2: EDirectWriteAccess=0x8, williamr@2: }; williamr@2: public: williamr@2: inline RHandleBase(); williamr@2: inline TInt Handle() const; williamr@2: inline void SetHandle(TInt aHandle); williamr@2: inline TInt SetReturnedHandle(TInt aHandleOrError); williamr@2: static void DoExtendedClose(); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TName Name() const; williamr@2: IMPORT_C TFullName FullName() const; williamr@2: IMPORT_C void FullName(TDes& aName) const; williamr@2: IMPORT_C void SetHandleNC(TInt aHandle); williamr@2: IMPORT_C TInt Duplicate(const RThread& aSrc,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void HandleInfo(THandleInfo* anInfo); williamr@2: IMPORT_C TUint Attributes() const; williamr@2: IMPORT_C TInt BTraceId() const; williamr@2: IMPORT_C void NotifyDestruction(TRequestStatus& aStatus); /**< @internalTechnology */ williamr@2: protected: williamr@2: inline RHandleBase(TInt aHandle); williamr@2: IMPORT_C TInt Open(const TFindHandleBase& aHandle,TOwnerType aType); williamr@2: static TInt SetReturnedHandle(TInt aHandleOrError,RHandleBase& aHandle); williamr@2: TInt OpenByName(const TDesC &aName,TOwnerType aOwnerType,TInt aObjectType); williamr@2: #endif williamr@2: private: williamr@2: static void DoExtendedCloseL(); williamr@2: protected: williamr@2: TInt iHandle; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class RMessagePtr2; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a semaphore. williamr@2: williamr@2: The semaphore itself is a Kernel side object. williamr@2: williamr@2: As with all handles, they should be closed after use. RHandleBase provides williamr@2: the necessary Close() function, which should be called when the handle is williamr@2: no longer required. williamr@2: williamr@2: @see RHandleBase::Close williamr@2: */ williamr@2: class RSemaphore : public RHandleBase williamr@2: { williamr@2: public: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline TInt Open(const TFindSemaphore& aFind,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateLocal(TInt aCount,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateGlobal(const TDesC& aName,TInt aCount,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt OpenGlobal(const TDesC& aName,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void Wait(); williamr@2: IMPORT_C TInt Wait(TInt aTimeout); // timeout in microseconds williamr@2: IMPORT_C void Signal(); williamr@2: IMPORT_C void Signal(TInt aCount); williamr@2: #endif williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A fast semaphore. williamr@2: williamr@2: This is a layer over a standard semaphore, and only calls into the kernel side williamr@2: if there is contention. williamr@2: */ williamr@2: class RFastLock : public RSemaphore williamr@2: { williamr@2: public: williamr@2: inline RFastLock(); williamr@2: IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void Wait(); williamr@2: IMPORT_C void Signal(); williamr@2: private: williamr@2: TInt iCount; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@4: A read-write lock. williamr@4: williamr@4: This is a lock for co-ordinating readers and writers to shared resources. williamr@4: It is designed to allow multiple concurrent readers. williamr@4: It is not a kernel side object and so does not inherit from RHandleBase. williamr@4: */ williamr@4: class RReadWriteLock williamr@4: { williamr@4: public: williamr@4: enum TReadWriteLockPriority williamr@4: { williamr@4: /** Pending writers always get the lock before pending readers */ williamr@4: EWriterPriority, williamr@4: /** Lock is given alternately to pending readers and writers */ williamr@4: EAlternatePriority, williamr@4: /** Pending readers always get the lock before pending writers - beware writer starvation! */ williamr@4: EReaderPriority, williamr@4: }; williamr@4: enum TReadWriteLockClientCategoryLimit williamr@4: { williamr@4: /** Maximum number of clients in each category: read locked, read lock pending, write lock pending */ williamr@4: EReadWriteLockClientCategoryLimit = KMaxTUint16 williamr@4: }; williamr@4: williamr@4: public: williamr@4: inline RReadWriteLock(); williamr@4: IMPORT_C TInt CreateLocal(TReadWriteLockPriority aPriority = EWriterPriority); williamr@4: IMPORT_C void Close(); williamr@4: williamr@4: IMPORT_C void ReadLock(); williamr@4: IMPORT_C void WriteLock(); williamr@4: IMPORT_C TBool TryReadLock(); williamr@4: IMPORT_C TBool TryWriteLock(); williamr@4: IMPORT_C TBool TryUpgradeReadLock(); williamr@4: IMPORT_C void DowngradeWriteLock(); williamr@4: IMPORT_C void Unlock(); williamr@4: williamr@4: private: williamr@4: RReadWriteLock(const RReadWriteLock& aLock); williamr@4: RReadWriteLock& operator=(const RReadWriteLock& aLock); williamr@4: williamr@4: TInt UnlockWriter(); williamr@4: TInt UnlockAlternate(); williamr@4: TInt UnlockReader(); williamr@4: williamr@4: private: williamr@4: volatile TUint64 iValues; // Bits 0-15: readers; bit 16: writer; bits 32-47: readersPending; bits 48-63: writersPending williamr@4: TReadWriteLockPriority iPriority; williamr@4: RSemaphore iReaderSem; williamr@4: RSemaphore iWriterSem; williamr@4: TUint32 iSpare[4]; // Reserved for future development williamr@4: }; williamr@4: williamr@4: williamr@4: williamr@4: williamr@4: /** williamr@4: @publishedAll williamr@4: @released williamr@4: williamr@2: The user-side handle to a logical channel. williamr@2: williamr@2: The class provides functions that are used to open a channel williamr@2: to a device driver, and to make requests. A device driver provides williamr@2: a derived class to give the user-side a tailored interface to the driver. williamr@2: */ williamr@2: class RBusLogicalChannel : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess); williamr@2: protected: williamr@2: inline TInt DoCreate(const TDesC& aDevice, const TVersion& aVer, TInt aUnit, const TDesC* aDriver, const TDesC8* anInfo, TOwnerType aType=EOwnerProcess, TBool aProtected=EFalse); williamr@2: IMPORT_C void DoCancel(TUint aReqMask); williamr@2: IMPORT_C void DoRequest(TInt aReqNo,TRequestStatus& aStatus); williamr@2: IMPORT_C void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TAny* a1); williamr@2: IMPORT_C void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TAny* a1,TAny* a2); williamr@2: IMPORT_C TInt DoControl(TInt aFunction); williamr@2: IMPORT_C TInt DoControl(TInt aFunction,TAny* a1); williamr@2: IMPORT_C TInt DoControl(TInt aFunction,TAny* a1,TAny* a2); williamr@2: inline TInt DoSvControl(TInt aFunction) { return DoControl(aFunction); } williamr@2: inline TInt DoSvControl(TInt aFunction,TAny* a1) { return DoControl(aFunction, a1); } williamr@2: inline TInt DoSvControl(TInt aFunction,TAny* a1,TAny* a2) { return DoControl(aFunction, a1, a2); } williamr@2: private: williamr@2: IMPORT_C TInt DoCreate(const TDesC& aDevice, const TVersion& aVer, TInt aUnit, const TDesC* aDriver, const TDesC8* aInfo, TInt aType); williamr@2: private: williamr@2: // Padding for Binary Compatibility purposes williamr@2: TInt iPadding1; williamr@2: TInt iPadding2; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: williamr@2: Base class for memory allocators. williamr@2: */ williamr@2: // Put pure virtual functions into a separate base class so that vptr is at same williamr@2: // place in both GCC98r2 and EABI builds. williamr@2: class MAllocator williamr@2: { williamr@2: public: williamr@2: virtual TAny* Alloc(TInt aSize)=0; williamr@2: virtual void Free(TAny* aPtr)=0; williamr@2: virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0)=0; williamr@2: virtual TInt AllocLen(const TAny* aCell) const =0; williamr@2: virtual TInt Compress()=0; williamr@2: virtual void Reset()=0; williamr@2: virtual TInt AllocSize(TInt& aTotalAllocSize) const =0; williamr@2: virtual TInt Available(TInt& aBiggestBlock) const =0; williamr@2: virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL)=0; williamr@2: virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)=0; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Base class for heaps. williamr@2: */ williamr@2: class RAllocator : public MAllocator williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: /** williamr@2: A set of heap allocation failure flags. williamr@2: williamr@2: This enumeration indicates how to simulate heap allocation failure. williamr@2: williamr@2: @see RAllocator::__DbgSetAllocFail() williamr@2: */ williamr@2: enum TAllocFail { williamr@2: /** williamr@2: Attempts to allocate from this heap fail at a random rate; williamr@2: however, the interval pattern between failures is the same williamr@2: every time simulation is started. williamr@2: */ williamr@2: ERandom, williamr@2: williamr@2: williamr@2: /** williamr@2: Attempts to allocate from this heap fail at a random rate. williamr@2: The interval pattern between failures may be different every williamr@2: time the simulation is started. williamr@2: */ williamr@2: ETrueRandom, williamr@2: williamr@2: williamr@2: /** williamr@2: Attempts to allocate from this heap fail at a rate aRate; williamr@2: for example, if aRate is 3, allocation fails at every williamr@2: third attempt. williamr@2: */ williamr@2: EDeterministic, williamr@2: williamr@2: williamr@2: /** williamr@2: Cancels simulated heap allocation failure. williamr@2: */ williamr@2: ENone, williamr@2: williamr@2: williamr@2: /** williamr@2: An allocation from this heap will fail after the next aRate - 1 williamr@2: allocation attempts. For example, if aRate = 1 then the next williamr@2: attempt to allocate from this heap will fail. williamr@2: */ williamr@2: EFailNext, williamr@2: williamr@2: /** williamr@2: Cancels simulated heap allocation failure, and sets williamr@2: the nesting level for all allocated cells to zero. williamr@2: */ williamr@2: EReset, williamr@2: williamr@2: /** williamr@2: aBurst allocations from this heap fail at a random rate; williamr@2: however, the interval pattern between failures is the same williamr@2: every time the simulation is started. williamr@2: */ williamr@2: EBurstRandom, williamr@2: williamr@2: williamr@2: /** williamr@2: aBurst allocations from this heap fail at a random rate. williamr@2: The interval pattern between failures may be different every williamr@2: time the simulation is started. williamr@2: */ williamr@2: EBurstTrueRandom, williamr@2: williamr@2: williamr@2: /** williamr@2: aBurst allocations from this heap fail at a rate aRate. williamr@2: For example, if aRate is 10 and aBurst is 2, then 2 allocations williamr@2: will fail at every tenth attempt. williamr@2: */ williamr@2: EBurstDeterministic, williamr@2: williamr@2: /** williamr@2: aBurst allocations from this heap will fail after the next aRate - 1 williamr@2: allocation attempts have occurred. For example, if aRate = 1 and williamr@2: aBurst = 3 then the next 3 attempts to allocate from this heap will fail. williamr@2: */ williamr@2: EBurstFailNext, williamr@2: williamr@2: /** williamr@2: Use this to determine how many times the current debug williamr@2: failure mode has failed so far. williamr@2: @see RAllocator::__DbgCheckFailure() williamr@2: */ williamr@2: ECheckFailure, williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Heap debug checking type flag. williamr@2: */ williamr@2: enum TDbgHeapType { williamr@2: /** williamr@2: The heap is a user heap. williamr@2: */ williamr@2: EUser, williamr@2: williamr@2: /** williamr@2: The heap is the Kernel heap. williamr@2: */ williamr@2: EKernel williamr@2: }; williamr@2: williamr@2: williamr@2: enum TAllocDebugOp {ECount, EMarkStart, EMarkEnd, ECheck, ESetFail, ECopyDebugInfo, ESetBurstFail}; williamr@2: williamr@2: williamr@2: /** williamr@2: Flags controlling reallocation. williamr@2: */ williamr@2: enum TReAllocMode { williamr@2: /** williamr@2: A reallocation of a cell must not change williamr@2: the start address of the cell. williamr@2: */ williamr@2: ENeverMove=1, williamr@2: williamr@2: /** williamr@2: Allows the start address of the cell to change williamr@2: if the cell shrinks in size. williamr@2: */ williamr@2: EAllowMoveOnShrink=2 williamr@2: }; williamr@2: williamr@2: williamr@4: enum TFlags {ESingleThreaded=1, EFixedSize=2, ETraceAllocs=4, EMonitorMemory=8,}; williamr@2: struct SCheckInfo {TBool iAll; TInt iCount; const TDesC8* iFileName; TInt iLineNum;}; williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: struct SRAllocatorBurstFail {TInt iBurst; TInt iRate; TInt iUnused[2];}; williamr@4: #endif williamr@2: enum {EMaxHandles=32}; williamr@4: williamr@2: public: williamr@2: inline RAllocator(); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C TInt Open(); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TAny* AllocZ(TInt aSize); williamr@2: IMPORT_C TAny* AllocZL(TInt aSize); williamr@2: IMPORT_C TAny* AllocL(TInt aSize); williamr@2: IMPORT_C TAny* AllocLC(TInt aSize); williamr@2: IMPORT_C void FreeZ(TAny*& aCell); williamr@2: IMPORT_C TAny* ReAllocL(TAny* aCell, TInt aSize, TInt aMode=0); williamr@2: IMPORT_C TInt Count() const; williamr@2: IMPORT_C TInt Count(TInt& aFreeCount) const; williamr@2: #endif williamr@2: UIMPORT_C void Check() const; williamr@2: UIMPORT_C void __DbgMarkStart(); williamr@2: UIMPORT_C TUint32 __DbgMarkEnd(TInt aCount); williamr@2: UIMPORT_C TInt __DbgMarkCheck(TBool aCountAll, TInt aCount, const TDesC8& aFileName, TInt aLineNum); williamr@2: inline void __DbgMarkCheck(TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum); williamr@2: UIMPORT_C void __DbgSetAllocFail(TAllocFail aType, TInt aRate); williamr@2: UIMPORT_C void __DbgSetBurstAllocFail(TAllocFail aType, TUint aRate, TUint aBurst); williamr@2: UIMPORT_C TUint __DbgCheckFailure(); williamr@2: protected: williamr@2: UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C virtual void DoClose(); williamr@2: #endif williamr@2: protected: williamr@2: TInt iAccessCount; williamr@2: TInt iHandleCount; williamr@2: TInt* iHandles; williamr@2: TUint32 iFlags; williamr@2: TInt iCellCount; williamr@2: TInt iTotalAllocSize; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class UserHeap; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents the default implementation for a heap. williamr@2: williamr@2: The default implementation uses an address-ordered first fit type algorithm. williamr@2: williamr@2: The heap itself is contained in a chunk and may be the only occupant of the williamr@2: chunk or may share the chunk with the program stack. williamr@2: williamr@2: The class contains member functions for allocating, adjusting, freeing individual williamr@2: cells and generally managing the heap. williamr@2: williamr@2: The class is not a handle in the same sense that RChunk is a handle; i.e. williamr@2: there is no Kernel object which corresponds to the heap. williamr@2: */ williamr@2: class RHeap : public RAllocator williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The structure of a heap cell header for a heap cell on the free list. williamr@2: */ williamr@2: struct SCell { williamr@2: /** williamr@2: The length of the cell, which includes the length of williamr@2: this header. williamr@2: */ williamr@2: TInt len; williamr@2: williamr@2: williamr@2: /** williamr@2: A pointer to the next cell in the free list. williamr@2: */ williamr@2: SCell* next; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: The structure of a heap cell header for an allocated heap cell in a debug build. williamr@2: */ williamr@2: struct SDebugCell { williamr@2: /** williamr@2: The length of the cell, which includes the length of williamr@2: this header. williamr@2: */ williamr@2: TInt len; williamr@2: williamr@2: williamr@2: /** williamr@2: The nested level. williamr@2: */ williamr@2: TInt nestingLevel; williamr@2: williamr@2: williamr@2: /** williamr@2: The cumulative number of allocated cells williamr@2: */ williamr@2: TInt allocCount; williamr@2: }; williamr@4: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SHeapCellInfo { RHeap* iHeap; TInt iTotalAlloc; TInt iTotalAllocSize; TInt iTotalFree; TInt iLevelAlloc; SDebugCell* iStranded; }; williamr@2: williamr@4: /** williamr@4: @internalComponent williamr@4: */ williamr@4: struct _s_align {char c; double d;}; williamr@4: williamr@4: /** williamr@4: The default cell alignment. williamr@4: */ williamr@2: enum {ECellAlignment = sizeof(_s_align)-sizeof(double)}; williamr@2: williamr@2: /** williamr@2: Size of a free cell header. williamr@2: */ williamr@2: enum {EFreeCellSize = sizeof(SCell)}; williamr@2: williamr@2: williamr@2: #ifdef _DEBUG williamr@2: /** williamr@2: Size of an allocated cell header in a debug build. williamr@2: */ williamr@2: enum {EAllocCellSize = sizeof(SDebugCell)}; williamr@2: #else williamr@2: /** williamr@2: Size of an allocated cell header in a release build. williamr@2: */ williamr@2: enum {EAllocCellSize = sizeof(SCell*)}; williamr@2: #endif williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: enum TDebugOp {EWalk=128}; williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: enum TCellType williamr@2: {EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress, williamr@2: EBadFreeCellAddress, EBadFreeCellSize}; williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: enum TDebugHeapId {EUser=0, EKernel=1}; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: enum TDefaultShrinkRatios {EShrinkRatio1=256, EShrinkRatioDflt=512}; williamr@4: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: /** williamr@2: @internalComponent williamr@2: */ williamr@4: #else williamr@4: private: williamr@4: #endif williamr@2: typedef void (*TWalkFunc)(TAny*, TCellType, TAny*, TInt); williamr@4: williamr@2: public: williamr@2: UIMPORT_C virtual TAny* Alloc(TInt aSize); williamr@2: UIMPORT_C virtual void Free(TAny* aPtr); williamr@2: UIMPORT_C virtual TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode=0); williamr@2: UIMPORT_C virtual TInt AllocLen(const TAny* aCell) const; williamr@2: #ifndef __KERNEL_MODE__ williamr@2: UIMPORT_C virtual TInt Compress(); williamr@2: UIMPORT_C virtual void Reset(); williamr@2: UIMPORT_C virtual TInt AllocSize(TInt& aTotalAllocSize) const; williamr@2: UIMPORT_C virtual TInt Available(TInt& aBiggestBlock) const; williamr@2: #endif williamr@2: UIMPORT_C virtual TInt DebugFunction(TInt aFunc, TAny* a1=NULL, TAny* a2=NULL); williamr@2: protected: williamr@2: UIMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); williamr@2: public: williamr@2: UIMPORT_C RHeap(TInt aMaxLength, TInt aAlign=0, TBool aSingleThread=ETrue); williamr@2: UIMPORT_C RHeap(TInt aChunkHandle, TInt aOffset, TInt aMinLength, TInt aMaxLength, TInt aGrowBy, TInt aAlign=0, TBool aSingleThread=EFalse); williamr@2: UIMPORT_C TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW; williamr@2: inline void operator delete(TAny* aPtr, TAny* aBase); williamr@2: inline TUint8* Base() const; williamr@2: inline TInt Size() const; williamr@2: inline TInt MaxLength() const; williamr@2: inline TInt Align(TInt a) const; williamr@2: inline const TAny* Align(const TAny* a) const; williamr@2: inline TBool IsLastCell(const SCell* aCell) const; williamr@2: inline void Lock() const; williamr@2: inline void Unlock() const; williamr@2: inline TInt ChunkHandle() const; williamr@2: protected: williamr@2: inline RHeap(); williamr@2: void Initialise(); williamr@2: SCell* DoAlloc(TInt aSize, SCell*& aLastFree); williamr@2: void DoFree(SCell* pC); williamr@2: TInt TryToGrowHeap(TInt aSize, SCell* aLastFree); williamr@2: inline void FindFollowingFreeCell(SCell* aCell, SCell*& pPrev, SCell*& aNext); williamr@2: TInt TryToGrowCell(SCell* pC, SCell* pP, SCell* pE, TInt aSize); williamr@2: TInt Reduce(SCell* aCell); williamr@2: UIMPORT_C SCell* GetAddress(const TAny* aCell) const; williamr@2: void CheckCell(const SCell* aCell) const; williamr@2: void Walk(TWalkFunc aFunc, TAny* aPtr); williamr@2: static void WalkCheckCell(TAny* aPtr, TCellType aType, TAny* aCell, TInt aLen); williamr@2: TInt DoCountAllocFree(TInt& aFree); williamr@2: TInt DoCheckHeap(SCheckInfo* aInfo); williamr@2: void DoMarkStart(); williamr@2: TUint32 DoMarkEnd(TInt aExpected); williamr@2: void DoSetAllocFail(TAllocFail aType, TInt aRate); williamr@2: TBool CheckForSimulatedAllocFail(); williamr@2: inline TInt SetBrk(TInt aBrk); williamr@2: inline TAny* ReAllocImpl(TAny* aPtr, TInt aSize, TInt aMode); williamr@2: void DoSetAllocFail(TAllocFail aType, TInt aRate, TUint aBurst); williamr@2: protected: williamr@2: TInt iMinLength; williamr@2: TInt iMaxLength; williamr@2: TInt iOffset; williamr@2: TInt iGrowBy; williamr@2: TInt iChunkHandle; williamr@2: RFastLock iLock; williamr@2: TUint8* iBase; williamr@2: TUint8* iTop; williamr@2: TInt iAlign; williamr@2: TInt iMinCell; williamr@2: TInt iPageSize; williamr@2: SCell iFree; williamr@2: protected: williamr@2: TInt iNestingLevel; williamr@2: TInt iAllocCount; williamr@2: TAllocFail iFailType; williamr@2: TInt iFailRate; williamr@2: TBool iFailed; williamr@2: TInt iFailAllocCount; williamr@2: TInt iRand; williamr@2: TAny* iTestData; williamr@2: williamr@2: friend class UserHeap; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class OnlyCreateWithNull; williamr@2: williamr@2: /** @internalTechnology */ williamr@2: typedef void (OnlyCreateWithNull::* __NullPMF)(); williamr@2: williamr@2: /** @internalTechnology */ williamr@2: class OnlyCreateWithNull williamr@2: { williamr@2: public: williamr@2: inline OnlyCreateWithNull(__NullPMF /*aPointerToNull*/) {} williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a message sent by the client to the server. williamr@2: williamr@2: A server's interaction with its clients is channelled through an RMessagePtr2 williamr@2: object, which acts as a handle to a message sent by the client. williamr@2: The details of the original message are kept by the kernel allowing it enforce williamr@2: correct usage of the member functions of this class. williamr@2: williamr@2: @see RMessage2 williamr@2: */ williamr@2: class RMessagePtr2 williamr@2: { williamr@2: public: williamr@2: inline RMessagePtr2(); williamr@2: inline TBool IsNull() const; williamr@2: inline TInt Handle() const; williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C void Complete(TInt aReason) const; williamr@2: IMPORT_C void Complete(RHandleBase aHandle) const; williamr@2: IMPORT_C TInt GetDesLength(TInt aParam) const; williamr@2: IMPORT_C TInt GetDesLengthL(TInt aParam) const; williamr@2: IMPORT_C TInt GetDesMaxLength(TInt aParam) const; williamr@2: IMPORT_C TInt GetDesMaxLengthL(TInt aParam) const; williamr@2: IMPORT_C void ReadL(TInt aParam,TDes8& aDes,TInt aOffset=0) const; williamr@2: IMPORT_C void ReadL(TInt aParam,TDes16 &aDes,TInt aOffset=0) const; williamr@2: IMPORT_C void WriteL(TInt aParam,const TDesC8& aDes,TInt aOffset=0) const; williamr@2: IMPORT_C void WriteL(TInt aParam,const TDesC16& aDes,TInt aOffset=0) const; williamr@2: IMPORT_C TInt Read(TInt aParam,TDes8& aDes,TInt aOffset=0) const; williamr@2: IMPORT_C TInt Read(TInt aParam,TDes16 &aDes,TInt aOffset=0) const; williamr@2: IMPORT_C TInt Write(TInt aParam,const TDesC8& aDes,TInt aOffset=0) const; williamr@2: IMPORT_C TInt Write(TInt aParam,const TDesC16& aDes,TInt aOffset=0) const; williamr@2: IMPORT_C void Panic(const TDesC& aCategory,TInt aReason) const; williamr@2: IMPORT_C void Kill(TInt aReason) const; williamr@2: IMPORT_C void Terminate(TInt aReason) const; williamr@2: IMPORT_C TInt SetProcessPriority(TProcessPriority aPriority) const; williamr@2: inline void SetProcessPriorityL(TProcessPriority aPriority) const; williamr@2: IMPORT_C TInt Client(RThread& aClient, TOwnerType aOwnerType=EOwnerProcess) const; williamr@2: inline void ClientL(RThread& aClient, TOwnerType aOwnerType=EOwnerProcess) const; williamr@2: IMPORT_C TUint ClientProcessFlags() const; williamr@2: IMPORT_C const TRequestStatus* ClientStatus() const; williamr@4: IMPORT_C TBool ClientIsRealtime() const; williamr@4: williamr@2: /** williamr@2: Return the Secure ID of the process which sent this message. williamr@2: williamr@2: If an intended use of this method is to check that the Secure ID is williamr@2: a given value, then the use of a TSecurityPolicy object should be williamr@2: considered. E.g. Instead of something like: williamr@2: williamr@2: @code williamr@2: RMessagePtr2& message; williamr@2: TInt error = message.SecureId()==KRequiredSecureId ? KErrNone : KErrPermissionDenied; williamr@2: @endcode williamr@2: williamr@2: this could be used; williamr@2: williamr@2: @code williamr@2: RMessagePtr2& message; williamr@2: static _LIT_SECURITY_POLICY_S0(mySidPolicy, KRequiredSecureId); williamr@4: TBool pass = mySidPolicy().CheckPolicy(message); williamr@2: @endcode williamr@2: williamr@2: This has the benefit that the TSecurityPolicy::CheckPolicy methods are williamr@2: configured by the system wide Platform Security configuration. I.e. are williamr@2: capable of emitting diagnostic messages when a check fails and/or the williamr@2: check can be forced to always pass. williamr@2: williamr@2: @see TSecurityPolicy::CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const williamr@2: @see _LIT_SECURITY_POLICY_S0 williamr@2: williamr@2: @return The Secure ID. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C TSecureId SecureId() const; williamr@2: williamr@2: /** williamr@2: Return the Vendor ID of the process which sent this message. williamr@2: williamr@2: If an intended use of this method is to check that the Vendor ID is williamr@2: a given value, then the use of a TSecurityPolicy object should be williamr@2: considered. E.g. Instead of something like: williamr@2: williamr@2: @code williamr@2: RMessagePtr2& message; williamr@2: TInt error = message.VendorId()==KRequiredVendorId ? KErrNone : KErrPermissionDenied; williamr@2: @endcode williamr@2: williamr@2: this could be used; williamr@2: williamr@2: @code williamr@2: RMessagePtr2& message; williamr@2: static _LIT_SECURITY_POLICY_V0(myVidPolicy, KRequiredVendorId); williamr@4: TBool pass = myVidPolicy().CheckPolicy(message); williamr@2: @endcode williamr@2: williamr@2: This has the benefit that the TSecurityPolicy::CheckPolicy methods are williamr@2: configured by the system wide Platform Security configuration. I.e. are williamr@2: capable of emitting diagnostic messages when a check fails and/or the williamr@2: check can be forced to always pass. williamr@2: williamr@2: @see TSecurityPolicy::CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const williamr@2: @see _LIT_SECURITY_POLICY_V0 williamr@2: williamr@2: @return The Vendor ID. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C TVendorId VendorId() const; williamr@2: williamr@2: /** williamr@2: Check if the process which sent this message has a given capability. williamr@2: williamr@2: When a check fails the action taken is determined by the system wide Platform Security williamr@2: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. williamr@2: If PlatSecEnforcement is OFF, then this function will return ETrue even though the williamr@2: check failed. williamr@2: williamr@2: @param aCapability The capability to test. williamr@2: @param aDiagnostic A string that will be emitted along with any diagnostic message williamr@2: that may be issued if the test finds the capability is not present. williamr@2: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro williamr@2: which enables it to be easily removed from the system. williamr@2: @return ETrue if process which sent this message has the capability, EFalse otherwise. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline TBool HasCapability(TCapability aCapability, const char* aDiagnostic=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline TBool HasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline TBool HasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: /** williamr@2: Check if the process which sent this message has a given capability. williamr@2: williamr@2: When a check fails the action taken is determined by the system wide Platform Security williamr@2: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. williamr@2: If PlatSecEnforcement is OFF, then this function will not leave even though the williamr@2: check failed. williamr@2: williamr@2: @param aCapability The capability to test. williamr@2: @param aDiagnosticMessage A string that will be emitted along with any diagnostic message williamr@2: that may be issued if the test finds the capability is not present. williamr@2: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro williamr@2: which enables it to be easily removed from the system. williamr@2: @leave KErrPermissionDenied, if the process does not have the capability. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline void HasCapabilityL(TCapability aCapability, const char* aDiagnosticMessage=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline void HasCapabilityL(TCapability aCapability, OnlyCreateWithNull aDiagnosticMessage=NULL) const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline void HasCapabilityL(TCapability aCapability, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: /** williamr@2: Check if the process which sent this message has both of the given capabilities. williamr@2: williamr@2: When a check fails the action taken is determined by the system wide Platform Security williamr@2: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. williamr@2: If PlatSecEnforcement is OFF, then this function will return ETrue even though the williamr@2: check failed. williamr@2: williamr@2: @param aCapability1 The first capability to test. williamr@2: @param aCapability2 The second capability to test. williamr@2: @param aDiagnostic A string that will be emitted along with any diagnostic message williamr@2: that may be issued if the test finds a capability is not present. williamr@2: This string should be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro williamr@2: which enables it to be easily removed from the system. williamr@2: @return ETrue if the process which sent this message has both the capabilities, EFalse otherwise. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline TBool HasCapability(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: /** williamr@2: Check if the process which sent this message has both of the given capabilities. williamr@2: williamr@2: When a check fails the action taken is determined by the system wide Platform Security williamr@2: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. williamr@2: If PlatSecEnforcement is OFF, then this function will not leave even though the williamr@2: check failed. williamr@2: williamr@2: @param aCapability1 The first capability to test. williamr@2: @param aCapability2 The second capability to test. williamr@2: @param aDiagnosticMessage A string that will be emitted along with any diagnostic message williamr@2: that may be issued if the test finds a capability is not present. williamr@2: This string should be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro williamr@2: which enables it to be easily removed from the system. williamr@2: @leave KErrPermissionDenied, if the process does not have the capabilities. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline void HasCapabilityL(TCapability aCapability1, TCapability aCapability2, const char* aDiagnosticMessage=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline void HasCapabilityL(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnosticMessage=NULL) const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline void HasCapabilityL(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: /** williamr@2: @deprecated Use SecureId() williamr@2: */ williamr@2: inline TUid Identity() const { return SecureId(); } williamr@2: #endif williamr@2: williamr@2: private: williamr@2: // Implementations of functions with diagnostics williamr@2: IMPORT_C TBool DoHasCapability(TCapability aCapability, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoHasCapability(TCapability aCapability) const; williamr@2: IMPORT_C TBool DoHasCapability(TCapability aCapability, TCapability aCapability2, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoHasCapability(TCapability aCapability, TCapability aCapability2) const; williamr@2: williamr@2: protected: williamr@2: TInt iHandle; williamr@2: }; williamr@2: inline TBool operator==(RMessagePtr2 aLeft,RMessagePtr2 aRight); williamr@2: inline TBool operator!=(RMessagePtr2 aLeft,RMessagePtr2 aRight); williamr@2: williamr@2: class CSession2; williamr@2: williamr@2: #define __IPC_V2_PRESENT__ williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An object that encapsulates the details of a client request. williamr@2: */ williamr@2: class RMessage2 : public RMessagePtr2 williamr@2: { williamr@2: friend class CServer2; williamr@2: public: williamr@2: williamr@2: /** williamr@2: Defines internal message types. williamr@2: */ williamr@2: enum TSessionMessages { williamr@2: /** williamr@2: A message type used internally that means connect. williamr@2: */ williamr@2: EConnect=-1, williamr@2: williamr@2: /** williamr@2: A message type used internally that means disconnect. williamr@2: */ williamr@2: EDisConnect=-2 williamr@2: }; williamr@2: public: williamr@2: inline RMessage2(); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C explicit RMessage2(const RMessagePtr2& aPtr); williamr@2: void SetAuthorised() const; williamr@2: void ClearAuthorised() const; williamr@2: TBool Authorised() const; williamr@2: #endif williamr@2: inline TInt Function() const; williamr@2: inline TInt Int0() const; williamr@2: inline TInt Int1() const; williamr@2: inline TInt Int2() const; williamr@2: inline TInt Int3() const; williamr@2: inline const TAny* Ptr0() const; williamr@2: inline const TAny* Ptr1() const; williamr@2: inline const TAny* Ptr2() const; williamr@2: inline const TAny* Ptr3() const; williamr@2: inline CSession2* Session() const; williamr@2: protected: williamr@2: williamr@2: /** williamr@2: The request type. williamr@2: */ williamr@2: TInt iFunction; williamr@2: williamr@2: /** williamr@2: A copy of the message arguments. williamr@2: */ williamr@2: TInt iArgs[KMaxMessageArguments]; williamr@2: private: williamr@2: TInt iSpare1; williamr@2: protected: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TAny* iSessionPtr; williamr@2: private: williamr@2: mutable TInt iFlags;// Currently only used for *Authorised above williamr@2: TInt iSpare3; // Reserved for future use williamr@2: williamr@2: friend class RMessage; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines an 8-bit modifiable buffer descriptor to contain passwords when dealing williamr@2: with password security support in a file server session. williamr@2: williamr@2: The descriptor takes a maximum length of KMaxMediaPassword. williamr@2: williamr@2: @see KMaxMediaPassword williamr@2: */ williamr@2: typedef TBuf8 TMediaPassword; // 128 bit williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedPartner williamr@2: @prototype williamr@2: A configuration flag for the shared chunk buffer configuration class (used by the multimedia device drivers). This being williamr@2: set signifies that a buffer offset list follows the buffer configuration class. This list holds the offset of each buffer. williamr@2: */ williamr@2: const TUint KScFlagBufOffsetListInUse=0x00000001; williamr@2: williamr@2: /** williamr@2: @publishedPartner williamr@2: @prototype williamr@2: A configuration flag for the shared chunk buffer configuration class (used by the multimedia device drivers). This being williamr@2: set is a suggestion that the shared chunk should be configured leaving guard pages around each buffers. williamr@2: */ williamr@2: const TUint KScFlagUseGuardPages=0x00000002; williamr@2: williamr@2: /** williamr@2: @publishedPartner williamr@2: @prototype williamr@2: The shared chunk buffer configuration class (used by the multimedia device drivers). This is used to hold information williamr@2: on the current buffer configuration within a shared chunk. williamr@2: */ williamr@2: class TSharedChunkBufConfigBase williamr@2: { williamr@2: public: williamr@2: inline TSharedChunkBufConfigBase(); williamr@2: public: williamr@2: /** The number of buffers. */ williamr@2: TInt iNumBuffers; williamr@2: /** The size of each buffer in bytes. */ williamr@2: TInt iBufferSizeInBytes; williamr@2: /** Reserved field. */ williamr@2: TInt iReserved1; williamr@2: /** Shared chunk buffer flag settings. */ williamr@2: TUint iFlags; williamr@2: }; williamr@2: williamr@2: williamr@2: /** Maximum size of capability set williamr@2: williamr@2: @internalTechnology williamr@2: */ williamr@2: const TInt KCapabilitySetMaxSize = (((TInt)ECapability_HardLimit + 7)>>3); williamr@2: williamr@2: /** Maximum size of any future extension to TSecurityPolicy williamr@2: williamr@2: @internalTechnology williamr@2: */ williamr@2: const TInt KMaxSecurityPolicySize = KCapabilitySetMaxSize + 3*sizeof(TUint32); williamr@2: williamr@4: williamr@2: /** Class representing an arbitrary set of capabilities. williamr@2: williamr@2: This class can only contain capabilities supported by the current OS version. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TCapabilitySet williamr@2: { williamr@2: public: williamr@2: inline TCapabilitySet(); williamr@2: inline TCapabilitySet(TCapability aCapability); williamr@2: IMPORT_C TCapabilitySet(TCapability aCapability1, TCapability aCapability2); williamr@2: IMPORT_C void SetEmpty(); williamr@2: inline void Set(TCapability aCapability); williamr@2: inline void Set(TCapability aCapability1, TCapability aCapability2); williamr@2: IMPORT_C void SetAllSupported(); williamr@2: IMPORT_C void AddCapability(TCapability aCapability); williamr@2: IMPORT_C void RemoveCapability(TCapability aCapability); williamr@2: IMPORT_C void Union(const TCapabilitySet& aCapabilities); williamr@2: IMPORT_C void Intersection(const TCapabilitySet& aCapabilities); williamr@2: IMPORT_C void Remove(const TCapabilitySet& aCapabilities); williamr@2: IMPORT_C TBool HasCapability(TCapability aCapability) const; williamr@2: IMPORT_C TBool HasCapabilities(const TCapabilitySet& aCapabilities) const; williamr@2: williamr@2: /** williamr@2: Make this set consist of the capabilities which are disabled on this platform. williamr@2: @internalTechnology williamr@2: */ williamr@2: IMPORT_C void SetDisabled(); williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: TBool NotEmpty() const; williamr@4: williamr@2: private: williamr@2: TUint32 iCaps[KCapabilitySetMaxSize / sizeof(TUint32)]; williamr@2: }; williamr@2: williamr@2: #ifndef __SECURITY_INFO_DEFINED__ williamr@2: #define __SECURITY_INFO_DEFINED__ williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: struct SCapabilitySet williamr@2: { williamr@2: enum {ENCapW=2}; williamr@2: williamr@2: inline void AddCapability(TCapability aCap1) {((TCapabilitySet*)this)->AddCapability(aCap1);} williamr@2: inline void Remove(const SCapabilitySet& aCaps) {((TCapabilitySet*)this)->Remove(*((TCapabilitySet*)&aCaps));} williamr@2: inline TBool NotEmpty() const {return ((TCapabilitySet*)this)->NotEmpty();} williamr@2: williamr@2: inline const TUint32& operator[] (TInt aIndex) const { return iCaps[aIndex]; } williamr@2: inline TUint32& operator[] (TInt aIndex) { return iCaps[aIndex]; } williamr@2: williamr@2: TUint32 iCaps[ENCapW]; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: struct SSecurityInfo williamr@2: { williamr@2: TUint32 iSecureId; williamr@2: TUint32 iVendorId; williamr@2: SCapabilitySet iCaps; // Capabilities re. platform security williamr@2: }; williamr@2: williamr@2: #endif williamr@2: williamr@2: /** Define this macro to reference the set of all capabilities. williamr@2: @internalTechnology williamr@2: */ williamr@2: #ifdef __REFERENCE_ALL_SUPPORTED_CAPABILITIES__ williamr@2: williamr@2: extern const SCapabilitySet AllSupportedCapabilities; williamr@2: williamr@2: #endif //__REFERENCE_ALL_SUPPORTED_CAPABILITIES__ williamr@2: williamr@2: /** Define this macro to include the set of all capabilities. williamr@2: @internalTechnology williamr@2: */ williamr@2: #ifdef __INCLUDE_ALL_SUPPORTED_CAPABILITIES__ williamr@2: williamr@2: /** The set of all capabilities. williamr@2: @internalTechnology williamr@2: */ williamr@2: const SCapabilitySet AllSupportedCapabilities = { williamr@2: { williamr@2: ECapability_Limit<32 ? (TUint32)((1u<<(ECapability_Limit&31))-1u) : 0xffffffffu williamr@2: , williamr@2: ECapability_Limit>=32 ? (TUint32)((1u<<(ECapability_Limit&31))-1u) : 0u williamr@2: } williamr@2: }; williamr@2: williamr@2: #endif // __INCLUDE_ALL_SUPPORTED_CAPABILITIES__ williamr@2: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: class RProcess; williamr@2: class RThread; williamr@2: class RMessagePtr2; williamr@2: class RSessionBase; williamr@2: #else williamr@2: class DProcess; williamr@2: class DThread; williamr@2: #endif williamr@2: williamr@2: /** Class representing all security attributes of a process or DLL. williamr@2: These comprise a set of capabilities, a Secure ID and a Vendor ID. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TSecurityInfo williamr@2: { williamr@2: public: williamr@2: inline TSecurityInfo(); williamr@4: #ifdef __KERNEL_MODE__ williamr@4: IMPORT_C TSecurityInfo(DProcess* aProcess); williamr@4: IMPORT_C TSecurityInfo(DThread* aThread); williamr@4: #else williamr@2: IMPORT_C TSecurityInfo(RProcess aProcess); williamr@2: IMPORT_C TSecurityInfo(RThread aThread); williamr@2: IMPORT_C TSecurityInfo(RMessagePtr2 aMesPtr); williamr@2: inline void Set(RProcess aProcess); williamr@2: inline void Set(RThread aThread); williamr@2: inline void Set(RMessagePtr2 aMsgPtr); williamr@2: TInt Set(RSessionBase aSession); /**< @internalComponent */ williamr@2: inline void SetToCurrentInfo(); williamr@2: IMPORT_C void SetToCreatorInfo(); williamr@2: #endif //__KERNEL_MODE__ williamr@2: public: williamr@2: TSecureId iSecureId; /**< Secure ID */ williamr@2: TVendorId iVendorId; /**< Vendor ID */ williamr@2: TCapabilitySet iCaps; /**< Capability Set */ williamr@2: }; williamr@2: williamr@2: williamr@2: /** Class representing a generic security policy williamr@2: williamr@2: This class can specify a security policy consisting of either: williamr@2: williamr@2: -# A check for between 0 and 7 capabilities williamr@2: -# A check for a given Secure ID along with 0-3 capabilities williamr@2: -# A check for a given Vendor ID along with 0-3 capabilities williamr@2: williamr@2: If multiple capabilities are specified, all of them must be present for the williamr@2: security check to succeed ('AND' relation). williamr@2: williamr@2: The envisaged use case for this class is to specify access rights to an object williamr@2: managed either by the kernel or by a server but in principle owned by a client williamr@2: and usable in a limited way by other clients. For example williamr@2: - Publish and Subscribe properties williamr@2: - DBMS databases williamr@2: williamr@2: In these cases the owning client would pass one (or more) of these objects to williamr@2: the server to specify which security checks should be done on other clients williamr@2: before allowing access to the object. williamr@2: williamr@2: To pass a TSecurityPolicy object via IPC, a client should obtain a descriptor williamr@2: for the object using Package() and send this. When a server receives this descriptor williamr@2: it should read the descriptor contents into a TSecurityPolicyBuf and then williamr@2: Set() should be used to create a policy object from this. williamr@2: williamr@2: Because this class has non-default constructors, compilers will not initialise williamr@2: this object at compile time, instead code will be generated to construct the object williamr@2: at run-time. This is wasteful - and Symbian OS DLLs are not permitted to have williamr@2: such uninitialised data. To overcome these problems a set of macros are provided to williamr@2: construct a const object which behaves like a TSecurityPolicy. These are: williamr@2: williamr@2: _LIT_SECURITY_POLICY_C1 through _LIT_SECURITY_POLICY_C7, williamr@2: _LIT_SECURITY_POLICY_S0 through _LIT_SECURITY_POLICY_S3 and williamr@2: _LIT_SECURITY_POLICY_V0 through _LIT_SECURITY_POLICY_V3. williamr@2: williamr@2: Also, the macros _LIT_SECURITY_POLICY_PASS and _LIT_SECURITY_POLICY_FAIL are provided williamr@2: in order to allow easy construction of a const object which can be used as a williamr@2: TSecuityPolicy which always passes or always fails, respectively. williamr@2: williamr@2: If a security policy object is needed to be embedded in another class then the williamr@2: TStaticSecurityPolicy structure can be used. This behaves in the same way as a williamr@2: TSecurityPolicy object but may be initialised at compile time. williamr@2: williamr@2: @see TStaticSecurityPolicy williamr@2: @see TSecurityPolicyBuf williamr@2: @see _LIT_SECURITY_POLICY_PASS williamr@2: @see _LIT_SECURITY_POLICY_FAIL williamr@2: @see _LIT_SECURITY_POLICY_C1 williamr@2: @see _LIT_SECURITY_POLICY_C2 williamr@2: @see _LIT_SECURITY_POLICY_C3 williamr@2: @see _LIT_SECURITY_POLICY_C4 williamr@2: @see _LIT_SECURITY_POLICY_C5 williamr@2: @see _LIT_SECURITY_POLICY_C6 williamr@2: @see _LIT_SECURITY_POLICY_C7 williamr@2: @see _LIT_SECURITY_POLICY_S0 williamr@2: @see _LIT_SECURITY_POLICY_S1 williamr@2: @see _LIT_SECURITY_POLICY_S2 williamr@2: @see _LIT_SECURITY_POLICY_S3 williamr@2: @see _LIT_SECURITY_POLICY_V0 williamr@2: @see _LIT_SECURITY_POLICY_V1 williamr@2: @see _LIT_SECURITY_POLICY_V2 williamr@2: @see _LIT_SECURITY_POLICY_V3 williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TSecurityPolicy williamr@2: { williamr@2: public: williamr@2: enum TSecPolicyType williamr@2: { williamr@2: EAlwaysFail=0, williamr@2: EAlwaysPass=1, williamr@2: }; williamr@2: williamr@2: public: williamr@2: inline TSecurityPolicy(); williamr@2: IMPORT_C TSecurityPolicy(TSecPolicyType aType); williamr@2: IMPORT_C TSecurityPolicy(TCapability aCap1, TCapability aCap2 = ECapability_None, TCapability aCap3 = ECapability_None); williamr@2: IMPORT_C TSecurityPolicy(TCapability aCap1, TCapability aCap2, TCapability aCap3, TCapability aCap4, TCapability aCap5 = ECapability_None, TCapability aCap6 = ECapability_None, TCapability aCap7 = ECapability_None); williamr@2: IMPORT_C TSecurityPolicy(TSecureId aSecureId, TCapability aCap1 = ECapability_None, TCapability aCap2 = ECapability_None, TCapability aCap3 = ECapability_None); williamr@2: IMPORT_C TSecurityPolicy(TVendorId aVendorId, TCapability aCap1 = ECapability_None, TCapability aCap2 = ECapability_None, TCapability aCap3 = ECapability_None); williamr@2: IMPORT_C TInt Set(const TDesC8& aDes); williamr@2: IMPORT_C TPtrC8 Package() const; williamr@2: williamr@2: #ifdef __KERNEL_MODE__ williamr@2: williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline TBool CheckPolicy(DProcess* aProcess, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(DThread* aThread, const char* aDiagnostic=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline TBool CheckPolicy(DProcess* aProcess, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(DThread* aThread, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: #else // !__KERNEL_MODE__ williamr@2: williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline TBool CheckPolicy(RProcess aProcess, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(RThread aThread, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicyCreator(const char* aDiagnostic=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: TInt CheckPolicy(RSessionBase aSession) const; /**< @internalComponent */ williamr@2: williamr@2: #endif //__KERNEL_MODE__ williamr@2: williamr@2: TBool Validate() const; williamr@2: williamr@2: private: williamr@2: #ifdef __KERNEL_MODE__ williamr@2: IMPORT_C TBool DoCheckPolicy(DProcess* aProcess, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoCheckPolicy(DProcess* aProcess) const; williamr@2: IMPORT_C TBool DoCheckPolicy(DThread* aThread, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoCheckPolicy(DThread* aThread) const; williamr@2: #else // !__KERNEL_MODE__ williamr@2: IMPORT_C TBool DoCheckPolicy(RProcess aProcess, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoCheckPolicy(RProcess aProcess) const; williamr@2: IMPORT_C TBool DoCheckPolicy(RThread aThread, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoCheckPolicy(RThread aThread) const; williamr@2: IMPORT_C TBool DoCheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoCheckPolicy(RMessagePtr2 aMsgPtr) const; williamr@2: IMPORT_C TBool DoCheckPolicyCreator(const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoCheckPolicyCreator() const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: TBool DoCheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic) const; williamr@2: #endif //__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: TBool DoCheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing) const; williamr@2: #endif //__KERNEL_MODE__ williamr@2: williamr@2: public: williamr@2: /** Constants to specify the type of TSecurityPolicy objects. williamr@2: */ williamr@2: enum TType williamr@2: { williamr@2: ETypeFail=0, /**< Always fail*/ williamr@2: ETypePass=1, /**< Always pass*/ williamr@2: ETypeC3=2, /**< Up to 3 capabilities*/ williamr@2: ETypeC7=3, /**< Up to 7 capabilities*/ williamr@2: ETypeS3=4, /**< Secure ID and up to 3 capabilities*/ williamr@2: ETypeV3=5, /**< Vendor ID and up to 3 capabilities*/ williamr@2: williamr@2: /** The number of possible TSecurityPolicy types williamr@4: This is intended for internal Symbian use only. williamr@2: @internalTechnology williamr@2: */ williamr@2: ETypeLimit williamr@2: williamr@2: // other values may be added to indicate expanded policy objects (future extensions) williamr@2: }; williamr@2: protected: williamr@2: TBool CheckPolicy(const SSecurityInfo& aSecInfo, SSecurityInfo& aMissing) const; williamr@2: private: williamr@2: void ConstructAndCheck3(TCapability aCap1, TCapability aCap2, TCapability aCap3); williamr@2: private: williamr@2: TUint8 iType; williamr@2: TUint8 iCaps[3]; // missing capabilities are set to 0xff williamr@2: union williamr@2: { williamr@2: TUint32 iSecureId; williamr@2: TUint32 iVendorId; williamr@2: TUint8 iExtraCaps[4]; // missing capabilities are set to 0xff williamr@2: }; williamr@2: friend class TCompiledSecurityPolicy; williamr@2: }; williamr@2: williamr@2: /** Provides a TPkcgBuf wrapper for a descriptorised TSecurityPolicy. This a williamr@2: suitable container for passing a security policy across IPC. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: typedef TPckgBuf TSecurityPolicyBuf; williamr@2: williamr@2: williamr@2: /** Structure for compile-time initialisation of a security policy. williamr@2: williamr@2: This structure behaves in the same way as a TSecurityPolicy object but has williamr@2: the advantage that it may be initialised at compile time. E.g. williamr@2: the following line defines a security policy 'KSecurityPolictReadUserData' williamr@2: which checks ReadUserData capability. williamr@2: williamr@2: @code williamr@2: _LIT_SECURITY_POLICY_C1(KSecurityPolictReadUserData,ECapabilityReadUserData) williamr@2: @endcode williamr@2: williamr@2: Or, an array of security policies may be created like this: williamr@2: @code williamr@2: static const TStaticSecurityPolicy MyPolicies[] = williamr@2: { williamr@2: _INIT_SECURITY_POLICY_C1(ECapabilityReadUserData), williamr@2: _INIT_SECURITY_POLICY_PASS(), williamr@2: _INIT_SECURITY_POLICY_S0(0x1234567) williamr@2: } williamr@2: @endcode williamr@2: williamr@2: This class should not be initialised directly, instead one of the following williamr@2: macros should be used: williamr@2: williamr@2: - _INIT_SECURITY_POLICY_PASS williamr@2: - _INIT_SECURITY_POLICY_FAIL williamr@2: - _INIT_SECURITY_POLICY_C1 williamr@2: - _INIT_SECURITY_POLICY_C2 williamr@2: - _INIT_SECURITY_POLICY_C3 williamr@2: - _INIT_SECURITY_POLICY_C4 williamr@2: - _INIT_SECURITY_POLICY_C5 williamr@2: - _INIT_SECURITY_POLICY_C6 williamr@2: - _INIT_SECURITY_POLICY_C7 williamr@2: - _INIT_SECURITY_POLICY_S0 williamr@2: - _INIT_SECURITY_POLICY_S1 williamr@2: - _INIT_SECURITY_POLICY_S2 williamr@2: - _INIT_SECURITY_POLICY_S3 williamr@2: - _INIT_SECURITY_POLICY_V0 williamr@2: - _INIT_SECURITY_POLICY_V1 williamr@2: - _INIT_SECURITY_POLICY_V2 williamr@2: - _INIT_SECURITY_POLICY_V3 williamr@2: - _LIT_SECURITY_POLICY_PASS williamr@2: - _LIT_SECURITY_POLICY_FAIL williamr@2: - _LIT_SECURITY_POLICY_C1 williamr@2: - _LIT_SECURITY_POLICY_C2 williamr@2: - _LIT_SECURITY_POLICY_C3 williamr@2: - _LIT_SECURITY_POLICY_C4 williamr@2: - _LIT_SECURITY_POLICY_C5 williamr@2: - _LIT_SECURITY_POLICY_C6 williamr@2: - _LIT_SECURITY_POLICY_C7 williamr@2: - _LIT_SECURITY_POLICY_S0 williamr@2: - _LIT_SECURITY_POLICY_S1 williamr@2: - _LIT_SECURITY_POLICY_S2 williamr@2: - _LIT_SECURITY_POLICY_S3 williamr@2: - _LIT_SECURITY_POLICY_V0 williamr@2: - _LIT_SECURITY_POLICY_V1 williamr@2: - _LIT_SECURITY_POLICY_V2 williamr@2: - _LIT_SECURITY_POLICY_V3 williamr@2: williamr@2: @see TSecurityPolicy williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: struct TStaticSecurityPolicy williamr@2: { williamr@2: inline const TSecurityPolicy* operator&() const; williamr@2: inline operator const TSecurityPolicy&() const; williamr@2: inline const TSecurityPolicy& operator()() const; williamr@2: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline TBool CheckPolicy(RProcess aProcess, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(RThread aThread, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic=0) const; williamr@2: inline TBool CheckPolicyCreator(const char* aDiagnostic=0) const; williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic=NULL) const; williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline TBool CheckPolicy(RProcess aProcess, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicy(RThread aThread, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: inline TBool CheckPolicyCreator(OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: #endif // !__KERNEL_MODE__ williamr@2: williamr@2: TUint32 iA; /**< @internalComponent */ williamr@2: TUint32 iB; /**< @internalComponent */ williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: A dummy enum for use by the CAPABILITY_AS_TUINT8 macro williamr@2: @internalComponent williamr@2: */ williamr@2: enum __invalid_capability_value {}; williamr@2: williamr@2: /** williamr@2: A macro to cast a TCapability to a TUint8. williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param cap The capability value williamr@2: @internalComponent williamr@2: */ williamr@2: #define CAPABILITY_AS_TUINT8(cap) \ williamr@2: ((TUint8)(int)( \ williamr@2: (cap)==ECapability_None \ williamr@2: ? (__invalid_capability_value(*)[1])(ECapability_None) \ williamr@2: : (__invalid_capability_value(*)[((TUint)(cap+1)<=(TUint)ECapability_Limit)?1:2])(cap) \ williamr@2: )) williamr@2: williamr@2: williamr@2: /** williamr@2: A macro to construct a TUint32 from four TUint8s. The TUint32 is in BigEndian williamr@2: ordering useful for class layout rather than number generation. williamr@2: williamr@2: @param i1 The first TUint8 williamr@2: @param i2 The second TUint8 williamr@2: @param i3 The third TUint8 williamr@2: @param i4 The fourth TUint8 williamr@2: @internalComponent williamr@2: */ williamr@2: #define FOUR_TUINT8(i1,i2,i3,i4) \ williamr@2: (TUint32)( \ williamr@2: (TUint8)i1 | \ williamr@2: (TUint8)i2 << 8 | \ williamr@2: (TUint8)i3 << 16 | \ williamr@2: (TUint8)i4 << 24 \ williamr@2: ) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object that williamr@2: always fails. That is, checks against this policy will always fail, williamr@2: irrespective of the security attributes of the item being checked. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_FAIL \ williamr@2: { \ williamr@2: FOUR_TUINT8( \ williamr@2: (TUint8)TSecurityPolicy::ETypeFail, \ williamr@2: (TUint8)0xff, \ williamr@2: (TUint8)0xff, \ williamr@2: (TUint8)0xff \ williamr@2: ), \ williamr@2: (TUint32)0xffffffff \ williamr@2: } williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object that always williamr@2: fails. That is, checks against this policy will always fail, irrespective of williamr@2: the security attributes of the item being checked. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: @param n Name to use for policy object williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_FAIL(n) const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_FAIL williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object that williamr@2: always passes. That is, checks against this policy will always pass, williamr@2: irrespective of the security attributes of the item being checked. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_PASS \ williamr@2: { \ williamr@2: FOUR_TUINT8( \ williamr@2: (TUint8)TSecurityPolicy::ETypePass, \ williamr@2: (TUint8)0xff, \ williamr@2: (TUint8)0xff, \ williamr@2: (TUint8)0xff \ williamr@2: ), \ williamr@2: (TUint32)0xffffffff \ williamr@2: } williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object that always williamr@2: passes. That is, checks against this policy will always pass, irrespective of williamr@2: the security attributes of the item being checked. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: @param n Name to use for policy object williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_PASS(n) const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_PASS williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for seven capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: @param c5 The fifth capability to check (enumerator of TCapability) williamr@2: @param c6 The sixth capability to check (enumerator of TCapability) williamr@2: @param c7 The seventh capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,c6,c7) \ williamr@2: { \ williamr@2: FOUR_TUINT8( \ williamr@2: (TUint8)TSecurityPolicy::ETypeC7, \ williamr@2: CAPABILITY_AS_TUINT8(c1), \ williamr@2: CAPABILITY_AS_TUINT8(c2), \ williamr@2: CAPABILITY_AS_TUINT8(c3) \ williamr@2: ), \ williamr@2: FOUR_TUINT8( \ williamr@2: CAPABILITY_AS_TUINT8(c4), \ williamr@2: CAPABILITY_AS_TUINT8(c5), \ williamr@2: CAPABILITY_AS_TUINT8(c6), \ williamr@2: CAPABILITY_AS_TUINT8(c7) \ williamr@2: ) \ williamr@2: } williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for seven capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: @param c5 The fifth capability to check (enumerator of TCapability) williamr@2: @param c6 The sixth capability to check (enumerator of TCapability) williamr@2: @param c7 The seventh capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,c5,c6,c7) \ williamr@2: const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,c6,c7) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for six capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: @param c5 The fifth capability to check (enumerator of TCapability) williamr@2: @param c6 The sixth capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C6(c1,c2,c3,c4,c5,c6) \ williamr@2: _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,c6,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for six capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: @param c5 The fifth capability to check (enumerator of TCapability) williamr@2: @param c6 The sixth capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C6(n,c1,c2,c3,c4,c5,c6) \ williamr@2: _LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,c5,c6,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for five capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: @param c5 The fifth capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C5(c1,c2,c3,c4,c5) \ williamr@2: _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,c5,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for five capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: @param c5 The fifth capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C5(n,c1,c2,c3,c4,c5) \ williamr@2: _LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,c5,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for four capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C4(c1,c2,c3,c4) \ williamr@2: _INIT_SECURITY_POLICY_C7(c1,c2,c3,c4,ECapability_None,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for four capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: @param c4 The fourth capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C4(n,c1,c2,c3,c4) \ williamr@2: _LIT_SECURITY_POLICY_C7(n,c1,c2,c3,c4,ECapability_None,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for three capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C3(c1,c2,c3) \ williamr@2: { \ williamr@2: FOUR_TUINT8( \ williamr@2: (TUint8)TSecurityPolicy::ETypeC3, \ williamr@2: CAPABILITY_AS_TUINT8(c1), \ williamr@2: CAPABILITY_AS_TUINT8(c2), \ williamr@2: CAPABILITY_AS_TUINT8(c3) \ williamr@2: ), \ williamr@2: (TUint32)0xffffffff \ williamr@2: } williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for three capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C3(n,c1,c2,c3) \ williamr@2: const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_C3(c1,c2,c3) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for two capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C2(c1,c2) \ williamr@2: _INIT_SECURITY_POLICY_C3(c1,c2,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for two capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C2(n,c1,c2) \ williamr@2: _LIT_SECURITY_POLICY_C3(n,c1,c2,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for one capability. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_C1(c1) \ williamr@2: _INIT_SECURITY_POLICY_C3(c1,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for one capability. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning will be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_C1(n,c1) \ williamr@2: _LIT_SECURITY_POLICY_C3(n,c1,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a secure ID and three capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param sid The SID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_S3(sid,c1,c2,c3) \ williamr@2: { \ williamr@2: FOUR_TUINT8( \ williamr@2: (TUint8)TSecurityPolicy::ETypeS3, \ williamr@2: CAPABILITY_AS_TUINT8(c1), \ williamr@2: CAPABILITY_AS_TUINT8(c2), \ williamr@2: CAPABILITY_AS_TUINT8(c3) \ williamr@2: ), \ williamr@2: (TUint32)(sid) \ williamr@2: } williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a secure ID and three capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param sid The SID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_S3(n,sid,c1,c2,c3) \ williamr@2: const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_S3(sid,c1,c2,c3) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a secure ID and two capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param sid The SID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_S2(sid,c1,c2) \ williamr@2: _INIT_SECURITY_POLICY_S3(sid,c1,c2,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a secure ID and two capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param sid The SID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_S2(n,sid,c1,c2) \ williamr@2: _LIT_SECURITY_POLICY_S3(n,sid,c1,c2,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a secure ID and one capability. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param sid The SID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_S1(sid,c1) \ williamr@2: _INIT_SECURITY_POLICY_S3(sid,c1,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a secure ID and one capability. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param sid The SID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_S1(n,sid,c1) \ williamr@2: _LIT_SECURITY_POLICY_S3(n,sid,c1,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a secure ID. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: @param sid The SID value to check for williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_S0(sid) \ williamr@2: _INIT_SECURITY_POLICY_S3(sid,ECapability_None,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a secure ID. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param sid The SID value to check for williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_S0(n,sid) \ williamr@2: _LIT_SECURITY_POLICY_S3(n,sid,ECapability_None,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a vendor ID and three capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param vid The VID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_V3(vid,c1,c2,c3) \ williamr@2: { \ williamr@2: FOUR_TUINT8( \ williamr@2: (TUint8)TSecurityPolicy::ETypeV3, \ williamr@2: CAPABILITY_AS_TUINT8(c1), \ williamr@2: CAPABILITY_AS_TUINT8(c2), \ williamr@2: CAPABILITY_AS_TUINT8(c3) \ williamr@2: ), \ williamr@2: (TUint32)(vid) \ williamr@2: } williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a vendor ID and three capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param vid The VID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: @param c3 The third capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_V3(n,vid,c1,c2,c3) \ williamr@2: const TStaticSecurityPolicy n = _INIT_SECURITY_POLICY_V3(vid,c1,c2,c3) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a vendor ID and two capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param vid The VID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_V2(vid,c1,c2) \ williamr@2: _INIT_SECURITY_POLICY_V3(vid,c1,c2,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a vendor ID and two capabilities. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param vid The VID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: @param c2 The second capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_V2(n,vid,c1,c2) \ williamr@2: _LIT_SECURITY_POLICY_V3(n,vid,c1,c2,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a vendor ID and one capability. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param vid The VID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_V1(vid,c1) \ williamr@2: _INIT_SECURITY_POLICY_V3(vid,c1,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a vendor ID and one capability. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: If an invlid capability value is specified then, dependant on the compiler, williamr@2: a compile time error or warning be produced which includes the label williamr@2: "__invalid_capability_value" williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param vid The VID value to check for williamr@2: @param c1 The first capability to check (enumerator of TCapability) williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_V1(n,vid,c1) \ williamr@2: _LIT_SECURITY_POLICY_V3(n,vid,c1,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time initialisation of a security policy object williamr@2: The policy will check for a vendor ID. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: @param vid The VID value to check for williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _INIT_SECURITY_POLICY_V0(vid) \ williamr@2: _INIT_SECURITY_POLICY_V3(vid,ECapability_None,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: /** Macro for compile-time definition of a security policy object williamr@2: The policy will check for a vendor ID. williamr@2: williamr@2: The object declared has an implicit conversion to const TSecurityPolicy&. williamr@2: Taking the address of the object will return a const TSecurityPolicy*. williamr@2: Explicit conversion to const TSecurityPolicy& may be effected by using the williamr@2: function call operator n(). williamr@2: williamr@2: @param n Name to use for policy object williamr@2: @param vid The VID value to check for williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define _LIT_SECURITY_POLICY_V0(n,vid) \ williamr@2: _LIT_SECURITY_POLICY_V3(n,vid,ECapability_None,ECapability_None,ECapability_None) williamr@2: williamr@2: williamr@2: williamr@2: #ifdef __KERNEL_MODE__ williamr@2: class DThread; williamr@2: class RMessageK; williamr@2: #endif williamr@2: class TPlatSecDiagnostic; williamr@2: williamr@2: /** williamr@2: Class containing Platform Security related methods williamr@2: @internalTechnology williamr@2: */ williamr@2: class PlatSec williamr@2: { williamr@2: #ifndef __KERNEL_MODE__ williamr@2: public: williamr@2: /** williamr@2: Tests whether a given Platform Security capability is enforced by the system. williamr@2: williamr@2: Capabilities may not be enforced for several reasons: williamr@2: -# The capability has been explicitly disabled on this system williamr@2: by use of the PlatSecDisabledCaps configuration parameter williamr@2: -# Platform Security checks have been globally disabled williamr@2: by use of the EPlatSecEnforcement configuration parameter williamr@2: -# The capability value is unknown. I.e. Is not part of the set of supported williamr@2: capabilities. See TCapabilitySet::SetAllSupported(). williamr@2: williamr@2: @param aCapability The capability to test williamr@2: @return A non-zero value if the capability is enforced, zero if it is not. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C static TBool IsCapabilityEnforced(TCapability aCapability); williamr@2: williamr@2: /** williamr@2: An enumeration used with PlatSecSetting() williamr@2: @see PlatSecSetting() williamr@2: @publishedAll williamr@2: @test williamr@2: */ williamr@2: enum TConfigSetting williamr@2: { williamr@2: EPlatSecEnforcement, /**< Used to request the value of the PlatSecEnforcement setting */ williamr@2: EPlatSecDiagnotics, /**< Used to request the value of the PlatSecDiagnotics setting */ williamr@2: EPlatSecProcessIsolation, /**< Used to request the value of the PlatSecProcessIsolation setting */ williamr@2: EPlatSecEnforceSysBin, /**< Used to request the value of the PlatSecEnforceSysBin setting */ williamr@2: EPlatSecLocked, /**< Used to request the value of the PlatSecLocked setting */ williamr@2: }; williamr@2: williamr@2: /** williamr@2: A test function to return the state of a given Platform Security configuration setting. williamr@2: @param aSetting An enumerated value representing the required setting williamr@2: @return A value representing the setting. 0 represents 'OFF', 1 represents 'ON' williamr@2: Other values may be returned for some settings, these exceptions are documented williamr@2: in the description for individual enumerations of TConfigSetting. williamr@2: @see TConfigSetting williamr@2: @publishedAll williamr@2: @test williamr@2: */ williamr@2: IMPORT_C static TInt ConfigSetting(TConfigSetting aSetting); williamr@2: williamr@2: #endif // Not __KERNEL_MODE__ williamr@2: williamr@2: // williamr@2: // All methods below here are internalTechnology williamr@2: // williamr@2: williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: public: williamr@2: /** @internalTechnology */ williamr@2: static inline TInt LoaderCapabilityViolation(const TDesC8& aImporterName, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps); williamr@2: #ifdef __KERNEL_MODE__ williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(const DProcess* aViolatingProcess, TCapability aCapability, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(const DThread* aViolatingThread, TCapability aCapability, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt SecureIdCheckFail(const DProcess* aViolatingProcess, TSecureId aSid, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(const DProcess* aProcess, const SSecurityInfo& aMissing, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(const DThread* aProcess, const SSecurityInfo& aMissing, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt ProcessIsolationFail(const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt ProcessIsolationIPCFail(RMessageK* aMessage, const char* aContextText); williamr@2: #else // !__KERNEL_MODE__ williamr@2: /** @internalTechnology */ williamr@2: static inline TInt LoaderCapabilityViolation(RProcess aLoadingProcess, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CreatorCapabilityCheckFail(TCapability aCapability, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CreatorCapabilityCheckFail(const TCapabilitySet& aMissingCaps, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(TInt aHandle, TCapability aCapability, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(TInt aHandle, const TCapabilitySet& aMissingCaps, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(TInt aHandle, const SSecurityInfo& aMissing, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, TCapability aCapability, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, const TCapabilitySet& aMissingCaps, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(RMessagePtr2 aMessage, const SSecurityInfo& aMissingCaps, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(RSessionBase aSession, const SSecurityInfo& aMissingCaps, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CreatorPolicyCheckFail(const SSecurityInfo& aMissingCaps, const char* aContextText); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CreatorCapabilityCheckFail(TCapability aCapability); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CreatorCapabilityCheckFail(const TCapabilitySet& aMissingCaps); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(TInt aHandle, TCapability aCapability); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(TInt aHandle, const TCapabilitySet& aMissingCaps); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(TInt aHandle, const SSecurityInfo& aMissing); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, TCapability aCapability); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CapabilityCheckFail(RMessagePtr2 aMessage, const TCapabilitySet& aMissingCaps); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt PolicyCheckFail(RMessagePtr2 aMessage, const SSecurityInfo& aMissingCaps); williamr@2: /** @internalTechnology */ williamr@2: static inline TInt CreatorPolicyCheckFail(const SSecurityInfo& aMissingCaps); williamr@2: #endif //__KERNEL_MODE__ williamr@2: williamr@2: private: williamr@2: UIMPORT_C static TInt EmitDiagnostic(TPlatSecDiagnostic& aDiagnostic, const char* aContextText); williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #ifndef __KERNEL_MODE__ williamr@2: private: williamr@2: IMPORT_C static TInt EmitDiagnostic(TPlatSecDiagnostic& aDiagnostic, const char* aContextText); williamr@2: #endif // !__KERNEL_MODE__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: williamr@2: public: williamr@2: /** @internalTechnology */ williamr@2: UIMPORT_C static TInt EmitDiagnostic(); williamr@2: }; williamr@2: williamr@2: williamr@4: #define KMaxSerialNumLength 64 williamr@4: typedef TBuf8 TMediaSerialNumber; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains information about the code and data sections belonging to a process. williamr@2: williamr@2: @see RProcess::GetMemoryInfo williamr@2: */ williamr@2: class TProcessMemoryInfo williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The code base address (.text). williamr@2: */ williamr@2: TUint32 iCodeBase; williamr@2: williamr@2: williamr@2: /** williamr@2: The size of the code section (.text). williamr@2: */ williamr@2: TUint32 iCodeSize; williamr@2: williamr@2: williamr@2: /** williamr@2: The base address of the constant data section (.radata). williamr@2: */ williamr@2: TUint32 iConstDataBase; williamr@2: williamr@2: williamr@2: /** williamr@2: The size of the constant data section (.radata). williamr@2: */ williamr@2: williamr@2: TUint32 iConstDataSize; williamr@2: williamr@2: williamr@2: /** williamr@2: The base address of the initialised data section (.data). williamr@2: */ williamr@2: TUint32 iInitialisedDataBase; williamr@2: williamr@2: williamr@2: /** williamr@2: The size of the initialised data section (.data). williamr@2: */ williamr@2: TUint32 iInitialisedDataSize; williamr@2: williamr@2: williamr@2: /** williamr@2: The base address of the uninitialised data section (.bss). williamr@2: */ williamr@2: TUint32 iUninitialisedDataBase; williamr@2: williamr@2: williamr@2: /** williamr@2: The size of the uninitialised data section (.bss). williamr@2: */ williamr@2: TUint32 iUninitialisedDataSize; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a more useful synonym for TProcessMemoryInfo. williamr@2: */ williamr@2: typedef TProcessMemoryInfo TModuleMemoryInfo; // more accurate name - remove old one later williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: class CBase; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Generic array. williamr@2: williamr@2: This class defines a generic array which can be constructed by any of the williamr@2: following templated concrete arrays: williamr@2: williamr@2: 1. CArrayFixFlat williamr@2: williamr@2: 2. CArrayFixSeg williamr@2: williamr@2: 3. CArrayVarFlat williamr@2: williamr@2: 4. CArrayVarSeg williamr@2: williamr@2: 5. CArrayPakFlat williamr@2: williamr@2: 6. RArray williamr@2: williamr@2: 7. RPointerArray williamr@2: williamr@2: and also by the following template specialisation classes: williamr@2: williamr@2: 1. RArray williamr@2: williamr@2: 2. RArray williamr@2: williamr@2: It allows a degree of polymorphism amongst the array classes. It permits the williamr@2: operator[] and the Count() member functions of an array to be invoked without williamr@2: knowing which array class has been used to construct that array. williamr@2: williamr@2: TArray allows access to elements of an array but does not permit changes to williamr@2: those elements. williamr@2: williamr@2: Use the Array() member function of an array to construct and return williamr@2: a TArray object for that array. williamr@2: williamr@2: A TArray type object is not intended to be constructed explicitly williamr@2: by user code. williamr@2: williamr@2: @see CArrayFixFlat williamr@2: @see CArrayFixSeg williamr@2: @see CArrayVarFlat williamr@2: @see CArrayVarSeg williamr@2: @see CArrayPakFlat williamr@2: @see RArray williamr@2: @see RPointerArray williamr@2: @see RArray williamr@2: @see RArray williamr@2: */ williamr@2: template williamr@2: class TArray williamr@2: { williamr@2: public: williamr@2: inline TArray(TInt (*aCount)(const CBase* aPtr),const TAny*(*anAt)(const CBase* aPtr,TInt anIndex),const CBase* aPtr); williamr@2: inline TInt Count() const; williamr@2: inline const T& operator[](TInt anIndex) const; williamr@2: private: williamr@2: const CBase* iPtr; williamr@2: TInt (*iCount)(const CBase* aPtr); williamr@2: const TAny*(*iAt)(const CBase* aPtr,TInt anIndex); williamr@2: }; williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a function type used by a TIdentityRelation object. williamr@2: williamr@2: A function of this type implements an algorithm for determining whether williamr@2: two objects match. williamr@2: williamr@2: @see TIdentityRelation williamr@2: */ williamr@2: typedef TBool (*TGeneralIdentityRelation)(const TAny*, const TAny*); williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines a function type used by a TLinearOrder object williamr@2: williamr@2: A function of this type implements an algorithm that determines williamr@2: the order of two objects. williamr@2: williamr@2: @see TLinearOrder williamr@2: */ williamr@2: typedef TInt (*TGeneralLinearOrder)(const TAny*, const TAny*); williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A templated class which packages a function that determines whether two williamr@2: objects of a given class type match. During linear search operations the search williamr@2: term is always passed as the first argument and the second argument is an williamr@2: element of the array being searched. williamr@2: williamr@2: A TIdentityRelation object is constructed and passed as a parameter to williamr@2: member functions of the array classes RArray and RPointerArray. williamr@2: williamr@2: @see RArray williamr@2: @see RPointerArray williamr@2: */ williamr@2: template williamr@2: class TIdentityRelation williamr@2: { williamr@2: public: williamr@4: inline TIdentityRelation(); williamr@2: inline TIdentityRelation( TBool (*anIdentity)(const T&, const T&) ); williamr@2: inline operator TGeneralIdentityRelation() const; williamr@2: private: williamr@4: inline static TBool EqualityOperatorCompare(const T& aLeft, const T& aRight); williamr@4: private: williamr@2: TGeneralIdentityRelation iIdentity; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A set of common identity relations for frequently occurring types. williamr@2: williamr@2: @see RArray williamr@2: @see RPointerArray williamr@2: @see RHashSet williamr@2: @see RPtrHashSet williamr@2: @see RHashMap williamr@2: @see RPtrHashMap williamr@2: */ williamr@2: class DefaultIdentity williamr@2: { williamr@2: public: williamr@2: IMPORT_C static TBool Integer(const TInt&, const TInt&); williamr@2: IMPORT_C static TBool Des8(const TDesC8&, const TDesC8&); williamr@2: IMPORT_C static TBool Des16(const TDesC16&, const TDesC16&); williamr@2: IMPORT_C static TBool IntegerPtr(TInt* const&, TInt* const&); williamr@2: IMPORT_C static TBool Des8Ptr(TDesC8* const&, TDesC8* const&); williamr@2: IMPORT_C static TBool Des16Ptr(TDesC16* const&, TDesC16* const&); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A templated class which packages a function that determines the order of two williamr@2: objects of a given class type. During binary search operations the search term williamr@2: is always passed as the first argument and the second argument is an element williamr@2: of the array being searched. williamr@2: williamr@2: A TLinearOrder object is constructed and passed as a parameter to member williamr@2: functions of the array classes RArray and RPointerArray. williamr@2: williamr@2: @see RArray williamr@2: @see RPointerArray williamr@2: */ williamr@2: template williamr@2: class TLinearOrder williamr@2: { williamr@2: public: williamr@2: inline TLinearOrder( TInt(*anOrder)(const T&, const T&) ); williamr@2: inline operator TGeneralLinearOrder() const; williamr@2: private: williamr@2: TGeneralLinearOrder iOrder; williamr@2: }; williamr@2: williamr@2: williamr@2: /* williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A set of values that tell array search functions which array element is to be williamr@2: returned when there are duplicate elements in the array. williamr@2: williamr@2: These values are used by RArray, RPointerArray, RArray, williamr@2: and RArray search functions. williamr@2: williamr@2: Examples of functions that take williamr@2: these enum values are: RPointerArray::SpecificFindInOrderL(), williamr@2: and RArray::SpecificFindInSignedKeyOrder(). williamr@2: williamr@2: @see RArray williamr@2: @see RPointerArray williamr@2: @see RArray williamr@2: @see RArray williamr@2: */ williamr@2: enum TArrayFindMode williamr@2: { williamr@2: /** williamr@2: Indicates that any element in a block of duplicate elements can be williamr@2: returned by a search function. williamr@2: williamr@2: Note that using this mode, there can be no guarantee that the element williamr@2: returned by the search functions will be the same if the size of the array williamr@2: changes between successive calls to those functions. williamr@2: */ williamr@2: EArrayFindMode_Any = 0, williamr@2: williamr@2: /** williamr@2: Indicates that the first element in a block of duplicate elements williamr@2: is returned. williamr@2: */ williamr@2: EArrayFindMode_First = 1, williamr@2: williamr@2: /** williamr@2: Indicates that the first element after the last element in a block williamr@2: of duplicate elements is returned. williamr@2: */ williamr@2: EArrayFindMode_Last = 2, williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: EArrayFindMode_Limit = 3 williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: williamr@2: Base class used in the derivation of RPointerArray, RArray, williamr@2: and RArray. williamr@2: williamr@2: The base class is inherited privately. williamr@2: williamr@2: The class is internal and is not intended for use. williamr@2: */ williamr@2: class RPointerArrayBase williamr@2: { williamr@2: protected: williamr@2: IMPORT_C RPointerArrayBase(); williamr@2: IMPORT_C RPointerArrayBase(TInt aGranularity); williamr@2: IMPORT_C RPointerArrayBase(TInt aMinGrowBy, TInt aFactor); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TInt Count() const; williamr@2: inline void ZeroCount() {iCount=0;} williamr@2: inline TAny** Entries() {return iEntries;} williamr@2: IMPORT_C TAny*& At(TInt anIndex) const; williamr@2: IMPORT_C TInt Append(const TAny* anEntry); williamr@2: IMPORT_C TInt Insert(const TAny* anEntry, TInt aPos); williamr@2: IMPORT_C void Remove(TInt anIndex); williamr@2: IMPORT_C void Compress(); williamr@2: IMPORT_C void Reset(); williamr@2: IMPORT_C TInt Find(const TAny* anEntry) const; williamr@2: IMPORT_C TInt Find(const TAny* anEntry, TGeneralIdentityRelation anIdentity) const; williamr@2: IMPORT_C TInt FindReverse(const TAny* aEntry) const; williamr@2: IMPORT_C TInt FindReverse(const TAny* aEntry, TGeneralIdentityRelation aIdentity) const; williamr@2: IMPORT_C TInt FindIsqSigned(TInt anEntry) const; williamr@2: IMPORT_C TInt FindIsqUnsigned(TUint anEntry) const; williamr@2: IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const; williamr@2: IMPORT_C TInt FindIsqSigned(TInt anEntry, TInt aMode) const; williamr@2: IMPORT_C TInt FindIsqUnsigned(TUint anEntry, TInt aMode) const; williamr@2: IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TInt aMode) const; williamr@2: IMPORT_C TInt InsertIsqSigned(TInt anEntry, TBool aAllowRepeats); williamr@2: IMPORT_C TInt InsertIsqUnsigned(TUint anEntry, TBool aAllowRepeats); williamr@2: IMPORT_C TInt InsertIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TBool aAllowRepeats); williamr@2: IMPORT_C TInt BinarySearchSigned(TInt anEntry, TInt& anIndex) const; williamr@2: IMPORT_C TInt BinarySearchUnsigned(TUint anEntry, TInt& anIndex) const; williamr@2: IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder) const; williamr@2: IMPORT_C TInt BinarySearchSigned(TInt anEntry, TInt& anIndex, TInt aMode) const; williamr@2: IMPORT_C TInt BinarySearchUnsigned(TUint anEntry, TInt& anIndex, TInt aMode) const; williamr@2: IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder, TInt aMode) const; williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C RPointerArrayBase(TAny** aEntries, TInt aCount); williamr@2: IMPORT_C void GranularCompress(); williamr@2: IMPORT_C TInt DoReserve(TInt aCount); williamr@2: IMPORT_C void HeapSortSigned(); williamr@2: IMPORT_C void HeapSortUnsigned(); williamr@2: IMPORT_C void HeapSort(TGeneralLinearOrder anOrder); williamr@2: IMPORT_C static TInt GetCount(const CBase* aPtr); williamr@2: IMPORT_C static const TAny* GetElementPtr(const CBase* aPtr, TInt aIndex); williamr@2: #endif williamr@2: private: williamr@2: TInt Grow(); williamr@2: private: williamr@2: TInt iCount; williamr@2: TAny** iEntries; williamr@2: TInt iAllocated; williamr@2: TInt iGranularity; // positive means linear, negative means exponential growth williamr@2: TInt iSpare1; williamr@2: TInt iSpare2; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A simple and efficient array of pointers to objects. williamr@2: williamr@2: The elements of the array are pointers to instances of a class; this class williamr@2: is specified as the template parameter T. williamr@2: williamr@2: The class offers standard array behaviour which includes insertion, appending williamr@2: and sorting of pointers. williamr@2: williamr@2: Derivation from RPointerArrayBase is private. williamr@2: */ williamr@2: template williamr@2: class RPointerArray : private RPointerArrayBase williamr@2: { williamr@2: public: williamr@2: inline RPointerArray(); williamr@2: inline explicit RPointerArray(TInt aGranularity); williamr@2: inline RPointerArray(TInt aMinGrowBy, TInt aFactor); williamr@2: inline void Close(); williamr@2: inline TInt Count() const; williamr@2: inline T* const& operator[](TInt anIndex) const; williamr@2: inline T*& operator[](TInt anIndex); williamr@2: inline TInt Append(const T* anEntry); williamr@2: inline TInt Insert(const T* anEntry, TInt aPos); williamr@2: inline void Remove(TInt anIndex); williamr@2: inline void Compress(); williamr@2: inline void Reset(); williamr@2: void ResetAndDestroy(); williamr@2: inline TInt Find(const T* anEntry) const; williamr@2: inline TInt Find(const T* anEntry, TIdentityRelation anIdentity) const; williamr@2: template williamr@2: inline TInt Find(const K& aKey, TBool (*apfnCompare)(const K* k, const T& t)) const williamr@2: /** williamr@2: Finds the first object pointer in the array which matches aKey using williamr@2: the comparison algorithm provided by apfnCompare. williamr@2: williamr@2: The find operation always starts at the low index end of the array. There williamr@2: is no assumption about the order of objects in the array. williamr@2: williamr@2: @param aKey The key of type K to be compared with the elements of the array using apfnCompare. williamr@2: @param apfnCompare A function defining the identity relation between the williamr@2: object pointers in the array, and their keys of type K. The williamr@2: function returns true if k and t match based on this relationship. williamr@2: williamr@2: @return The index of the first matching object pointer within the array. williamr@2: KErrNotFound, if no suitable object pointer can be found. williamr@2: */ williamr@2: { return RPointerArrayBase::Find((T*)&aKey,*(TIdentityRelation*)&apfnCompare); } williamr@2: inline TInt FindReverse(const T* anEntry) const; williamr@2: inline TInt FindReverse(const T* anEntry, TIdentityRelation anIdentity) const; williamr@2: template williamr@2: inline TInt FindReverse(const K& aKey, TInt (*apfnMatch)(const K* k, const T& t)) const williamr@2: /** williamr@2: Finds the first object pointer in the array which matches aKey using williamr@2: the comparison algorithm provided by apfnCompare. williamr@2: williamr@2: The find operation always starts at the high index end of the array. There williamr@2: is no assumption about the order of objects in the array. williamr@2: williamr@2: @param aKey The key of type K to be compared with the elements of the array using apfnMatch. williamr@2: @param apfnMatch A function defining the identity relation between the williamr@2: object pointers in the array, and their keys of type K. The williamr@2: function returns true if k and t match based on this relationship. williamr@2: williamr@2: @return The index of the first matching object pointer within the array. williamr@2: KErrNotFound, if no suitable object pointer can be found. williamr@2: */ williamr@2: williamr@2: { return RPointerArrayBase::FindReverse((T*)&aKey,*(TIdentityRelation*)&apfnMatch); } williamr@2: inline TInt FindInAddressOrder(const T* anEntry) const; williamr@2: inline TInt FindInOrder(const T* anEntry, TLinearOrder anOrder) const; williamr@2: inline TInt FindInAddressOrder(const T* anEntry, TInt& anIndex) const; williamr@2: inline TInt FindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder anOrder) const; williamr@2: template williamr@2: inline TInt FindInOrder(const K& aKey, TInt (*apfnCompare)(const K* k, const T& t)) const williamr@2: /** williamr@2: Finds the object pointer in the array whose object matches the specified williamr@2: key, (Using the relationship defined within apfnCompare) using a binary search williamr@2: technique and an ordering algorithm. williamr@2: williamr@2: The function assumes that existing object pointers in the array are ordered williamr@2: so that the objects themselves are in object order as determined by an algorithm williamr@2: supplied by the caller and packaged as a TLinearOrder. williamr@2: williamr@2: @param aKey The key of type K to be compared with the elements of the array using apfnCompare. williamr@2: @param apfnCompare A function which defines the order that the array was sorted, williamr@2: where in it aKey (via the defined relationship) should fit, and if the key is present. williamr@2: williamr@2: @return The index of the matching object pointer within the array. williamr@2: KErrNotFound, if no suitable object pointer can be found. williamr@2: */ williamr@2: { return RPointerArrayBase::FindIsq((T*)&aKey,*(TLinearOrder*)&apfnCompare); } williamr@2: inline TInt SpecificFindInAddressOrder(const T* anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrder(const T* anEntry, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline TInt SpecificFindInAddressOrder(const T* anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrder(const T* anEntry, TInt& anIndex, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline TInt InsertInAddressOrder(const T* anEntry); williamr@2: inline TInt InsertInOrder(const T* anEntry, TLinearOrder anOrder); williamr@2: inline TInt InsertInAddressOrderAllowRepeats(const T* anEntry); williamr@2: inline TInt InsertInOrderAllowRepeats(const T* anEntry, TLinearOrder anOrder); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void AppendL(const T* anEntry); williamr@2: inline void InsertL(const T* anEntry, TInt aPos); williamr@2: inline TInt FindL(const T* anEntry) const; williamr@2: inline TInt FindL(const T* anEntry, TIdentityRelation anIdentity) const; williamr@2: inline TInt FindReverseL(const T* anEntry) const; williamr@2: inline TInt FindReverseL(const T* anEntry, TIdentityRelation anIdentity) const; williamr@2: inline TInt FindInAddressOrderL(const T* anEntry) const; williamr@2: inline TInt FindInOrderL(const T* anEntry, TLinearOrder anOrder) const; williamr@2: inline void FindInAddressOrderL(const T* anEntry, TInt& anIndex) const; williamr@2: inline void FindInOrderL(const T* anEntry, TInt& anIndex, TLinearOrder anOrder) const; williamr@2: inline TInt SpecificFindInAddressOrderL(const T* anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrderL(const T* anEntry, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline void SpecificFindInAddressOrderL(const T* anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline void SpecificFindInOrderL(const T* anEntry, TInt& anIndex, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline void InsertInAddressOrderL(const T* anEntry); williamr@2: inline void InsertInOrderL(const T* anEntry, TLinearOrder anOrder); williamr@2: inline void InsertInAddressOrderAllowRepeatsL(const T* anEntry); williamr@2: inline void InsertInOrderAllowRepeatsL(const T* anEntry, TLinearOrder anOrder); williamr@2: williamr@2: inline RPointerArray(T** aEntries, TInt aCount); williamr@2: inline void GranularCompress(); williamr@2: inline TInt Reserve(TInt aCount); williamr@2: inline void ReserveL(TInt aCount); williamr@2: inline void SortIntoAddressOrder(); williamr@2: inline void Sort(TLinearOrder anOrder); williamr@2: inline TArray Array() const; williamr@2: #endif williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Array of raw pointers. williamr@2: williamr@2: The array is a simple and efficient specialized array of TAny pointers offering williamr@2: standard array behaviour. williamr@2: williamr@2: The derivation from RPointerArrayBase is private. williamr@2: */ williamr@2: TEMPLATE_SPECIALIZATION class RPointerArray : private RPointerArrayBase williamr@2: { williamr@2: public: williamr@2: inline RPointerArray(); williamr@2: inline explicit RPointerArray(TInt aGranularity); williamr@2: inline RPointerArray(TInt aMinGrowBy, TInt aFactor); williamr@2: inline void Close(); williamr@2: inline TInt Count() const; williamr@2: inline TAny* const& operator[](TInt anIndex) const; williamr@2: inline TAny*& operator[](TInt anIndex); williamr@2: inline TInt Append(const TAny* anEntry); williamr@2: inline TInt Insert(const TAny* anEntry, TInt aPos); williamr@2: inline void Remove(TInt anIndex); williamr@2: inline void Compress(); williamr@2: inline void Reset(); williamr@2: inline TInt Find(const TAny* anEntry) const; williamr@2: inline TInt FindReverse(const TAny* anEntry) const; williamr@2: inline TInt FindInAddressOrder(const TAny* anEntry) const; williamr@2: inline TInt FindInAddressOrder(const TAny* anEntry, TInt& anIndex) const; williamr@2: inline TInt SpecificFindInAddressOrder(const TAny* anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInAddressOrder(const TAny* anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline TInt InsertInAddressOrder(const TAny* anEntry); williamr@2: inline TInt InsertInAddressOrderAllowRepeats(const TAny* anEntry); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void AppendL(const TAny* anEntry); williamr@2: inline void InsertL(const TAny* anEntry, TInt aPos); williamr@2: inline TInt FindL(const TAny* anEntry) const; williamr@2: inline TInt FindReverseL(const TAny* anEntry) const; williamr@2: inline TInt FindInAddressOrderL(const TAny* anEntry) const; williamr@2: inline void FindInAddressOrderL(const TAny* anEntry, TInt& anIndex) const; williamr@2: inline TInt SpecificFindInAddressOrderL(const TAny* anEntry, TInt aMode) const; williamr@2: inline void SpecificFindInAddressOrderL(const TAny* anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline void InsertInAddressOrderL(const TAny* anEntry); williamr@2: inline void InsertInAddressOrderAllowRepeatsL(const TAny* anEntry); williamr@2: williamr@2: inline RPointerArray(TAny** aEntries, TInt aCount); williamr@2: inline void GranularCompress(); williamr@2: inline void SortIntoAddressOrder(); williamr@2: inline TArray Array() const; williamr@2: #endif williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: williamr@2: Base class used in the derivation of RArray. williamr@2: williamr@2: The base class is inherited privately. williamr@2: williamr@2: The class is internal and is not intended for use. williamr@2: */ williamr@2: class RArrayBase williamr@2: { williamr@2: protected: williamr@2: IMPORT_C RArrayBase(TInt anEntrySize); williamr@2: IMPORT_C RArrayBase(TInt anEntrySize, TInt aGranularity); williamr@2: IMPORT_C RArrayBase(TInt anEntrySize, TInt aGranularity, TInt aKeyOffset); williamr@2: IMPORT_C RArrayBase(TInt anEntrySize, TInt aMinGrowBy, TInt aKeyOffset, TInt aFactor); williamr@2: IMPORT_C RArrayBase(TInt aEntrySize,TAny* aEntries, TInt aCount); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TInt Count() const; williamr@2: IMPORT_C TAny* At(TInt anIndex) const; williamr@2: IMPORT_C TInt Append(const TAny* anEntry); williamr@2: IMPORT_C TInt Insert(const TAny* anEntry, TInt aPos); williamr@2: IMPORT_C void Remove(TInt anIndex); williamr@2: IMPORT_C void Compress(); williamr@2: IMPORT_C void Reset(); williamr@2: IMPORT_C TInt Find(const TAny* anEntry) const; williamr@2: IMPORT_C TInt Find(const TAny* anEntry, TGeneralIdentityRelation anIdentity) const; williamr@2: IMPORT_C TInt FindReverse(const TAny* aEntry) const; williamr@2: IMPORT_C TInt FindReverse(const TAny* aEntry, TGeneralIdentityRelation aIdentity) const; williamr@2: IMPORT_C TInt FindIsqSigned(const TAny* anEntry) const; williamr@2: IMPORT_C TInt FindIsqUnsigned(const TAny* anEntry) const; williamr@2: IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const; williamr@2: IMPORT_C TInt FindIsqSigned(const TAny* anEntry, TInt aMode) const; williamr@2: IMPORT_C TInt FindIsqUnsigned(const TAny* anEntry, TInt aMode) const; williamr@2: IMPORT_C TInt FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TInt aMode) const; williamr@2: IMPORT_C TInt InsertIsqSigned(const TAny* anEntry, TBool aAllowRepeats); williamr@2: IMPORT_C TInt InsertIsqUnsigned(const TAny* anEntry, TBool aAllowRepeats); williamr@2: IMPORT_C TInt InsertIsq(const TAny* anEntry, TGeneralLinearOrder anOrder, TBool aAllowRepeats); williamr@2: IMPORT_C TInt BinarySearchSigned(const TAny* anEntry, TInt& anIndex) const; williamr@2: IMPORT_C TInt BinarySearchUnsigned(const TAny* anEntry, TInt& anIndex) const; williamr@2: IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder) const; williamr@2: IMPORT_C TInt BinarySearchSigned(const TAny* anEntry, TInt& anIndex, TInt aMode) const; williamr@2: IMPORT_C TInt BinarySearchUnsigned(const TAny* anEntry, TInt& anIndex, TInt aMode) const; williamr@2: IMPORT_C TInt BinarySearch(const TAny* anEntry, TInt& anIndex, TGeneralLinearOrder anOrder, TInt aMode) const; williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C void GranularCompress(); williamr@2: IMPORT_C TInt DoReserve(TInt aCount); williamr@2: IMPORT_C void HeapSortSigned(); williamr@2: IMPORT_C void HeapSortUnsigned(); williamr@2: IMPORT_C void HeapSort(TGeneralLinearOrder anOrder); williamr@2: IMPORT_C static TInt GetCount(const CBase* aPtr); williamr@2: IMPORT_C static const TAny* GetElementPtr(const CBase* aPtr, TInt aIndex); williamr@2: #endif williamr@2: private: williamr@2: TInt Grow(); williamr@2: private: williamr@2: TInt iCount; williamr@2: TAny* iEntries; williamr@2: TInt iEntrySize; williamr@2: TInt iKeyOffset; williamr@2: TInt iAllocated; williamr@2: TInt iGranularity; // positive means linear, negative means exponential growth williamr@2: TInt iSpare1; williamr@2: TInt iSpare2; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A simple and efficient array of fixed length objects. williamr@2: williamr@2: The elements of the array are instances of a class; this class is specified williamr@2: as the template parameter T. williamr@2: williamr@2: The array offers standard array behaviour which includes insertion, appending williamr@2: and sorting of elements. williamr@2: williamr@2: Note: williamr@2: williamr@2: 1. where possible, this class should be used in preference to williamr@2: CArrayFixFlat. williamr@2: williamr@2: 2. the derivation from RArrayBase is private. williamr@2: williamr@2: 3. for performance reasons, RArray stores objects in the array as williamr@2: word (4 byte) aligned quantities. This means that some member functions williamr@2: do not work when RArray is instantiated for classes of less than 4 bytes williamr@2: in size, or when the class's alignment requirement is not 4. williamr@2: Be aware that it is possible to get an unhandled exception on hardware williamr@2: that enforces strict alignment. williamr@2: williamr@2: The affected functions are: williamr@2: williamr@2: 3.1 the constructor: RArray(TInt, T*, TInt) williamr@2: williamr@2: 3.2 Append(const T&) williamr@2: williamr@2: 3.3 Insert(const T&, TInt) williamr@2: williamr@2: 3.4 the [] operator, and then using the pointer to iterate through williamr@2: the array as you would with a C array. williamr@2: */ williamr@2: template williamr@2: class RArray : private RArrayBase williamr@2: { williamr@2: public: williamr@2: inline RArray(); williamr@2: inline explicit RArray(TInt aGranularity); williamr@2: inline RArray(TInt aGranularity, TInt aKeyOffset); williamr@2: inline RArray(TInt aMinGrowBy, TInt aKeyOffset, TInt aFactor); williamr@2: inline RArray(TInt aEntrySize,T* aEntries, TInt aCount); williamr@2: inline void Close(); williamr@2: inline TInt Count() const; williamr@2: inline const T& operator[](TInt anIndex) const; williamr@2: inline T& operator[](TInt anIndex); williamr@2: inline TInt Append(const T& anEntry); williamr@2: inline TInt Insert(const T& anEntry, TInt aPos); williamr@2: inline void Remove(TInt anIndex); williamr@2: inline void Compress(); williamr@2: inline void Reset(); williamr@2: inline TInt Find(const T& anEntry) const; williamr@2: inline TInt Find(const T& anEntry, TIdentityRelation anIdentity) const; williamr@2: template williamr@2: inline TInt Find(const K& aKey, TBool (*apfnCompare)(const K* k, const T& t)) const williamr@2: /** williamr@2: Finds the first object in the array which matches aKey using williamr@2: the comparison algorithm provided by apfnCompare. williamr@2: williamr@2: The find operation always starts at the low index end of the array. There williamr@2: is no assumption about the order of objects in the array. williamr@2: williamr@2: @param aKey The key of type K to be compared with the elements of the array using apfnCompare. williamr@2: @param apfnCompare A function defining the identity relation between the williamr@2: object in the array, and their keys of type K. The function williamr@2: returns true if k and t match based on this relationship. williamr@2: williamr@2: @return The index of the first matching object within the array. williamr@2: KErrNotFound, if no suitable object can be found. williamr@2: */ williamr@2: { return RArrayBase::Find((T*)&aKey,*(TIdentityRelation*)&apfnCompare); } williamr@2: inline TInt FindReverse(const T& anEntry) const; williamr@2: inline TInt FindReverse(const T& anEntry, TIdentityRelation anIdentity) const; williamr@2: template williamr@2: inline TInt FindReverse(const K& aKey, TInt (*apfnMatch)(const K* k, const T& t)) const williamr@2: /** williamr@2: Finds the first object in the array which matches aKey using the comparison williamr@2: algorithm provided by apfnCompare. williamr@2: williamr@2: The find operation always starts at the high index end of the array. There williamr@2: is no assumption about the order of objects in the array. williamr@2: williamr@2: @param aKey The key of type K to be compared with the elements of the array using apfnMatch. williamr@2: @param apfnMatch A function defining the identity relation between the williamr@2: object in the array, and their keys of type K. The function williamr@2: returns true if k and t match based on this relationship. williamr@2: williamr@2: @return The index of the first matching object within the array. williamr@2: KErrNotFound, if no suitable object can be found. williamr@2: */ williamr@2: { return RArrayBase::FindReverse((T*)&aKey,*(TIdentityRelation*)&apfnMatch); } williamr@2: inline TInt FindInSignedKeyOrder(const T& anEntry) const; williamr@2: inline TInt FindInUnsignedKeyOrder(const T& anEntry) const; williamr@2: inline TInt FindInOrder(const T& anEntry, TLinearOrder anOrder) const; williamr@2: inline TInt FindInSignedKeyOrder(const T& anEntry, TInt& anIndex) const; williamr@2: inline TInt FindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex) const; williamr@2: inline TInt FindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder anOrder) const; williamr@2: template williamr@2: inline TInt FindInOrder(const K& aKey, TInt (*apfnCompare)(const K* k, const T& t)) const williamr@2: /** williamr@2: Finds the object in the array whose object matches the specified williamr@2: key, (Using the relationship defined within apfnCompare) using a binary search williamr@2: technique and an ordering algorithm. williamr@2: williamr@2: The function assumes that existing objects in the array are ordered so williamr@2: that the objects themselves are in object order as determined by an algorithm williamr@2: supplied by the caller and packaged as a TLinearOrder. williamr@2: williamr@2: @param aKey The key of type K to be compared with the elements of the array using apfnCompare. williamr@2: @param apfnCompare A function which defines the order that the array was sorted, williamr@2: where in it aKey (via the defined relationship) should fit, and if the key is present. williamr@2: williamr@2: @return The index of the matching object within the array. williamr@2: KErrNotFound, if no suitable object can be found. williamr@2: */ williamr@2: williamr@2: { return RArrayBase::FindIsq((T*)&aKey,*(TLinearOrder*)&apfnCompare); } williamr@2: inline TInt SpecificFindInSignedKeyOrder(const T& anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrder(const T& anEntry, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline TInt SpecificFindInSignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline TInt SpecificFindInUnsignedKeyOrder(const T& anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrder(const T& anEntry, TInt& anIndex, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline TInt InsertInSignedKeyOrder(const T& anEntry); williamr@2: inline TInt InsertInUnsignedKeyOrder(const T& anEntry); williamr@2: inline TInt InsertInOrder(const T& anEntry, TLinearOrder anOrder); williamr@2: inline TInt InsertInSignedKeyOrderAllowRepeats(const T& anEntry); williamr@2: inline TInt InsertInUnsignedKeyOrderAllowRepeats(const T& anEntry); williamr@2: inline TInt InsertInOrderAllowRepeats(const T& anEntry, TLinearOrder anOrder); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void AppendL(const T& anEntry); williamr@2: inline void InsertL(const T& anEntry, TInt aPos); williamr@2: inline TInt FindL(const T& anEntry) const; williamr@2: inline TInt FindL(const T& anEntry, TIdentityRelation anIdentity) const; williamr@2: inline TInt FindReverseL(const T& anEntry) const; williamr@2: inline TInt FindReverseL(const T& anEntry, TIdentityRelation anIdentity) const; williamr@2: inline TInt FindInSignedKeyOrderL(const T& anEntry) const; williamr@2: inline TInt FindInUnsignedKeyOrderL(const T& anEntry) const; williamr@2: inline TInt FindInOrderL(const T& anEntry, TLinearOrder anOrder) const; williamr@2: inline void FindInSignedKeyOrderL(const T& anEntry, TInt& anIndex) const; williamr@2: inline void FindInUnsignedKeyOrderL(const T& anEntry, TInt& anIndex) const; williamr@2: inline void FindInOrderL(const T& anEntry, TInt& anIndex, TLinearOrder anOrder) const; williamr@2: inline TInt SpecificFindInSignedKeyOrderL(const T& anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInUnsignedKeyOrderL(const T& anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrderL(const T& anEntry, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline void SpecificFindInSignedKeyOrderL(const T& anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline void SpecificFindInUnsignedKeyOrderL(const T& anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline void SpecificFindInOrderL(const T& anEntry, TInt& anIndex, TLinearOrder anOrder, TInt aMode) const; williamr@2: inline void InsertInSignedKeyOrderL(const T& anEntry); williamr@2: inline void InsertInUnsignedKeyOrderL(const T& anEntry); williamr@2: inline void InsertInOrderL(const T& anEntry, TLinearOrder anOrder); williamr@2: inline void InsertInSignedKeyOrderAllowRepeatsL(const T& anEntry); williamr@2: inline void InsertInUnsignedKeyOrderAllowRepeatsL(const T& anEntry); williamr@2: inline void InsertInOrderAllowRepeatsL(const T& anEntry, TLinearOrder anOrder); williamr@2: williamr@2: inline void GranularCompress(); williamr@2: inline TInt Reserve(TInt aCount); williamr@2: inline void ReserveL(TInt aCount); williamr@2: inline void SortSigned(); williamr@2: inline void SortUnsigned(); williamr@2: inline void Sort(TLinearOrder anOrder); williamr@2: inline TArray Array() const; williamr@2: #endif williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A simple and efficient specialized array of signed integers offering standard williamr@2: array behaviour. williamr@2: williamr@2: Note that derivation from RPointerArrayBase is private. williamr@2: */ williamr@2: TEMPLATE_SPECIALIZATION class RArray : private RPointerArrayBase williamr@2: { williamr@2: public: williamr@2: inline RArray(); williamr@2: inline explicit RArray(TInt aGranularity); williamr@2: inline RArray(TInt aMinGrowBy, TInt aFactor); williamr@2: inline void Close(); williamr@2: inline TInt Count() const; williamr@2: inline const TInt& operator[](TInt anIndex) const; williamr@2: inline TInt& operator[](TInt anIndex); williamr@2: inline TInt Append(TInt anEntry); williamr@2: inline TInt Insert(TInt anEntry, TInt aPos); williamr@2: inline void Remove(TInt anIndex); williamr@2: inline void Compress(); williamr@2: inline void Reset(); williamr@2: inline TInt Find(TInt anEntry) const; williamr@2: inline TInt FindReverse(TInt anEntry) const; williamr@2: inline TInt FindInOrder(TInt anEntry) const; williamr@2: inline TInt FindInOrder(TInt anEntry, TInt& anIndex) const; williamr@2: inline TInt SpecificFindInOrder(TInt anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrder(TInt anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline TInt InsertInOrder(TInt anEntry); williamr@2: inline TInt InsertInOrderAllowRepeats(TInt anEntry); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void AppendL(TInt anEntry); williamr@2: inline void InsertL(TInt anEntry, TInt aPos); williamr@2: inline TInt FindL(TInt anEntry) const; williamr@2: inline TInt FindReverseL(TInt anEntry) const; williamr@2: inline TInt FindInOrderL(TInt anEntry) const; williamr@2: inline void FindInOrderL(TInt anEntry, TInt& anIndex) const; williamr@2: inline TInt SpecificFindInOrderL(TInt anEntry, TInt aMode) const; williamr@2: inline void SpecificFindInOrderL(TInt anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline void InsertInOrderL(TInt anEntry); williamr@2: inline void InsertInOrderAllowRepeatsL(TInt anEntry); williamr@2: williamr@2: inline RArray(TInt* aEntries, TInt aCount); williamr@2: inline void GranularCompress(); williamr@2: inline TInt Reserve(TInt aCount); williamr@2: inline void ReserveL(TInt aCount); williamr@2: inline void Sort(); williamr@2: inline TArray Array() const; williamr@2: #endif williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Array of unsigned integers. williamr@2: williamr@2: The array is a simple and efficient specialized array of unsigned integers williamr@2: offering standard array behaviour. williamr@2: williamr@2: The derivation from RPointerArrayBase is private. williamr@2: */ williamr@2: TEMPLATE_SPECIALIZATION class RArray : private RPointerArrayBase williamr@2: { williamr@2: public: williamr@2: inline RArray(); williamr@2: inline explicit RArray(TInt aGranularity); williamr@2: inline RArray(TInt aMinGrowBy, TInt aFactor); williamr@2: inline void Close(); williamr@2: inline TInt Count() const; williamr@2: inline const TUint& operator[](TInt anIndex) const; williamr@2: inline TUint& operator[](TInt anIndex); williamr@2: inline TInt Append(TUint anEntry); williamr@2: inline TInt Insert(TUint anEntry, TInt aPos); williamr@2: inline void Remove(TInt anIndex); williamr@2: inline void Compress(); williamr@2: inline void Reset(); williamr@2: inline TInt Find(TUint anEntry) const; williamr@2: inline TInt FindReverse(TUint anEntry) const; williamr@2: inline TInt FindInOrder(TUint anEntry) const; williamr@2: inline TInt FindInOrder(TUint anEntry, TInt& anIndex) const; williamr@2: inline TInt SpecificFindInOrder(TUint anEntry, TInt aMode) const; williamr@2: inline TInt SpecificFindInOrder(TUint anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline TInt InsertInOrder(TUint anEntry); williamr@2: inline TInt InsertInOrderAllowRepeats(TUint anEntry); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void AppendL(TUint anEntry); williamr@2: inline void InsertL(TUint anEntry, TInt aPos); williamr@2: inline TInt FindL(TUint anEntry) const; williamr@2: inline TInt FindReverseL(TUint anEntry) const; williamr@2: inline TInt FindInOrderL(TUint anEntry) const; williamr@2: inline void FindInOrderL(TUint anEntry, TInt& anIndex) const; williamr@2: inline TInt SpecificFindInOrderL(TUint anEntry, TInt aMode) const; williamr@2: inline void SpecificFindInOrderL(TUint anEntry, TInt& anIndex, TInt aMode) const; williamr@2: inline void InsertInOrderL(TUint anEntry); williamr@2: inline void InsertInOrderAllowRepeatsL(TUint anEntry); williamr@2: williamr@2: inline RArray(TUint* aEntries, TInt aCount); williamr@2: inline void GranularCompress(); williamr@2: inline TInt Reserve(TInt aCount); williamr@2: inline void ReserveL(TInt aCount); williamr@2: inline void Sort(); williamr@2: inline TArray Array() const; williamr@2: #endif williamr@2: }; williamr@2: williamr@2: #ifndef __LEAVE_EQUALS_THROW__ williamr@2: williamr@2: class TTrapHandler; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: class TTrap williamr@2: { williamr@2: public: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: IMPORT_C TInt Trap(TInt& aResult); williamr@2: IMPORT_C static void UnTrap(); williamr@2: #endif williamr@2: public: williamr@2: enum {EMaxState=0x10}; williamr@2: public: williamr@2: TInt iState[EMaxState]; williamr@2: TTrap* iNext; williamr@2: TInt* iResult; williamr@2: TTrapHandler* iHandler; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Executes the set of C++ statements _s under a trap harness. williamr@2: williamr@2: Use this macro as a C++ statement. williamr@2: williamr@2: _r must be a TInt which has already been declared; if any of the williamr@2: C++ statements _s leaves, then the leave code is returned in _r, williamr@2: otherwise _r is set to KErrNone. williamr@2: williamr@2: _s can consist of multiple C++ statements; in theory, _s can consist williamr@2: of any legal C++ code but in practice, such statements consist of simple williamr@2: function calls, e.g. Foo() or an assignment of some value to the result of williamr@2: a function call, e.g. functionValue=GetFoo(). williamr@2: williamr@2: A cleanup stack is constructed for the set of C++ statements _s. williamr@2: If any function in _s leaves, objects pushed to the cleanup stack are williamr@2: cleaned-up. In addition, if any of the C++ statements in _s leaves, williamr@2: then remaining C++ code in _s is not executed and any variables which williamr@2: are assigned within that remaining code are not defined. williamr@2: williamr@2: @param _r An lvalue, convertible to TInt&, which will receive the result of williamr@2: any User::Leave() executed within _s or, if no leave occurred, williamr@2: it will be set to KErrNone. The value of _r on entry is not used. williamr@2: williamr@2: @param _s C++ statements which will be executed under a trap harness. williamr@2: williamr@2: @see TRAPD williamr@2: */ williamr@2: #define TRAP(_r,_s) {TTrap __t;if (__t.Trap(_r)==0){_s;TTrap::UnTrap();}} williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Executes the set of C++ statements _s under a trap harness. williamr@2: williamr@2: Use this macro in the same way as you would TRAP, except that the williamr@2: variable _r is defined as part of the macro (and is therefore valid for the williamr@2: rest of the block in which the macro occurs). Often, this saves a line of code. williamr@2: williamr@2: @param _r A name, which will be declared as a TInt, and will receive the result williamr@2: of any User::Leave() executed within _s or, if no leave occurred, it williamr@2: will be set to KErrNone. After the macro, _r remains in scope until williamr@2: the end of its enclosing block. williamr@2: williamr@2: @param _s C++ statements which will be executed under a trap harness. williamr@2: williamr@2: @see TRAP williamr@2: */ williamr@2: #define TRAPD(_r,_s) TInt _r;{TTrap __t;if (__t.Trap(_r)==0){_s;TTrap::UnTrap();}} williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Executes the set of C++ statements _s under a trap harness. williamr@2: Any leave code generated is ignored. williamr@2: williamr@2: Use this macro as a C++ statement. williamr@2: williamr@2: This macro is functionally equivalent to: williamr@2: @code williamr@2: TInt x; williamr@2: TRAP(x,_s) williamr@2: @endcode williamr@2: or williamr@2: @code williamr@2: TRAPD(x,_s) williamr@2: @endcode williamr@2: where the value in 'x' is not used by any subsequent code. williamr@2: williamr@2: _s can consist of multiple C++ statements; in theory, _s can consist williamr@2: of any legal C++ code but in practice, such statements consist of simple williamr@2: function calls, e.g. Foo() or an assignment of some value to the result of williamr@2: a function call, e.g. functionValue=GetFoo(). williamr@2: williamr@2: A cleanup stack is constructed for the set of C++ statements _s. williamr@2: If any function in _s leaves, objects pushed to the cleanup stack are williamr@2: cleaned-up. In addition, if any of the C++ statements in _s leaves, williamr@2: then remaining C++ code in _s is not executed and any variables which williamr@2: are assigned within that remaining code are not defined. williamr@2: williamr@2: @param _s C++ statements which will be executed under a trap harness. williamr@2: williamr@2: @see TRAPD williamr@2: @see TRAP williamr@2: */ williamr@2: #define TRAP_IGNORE(_s) {TInt _ignore;TTrap __t;if (__t.Trap(_ignore)==0){_s;TTrap::UnTrap();}} williamr@2: williamr@2: williamr@2: #else //__LEAVE_EQUALS_THROW__ williamr@2: williamr@2: #ifdef __WINS__ williamr@2: /** @internalComponent */ williamr@2: #define __WIN32SEHTRAP TWin32SEHTrap __trap; __trap.Trap(); williamr@2: /** @internalComponent */ williamr@2: #define __WIN32SEHUNTRAP __trap.UnTrap(); williamr@2: IMPORT_C void EmptyFunction(); williamr@2: #define __CALL_EMPTY_FUNCTION EmptyFunction(); williamr@2: #else // !__WINS__ williamr@2: #define __WIN32SEHTRAP williamr@2: #define __WIN32SEHUNTRAP williamr@2: #define __CALL_EMPTY_FUNCTION williamr@2: #endif //__WINS__ williamr@2: williamr@2: /** williamr@2: This macro is used by the TRAP and TRAPD macros and provides a means williamr@2: of inserting code into uses of these. williamr@2: williamr@2: This macro is invoked before any 'trapped' code is called, and it should be williamr@2: redefined to do whatever task is required. E.g. this code: williamr@2: williamr@2: @code williamr@2: #undef TRAP_INSTRUMENTATION_START williamr@2: #define TRAP_INSTRUMENTATION_START DoMyLoging(__LINE__) williamr@2: @endcode williamr@2: williamr@2: Will cause all subsequent uses of the TRAP macros to behave in an williamr@2: equivalent way to: williamr@2: williamr@2: @code williamr@2: DoMyLoging(__LINE__) williamr@2: TRAP(r,SomeCodeL()); williamr@2: @endcode williamr@2: williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: williamr@2: @see TRAP williamr@2: @see TRAPD williamr@2: */ williamr@2: #define TRAP_INSTRUMENTATION_START williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: This macro is used by the TRAP and TRAPD macros and provides a means williamr@2: of inserting code into uses of these. williamr@2: williamr@2: This macro is invoked if the 'trapped' code did not Leave. williamr@2: E.g. this code: williamr@2: williamr@2: @code williamr@2: #undef TRAP_INSTRUMENTATION_NOLEAVE williamr@2: #define TRAP_INSTRUMENTATION_NOLEAVE DoMyLoging(__LINE__) williamr@2: @endcode williamr@2: williamr@2: Will cause all subsequent uses of the TRAP macros to behave in an williamr@2: equivalent way to: williamr@2: williamr@2: @code williamr@2: TRAP(r,SomeCodeL()); williamr@2: if(r==KErrNone) DoMyLoging(__LINE__); williamr@2: @endcode williamr@2: williamr@2: williamr@2: @param aLine The line number in the C++ source file where the TRAP or TRAPD williamr@2: macro was used. williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: williamr@2: @see TRAP williamr@2: @see TRAPD williamr@2: */ williamr@2: #define TRAP_INSTRUMENTATION_NOLEAVE williamr@2: williamr@2: williamr@2: /** williamr@2: This macro is used by the TRAP and TRAPD macros and provides a means williamr@2: of inserting code into uses of these. williamr@2: williamr@2: This macro is invoked if the 'trapped' code did Leave. E.g. this code: williamr@2: williamr@2: @code williamr@2: #undef TRAP_INSTRUMENTATION_LEAVE williamr@2: #define TRAP_INSTRUMENTATION_LEAVE(aResult) DoMyLoging(aResult,__LINE__) williamr@2: @endcode williamr@2: williamr@2: Will cause all subsequent uses of the TRAP macros to behave in an williamr@2: equivalent way to: williamr@2: williamr@2: @code williamr@2: TRAP(r,SomeCodeL()); williamr@2: if(r!=KErrNone) DoMyLoging(r,__LINE__); williamr@2: @endcode williamr@2: williamr@2: williamr@2: @param aResult A reference to the result value used in the TRAP macro. williamr@2: williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: williamr@2: @see TRAP williamr@2: @see TRAPD williamr@2: */ williamr@2: #define TRAP_INSTRUMENTATION_LEAVE(aResult) williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: This macro is used by the TRAP and TRAPD macros and provides a means williamr@2: of inserting code into uses of these. williamr@2: williamr@2: This macro is invoked after the 'trapped' code is called, regardless of whether williamr@2: or not it did Leave. It should be redefined to do whatever task is williamr@2: required. E.g. this code: williamr@2: williamr@2: @code williamr@2: #undef TRAP_INSTRUMENTATION_END williamr@2: #define TRAP_INSTRUMENTATION_END DoMyLoging(__LINE__) williamr@2: @endcode williamr@2: williamr@2: Will cause all subsequent uses of the TRAP macros to behave in an williamr@2: equivalent way to: williamr@2: williamr@2: @code williamr@2: TRAP(r,SomeCodeL()); williamr@2: DoMyLoging(__LINE__) williamr@2: @endcode williamr@2: williamr@2: williamr@2: @publishedPartner williamr@2: @released williamr@2: williamr@2: @see TRAP williamr@2: @see TRAPD williamr@2: */ williamr@2: #define TRAP_INSTRUMENTATION_END williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Executes the set of C++ statements _s under a trap harness. williamr@2: williamr@2: Use this macro as a C++ statement. williamr@2: williamr@2: _r must be a TInt which has already been declared; if any of the williamr@2: C++ statements _s leaves, then the leave code is returned in _r, williamr@2: otherwise _r is set to KErrNone. williamr@2: williamr@2: _s can consist of multiple C++ statements; in theory, _s can consist williamr@2: of any legal C++ code but in practice, such statements consist of simple williamr@2: function calls, e.g. Foo() or an assignment of some value to the result of williamr@2: a function call, e.g. functionValue=GetFoo(). williamr@2: williamr@2: A cleanup stack is constructed for the set of C++ statements _s. williamr@2: If any function in _s leaves, objects pushed to the cleanup stack are williamr@2: cleaned-up. In addition, if any of the C++ statements in _s leaves, williamr@2: then remaining C++ code in _s is not executed and any variables which williamr@2: are assigned within that remaining code are not defined. williamr@2: williamr@2: @param _r An lvalue, convertible to TInt&, which will receive the result of williamr@2: any User::Leave() executed within _s or, if no leave occurred, williamr@2: it will be set to KErrNone. The value of _r on entry is not used. williamr@2: williamr@2: @param _s C++ statements which will be executed under a trap harness. williamr@2: williamr@2: @see TRAPD williamr@2: */ williamr@2: williamr@2: /*__CALL_EMPTY_FUNCTION(call to a function with an empty body) was added as a williamr@2: workaround to a compiler bug (mwccsym2 - winscw ) which caused an incorrect williamr@2: trap handler to be invoked when multiple nested TRAP's were present and williamr@2: User::Leave(..) was called. */ williamr@2: williamr@2: #define TRAP(_r, _s) \ williamr@2: { \ williamr@2: TInt& __rref = _r; \ williamr@2: __rref = 0; \ williamr@2: { TRAP_INSTRUMENTATION_START; } \ williamr@2: try { \ williamr@2: __WIN32SEHTRAP \ williamr@2: TTrapHandler* ____t = User::MarkCleanupStack(); \ williamr@2: _s; \ williamr@2: User::UnMarkCleanupStack(____t); \ williamr@2: { TRAP_INSTRUMENTATION_NOLEAVE; } \ williamr@2: __WIN32SEHUNTRAP \ williamr@2: } \ williamr@2: catch (XLeaveException& l) \ williamr@2: { \ williamr@2: __rref = l.GetReason(); \ williamr@2: { TRAP_INSTRUMENTATION_LEAVE(__rref); } \ williamr@2: } \ williamr@2: catch (...) \ williamr@2: { \ williamr@2: User::Invariant(); \ williamr@2: } \ williamr@2: __CALL_EMPTY_FUNCTION \ williamr@2: { TRAP_INSTRUMENTATION_END; } \ williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Executes the set of C++ statements _s under a trap harness. williamr@2: williamr@2: Use this macro in the same way as you would TRAP, except that the williamr@2: variable _r is defined as part of the macro (and is therefore valid for the williamr@2: rest of the block in which the macro occurs). Often, this saves a line of code. williamr@2: williamr@2: @param _r A name, which will be declared as a TInt, and will receive the result williamr@2: of any User::Leave() executed within _s or, if no leave occurred, it williamr@2: will be set to KErrNone. After the macro, _r remains in scope until williamr@2: the end of its enclosing block. williamr@2: williamr@2: @param _s C++ statements which will be executed under a trap harness. williamr@2: williamr@2: @see TRAP williamr@2: */ williamr@2: williamr@2: /*__CALL_EMPTY_FUNCTION(call to a function with an empty body) was added as a williamr@2: workaround to a compiler bug (mwccsym2 - winscw ) which caused an incorrect williamr@2: trap handler to be invoked when multiple nested TRAP's were present and williamr@2: User::Leave(..) was called. */ williamr@2: williamr@2: williamr@2: #define TRAPD(_r, _s) \ williamr@2: TInt _r; \ williamr@2: { \ williamr@2: _r = 0; \ williamr@2: { TRAP_INSTRUMENTATION_START; } \ williamr@2: try { \ williamr@2: __WIN32SEHTRAP \ williamr@2: TTrapHandler* ____t = User::MarkCleanupStack(); \ williamr@2: _s; \ williamr@2: User::UnMarkCleanupStack(____t); \ williamr@2: { TRAP_INSTRUMENTATION_NOLEAVE; } \ williamr@2: __WIN32SEHUNTRAP \ williamr@2: } \ williamr@2: catch (XLeaveException& l) \ williamr@2: { \ williamr@2: _r = l.GetReason(); \ williamr@2: { TRAP_INSTRUMENTATION_LEAVE(_r); } \ williamr@2: } \ williamr@2: catch (...) \ williamr@2: { \ williamr@2: User::Invariant(); \ williamr@2: } \ williamr@2: __CALL_EMPTY_FUNCTION \ williamr@2: { TRAP_INSTRUMENTATION_END; } \ williamr@2: } williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Executes the set of C++ statements _s under a trap harness. williamr@2: Any leave code generated is ignored. williamr@2: williamr@2: Use this macro as a C++ statement. williamr@2: williamr@2: This macro is functionally equivalent to: williamr@2: @code williamr@2: TInt x; williamr@2: TRAP(x,_s) williamr@2: @endcode williamr@2: or williamr@2: @code williamr@2: TRAPD(x,_s) williamr@2: @endcode williamr@2: where the value in 'x' is not used by any subsequent code. williamr@2: williamr@2: Use this macro as a C++ statement. williamr@2: williamr@2: _s can consist of multiple C++ statements; in theory, _s can consist williamr@2: of any legal C++ code but in practice, such statements consist of simple williamr@2: function calls, e.g. Foo() or an assignment of some value to the result of williamr@2: a function call, e.g. functionValue=GetFoo(). williamr@2: williamr@2: A cleanup stack is constructed for the set of C++ statements _s. williamr@2: If any function in _s leaves, objects pushed to the cleanup stack are williamr@2: cleaned-up. In addition, if any of the C++ statements in _s leaves, williamr@2: then remaining C++ code in _s is not executed and any variables which williamr@2: are assigned within that remaining code are not defined. williamr@2: williamr@2: @param _s C++ statements which will be executed under a trap harness. williamr@2: williamr@2: @see TRAPD williamr@2: @see TRAP williamr@2: */ williamr@2: williamr@2: /*__CALL_EMPTY_FUNCTION(call to a function with an empty body) was added as a williamr@2: workaround to a compiler bug (mwccsym2 - winscw ) which caused an incorrect williamr@2: trap handler to be invoked when multiple nested TRAP's were present and williamr@2: User::Leave(..) was called. */ williamr@2: williamr@2: #define TRAP_IGNORE(_s) \ williamr@2: { \ williamr@2: { TRAP_INSTRUMENTATION_START; } \ williamr@2: try { \ williamr@2: __WIN32SEHTRAP \ williamr@2: TTrapHandler* ____t = User::MarkCleanupStack(); \ williamr@2: _s; \ williamr@2: User::UnMarkCleanupStack(____t); \ williamr@2: { TRAP_INSTRUMENTATION_NOLEAVE; } \ williamr@2: __WIN32SEHUNTRAP \ williamr@2: } \ williamr@2: catch (XLeaveException& l) \ williamr@2: { \ williamr@2: l.GetReason(); \ williamr@2: { TRAP_INSTRUMENTATION_LEAVE(l.Reason()); } \ williamr@2: } \ williamr@2: catch (...) \ williamr@2: { \ williamr@2: User::Invariant(); \ williamr@2: } \ williamr@2: __CALL_EMPTY_FUNCTION \ williamr@2: { TRAP_INSTRUMENTATION_END; } \ williamr@2: } williamr@2: williamr@2: williamr@2: #endif //__LEAVE_EQUALS_THROW__ williamr@2: williamr@4: /* The macro __SYMBIAN_STDCPP_SUPPORT__ is defined when building a StdC++ target. williamr@4: * In this case, operator new and operator delete below should not be declared williamr@4: * to avoid clashing with StdC++ declarations. williamr@4: */ williamr@4: williamr@4: #ifndef __SYMBIAN_STDCPP_SUPPORT__ williamr@4: williamr@4: #ifndef __OPERATOR_NEW_DECLARED__ williamr@4: williamr@4: /* Some operator new and operator delete overloads may be declared in compiler williamr@4: * pre-include files. williamr@4: * williamr@4: * __OPERATOR_NEW_DECLARED__ is #defined if they are, so that we can avoid williamr@4: * re-declaring them here. williamr@4: */ williamr@4: williamr@4: #define __OPERATOR_NEW_DECLARED__ williamr@4: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: GLREF_C TAny* operator new(TUint aSize) __NO_THROW; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: GLREF_C TAny* operator new(TUint aSize,TUint anExtraSize) __NO_THROW; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: GLREF_C void operator delete(TAny* aPtr) __NO_THROW; williamr@2: williamr@4: #ifndef __OMIT_VEC_OPERATOR_NEW_DECL__ williamr@4: /** williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: GLREF_C TAny* operator new[](TUint aSize) __NO_THROW; williamr@4: williamr@4: /** williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: GLREF_C void operator delete[](TAny* aPtr) __NO_THROW; williamr@4: #endif // !__OMIT_VEC_OPERATOR_NEW_DECL__ williamr@4: williamr@4: #endif // !__OPERATOR_NEW_DECLARED__ williamr@4: williamr@4: #endif // !__SYMBIAN_STDCPP_SUPPORT__ williamr@4: williamr@4: /** williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: inline TAny* operator new(TUint aSize, TAny* aBase) __NO_THROW; williamr@4: williamr@4: /** williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: inline void operator delete(TAny* aPtr, TAny* aBase) __NO_THROW; williamr@4: williamr@2: #ifndef __PLACEMENT_VEC_NEW_INLINE williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: inline TAny* operator new[](TUint aSize, TAny* aBase) __NO_THROW; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: inline void operator delete[](TAny* aPtr, TAny* aBase) __NO_THROW; williamr@2: williamr@2: #endif // !__PLACEMENT_VEC_NEW_INLINE williamr@2: williamr@2: #if !defined(__BOOL_NO_TRUE_TRAP__) williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: TBool operator==(TTrue,volatile const TBool); williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: TBool operator==(volatile const TBool,TTrue); williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: TBool operator!=(TTrue,volatile const TBool); williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: TBool operator!=(volatile const TBool,TTrue); williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A Version 2 client/server class that clients use to package williamr@2: the arguments to be sent to a server. williamr@2: williamr@2: The object can package up to 4 arguments together with information about each williamr@2: argument's type, width and accessibility; it is also possible for williamr@2: the package to contain zero arguments. In addition to the default constructor, williamr@2: the class has four templated constructors, allowing an object of this type to williamr@2: be constructed for 0, 1, 2, 3 or 4 arguments. williamr@2: williamr@2: Internally, the arguments are stored in a simple TInt array. williamr@2: Consecutive arguments in a constructor's parameter list are put into williamr@2: consecutive slots in the array. The Set() overloaded functions can be used williamr@2: to set argument values into specific slots within this array. williamr@2: */ williamr@2: class TIpcArgs williamr@2: { williamr@2: public: williamr@2: /** williamr@2: @internalComponent williamr@2: williamr@2: Argument types; some of these may be ORed together to specify williamr@2: type, accessibility, and width. williamr@2: */ williamr@2: enum TArgType williamr@2: { williamr@2: EUnspecified = 0, /**< Type not specified.*/ williamr@2: EHandle = 1, /**< Handle type.*/ williamr@2: EFlagDes = 4, /**< Descriptor type.*/ williamr@2: EFlagConst = 2, /**< Read only type.*/ williamr@2: EFlag16Bit = 1, /**< 16 bit rather than 8 bit.*/ williamr@2: EDes8 = EFlagDes, /**< 8 bit read/write descriptor.*/ williamr@2: EDes16 = EFlagDes|EFlag16Bit, /**< 16 bit read/write descriptor.*/ williamr@2: EDesC8 = EFlagDes|EFlagConst, /**< 8 bit read only descriptor.*/ williamr@2: EDesC16 = EFlagDes|EFlagConst|EFlag16Bit, /**< 16 bit read only descriptor.*/ williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@4: enum williamr@4: { williamr@4: KBitsPerType = 3, /**< Number of bits of type information used for each of the 4 arguments.*/ williamr@4: KPinArgShift = KBitsPerType*KMaxMessageArguments, /**< Bit number of the start of the pin flags. */ williamr@4: KPinArg0 = 1<<(KPinArgShift+0), /**< Set to pin argument at index 0.*/ williamr@4: KPinArg1 = 1<<(KPinArgShift+1), /**< Set to pin argument at index 1.*/ williamr@4: KPinArg2 = 1<<(KPinArgShift+2), /**< Set to pin argument at index 2.*/ williamr@4: KPinArg3 = 1<<(KPinArgShift+3), /**< Set to pin argument at index 3.*/ williamr@4: KPinMask = 0xf< williamr@2: inline explicit TIpcArgs(T0 a0) williamr@2: { williamr@2: Assign(iArgs[0],a0); williamr@2: iFlags=(Type(a0)<<(0*KBitsPerType)); williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: A templated constructor that constructs the argument package; it takes williamr@2: 2 arguments. williamr@2: williamr@2: @param a0 An argument of general class type T0 to be contained by williamr@2: this object. williamr@2: @param a1 An argument of general class type T1 to be contained by williamr@2: this object. williamr@2: */ williamr@2: template williamr@2: inline TIpcArgs(T0 a0,T1 a1) williamr@2: { williamr@2: Assign(iArgs[0],a0); williamr@2: Assign(iArgs[1],a1); williamr@2: iFlags=(Type(a0)<<(0*KBitsPerType))|(Type(a1)<<(1*KBitsPerType)); williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: A templated constructor that constructs the argument package; it takes williamr@2: 3 arguments. williamr@2: williamr@2: @param a0 An argument of general class type T0 to be contained by williamr@2: this object. williamr@2: @param a1 An argument of general class type T1 to be contained by williamr@2: this object. williamr@2: @param a2 An argument of general class type T2 to be contained by williamr@2: this object. williamr@2: */ williamr@2: template williamr@2: inline TIpcArgs(T0 a0,T1 a1,T2 a2) williamr@2: { williamr@2: Assign(iArgs[0],a0); williamr@2: Assign(iArgs[1],a1); williamr@2: Assign(iArgs[2],a2); williamr@2: iFlags=(Type(a0)<<(0*KBitsPerType))|(Type(a1)<<(1*KBitsPerType))|(Type(a2)<<(2*KBitsPerType)); williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: A templated constructor that constructs the argument package; it takes williamr@2: 4 arguments. williamr@2: williamr@2: @param a0 An argument of general class type T0 to be contained by williamr@2: this object. williamr@2: @param a1 An argument of general class type T1 to be contained by williamr@2: this object. williamr@2: @param a2 An argument of general class type T2 to be contained by williamr@2: this object. williamr@2: @param a3 An argument of general class type T3 to be contained by williamr@2: this object. williamr@2: */ williamr@2: template williamr@2: inline TIpcArgs(T0 a0,T1 a1,T2 a2,T3 a3) williamr@2: { williamr@2: Assign(iArgs[0],a0); williamr@2: Assign(iArgs[1],a1); williamr@2: Assign(iArgs[2],a2); williamr@2: Assign(iArgs[3],a3); williamr@2: iFlags=(Type(a0)<<(0*KBitsPerType))|(Type(a1)<<(1*KBitsPerType))|(Type(a2)<<(2*KBitsPerType))|(Type(a3)<<(3*KBitsPerType)); williamr@2: } williamr@2: // williamr@2: inline void Set(TInt aIndex,TNothing); williamr@2: inline void Set(TInt aIndex,TInt aValue); williamr@2: inline void Set(TInt aIndex,const TAny* aValue); williamr@2: inline void Set(TInt aIndex,RHandleBase aValue); williamr@2: inline void Set(TInt aIndex,const TDesC8* aValue); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void Set(TInt aIndex,const TDesC16* aValue); williamr@2: #endif williamr@2: inline void Set(TInt aIndex,TDes8* aValue); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline void Set(TInt aIndex,TDes16* aValue); williamr@2: #endif williamr@4: williamr@4: inline TIpcArgs& PinArgs(TBool aPinArg0=ETrue, TBool aPinArg1=ETrue, TBool aPinArg2=ETrue, TBool aPinArg3=ETrue); williamr@2: private: williamr@2: inline static TArgType Type(TNothing); williamr@2: inline static TArgType Type(TInt); williamr@2: inline static TArgType Type(const TAny*); williamr@2: inline static TArgType Type(RHandleBase aValue); williamr@2: inline static TArgType Type(const TDesC8*); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline static TArgType Type(const TDesC16*); williamr@2: #endif williamr@2: inline static TArgType Type(TDes8*); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline static TArgType Type(TDes16*); williamr@2: #endif williamr@2: // williamr@2: inline static void Assign(TInt&,TNothing); williamr@2: inline static void Assign(TInt& aArg,TInt aValue); williamr@2: inline static void Assign(TInt& aArg,const TAny* aValue); williamr@2: inline static void Assign(TInt& aArg,RHandleBase aValue); williamr@2: inline static void Assign(TInt& aArg,const TDesC8* aValue); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline static void Assign(TInt& aArg,const TDesC16* aValue); williamr@2: #endif williamr@2: inline static void Assign(TInt& aArg,TDes8* aValue); williamr@2: #ifndef __KERNEL_MODE__ williamr@2: inline static void Assign(TInt& aArg,TDes16* aValue); williamr@2: #endif williamr@2: public: williamr@2: williamr@2: /** williamr@2: The location where the message arguments are stored. williamr@2: williamr@2: There is no reason to access this data member directly and it should be williamr@2: considered as internal. williamr@2: */ williamr@2: TInt iArgs[KMaxMessageArguments]; williamr@2: williamr@2: /** williamr@2: The location where the flag bits describing the argument types are stored. williamr@2: williamr@2: The symbolic values describing the argument types are internal to Symbian, williamr@2: and there is therefore no reason to access this data member directly. williamr@2: It should be considered as internal. williamr@2: */ williamr@2: TInt iFlags; williamr@2: }; williamr@2: williamr@2: // Structures for passing 64 bit integers and doubles across GCC/EABI boundaries williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SInt64 williamr@2: { williamr@2: public: williamr@2: inline SInt64(); williamr@2: inline SInt64(Int64 a); williamr@2: inline SInt64& operator=(Int64 a); williamr@2: inline operator Int64() const; williamr@2: public: williamr@2: TUint32 iData[2]; // little endian williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SUint64 williamr@2: { williamr@2: public: williamr@2: inline SUint64(); williamr@2: inline SUint64(Uint64 a); williamr@2: inline SUint64& operator=(Uint64 a); williamr@2: inline operator Uint64() const; williamr@2: public: williamr@2: TUint32 iData[2]; // little endian williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SDouble williamr@2: { williamr@2: public: williamr@2: inline SDouble(); williamr@2: inline SDouble(TReal a); williamr@2: inline SDouble& operator=(TReal a); williamr@2: inline operator TReal() const; williamr@2: public: williamr@2: TUint32 iData[2]; // always little endian williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Stores information about a thread's stack. williamr@2: williamr@2: Note, on the emulator, the memory between iLimit and the thread's current stack pointer williamr@2: may not actually be committed. williamr@2: williamr@2: @see RThread::StackInfo() williamr@2: */ williamr@2: class TThreadStackInfo williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The address which the stack pointer would contain if the stack were empty. williamr@2: */ williamr@2: TLinAddr iBase; williamr@2: williamr@2: /** williamr@2: The address which the stack pointer would contain if the stack were full, williamr@2: (The lowest valid address). williamr@2: */ williamr@2: TLinAddr iLimit; williamr@2: williamr@2: /** williamr@2: The limit value for the stack if it were expanded to its maximum size. williamr@2: williamr@2: Currently expanding stacks is not supported so iExpandLimit==iLimit williamr@2: */ williamr@2: TLinAddr iExpandLimit; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifdef __SUPPORT_CPP_EXCEPTIONS__ williamr@2: /** williamr@2: @internalComponent williamr@2: @released williamr@2: williamr@2: The class used to implement User::Leave in term of throw and TRAP in terms of catch. williamr@2: williamr@2: */ williamr@2: class XLeaveException williamr@2: { williamr@2: public: williamr@2: inline XLeaveException() {} williamr@2: inline XLeaveException(TInt aReason) {iR = aReason;} williamr@2: inline TInt Reason() const {return iR;} williamr@2: IMPORT_C TInt GetReason() const; williamr@2: private: williamr@2: #if __ARMCC_VERSION >= 220000 williamr@2: // From rvct 2.2 onwards we want the class impedimenta to be shared, so create a key function. williamr@2: // Unfortunately we can't make this the key function the dtor since this would make it impossible for existing 2.1 williamr@2: // derived binaries to be 'BC' with 2.2 binaries (in the general case (which I wont attempt to describe coz its williamr@2: // 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 williamr@2: // for catch handlers to work :-( (see the old code). williamr@2: virtual void ForceKeyFunction(); williamr@2: #endif williamr@2: private: williamr@2: #if __ARMCC_VERSION < 220000 williamr@2: TAny* iVtable; // reserve space for vtable williamr@2: #endif williamr@2: TInt iR; williamr@2: }; williamr@2: williamr@2: // The standard header file defines the following guard macro for EDG and CW, VC++, GCC respectively. williamr@2: // The guard below is ugly. It will surely come back and bite us unless we resolve the whole issue of standard headers williamr@4: // when we move to supporting Standard C++. williamr@4: williamr@4: // The macro __SYMBIAN_STDCPP_SUPPORT__ is defined when building a StdC++ target. williamr@4: // In this case, we include the StdC++ specification rather than declaring uncaught_exception. williamr@4: williamr@4: #ifdef __SYMBIAN_STDCPP_SUPPORT__ williamr@4: #include williamr@4: #elif !defined(_EXCEPTION) && !defined(_EXCEPTION_) && !defined(__EXCEPTION__) williamr@2: // Declare standard C++ functions relating to exceptions here williamr@2: namespace std { williamr@4: #if defined(__VC32__) || defined(__CW32__) williamr@4: bool uncaught_exception(); williamr@4: #else williamr@4: IMPORT_C bool uncaught_exception(); williamr@4: #endif williamr@2: void terminate(void); williamr@2: void unexpected(void); williamr@2: typedef void (*terminate_handler)(); williamr@2: terminate_handler set_terminate(terminate_handler h) throw(); williamr@2: typedef void (*unexpected_handler)(); williamr@2: unexpected_handler set_unexpected(unexpected_handler h) throw(); williamr@2: } williamr@2: williamr@2: #endif williamr@2: #endif //__SUPPORT_CPP_EXCEPTIONS__ williamr@2: williamr@2: #ifdef __WINS__ williamr@2: williamr@2: #ifndef __WIN32_SEH_TYPES_KNOWN__ williamr@2: class __UnknownWindowsType1; williamr@2: class __UnknownWindowsType2; williamr@2: #endif williamr@2: williamr@2: class TWin32SEHTrap; williamr@2: williamr@2: /** williamr@2: * Typedef for the SEH handler function williamr@2: * @internalComponent williamr@2: */ williamr@2: typedef TUint32 (TWin32SEHExceptionHandler)(__UnknownWindowsType1* aExceptionRecord, TWin32SEHTrap* aRegistrationRecord, __UnknownWindowsType2* aContext); williamr@2: williamr@2: /** williamr@2: * @internalComponent williamr@2: */ williamr@2: class TWin32SEHTrap williamr@2: { williamr@2: private: williamr@2: // Prevent copy/assign williamr@2: TWin32SEHTrap(TWin32SEHTrap const &); williamr@2: TWin32SEHTrap& operator=(TWin32SEHTrap const &); williamr@2: williamr@2: #ifdef __KERNEL_MODE__ williamr@2: // williamr@2: // Kernel-side functions for nkern exception handler williamr@2: // williamr@2: public: williamr@2: /** Find final exception handler in SEH chain */ williamr@2: static TWin32SEHTrap* IterateForFinal(); williamr@2: williamr@2: /** Access exception handler */ williamr@2: TWin32SEHExceptionHandler* ExceptionHandler(); williamr@2: williamr@2: private: williamr@2: williamr@2: #else // !__KERNEL_MODE__ williamr@2: // williamr@2: // User-side functions for use in TRAP(...) williamr@2: // williamr@2: public: williamr@2: UIMPORT_C TWin32SEHTrap(); williamr@2: williamr@2: public: williamr@2: /** Add object to SEH chain */ williamr@2: UIMPORT_C void Trap(); williamr@2: williamr@2: /** Remove object from SEH chain */ williamr@2: UIMPORT_C void UnTrap(); williamr@2: williamr@2: #ifndef __IN_SEH_CPP__ williamr@2: private: williamr@2: #endif williamr@2: /** Handle Win32 exceptions */ williamr@2: static TUint32 ExceptionHandler(__UnknownWindowsType1* aException, TWin32SEHTrap* aRegistrationRecord, __UnknownWindowsType2* aContext); williamr@2: williamr@2: #endif //__KERNEL_MODE__ williamr@2: williamr@2: // williamr@2: // NB: This is really an _EXCEPTION_REGISTRATION_RECORD williamr@2: // williamr@2: TWin32SEHTrap* iPrevExceptionRegistrationRecord; /** Link to previous SEH record */ williamr@2: TWin32SEHExceptionHandler* iExceptionHandler; /** SEH handler function */ williamr@2: williamr@2: private: williamr@2: TUint32 iPadding[254]; // discourage the compiler from putting this in reused function parameter space williamr@2: }; williamr@2: williamr@2: #else // !__WINS__ williamr@2: williamr@2: #ifdef __X86__ williamr@2: /** williamr@2: * @internalComponent williamr@2: */ williamr@2: class TWin32SEHTrap williamr@2: { williamr@2: public: williamr@2: UIMPORT_C TWin32SEHTrap(); williamr@2: UIMPORT_C void Trap(); williamr@2: UIMPORT_C void UnTrap(); williamr@2: }; williamr@2: #endif //__X86__ williamr@2: #endif //__WINS__ williamr@2: williamr@4: /** williamr@4: @internalTechnology williamr@4: */ williamr@4: struct TEmulatorImageHeader williamr@4: { williamr@4: TUid iUids[KMaxCheckedUid]; williamr@4: TProcessPriority iPriority; williamr@4: SSecurityInfo iS; williamr@4: TUint32 iSpare1; williamr@4: TUint32 iSpare2; williamr@4: TUint32 iModuleVersion; williamr@4: TUint32 iFlags; williamr@4: }; williamr@4: williamr@4: // forward declaration of shareable data buffers pool infomation williamr@4: class TShPoolInfo; williamr@4: williamr@2: #include williamr@2: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@4: #endif williamr@4: williamr@2: #endif //__E32CMN_H__ williamr@4: