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\e32std.h williamr@2: // williamr@2: // williamr@2: williamr@2: #ifndef __E32STD_H__ williamr@2: #define __E32STD_H__ williamr@2: williamr@2: #ifdef __KERNEL_MODE__ williamr@2: #error !! Including e32std.h in kernel code !! williamr@2: #endif williamr@2: williamr@2: #include williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TFunctor williamr@2: { williamr@2: public: williamr@2: IMPORT_C virtual void operator()() =0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Encapsulates a general call-back function. williamr@2: williamr@2: The class encapsulates: williamr@2: williamr@2: 1. a pointer to a function which takes an argument of type TAny* and returns williamr@2: a TInt. williamr@2: williamr@2: 2. a pointer which is passed to the function every time it is called. williamr@2: The pointer can point to any object. It can also be NULL. williamr@2: williamr@2: The callback function can be a static function of a class, williamr@2: e.g. TInt X::Foo(TAny *) or it can be a function which is not a member of williamr@2: any class, e.g. TInt Foo(TAny *). williamr@2: williamr@2: When used with the CIdle and the CPeriodic classes, the callback function williamr@2: is intended to be called repeatedly; the encapsulated pointer is passed on williamr@2: each call. Typically, the pointer refers to an object which records the state williamr@2: of the task across each call. When used with CIdle, the callback function williamr@2: should also return a true (non-zero) value if it is intended to be called williamr@2: again, otherwise it should return a false (zero) value. williamr@2: williamr@2: @see CIdle williamr@2: @see CPeriodic williamr@2: */ williamr@2: class TCallBack williamr@2: { williamr@2: public: williamr@2: inline TCallBack(); williamr@2: inline TCallBack(TInt (*aFunction)(TAny* aPtr)); williamr@2: inline TCallBack(TInt (*aFunction)(TAny* aPtr),TAny* aPtr); williamr@2: inline TInt CallBack() const; williamr@2: public: williamr@2: williamr@2: /** williamr@2: A pointer to the callback function. williamr@2: */ williamr@2: TInt (*iFunction)(TAny* aPtr); williamr@2: williamr@2: williamr@2: /** williamr@2: A pointer that is passed to the callback function when williamr@2: the function is called. williamr@2: */ williamr@2: TAny* iPtr; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An object embedded within a class T so that objects of type T can form part williamr@2: of a singly linked list. williamr@2: williamr@2: A link object encapsulates a pointer to the next link object in the list. williamr@2: williamr@2: @see TSglQue williamr@2: */ williamr@2: class TSglQueLink williamr@2: { williamr@2: #if defined _DEBUG williamr@2: public: williamr@2: inline TSglQueLink() : iNext(NULL) williamr@2: /** williamr@2: An explicitly coded default constructor that is only defined for DEBUG builds. williamr@2: williamr@2: It sets the pointer to the next link object to NULL. williamr@2: williamr@2: @see iNext williamr@2: */ williamr@2: {} williamr@2: #endif williamr@2: private: williamr@2: IMPORT_C void Enque(TSglQueLink* aLink); williamr@2: public: williamr@2: /** williamr@2: A pointer to the next link object in the list. williamr@2: */ williamr@2: TSglQueLink* iNext; williamr@2: friend class TSglQueBase; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A base class that provides implementation for the link object of a doubly williamr@2: linked list. williamr@2: williamr@2: It also encapsulates pointers both to the next and the previous link williamr@2: objects in the doubly linked list. williamr@2: williamr@2: The class is abstract and is not intended to be instantiated. williamr@2: williamr@2: @see TDblQueLink williamr@2: */ williamr@2: class TDblQueLinkBase williamr@2: { williamr@2: public: williamr@2: inline TDblQueLinkBase() : iNext(NULL) williamr@2: /** williamr@2: Default constructor. williamr@2: williamr@2: It sets the pointer to the next link object to NULL. williamr@2: williamr@2: @see iNext williamr@2: */ williamr@2: {} williamr@2: IMPORT_C void Enque(TDblQueLinkBase* aLink); williamr@2: IMPORT_C void AddBefore(TDblQueLinkBase* aLink); williamr@2: public: williamr@2: /** williamr@2: A pointer to the next link object in the list. williamr@2: */ williamr@2: TDblQueLinkBase* iNext; williamr@2: williamr@2: /** williamr@2: A pointer to the previous link object in the list. williamr@2: */ williamr@2: TDblQueLinkBase* iPrev; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An object embedded within a class T so that objects of type T can form part williamr@2: of a doubly linked list. williamr@2: */ williamr@2: class TDblQueLink : public TDblQueLinkBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C void Deque(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An object embedded within a class T so that objects of type T can form part williamr@2: of an ordered doubly linked list. williamr@2: williamr@2: Objects are added to the doubly linked list in descending priority order. williamr@2: */ williamr@2: class TPriQueLink : public TDblQueLink williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The priority value. williamr@2: williamr@2: Objects are added to the doubly linked list in descending order of this value. williamr@2: */ williamr@2: TInt iPriority; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An object embedded within a class T so that objects of type T can form part williamr@2: of a delta doubly linked list. williamr@2: */ williamr@2: class TDeltaQueLink : public TDblQueLinkBase williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The delta value. williamr@2: */ williamr@2: TInt iDelta; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An object embedded within a class T so that objects of type T can form part williamr@2: of a doubly linked list sorted by tick count. williamr@2: */ williamr@2: class TTickCountQueLink : public TDblQueLink williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The tick count. williamr@2: */ williamr@2: TUint iTickCount; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A base class that provides implementation for the singly linked list header. williamr@2: williamr@2: It also encapsulates the offset value of a link object. williamr@2: williamr@2: The class is abstract and is not intended to be instantiated. williamr@2: williamr@2: @see TSglQue williamr@2: */ williamr@2: class TSglQueBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBool IsEmpty() const; williamr@2: IMPORT_C void SetOffset(TInt aOffset); williamr@2: IMPORT_C void Reset(); williamr@2: protected: williamr@2: IMPORT_C TSglQueBase(); williamr@2: IMPORT_C TSglQueBase(TInt aOffset); williamr@2: IMPORT_C void DoAddFirst(TAny* aPtr); williamr@2: IMPORT_C void DoAddLast(TAny* aPtr); williamr@2: IMPORT_C void DoRemove(TAny* aPtr); williamr@2: protected: williamr@2: /** williamr@2: A pointer to the first element in the list. williamr@2: */ williamr@2: TSglQueLink* iHead; williamr@2: williamr@2: /** williamr@2: A pointer to the last element in the list. williamr@2: */ williamr@2: TSglQueLink* iLast; williamr@2: williamr@2: /** williamr@2: The offset of a component link object within elements that form the list. williamr@2: */ williamr@2: TInt iOffset; williamr@2: private: williamr@2: TSglQueBase(const TSglQueBase& aQue); williamr@2: TSglQueBase &operator=(const TSglQueBase& aQue); williamr@2: friend class TSglQueIterBase; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A base class that provides implementation for the doubly linked list header. williamr@2: williamr@2: It also encapsulates the offset value of a link object. williamr@2: williamr@2: The class is abstract and is not intended to be instantiated. williamr@2: williamr@2: @see TDblQue williamr@2: */ williamr@2: class TDblQueBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBool IsEmpty() const; williamr@2: IMPORT_C void SetOffset(TInt aOffset); williamr@2: IMPORT_C void Reset(); williamr@2: protected: williamr@2: IMPORT_C TDblQueBase(); williamr@2: IMPORT_C TDblQueBase(TInt aOffset); williamr@2: IMPORT_C void DoAddFirst(TAny* aPtr); williamr@2: IMPORT_C void DoAddLast(TAny* aPtr); williamr@2: IMPORT_C void DoAddPriority(TAny* aPtr); williamr@2: IMPORT_C void __DbgTestEmpty() const; williamr@2: protected: williamr@2: /** williamr@2: The head, or anchor point of the queue. williamr@2: */ williamr@2: TDblQueLink iHead; williamr@2: williamr@2: /** williamr@2: The offset of a component link object within elements that form the list. williamr@2: */ williamr@2: TInt iOffset; williamr@2: private: williamr@2: TDblQueBase(const TDblQueBase& aQue); williamr@2: TDblQueBase& operator=(const TDblQueBase& aQue); williamr@2: friend class TDblQueIterBase; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A base class that provides implementation for the TDeltaQue template class. williamr@2: williamr@2: The class is abstract and is not intended to be instantiated. williamr@2: williamr@2: @see TDeltaQue williamr@2: */ williamr@2: class TDeltaQueBase : public TDblQueBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBool CountDown(); williamr@2: IMPORT_C TBool CountDown(TInt aValue); williamr@2: IMPORT_C TBool FirstDelta(TInt& aValue); williamr@2: IMPORT_C void Reset(); williamr@2: protected: williamr@2: IMPORT_C TDeltaQueBase(); williamr@2: IMPORT_C TDeltaQueBase(TInt aOffset); williamr@2: IMPORT_C void DoAddDelta(TAny* aPtr,TInt aDelta); williamr@2: IMPORT_C void DoRemove(TAny* aPtr); williamr@2: IMPORT_C TAny* DoRemoveFirst(); williamr@2: protected: williamr@2: /** williamr@2: Pointer to the delta value in the first link element. williamr@2: */ williamr@2: TInt* iFirstDelta; 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 that provides the behaviour for managing a singly linked williamr@2: list. williamr@2: williamr@2: It also acts as the head of the list, maintaining the pointers into the list. williamr@2: williamr@2: The template parameter defines the type of element that forms the singly linked williamr@2: list and is the class that acts as host to the link object. williamr@2: williamr@2: @see TSglQueLink williamr@2: */ williamr@2: template williamr@2: class TSglQue : public TSglQueBase williamr@2: { williamr@2: public: williamr@2: inline TSglQue(); williamr@2: inline explicit TSglQue(TInt aOffset); williamr@2: inline void AddFirst(T& aRef); williamr@2: inline void AddLast(T& aRef); williamr@2: inline TBool IsFirst(const T* aPtr) const; williamr@2: inline TBool IsLast(const T* aPtr) const; williamr@2: inline T* First() const; williamr@2: inline T* Last() const; williamr@2: inline void Remove(T& aRef); 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 that provides the behaviour for managing a doubly linked williamr@2: list. williamr@2: williamr@2: It also acts as the head of the list, maintaining the pointers into the list. williamr@2: williamr@2: The template parameter defines the type of element that forms the doubly linked williamr@2: list and is the class that acts as host to the link object. williamr@2: williamr@2: @see TDblQueLink williamr@2: */ williamr@2: template williamr@2: class TDblQue : public TDblQueBase williamr@2: { williamr@2: public: williamr@2: inline TDblQue(); williamr@2: inline explicit TDblQue(TInt aOffset); williamr@2: inline void AddFirst(T& aRef); williamr@2: inline void AddLast(T& aRef); williamr@2: inline TBool IsHead(const T* aPtr) const; williamr@2: inline TBool IsFirst(const T* aPtr) const; williamr@2: inline TBool IsLast(const T* aPtr) const; williamr@2: inline T* First() const; williamr@2: inline T* Last() 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 that provides the behaviour for managing a doubly linked williamr@2: list in which the elements are added in descending priority order. williamr@2: williamr@2: Priority is defined by the value of the TPriQueLink::iPriority member of williamr@2: the link element. williamr@2: williamr@2: The template parameter defines the type of element that forms the doubly linked williamr@2: list and is the class that acts as host to the link object. williamr@2: williamr@2: @see TPriQueLink williamr@2: @see TPriQueLink::iPriority williamr@2: */ williamr@2: template williamr@2: class TPriQue : public TDblQueBase williamr@2: { williamr@2: public: williamr@2: inline TPriQue(); williamr@2: inline explicit TPriQue(TInt aOffset); williamr@2: inline void Add(T& aRef); williamr@2: inline TBool IsHead(const T* aPtr) const; williamr@2: inline TBool IsFirst(const T* aPtr) const; williamr@2: inline TBool IsLast(const T* aPtr) const; williamr@2: inline T* First() const; williamr@2: inline T* Last() 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 that provides the behaviour for managing a doubly linked williamr@2: list in which elements represent values which are increments, or deltas, on williamr@2: the value represented by a preceding element. williamr@2: williamr@2: The list is ordered so that the head of the queue represents a nominal zero williamr@2: point. williamr@2: williamr@2: The delta value of a new element represents its 'distance' from the nominal williamr@2: zero point. The new element is added into the list, and the delta values of williamr@2: adjacent elements (and of the new element, if necessary) are adjusted, so williamr@2: that the sum of all deltas, up to and including the new element, is the same williamr@2: as the new element's intended 'distance' from the nominal zero point. williamr@2: williamr@2: A common use for a list of this type is as a queue of timed events, where williamr@2: the delta values represent the intervals between the events. williamr@2: williamr@2: The delta value is defined by the value of the TDeltaQueLink::iDelta member williamr@2: of the link element. williamr@2: williamr@2: The template parameter defines the type of element that forms the doubly linked williamr@2: list and is the class that acts as host to the link object. williamr@2: williamr@2: @see TDeltaQueLink williamr@2: @see TDeltaQueLink::iDelta williamr@2: */ williamr@2: template williamr@2: class TDeltaQue : public TDeltaQueBase williamr@2: { williamr@2: public: williamr@2: inline TDeltaQue(); williamr@2: inline explicit TDeltaQue(TInt aOffset); williamr@2: inline void Add(T& aRef,TInt aDelta); williamr@2: inline void Remove(T& aRef); williamr@2: inline T* RemoveFirst(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: // Forward declaration williamr@2: class TTickCountQueLink; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: @released williamr@2: williamr@2: A class that provides the behaviour for managing a doubly linked list williamr@2: in which elements are added in order of the time until their tick count. williamr@2: williamr@2: A common use for a list of this type is as a queue of timed events, where williamr@2: the tick counts are the expiry times of the events. williamr@2: williamr@2: The tick count is defined by the value of the TTickCountQueLink::iTickCount williamr@2: member of the link element. williamr@2: williamr@2: @see TTickCountQueLink williamr@2: @see TTickCountQueLink::iTickCount williamr@2: */ williamr@2: class TTickCountQue : public TDblQueBase williamr@2: { williamr@2: public: williamr@2: TTickCountQue(); williamr@2: void Add(TTickCountQueLink& aRef); williamr@2: TTickCountQueLink* First() const; williamr@2: TTickCountQueLink* RemoveFirst(); williamr@2: TTickCountQueLink* RemoveFirst(TUint aTickCount); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A base class that provides implementation for the singly linked list iterator. williamr@2: williamr@2: It also encapsulates a pointer to the current link link list element. williamr@2: williamr@2: The class is abstract and is not intended to be instantiated. williamr@2: */ williamr@2: class TSglQueIterBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C void SetToFirst(); williamr@2: protected: williamr@2: IMPORT_C TSglQueIterBase(TSglQueBase& aQue); williamr@2: IMPORT_C TAny* DoPostInc(); williamr@2: IMPORT_C TAny* DoCurrent(); williamr@2: IMPORT_C void DoSet(TAny* aLink); williamr@2: protected: williamr@2: TInt iOffset; williamr@2: TSglQueLink* iHead; williamr@2: TSglQueLink* iNext; 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 that provides the behaviour for iterating through a set of williamr@2: singly linked list elements. williamr@2: williamr@2: The template parameter defines the type of element that forms the singly linked williamr@2: list. The class defined in the template parameter contains the link object. williamr@2: */ williamr@2: template williamr@2: class TSglQueIter : public TSglQueIterBase williamr@2: { williamr@2: public: williamr@2: inline TSglQueIter(TSglQueBase& aQue); williamr@2: inline void Set(T& aLink); williamr@2: inline operator T*(); williamr@2: inline T* operator++(TInt); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A base class that provides implementation for the doubly linked list iterator. williamr@2: williamr@2: It also encapsulates a pointer to the current link list element. williamr@2: williamr@2: The class is abstract and is not intended to be instantiated. williamr@2: */ williamr@2: class TDblQueIterBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C void SetToFirst(); williamr@2: IMPORT_C void SetToLast(); williamr@2: protected: williamr@2: IMPORT_C TDblQueIterBase(TDblQueBase& aQue); williamr@2: IMPORT_C TAny* DoPostInc(); williamr@2: IMPORT_C TAny* DoPostDec(); williamr@2: IMPORT_C TAny* DoCurrent(); williamr@2: IMPORT_C void DoSet(TAny* aLink); williamr@2: protected: williamr@2: /** williamr@2: The offset of a component link object within elements that form the list. williamr@2: */ williamr@2: TInt iOffset; williamr@2: williamr@2: /** williamr@2: Pointer to the anchor for the list. williamr@2: */ williamr@2: TDblQueLinkBase* iHead; williamr@2: williamr@2: /** williamr@2: Pointer to the current element. williamr@2: */ williamr@2: TDblQueLinkBase* iNext; 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 that provides the behaviour for iterating through a set of williamr@2: doubly linked list elements. williamr@2: williamr@2: The template parameter defines the type of element that forms the doubly linked williamr@2: list. The class defined in the template parameter contains the link object. williamr@2: */ williamr@2: template williamr@2: class TDblQueIter : public TDblQueIterBase williamr@2: { williamr@2: public: williamr@2: inline TDblQueIter(TDblQueBase& aQue); williamr@2: inline void Set(T& aLink); williamr@2: inline operator T*(); williamr@2: inline T* operator++(TInt); williamr@2: inline T* operator--(TInt); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Governs the type of comparison to be made between descriptor keys or between williamr@2: text keys. williamr@2: williamr@2: @see TKeyArrayFix williamr@2: @see TKeyArrayVar williamr@2: @see TKeyArrayPak williamr@2: */ williamr@2: enum TKeyCmpText williamr@2: { williamr@2: /** williamr@2: For a Unicode build, this is the same as ECmpNormal16. williamr@2: For a non-Unicode build, this is the same as ECmpNormal8. williamr@2: williamr@2: Using the build independent names (i.e. TPtrC, TPtr, TBufC, TBuf or TText) williamr@2: allows the compiler to chose the correct variant according to the build. williamr@2: */ williamr@2: ECmpNormal, williamr@2: williamr@2: williamr@2: /** williamr@2: For descriptor keys, the key is assumed to be the 8 bit variant, derived williamr@2: from TDesc8. A simple comparison is done between the content of the williamr@2: descriptors; the data is not folded and collation rules are not applied for williamr@2: the purpose of the comparison. williamr@2: williamr@2: For text keys, the key is assumed to be the 8 bit variant, of type TText8. williamr@2: A normal comparison is done between the text data; the data is not folded williamr@2: and collation rules are not applied for the purpose of the comparison. williamr@2: */ williamr@2: ECmpNormal8, williamr@2: williamr@2: williamr@2: /** williamr@2: For descriptor keys, the key is assumed to be the 16 bit variant, derived williamr@2: from TDesc16. A simple comparison is done between the content of the williamr@2: descriptors; the data is not folded and collation rules are not applied for williamr@2: the purpose of the comparison. williamr@2: williamr@2: For text keys, the key is assumed to be the 16 bit variant, of type williamr@2: TText16. A normal comparison is done between the text data; the data is williamr@2: not folded and collation rules are not applied for the purpose of the williamr@2: comparison. williamr@2: */ williamr@2: ECmpNormal16, williamr@2: williamr@2: williamr@2: /** williamr@2: For a Unicode build, this is the same as EcmpFolded16. williamr@2: For a non-Unicode build, this is the same as EcmpFolded8. williamr@2: williamr@2: Using the build independent names (i.e. TPtrC, TPtr, TBufC, TBuf or TText) williamr@2: allows the compiler to chose the correct variant according to the build. williamr@2: */ williamr@2: ECmpFolded, williamr@2: williamr@2: williamr@2: /** williamr@2: For descriptor keys, the key is assumed to be the 8 bit variant, williamr@2: derived from TDesc8. The descriptor contents are folded for the purpose williamr@2: of the comparison. williamr@2: williamr@2: For text keys, the key is assumed to be the 8 bit variant, of type williamr@2: TText8. The text data is folded for the purpose of the comparison. williamr@2: */ williamr@2: ECmpFolded8, williamr@2: williamr@2: williamr@2: /** williamr@2: For descriptor keys, the key is assumed to be the 16 bit variant, williamr@2: derived from TDesc16. The descriptor contents are folded for the purpose williamr@2: of the comparison. williamr@2: williamr@2: For text keys, the key is assumed to be the 16 bit variant, of type williamr@2: TText16. The text data is folded for the purpose of the comparison. williamr@2: */ williamr@2: ECmpFolded16, williamr@2: williamr@2: williamr@2: /** williamr@2: For a Unicode build, this is the same as EcmpCollated16. williamr@2: For a non-Unicode build, this is the same as EcmpCollated8. williamr@2: williamr@2: Using the build independent names (i.e. TPtrC, TPtr, TBufC, TBuf or TText) williamr@2: allows the compiler to chose the correct variant according to the build. williamr@2: */ williamr@2: ECmpCollated, williamr@2: williamr@2: williamr@2: /** williamr@2: For descriptor keys, the key is assumed to be the 8 bit variant, williamr@2: derived from TDesc8. Collation rules are applied for the purpose of williamr@2: the comparison. williamr@2: williamr@2: For text keys, the key is assumed to be the 8 bit variant, of type williamr@2: TText8. Collation rules are applied for the purpose of the comparison. williamr@2: */ williamr@2: ECmpCollated8, williamr@2: williamr@2: williamr@2: /** williamr@2: For descriptor keys, the key is assumed to be the 16 bit variant, williamr@2: derived from TDesc16. Collation rules are applied for the purpose of williamr@2: the comparison. williamr@2: williamr@2: For text keys, the key is assumed to be the 16 bit variant, williamr@2: of type TText16. Collation rules are applied for the purpose of williamr@2: the comparison. williamr@2: */ williamr@2: ECmpCollated16 williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Governs the type of comparison to be made between numeric keys. williamr@2: williamr@2: @see TKeyArrayFix williamr@2: @see TKeyArrayVar williamr@2: @see TKeyArrayPak williamr@2: */ williamr@2: enum TKeyCmpNumeric williamr@2: { williamr@2: /** williamr@2: The key is assumed to be of type TInt8. williamr@2: */ williamr@2: ECmpTInt8=((ECmpCollated16+1)<<1), williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TInt16. williamr@2: */ williamr@2: ECmpTInt16, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TInt32. williamr@2: */ williamr@2: ECmpTInt32, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TInt. williamr@2: */ williamr@2: ECmpTInt, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TUint8. williamr@2: */ williamr@2: ECmpTUint8, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TUint16. williamr@2: */ williamr@2: ECmpTUint16, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TUint32. williamr@2: */ williamr@2: ECmpTUint32, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TUint. williamr@2: */ williamr@2: ECmpTUint, williamr@2: williamr@2: williamr@2: /** williamr@2: The key is assumed to be of type TInt64. williamr@2: */ williamr@2: ECmpTInt64 williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the characteristics of a key used to access the elements of an array. williamr@2: williamr@2: The class is abstract and cannot be instantiated. A derived class must be williamr@2: defined and implemented. williamr@2: williamr@2: The classes TKeyArrayFix, TKeyArrayVar and TKeyArrayPak, derived from TKey, williamr@2: are already supplied to implement keys for the fixed length element, variable williamr@2: length element and packed arrays. williamr@2: williamr@2: A derived class would normally be written to define the characteristics of williamr@2: a key for a non standard array. williamr@2: williamr@2: @see TKeyArrayFix williamr@2: @see TKeyArrayVar williamr@2: @see TKeyArrayPak williamr@2: */ williamr@2: class TKey williamr@2: { williamr@2: public: williamr@2: inline void SetPtr(const TAny* aPtr); williamr@2: IMPORT_C virtual TInt Compare(TInt aLeft,TInt aRight) const; williamr@2: IMPORT_C virtual TAny* At(TInt anIndex) const; williamr@2: protected: williamr@2: IMPORT_C TKey(); williamr@2: IMPORT_C TKey(TInt aOffset,TKeyCmpText aType); williamr@2: IMPORT_C TKey(TInt aOffset,TKeyCmpText aType,TInt aLength); williamr@2: IMPORT_C TKey(TInt aOffset,TKeyCmpNumeric aType); williamr@2: protected: williamr@2: TInt iKeyOffset; williamr@2: TInt iKeyLength; williamr@2: TInt iCmpType; williamr@2: const TAny* iPtr; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the basic behaviour for swapping two elements of an array. williamr@2: williamr@2: The class is abstract. A derived class must be defined and implemented to williamr@2: use the functionality. williamr@2: williamr@2: A derived class can define how to swap two elements of an array. In practice, williamr@2: this means providing an implementation for the virtual function Swap(). williamr@2: williamr@2: To support this, the derived class is also likely to need a pointer to the williamr@2: array itself and suitable constructors and/or other member functions to set williamr@2: such a pointer. williamr@2: */ williamr@2: class TSwap williamr@2: { williamr@2: public: williamr@2: IMPORT_C TSwap(); williamr@2: IMPORT_C virtual void Swap(TInt aLeft,TInt aRight) const; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Folds a specified character and provides functions to fold additional williamr@2: characters after construction of the object. williamr@2: williamr@2: Folding converts the character to a form which can be used in tolerant williamr@2: comparisons without control over the operations performed. Tolerant comparisons williamr@2: are those which ignore character differences like case and accents. williamr@2: williamr@2: Note that folding is locale-independent behaviour. It is also important to williamr@2: note that there can be no guarantee that folding is in any way culturally williamr@2: appropriate, and should not be used for matching characters in williamr@2: natural language. williamr@2: williamr@2: @see User::Fold williamr@2: */ williamr@2: class TCharF : public TChar williamr@2: { williamr@2: public: williamr@2: inline TCharF(TUint aChar); williamr@2: inline TCharF(const TChar& aChar); williamr@2: inline TCharF& operator=(TUint aChar); williamr@2: inline TCharF& operator=(const TChar& aChar); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Converts a specified character to lower case and provides functions to convert williamr@2: additional characters after construction of the object. williamr@2: */ williamr@2: class TCharLC : public TChar williamr@2: { williamr@2: public: williamr@2: inline TCharLC(TUint aChar); williamr@2: inline TCharLC(const TChar& aChar); williamr@2: inline TCharLC& operator=(TUint aChar); williamr@2: inline TCharLC& operator=(const TChar& aChar); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Converts a specified character to upper case and provides functions to convert williamr@2: additional characters after construction of the object. williamr@2: */ williamr@2: class TCharUC : public TChar williamr@2: { williamr@2: public: williamr@2: inline TCharUC(TUint aChar); williamr@2: inline TCharUC(const TChar& aChar); williamr@2: inline TCharUC& operator=(TUint aChar); williamr@2: inline TCharUC& operator=(const TChar& aChar); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the character representation of a real number type such williamr@2: as a TReal or a TRealX. williamr@2: williamr@2: An object of this type is used by functions that convert real values to williamr@2: character format, for example, the descriptor functions: williamr@2: Num(), AppendNum() and Format(). williamr@2: williamr@2: There are three constructors for constructing a suitable object. williamr@2: The data members of the class, however, are public and can be williamr@2: explicitly set after construction. williamr@2: */ williamr@2: class TRealFormat williamr@2: { williamr@2: public: williamr@2: IMPORT_C TRealFormat(); williamr@2: IMPORT_C TRealFormat(TInt aWidth); williamr@2: IMPORT_C TRealFormat(TInt aWidth,TInt aDecimalPlaces); williamr@2: public: williamr@2: /** williamr@2: Governs the format of the character representation of the real number. williamr@2: williamr@2: This is set to one of the defined format types. williamr@2: williamr@2: One or more of the defined format flags can subsequently be ORed into this member. williamr@2: williamr@2: @see KRealFormatFixed williamr@2: @see KRealFormatExponent williamr@2: @see KRealFormatGeneral williamr@2: @see KRealFormatNoExponent williamr@2: @see KRealFormatCalculator williamr@2: @see KExtraSpaceForSign williamr@2: @see KAllowThreeDigitExp williamr@2: @see KDoNotUseTriads williamr@2: @see KGeneralLimit williamr@2: @see KUseSigFigs williamr@2: */ williamr@2: TInt iType; williamr@2: williamr@2: williamr@2: /** williamr@2: Defines the maximum number of characters required to represent the number. williamr@2: */ williamr@2: TInt iWidth; williamr@2: williamr@2: williamr@2: /** williamr@2: Defines either the number of characters to be used to represent the decimal williamr@2: portion of the number, or the maximum number of significant digits in williamr@2: the character representation of the number. williamr@2: williamr@2: The interpretation depends on the chosen format as defined by iType. williamr@2: williamr@2: @see TRealFormat::iType williamr@2: */ williamr@2: TInt iPlaces; williamr@2: williamr@2: williamr@2: /** williamr@2: Defines the character to be used to separate the integer portion of williamr@2: a number representation from its decimal portion. williamr@2: williamr@2: In general, the character used for this purpose is a matter of local williamr@2: convention. The TLocale::DecimalSeparator() function can supply the williamr@2: desired character. williamr@2: williamr@2: @see TLocale williamr@2: */ williamr@2: TChar iPoint; williamr@2: williamr@2: williamr@2: /** williamr@2: Defines the character to be used to delimit groups of three digits in williamr@2: the integer part of the number. williamr@2: williamr@2: In general, the character used for this purpose is a matter of local williamr@2: convention. The TLocale::ThousandsSeparator() function can supply the williamr@2: desired character. williamr@2: williamr@2: @see TLocale williamr@2: */ williamr@2: TChar iTriad; williamr@2: williamr@2: williamr@2: /** williamr@2: Defines the threshold number of digits above which triad separation is to williamr@2: occur. A value of zero disables triad separation and no triad separation williamr@2: character (i.e. the character held in iTriad) is inserted into the williamr@2: resulting character representation regardless of the number of characters. williamr@2: williamr@2: For example, a value of 1 causes the number 1000 to be represented by the williamr@2: characters "1,000" whereas a value of 4 causes the same number to be williamr@2: represented by the characters "1000" (This assumes the ‘,’ triad separation williamr@2: character). williamr@2: williamr@2: Note that no triad separation occurs if the flag KDoNotUseTriads is set in williamr@2: the iType data member. williamr@2: williamr@2: @see TRealFormat::iTriad williamr@2: @see KDoNotUseTriads williamr@2: */ williamr@2: TInt iTriLen; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the extraction mark used by the TLex8 class to indicate the current williamr@2: lexical element being analysed. williamr@2: williamr@2: In practice, objects of this type are accessed through the TLexMark typedef. williamr@2: williamr@2: @see TLexMark williamr@2: @see TLex8 williamr@2: */ williamr@2: class TLexMark8 williamr@2: { williamr@2: public: williamr@2: inline TLexMark8(); williamr@2: private: williamr@2: inline TLexMark8(const TUint8* aString); williamr@2: const TUint8* iPtr; williamr@2: friend class TLex8; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class TRealX; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Provides general string-parsing functions suitable for numeric format williamr@2: conversions and syntactical-element parsing. williamr@2: williamr@2: The class is the 8-bit variant for non-Unicode strings and 8-bit wide williamr@2: characters. williamr@2: williamr@2: An instance of this class stores a string, maintaining an extraction mark williamr@2: to indicate the current lexical element being analysed and a pointer to the williamr@2: next character to be examined. williamr@2: williamr@2: Objects of this type are normally accessed through the build independent type williamr@2: TLex. williamr@2: williamr@2: @see TLex williamr@2: */ williamr@2: class TLex8 williamr@2: { williamr@2: public: williamr@2: IMPORT_C TLex8(); williamr@2: inline TLex8(const TUint8* aString); williamr@2: inline TLex8(const TDesC8& aDes); williamr@2: inline TLex8& operator=(const TUint8* aString); williamr@2: inline TLex8& operator=(const TDesC8& aDes); williamr@2: inline TBool Eos() const; williamr@2: inline void Mark(TLexMark8& aMark) const; williamr@2: inline void Mark(); williamr@2: IMPORT_C void Inc(); williamr@2: IMPORT_C void Inc(TInt aNumber); williamr@2: IMPORT_C TChar Get(); williamr@2: IMPORT_C TChar Peek() const; williamr@2: IMPORT_C void UnGet(); williamr@2: inline void UnGetToMark(); williamr@2: IMPORT_C void UnGetToMark(const TLexMark8 aMark); williamr@2: IMPORT_C void SkipSpace(); williamr@2: inline void SkipAndMark(TInt aNumber); williamr@2: IMPORT_C void SkipAndMark(TInt aNumber, TLexMark8& aMark); williamr@2: inline void SkipSpaceAndMark(); williamr@2: IMPORT_C void SkipSpaceAndMark(TLexMark8& aMark); williamr@2: IMPORT_C void SkipCharacters(); williamr@2: inline TInt TokenLength() const; williamr@2: IMPORT_C TInt TokenLength(const TLexMark8 aMark) const; williamr@2: IMPORT_C TPtrC8 MarkedToken() const; williamr@2: IMPORT_C TPtrC8 MarkedToken(const TLexMark8 aMark) const; williamr@2: IMPORT_C TPtrC8 NextToken(); williamr@2: IMPORT_C TPtrC8 Remainder() const; williamr@2: IMPORT_C TPtrC8 RemainderFromMark() const; williamr@2: IMPORT_C TPtrC8 RemainderFromMark(const TLexMark8 aMark) const; williamr@2: IMPORT_C TInt Offset() const; williamr@2: inline TInt MarkedOffset() const; williamr@2: IMPORT_C TInt MarkedOffset(const TLexMark8 aMark) const; williamr@2: IMPORT_C TInt Val(TInt8& aVal); williamr@2: IMPORT_C TInt Val(TInt16& aVal); williamr@2: IMPORT_C TInt Val(TInt32& aVal); williamr@2: IMPORT_C TInt Val(TInt64& aVal); williamr@2: inline TInt Val(TInt& aVal); williamr@2: IMPORT_C TInt Val(TUint8& aVal,TRadix aRadix); williamr@2: IMPORT_C TInt Val(TUint16& aVal,TRadix aRadix); williamr@2: IMPORT_C TInt Val(TUint32& aVal,TRadix aRadix); williamr@2: IMPORT_C TInt Val(TInt64& aVal, TRadix aRadix); williamr@2: inline TInt Val(TUint& aVal,TRadix aRadix=EDecimal); williamr@2: IMPORT_C TInt BoundedVal(TInt32& aVal,TInt aLimit); williamr@2: IMPORT_C TInt BoundedVal(TInt64& aVal, const TInt64& aLimit); williamr@2: IMPORT_C TInt BoundedVal(TUint32& aVal,TRadix aRadix,TUint aLimit); williamr@2: IMPORT_C TInt BoundedVal(TInt64& aVal, TRadix aRadix, const TInt64& aLimit); williamr@2: IMPORT_C TInt Val(TReal32& aVal); williamr@2: IMPORT_C TInt Val(TReal32& aVal,TChar aPoint); williamr@2: IMPORT_C TInt Val(TReal64& aVal); williamr@2: IMPORT_C TInt Val(TReal64& aVal,TChar aPoint); williamr@2: inline void Assign(const TLex8& aLex); williamr@2: IMPORT_C void Assign(const TUint8* aString); williamr@2: IMPORT_C void Assign(const TDesC8& aDes); williamr@2: TInt Val(TRealX& aVal); williamr@2: TInt Val(TRealX& aVal, TChar aPoint); williamr@2: williamr@2: /** @deprecated Use BoundedVal(TInt32& aVal,TInt aLimit) */ williamr@2: inline TInt Val(TInt32& aVal,TInt aLimit) { return BoundedVal(aVal,aLimit); }; williamr@2: williamr@2: /** @deprecated Use BoundedVal(TInt64& aVal,const TInt64& aLimit) */ williamr@2: inline TInt Val(TInt64& aVal,const TInt64& aLimit) { return BoundedVal(aVal,aLimit); }; williamr@2: williamr@2: /** @deprecated Use BoundedVal(TUint32& aVal,TRadix aRadix,TUint aLimit) */ williamr@2: inline TInt Val(TUint32& aVal,TRadix aRadix,TUint aLimit) { return BoundedVal(aVal,aRadix,aLimit); }; williamr@2: williamr@2: /** @deprecated Use BoundedVal(TInt64& aVal,TRadix aRadix,const TInt64& aLimit) */ williamr@2: inline TInt Val(TInt64& aVal,TRadix aRadix,const TInt64& aLimit) { return BoundedVal(aVal,aRadix,aLimit); }; williamr@2: private: williamr@4: void Scndig(TInt& aSig, TInt& aExp, TUint64& aDl); williamr@4: void ScndigAfterPoint(TInt& aSig, TUint64& aDl); williamr@2: void ValidateMark(const TLexMark8 aMark) const; williamr@2: private: williamr@2: const TUint8* iNext; williamr@2: const TUint8* iBuf; williamr@2: const TUint8* iEnd; williamr@2: TLexMark8 iMark; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the extraction mark used by the TLex16 class to indicate the current williamr@2: lexical element being analysed. williamr@2: williamr@2: In practice, objects of this type are accessed through the TLexMark typedef. williamr@2: williamr@2: @see TLexMark williamr@2: @see TLex16 williamr@2: */ williamr@2: class TLexMark16 williamr@2: { williamr@2: public: williamr@2: inline TLexMark16(); williamr@2: private: williamr@2: inline TLexMark16(const TUint16* aString); williamr@2: const TUint16* iPtr; williamr@2: friend class TLex16; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Provides general string-parsing functions suitable for numeric format williamr@2: conversions and syntactical-element parsing. williamr@2: williamr@2: The class is the 16-bit variant for Unicode strings and 16-bit wide williamr@2: characters. williamr@2: williamr@2: An instance of this class stores a string, maintaining an extraction mark williamr@2: to indicate the current lexical element being analysed and a pointer to the williamr@2: next character to be examined. williamr@2: williamr@2: Objects of this type are normally accessed through the build independent type williamr@2: TLex. williamr@2: williamr@2: @see TLex williamr@2: */ williamr@2: class TLex16 williamr@2: { williamr@2: public: williamr@2: IMPORT_C TLex16(); williamr@2: inline TLex16(const TUint16* aString); williamr@2: inline TLex16(const TDesC16& aDes); williamr@2: inline TLex16& operator=(const TUint16* aString); williamr@2: inline TLex16& operator=(const TDesC16& aDes); williamr@2: inline TBool Eos() const; williamr@2: inline void Mark(); williamr@2: inline void Mark(TLexMark16& aMark) const; williamr@2: IMPORT_C void Inc(); williamr@2: IMPORT_C void Inc(TInt aNumber); williamr@2: IMPORT_C TChar Get(); williamr@2: IMPORT_C TChar Peek() const; williamr@2: IMPORT_C void UnGet(); williamr@2: inline void UnGetToMark(); williamr@2: IMPORT_C void UnGetToMark(const TLexMark16 aMark); williamr@2: IMPORT_C void SkipSpace(); williamr@2: inline void SkipAndMark(TInt aNumber); williamr@2: IMPORT_C void SkipAndMark(TInt aNumber, TLexMark16& aMark); williamr@2: IMPORT_C void SkipSpaceAndMark(TLexMark16& aMark); williamr@2: inline void SkipSpaceAndMark(); williamr@2: IMPORT_C void SkipCharacters(); williamr@2: inline TInt TokenLength() const; williamr@2: IMPORT_C TInt TokenLength(const TLexMark16 aMark) const; williamr@2: IMPORT_C TPtrC16 MarkedToken() const; williamr@2: IMPORT_C TPtrC16 MarkedToken(const TLexMark16 aMark) const; williamr@2: IMPORT_C TPtrC16 NextToken(); williamr@2: IMPORT_C TPtrC16 Remainder() const; williamr@2: IMPORT_C TPtrC16 RemainderFromMark() const; williamr@2: IMPORT_C TPtrC16 RemainderFromMark(const TLexMark16 aMark) const; williamr@2: IMPORT_C TInt Offset() const; williamr@2: inline TInt MarkedOffset() const; williamr@2: IMPORT_C TInt MarkedOffset(const TLexMark16 aMark) const; williamr@2: IMPORT_C TInt Val(TInt8& aVal); williamr@2: IMPORT_C TInt Val(TInt16& aVal); williamr@2: IMPORT_C TInt Val(TInt32& aVal); williamr@2: IMPORT_C TInt Val(TInt64& aVal); williamr@2: inline TInt Val(TInt& aVal); williamr@2: IMPORT_C TInt Val(TUint8& aVal,TRadix aRadix); williamr@2: IMPORT_C TInt Val(TUint16& aVal,TRadix aRadix); williamr@2: IMPORT_C TInt Val(TUint32& aVal,TRadix aRadix); williamr@2: IMPORT_C TInt Val(TInt64& aVal, TRadix aRadix); williamr@2: // inline TInt Val(TInt64& aVal, TRadix aRadix) {return Val(aVal,aRadix);} williamr@2: inline TInt Val(TUint& aVal,TRadix aRadix=EDecimal); williamr@2: IMPORT_C TInt BoundedVal(TInt32& aVal,TInt aLimit); williamr@2: IMPORT_C TInt BoundedVal(TInt64& aVal, const TInt64& aLimit); williamr@2: IMPORT_C TInt BoundedVal(TUint32& aVal,TRadix aRadix,TUint aLimit); williamr@2: IMPORT_C TInt BoundedVal(TInt64& aVal, TRadix aRadix, const TInt64& aLimit); williamr@2: IMPORT_C TInt Val(TReal32& aVal); williamr@2: IMPORT_C TInt Val(TReal32& aVal,TChar aPoint); williamr@2: IMPORT_C TInt Val(TReal64& aVal); williamr@2: IMPORT_C TInt Val(TReal64& aVal,TChar aPoint); williamr@2: inline void Assign(const TLex16& aLex); williamr@2: IMPORT_C void Assign(const TUint16* aString); williamr@2: IMPORT_C void Assign(const TDesC16& aDes); williamr@2: TInt Val(TRealX& aVal); williamr@2: TInt Val(TRealX& aVal, TChar aPoint); williamr@2: williamr@2: /** @deprecated Use BoundedVal(TInt32& aVal,TInt aLimit) */ williamr@2: inline TInt Val(TInt32& aVal,TInt aLimit) { return BoundedVal(aVal,aLimit); }; williamr@2: williamr@2: /** @deprecated Use BoundedVal(TInt64& aVal,const TInt64& aLimit) */ williamr@2: inline TInt Val(TInt64& aVal,const TInt64& aLimit) { return BoundedVal(aVal,aLimit); }; williamr@2: williamr@2: /** @deprecated Use BoundedVal(TUint32& aVal,TRadix aRadix,TUint aLimit) */ williamr@2: inline TInt Val(TUint32& aVal,TRadix aRadix,TUint aLimit) { return BoundedVal(aVal,aRadix,aLimit); }; williamr@2: williamr@2: /** @deprecated Use BoundedVal(TInt64& aVal,TRadix aRadix,const TInt64& aLimit) */ williamr@2: inline TInt Val(TInt64& aVal,TRadix aRadix,const TInt64& aLimit) { return BoundedVal(aVal,aRadix,aLimit); }; williamr@2: private: williamr@4: void Scndig(TInt& aSig, TInt& aExp, TUint64& aDl); williamr@2: void ValidateMark(const TLexMark16 aMark) const; williamr@2: private: williamr@2: const TUint16* iNext; williamr@2: const TUint16* iBuf; williamr@2: const TUint16* iEnd; williamr@2: TLexMark16 iMark; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #if defined(_UNICODE) williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Provides access to general string-parsing functions suitable for numeric format williamr@2: conversions and syntactical-element parsing. williamr@2: williamr@2: It maps directly to either a TLex16 for a Unicode build or a TLex8 for a non-Unicode williamr@2: build. williamr@2: williamr@2: The build independent type should always be used unless an explicit 16 bit williamr@2: or 8 bit build variant is required. williamr@2: williamr@2: @see TLex16 williamr@2: @see TLex8 williamr@2: */ williamr@2: typedef TLex16 TLex; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the extraction mark used by the TLex classes to indicate the current williamr@2: lexical element being analysed. williamr@2: williamr@2: It maps directly to either a TLexMark16 for a Unicode build or a TLexMark8 williamr@2: for a non-Unicode build. williamr@2: williamr@2: The build independent type should always be used unless an explicit 16 bit williamr@2: or 8 bit build variant is required. williamr@2: */ williamr@2: typedef TLexMark16 TLexMark; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #else williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Provides access to general string-parsing functions suitable for numeric format williamr@2: conversions and syntactical-element parsing. williamr@2: williamr@2: It maps directly to either a TLex16 for a Unicode build or a TLex8 for a non-Unicode williamr@2: build. williamr@2: williamr@2: The build independent type should always be used unless an explicit 16 bit williamr@2: or 8 bit build variant is required. williamr@2: williamr@2: @see TLex16 williamr@2: @see TLex8 williamr@2: */ williamr@2: typedef TLex8 TLex; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Defines the extraction mark used by the TLex classes to indicate the current williamr@2: lexical element being analysed. williamr@2: williamr@2: It maps directly to either a TLexMark16 for a Unicode build or a TLexMark8 williamr@2: for a non-Unicode build. williamr@2: williamr@2: The build independent type should always be used unless an explicit 16 bit williamr@2: or 8 bit build variant is required. williamr@2: */ williamr@2: typedef TLexMark8 TLexMark; 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 Uid type together with a checksum. williamr@2: williamr@2: @see TUidType williamr@2: */ williamr@2: class TCheckedUid williamr@2: { williamr@2: public: williamr@2: IMPORT_C TCheckedUid(); williamr@2: IMPORT_C TCheckedUid(const TUidType& aUidType); williamr@2: IMPORT_C TCheckedUid(const TDesC8& aPtr); williamr@2: IMPORT_C void Set(const TUidType& aUidType); williamr@2: IMPORT_C void Set(const TDesC8& aPtr); williamr@2: IMPORT_C TPtrC8 Des() const; williamr@2: inline const TUidType& UidType() const; williamr@2: protected: williamr@2: IMPORT_C TUint Check() const; williamr@2: private: williamr@2: TUidType iType; williamr@2: TUint iCheck; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A date and time object in which the individual components are accessible in williamr@2: human-readable form. williamr@2: williamr@2: The individual components are: year, month, day, hour, minute, williamr@2: second and microsecond. williamr@2: williamr@2: These components are stored as integers and all except the year are checked for williamr@2: validity when a TDateTime is constructed or assigned new values. williamr@2: williamr@2: This class only supports getting and setting the entire date/time or any component williamr@2: of it. It does not support adding or subtracting intervals to or from a time. williamr@2: For functions which manipulate times, use class TTime. williamr@2: williamr@2: @see TTime williamr@2: */ williamr@2: class TDateTime williamr@2: { williamr@2: public: williamr@2: inline TDateTime(); williamr@2: IMPORT_C TDateTime(TInt aYear,TMonth aMonth,TInt aDay,TInt aHour,TInt aMinute, TInt aSecond,TInt aMicroSecond); williamr@2: IMPORT_C TInt Set(TInt aYear,TMonth aMonth,TInt aDay,TInt aHour,TInt aMinute, TInt aSecond,TInt aMicroSecond); williamr@2: IMPORT_C TInt SetYear(TInt aYear); williamr@2: IMPORT_C TInt SetYearLeapCheck(TInt aYear); williamr@2: IMPORT_C TInt SetMonth(TMonth aMonth); williamr@2: IMPORT_C TInt SetDay(TInt aDay); williamr@2: IMPORT_C TInt SetHour(TInt aHour); williamr@2: IMPORT_C TInt SetMinute(TInt aMinute); williamr@2: IMPORT_C TInt SetSecond(TInt aSecond); williamr@2: IMPORT_C TInt SetMicroSecond(TInt aMicroSecond); williamr@2: inline TInt Year() const; williamr@2: inline TMonth Month() const; williamr@2: inline TInt Day() const; williamr@2: inline TInt Hour() const; williamr@2: inline TInt Minute() const; williamr@2: inline TInt Second() const; williamr@2: inline TInt MicroSecond() const; williamr@2: private: williamr@2: TInt iYear; williamr@2: TMonth iMonth; williamr@2: TInt iDay; williamr@2: TInt iHour; williamr@2: TInt iMinute; williamr@2: TInt iSecond; williamr@2: TInt iMicroSecond; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval of a millionth of a second stored as williamr@2: a 64-bit integer. williamr@2: williamr@2: It supports the initialisation, setting and getting of an interval and provides williamr@2: standard comparison operations. Objects of this class can be added to and williamr@2: subtracted from TTime objects. williamr@2: williamr@2: @see TTime williamr@2: */ williamr@2: class TTimeIntervalMicroSeconds williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalMicroSeconds(); williamr@2: inline TTimeIntervalMicroSeconds(const TInt64& aInterval); williamr@2: inline TTimeIntervalMicroSeconds& operator=(const TInt64& aInterval); williamr@2: inline TBool operator==(const TTimeIntervalMicroSeconds& aInterval) const; williamr@2: inline TBool operator!=(const TTimeIntervalMicroSeconds& aInterval) const; williamr@2: inline TBool operator>=(const TTimeIntervalMicroSeconds& aInterval) const; williamr@2: inline TBool operator<=(const TTimeIntervalMicroSeconds& aInterval) const; williamr@2: inline TBool operator>(const TTimeIntervalMicroSeconds& aInterval) const; williamr@2: inline TBool operator<(const TTimeIntervalMicroSeconds& aInterval) const; williamr@2: inline const TInt64& Int64() const; williamr@2: private: williamr@2: TInt64 iInterval; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Provides a base class for all time interval classes using williamr@2: a 32-bit representation. williamr@2: williamr@2: It supports retrieving the interval and provides various operations for williamr@2: comparing intervals. Its concrete derived classes can be added to and williamr@2: subtracted from a TTime. williamr@2: williamr@2: The comparison operators simply compare the integer representations of the williamr@2: two intervals. They do not take account of different time interval units. williamr@2: So, for example, when comparing for equality an interval of three hours with williamr@2: an interval of three days, the result is true. williamr@2: williamr@2: @see TTime williamr@2: */ williamr@2: class TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TBool operator==(TTimeIntervalBase aInterval) const; williamr@2: inline TBool operator!=(TTimeIntervalBase aInterval) const; williamr@2: inline TBool operator>=(TTimeIntervalBase aInterval) const; williamr@2: inline TBool operator<=(TTimeIntervalBase aInterval) const; williamr@2: inline TBool operator>(TTimeIntervalBase aInterval) const; williamr@2: inline TBool operator<(TTimeIntervalBase aInterval) const; williamr@2: inline TInt Int() const; williamr@2: protected: williamr@2: inline TTimeIntervalBase(); williamr@2: inline TTimeIntervalBase(TInt aInterval); williamr@2: protected: williamr@2: TInt iInterval; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a microsecond time interval stored in 32 rather than 64 bits. williamr@2: williamr@2: Its range is +-2147483647, which is +-35 minutes, 47 seconds. Comparison and williamr@2: interval retrieval functions are provided by the base class TTimeIntervalBase. williamr@2: */ williamr@2: class TTimeIntervalMicroSeconds32 : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalMicroSeconds32(); williamr@2: inline TTimeIntervalMicroSeconds32(TInt aInterval); williamr@2: inline TTimeIntervalMicroSeconds32& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval in seconds. williamr@2: williamr@2: Comparison and interval retrieval functions williamr@2: are provided by the base class TTimeIntervalBase. williamr@2: williamr@2: The range of values which it can represent is +-2147483647, which is equal to williamr@2: +-24855 days (approximately 68 years). williamr@2: */ williamr@2: class TTimeIntervalSeconds : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalSeconds(); williamr@2: inline TTimeIntervalSeconds(TInt aInterval); williamr@2: inline TTimeIntervalSeconds& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval in minutes. williamr@2: williamr@2: Comparison and interval retrieval functions williamr@2: are provided by the base class TTimeIntervalBase. williamr@2: */ williamr@2: class TTimeIntervalMinutes : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalMinutes(); williamr@2: inline TTimeIntervalMinutes(TInt aInterval); williamr@2: inline TTimeIntervalMinutes& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval in hours. williamr@2: williamr@2: Comparison and interval retrieval functions williamr@2: are provided by the base class TTimeIntervalBase. williamr@2: */ williamr@2: class TTimeIntervalHours : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalHours(); williamr@2: inline TTimeIntervalHours(TInt aInterval); williamr@2: inline TTimeIntervalHours& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval in days. williamr@2: williamr@2: Comparison and interval retrieval functions williamr@2: are provided by the base class TTimeIntervalBase. williamr@2: */ williamr@2: class TTimeIntervalDays : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalDays(); williamr@2: inline TTimeIntervalDays(TInt aInterval); williamr@2: inline TTimeIntervalDays& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval in months. williamr@2: williamr@2: Comparison and interval retrieval functions williamr@2: are provided by the base class TTimeIntervalBase. williamr@2: */ williamr@2: class TTimeIntervalMonths : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalMonths(); williamr@2: inline TTimeIntervalMonths(TInt aInterval); williamr@2: inline TTimeIntervalMonths& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Represents a time interval in years. williamr@2: williamr@2: Comparison and interval retrieval functions williamr@2: are provided by the base class TTimeIntervalBase. williamr@2: */ williamr@2: class TTimeIntervalYears : public TTimeIntervalBase williamr@2: { williamr@2: public: williamr@2: inline TTimeIntervalYears(); williamr@2: inline TTimeIntervalYears(TInt aInterval); williamr@2: inline TTimeIntervalYears& operator=(TInt aInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An enumeration one or both of whose enumerator values may be returned williamr@2: by TTime::Parse(). williamr@2: williamr@2: @see TTime::Parse williamr@2: */ williamr@2: enum { williamr@2: /** williamr@2: Indicates that a time is present. williamr@2: williamr@2: @see TTime::Parse williamr@2: */ williamr@2: EParseTimePresent=0x1, williamr@2: /** williamr@2: Indicates that a date is present. williamr@2: williamr@2: @see TTime::Parse williamr@2: */ williamr@2: EParseDatePresent=0x2 williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: class TLocale; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Stores and manipulates the date and time. williamr@2: williamr@2: It represents a date and time as a number of microseconds since midnight, williamr@4: January 1st, 1 AD nominal Gregorian. BC dates are represented by negative williamr@2: TTime values. A TTime object may be constructed from a TInt64, a TDateTime williamr@2: a string literal, or by default, which initialises the time to an arbitrary williamr@2: value. To access human-readable time information, the TTime may be converted williamr@2: from a TInt64 into a TDateTime, which represents the date and time as seven williamr@2: numeric fields and provides functions to extract these fields. Alternatively, williamr@2: to display the time as text, the time may be formatted and placed into a williamr@2: descriptor using a variety of formatting commands and which may or may not williamr@2: honour the system's locale settings. The conversion between time and text may williamr@2: be performed the other way around, so that a descriptor can be parsed and williamr@2: converted into a TTime value. williamr@2: williamr@2: In addition to setting and getting the date and time and converting between williamr@2: text and time, TTime provides functions to get intervals between times and williamr@2: standard comparison and arithmetic operators which enable time intervals to williamr@2: be added or subtracted to or from the time. williamr@2: williamr@2: @see TInt64 williamr@2: @see TDateTime williamr@2: */ williamr@2: class TTime williamr@2: { williamr@2: public: williamr@2: inline TTime(); williamr@2: inline TTime(const TInt64& aTime); williamr@2: IMPORT_C TTime(const TDesC& aString); williamr@2: IMPORT_C TTime(const TDateTime& aDateTime); williamr@2: inline TTime& operator=(const TInt64& aTime); williamr@2: IMPORT_C TTime& operator=(const TDateTime& aDateTime); williamr@2: IMPORT_C void HomeTime(); williamr@2: IMPORT_C void UniversalTime(); williamr@2: IMPORT_C TInt Set(const TDesC& aString); williamr@2: IMPORT_C TInt HomeTimeSecure(); williamr@2: IMPORT_C TInt UniversalTimeSecure(); williamr@2: williamr@2: IMPORT_C TDateTime DateTime() const; williamr@2: IMPORT_C TTimeIntervalMicroSeconds MicroSecondsFrom(TTime aTime) const; williamr@2: IMPORT_C TInt SecondsFrom(TTime aTime,TTimeIntervalSeconds& aInterval) const; williamr@2: IMPORT_C TInt MinutesFrom(TTime aTime,TTimeIntervalMinutes& aInterval) const; williamr@2: IMPORT_C TInt HoursFrom(TTime aTime,TTimeIntervalHours& aInterval) const; williamr@2: IMPORT_C TTimeIntervalDays DaysFrom(TTime aTime) const; williamr@2: IMPORT_C TTimeIntervalMonths MonthsFrom(TTime aTime) const; williamr@2: IMPORT_C TTimeIntervalYears YearsFrom(TTime aTime) const; williamr@2: williamr@2: IMPORT_C TInt DaysInMonth() const; williamr@2: IMPORT_C TDay DayNoInWeek() const; williamr@2: IMPORT_C TInt DayNoInMonth() const; williamr@2: IMPORT_C TInt DayNoInYear() const; williamr@2: IMPORT_C TInt DayNoInYear(TTime aStartDate) const; williamr@2: IMPORT_C TInt WeekNoInYear() const; williamr@2: IMPORT_C TInt WeekNoInYear(TTime aStartDate) const; williamr@2: IMPORT_C TInt WeekNoInYear(TFirstWeekRule aRule) const; williamr@2: IMPORT_C TInt WeekNoInYear(TTime aStartDate,TFirstWeekRule aRule) const; williamr@2: IMPORT_C void FormatL(TDes& aDes,const TDesC& aFormat) const; williamr@2: IMPORT_C void FormatL(TDes& aDes,const TDesC& aFormat,const TLocale& aLocale) const; williamr@2: IMPORT_C void RoundUpToNextMinute(); williamr@2: IMPORT_C TInt Parse(const TDesC& aDes,TInt aCenturyOffset=0); williamr@2: williamr@2: IMPORT_C TTime operator+(TTimeIntervalYears aYear) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalMonths aMonth) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalDays aDay) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalHours aHour) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalMinutes aMinute) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalSeconds aSecond) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalMicroSeconds aMicroSecond) const; williamr@2: IMPORT_C TTime operator+(TTimeIntervalMicroSeconds32 aMicroSecond) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalYears aYear) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalMonths aMonth) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalDays aDay) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalHours aHour) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalMinutes aMinute) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalSeconds aSecond) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalMicroSeconds aMicroSecond) const; williamr@2: IMPORT_C TTime operator-(TTimeIntervalMicroSeconds32 aMicroSecond) const; williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalYears aYear); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalMonths aMonth); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalDays aDay); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalHours aHour); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalMinutes aMinute); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalSeconds aSecond); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalMicroSeconds aMicroSecond); williamr@2: IMPORT_C TTime& operator+=(TTimeIntervalMicroSeconds32 aMicroSecond); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalYears aYear); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalMonths aMonth); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalDays aDay); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalHours aHour); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalMinutes aMinute); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalSeconds aSecond); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalMicroSeconds aMicroSecond); williamr@2: IMPORT_C TTime& operator-=(TTimeIntervalMicroSeconds32 aMicroSecond); williamr@2: inline TBool operator==(TTime aTime) const; williamr@2: inline TBool operator!=(TTime aTime) const; williamr@2: inline TBool operator>=(TTime aTime) const; williamr@2: inline TBool operator<=(TTime aTime) const; williamr@2: inline TBool operator>(TTime aTime) const; williamr@2: inline TBool operator<(TTime aTime) const; williamr@2: inline const TInt64& Int64() const; williamr@2: private: williamr@2: static TTime Convert(const TDateTime& aDateTime); williamr@2: private: williamr@2: TInt64 iTime; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A utility class whose functions may be used by the other date/time related williamr@2: classes. williamr@2: */ williamr@2: class Time williamr@2: { williamr@2: public: williamr@2: IMPORT_C static TTime NullTTime(); williamr@2: IMPORT_C static TTime MaxTTime(); williamr@2: IMPORT_C static TTime MinTTime(); williamr@2: IMPORT_C static TInt DaysInMonth(TInt aYear, TMonth aMonth); williamr@2: IMPORT_C static TBool IsLeapYear(TInt aYear); williamr@2: IMPORT_C static TInt LeapYearsUpTo(TInt aYear); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Gets a copy of the current locale's full text name for a day of the week. williamr@2: williamr@2: After construction or after a call to Set(), the copy of the text can be accessed williamr@2: and manipulated using the standard descriptor member functions provided by williamr@2: the base class. williamr@2: williamr@2: @see KMaxDayName williamr@2: */ williamr@2: class TDayName : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TDayName(); williamr@2: IMPORT_C TDayName(TDay aDay); williamr@2: IMPORT_C void Set(TDay aDay); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Gets a copy of the current locale's abbreviated text name for a day of the williamr@2: week. williamr@2: williamr@2: After construction or after a call to Set(), the copy of the abbreviated text williamr@2: can be accessed and manipulated using the standard descriptor member functions williamr@2: provided by the base class. williamr@2: williamr@2: The abbreviated day name cannot be assumed to be one character. In English, williamr@2: it is 3 characters (Mon, Tue, Wed etc.), but the length can vary from locale williamr@2: to locale, with a maximum length of KMaxDayNameAbb. williamr@2: williamr@2: @see KMaxDayNameAbb williamr@2: */ williamr@2: class TDayNameAbb : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TDayNameAbb(); williamr@2: IMPORT_C TDayNameAbb(TDay aDay); williamr@2: IMPORT_C void Set(TDay aDay); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Gets a copy of the current locale's full text name for a month. williamr@2: williamr@2: After construction or after a call to Set(), the copy of the text can be accessed williamr@2: and manipulated using the standard descriptor member functions provided by williamr@2: the base class. williamr@2: williamr@2: @see KMaxMonthName williamr@2: */ williamr@2: class TMonthName : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TMonthName(); williamr@2: IMPORT_C TMonthName(TMonth aMonth); williamr@2: IMPORT_C void Set(TMonth aMonth); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Gets a copy of the current locale's abbreviated text name for a month. williamr@2: williamr@2: After construction or after a call to Set(), the copy of the abbreviated text williamr@2: can be accessed and manipulated using the standard descriptor member functions williamr@2: provided by the base class. williamr@2: williamr@2: @see KMaxMonthNameAbb williamr@2: */ williamr@2: class TMonthNameAbb : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TMonthNameAbb(); williamr@2: IMPORT_C TMonthNameAbb(TMonth aMonth); williamr@2: IMPORT_C void Set(TMonth aMonth); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Gets a copy of the current locale's date suffix text for a specific day in williamr@2: the month. williamr@2: williamr@2: The text is the set of characters which can be appended to dates of the month williamr@2: (e.g. in English, st for 1st, nd for 2nd etc). williamr@2: williamr@2: After construction or after a call to Set(), the copy of the suffix text can williamr@2: be accessed and manipulated using the standard descriptor member functions williamr@2: provided by the base class. williamr@2: */ williamr@2: class TDateSuffix : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TDateSuffix(); williamr@2: IMPORT_C TDateSuffix(TInt aDateSuffix); williamr@2: IMPORT_C void Set(TInt aDateSuffix); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Current locale's am/pm text williamr@2: williamr@2: This class retrieves a copy of the current locale's text identifying time williamr@2: before and after noon. In English, this is am and pm. williamr@2: williamr@2: After construction or after a call to Set(), the copy of the text can be accessed williamr@2: and manipulated using the standard descriptor member functions provided by williamr@2: the base class. williamr@2: */ williamr@2: class TAmPmName : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TAmPmName(); williamr@2: IMPORT_C TAmPmName(TAmPm aSelector); williamr@2: IMPORT_C void Set(TAmPm aSelector); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Gets a copy of the currency symbol(s) in use by the current locale. williamr@2: williamr@2: After construction or after a call to TCurrencySymbol::Set(), the copy of williamr@2: the currency symbol(s) can be accessed and manipulated using the standard williamr@2: descriptor member functions provided by the base class. williamr@2: */ williamr@2: class TCurrencySymbol : public TBuf williamr@2: { williamr@2: public: williamr@2: IMPORT_C TCurrencySymbol(); williamr@2: IMPORT_C void Set(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains a format list that defines the short date format. williamr@2: williamr@2: An instance of this class should be passed as the second argument williamr@2: to TTime::FormatL(). williamr@2: The string does not include any time components. The content of the long williamr@2: date format specification is taken from the system-wide settings. williamr@2: williamr@2: For example, in the English locale, the short date format would be something williamr@2: like 14/1/2000. williamr@2: williamr@2: This class is used as follows: williamr@2: williamr@2: @code williamr@2: TTime now; williamr@2: now.HomeTime(); williamr@2: TBuf buffer; williamr@2: now.FormatL(buffer,TShortDateFormatSpec()); williamr@2: @endcode williamr@2: williamr@2: @see KMaxShortDateFormatSpec williamr@2: @see TTime::FormatL williamr@2: */ williamr@2: class TShortDateFormatSpec : public TBuf // to be passed into TTime::FormatL williamr@2: { williamr@2: public: williamr@2: IMPORT_C TShortDateFormatSpec(); williamr@2: IMPORT_C void Set(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains a format list that defines the long date format. williamr@2: williamr@2: An instance of this class should be passed as the second argument williamr@2: to TTime::FormatL(). williamr@2: The string does not include any time components. The content of the long williamr@2: date format specification is taken from the system-wide settings. williamr@2: williamr@2: For example, in the English locale, the long date format would be williamr@2: something like 14th January 2000. williamr@2: williamr@2: This class is used as follows: williamr@2: williamr@2: @code williamr@2: TTime now; williamr@2: now.HomeTime(); williamr@2: TBuf buffer; williamr@2: now.FormatL(buffer,TLongDateFormatSpec()); williamr@2: @endcode williamr@2: williamr@2: @see KMaxLongDateFormatSpec williamr@2: @see TTime::FormatL williamr@2: */ williamr@2: class TLongDateFormatSpec : public TBuf // to be passed into TTime::FormatL williamr@2: { williamr@2: public: williamr@2: IMPORT_C TLongDateFormatSpec(); williamr@2: IMPORT_C void Set(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains a format list that defines the time string format. williamr@2: williamr@2: An instance of this class should be passed as the second argument williamr@2: to TTime::FormatL(). williamr@2: The string does not include any time components. The content of the time format williamr@2: specification is taken from the system-wide settings. williamr@2: williamr@2: This class is used as follows: williamr@2: williamr@2: @code williamr@2: TTime now; williamr@2: now.HomeTime(); williamr@2: TBuf buffer; williamr@2: now.FormatL(buffer,TTimeFormatSpec()); williamr@2: @endcode williamr@2: williamr@2: @see KMaxTimeFormatSpec williamr@2: @see TTime::FormatL williamr@2: */ williamr@2: class TTimeFormatSpec : public TBuf // to be passed into TTime::FormatL williamr@2: { williamr@2: public: williamr@2: IMPORT_C TTimeFormatSpec(); williamr@2: IMPORT_C void Set(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Sets and gets the system's locale settings. williamr@2: williamr@2: Symbian OS maintains the locale information internally. On williamr@2: construction, this object is initialized with the system information williamr@2: for all locale items. williamr@2: */ williamr@2: class TLocale williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: Indicates how negative currency values are formatted. williamr@2: */ williamr@2: enum TNegativeCurrencyFormat williamr@2: { williamr@2: /** williamr@2: A minus sign is inserted before the currency symbol and value. williamr@2: */ williamr@2: ELeadingMinusSign, williamr@2: williamr@2: /** williamr@2: The currency value and symbol are enclosed in brackets (no minus sign williamr@2: is used). williamr@2: */ williamr@2: EInBrackets, //this one must be non-zero for binary compatibility with the old TBool TLocale::iCurrencyNegativeInBrackets which was exposed in the binary interface because it was accessed via *inline* functions williamr@2: williamr@2: /** williamr@2: A minus sign is inserted after the currency symbol and value. williamr@2: */ williamr@2: ETrailingMinusSign, williamr@2: williamr@2: /** williamr@2: A minus sign is inserted between the currency symbol and the value. williamr@2: */ williamr@2: EInterveningMinusSign williamr@2: }; williamr@2: williamr@2: /** williamr@2: Flags for negative currency values formatting williamr@2: */ williamr@2: enum williamr@2: { williamr@2: /** williamr@2: If this flag is set and the currency value being formatted is negative, williamr@2: if there is a space between the currency symbol and the value, williamr@2: that space is lost. williamr@2: */ williamr@2: EFlagNegativeLoseSpace = 0x00000001, williamr@2: williamr@2: /** williamr@2: If this flag is set and the currency value being formatted is negative, williamr@2: the position of the currency symbol is placed in the opposite direction williamr@2: from the position set for the positive currency value. williamr@2: */ williamr@2: EFlagNegativeCurrencySymbolOpposite=0x00000002 williamr@2: }; williamr@2: /** Indicates how the device universal time is maintained */ williamr@2: enum TDeviceTimeState williamr@2: { williamr@2: /** Universal time is maintained by the device RTC and the user selection williamr@2: of the locale of the device indicating offset from GMT and daylight saving*/ williamr@2: EDeviceUserTime, williamr@2: williamr@2: /** Universal time and offset from GMT is supplied by the mobile network williamr@2: and maintained by device RTC */ williamr@2: ENITZNetworkTimeSync williamr@2: }; williamr@2: public: williamr@2: IMPORT_C TLocale(); williamr@2: inline TLocale(TInt); williamr@2: IMPORT_C void Refresh(); williamr@2: IMPORT_C TInt Set() const; williamr@2: IMPORT_C void FormatCurrency(TDes& aText, TInt aAmount); williamr@2: IMPORT_C void FormatCurrency(TDes& aText, TInt64 aAmount); williamr@2: IMPORT_C void FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt aAmount); williamr@2: IMPORT_C void FormatCurrency(TDes& aText, TDesOverflow& aOverflowHandler, TInt64 aAmount); williamr@2: williamr@2: inline TInt CountryCode() const; williamr@2: inline void SetCountryCode(TInt aCode); williamr@2: inline TTimeIntervalSeconds UniversalTimeOffset() const; williamr@2: inline TDateFormat DateFormat() const; williamr@2: inline void SetDateFormat(TDateFormat aFormat); williamr@2: inline TTimeFormat TimeFormat() const; williamr@2: inline void SetTimeFormat(TTimeFormat aFormat); williamr@2: inline TLocalePos CurrencySymbolPosition() const; williamr@2: inline void SetCurrencySymbolPosition(TLocalePos aPos); williamr@2: inline TBool CurrencySpaceBetween() const; williamr@2: inline void SetCurrencySpaceBetween(TBool aSpace); williamr@2: inline TInt CurrencyDecimalPlaces() const; williamr@2: inline void SetCurrencyDecimalPlaces(TInt aPlaces); williamr@2: inline TBool CurrencyNegativeInBrackets() const; // These two functions are deprecated williamr@2: inline void SetCurrencyNegativeInBrackets(TBool aBool); // They are here to maintain compatibility. Use the New functions -> NegativeCurrencyFormat setter/getter. williamr@2: inline TBool CurrencyTriadsAllowed() const; williamr@2: inline void SetCurrencyTriadsAllowed(TBool aBool); williamr@2: inline TChar ThousandsSeparator() const; williamr@2: inline void SetThousandsSeparator(const TChar& aChar); williamr@2: inline TChar DecimalSeparator() const; williamr@2: inline void SetDecimalSeparator(const TChar& aChar); williamr@2: inline TChar DateSeparator(TInt aIndex) const; williamr@2: inline void SetDateSeparator(const TChar& aChar,TInt aIndex); williamr@2: inline TChar TimeSeparator(TInt aIndex) const; williamr@2: inline void SetTimeSeparator(const TChar& aChar,TInt aIndex); williamr@2: inline TBool AmPmSpaceBetween() const; williamr@2: inline void SetAmPmSpaceBetween(TBool aSpace); williamr@2: inline TLocalePos AmPmSymbolPosition() const; williamr@2: inline void SetAmPmSymbolPosition(TLocalePos aPos); williamr@2: inline TUint DaylightSaving() const; williamr@2: inline TBool QueryHomeHasDaylightSavingOn() const; williamr@2: inline TDaylightSavingZone HomeDaylightSavingZone() const; williamr@2: inline TUint WorkDays() const; williamr@2: inline void SetWorkDays(TUint aMask); williamr@2: inline TDay StartOfWeek() const; williamr@2: inline void SetStartOfWeek(TDay aDay); williamr@2: inline TClockFormat ClockFormat() const; williamr@2: inline void SetClockFormat(TClockFormat aFormat); williamr@2: inline TUnitsFormat UnitsGeneral() const; williamr@2: inline void SetUnitsGeneral(TUnitsFormat aFormat); williamr@2: inline TUnitsFormat UnitsDistanceShort() const; williamr@2: inline void SetUnitsDistanceShort(TUnitsFormat aFormat); williamr@2: inline TUnitsFormat UnitsDistanceLong() const; williamr@2: inline void SetUnitsDistanceLong(TUnitsFormat aFormat); williamr@2: inline TNegativeCurrencyFormat NegativeCurrencyFormat() const; williamr@2: inline void SetNegativeCurrencyFormat(TNegativeCurrencyFormat aNegativeCurrencyFormat); williamr@2: inline TBool NegativeLoseSpace() const; williamr@2: inline void SetNegativeLoseSpace(TBool aBool); williamr@2: inline TBool NegativeCurrencySymbolOpposite() const; williamr@2: inline void SetNegativeCurrencySymbolOpposite(TBool aBool); williamr@2: inline TLanguage LanguageDowngrade(TInt aIndex) const; // 0 <= aIndex < 3 williamr@2: inline void SetLanguageDowngrade(TInt aIndex, TLanguage aLanguage); williamr@2: inline TDigitType DigitType() const; williamr@2: inline void SetDigitType(TDigitType aDigitType); williamr@2: inline TDeviceTimeState DeviceTime() const; williamr@2: inline void SetDeviceTime(TDeviceTimeState aState); williamr@4: inline TInt RegionCode() const; williamr@2: williamr@2: void SetDefaults(); /**< @internalComponent */ williamr@2: williamr@2: private: williamr@2: friend class TExtendedLocale; williamr@2: private: williamr@2: TInt iCountryCode; williamr@2: TTimeIntervalSeconds iUniversalTimeOffset; williamr@2: TDateFormat iDateFormat; williamr@2: TTimeFormat iTimeFormat; williamr@2: TLocalePos iCurrencySymbolPosition; williamr@2: TBool iCurrencySpaceBetween; williamr@2: TInt iCurrencyDecimalPlaces; williamr@2: TNegativeCurrencyFormat iNegativeCurrencyFormat; // replaced TBool iCurrencyNegativeInBrackets williamr@2: TBool iCurrencyTriadsAllowed; williamr@2: TChar iThousandsSeparator; williamr@2: TChar iDecimalSeparator; williamr@2: TChar iDateSeparator[KMaxDateSeparators]; williamr@2: TChar iTimeSeparator[KMaxTimeSeparators]; williamr@2: TLocalePos iAmPmSymbolPosition; williamr@2: TBool iAmPmSpaceBetween; williamr@2: TUint iDaylightSaving; williamr@2: TDaylightSavingZone iHomeDaylightSavingZone; williamr@2: TUint iWorkDays; williamr@2: TDay iStartOfWeek; williamr@2: TClockFormat iClockFormat; williamr@2: TUnitsFormat iUnitsGeneral; williamr@2: TUnitsFormat iUnitsDistanceShort; williamr@2: TUnitsFormat iUnitsDistanceLong; williamr@2: TUint iExtraNegativeCurrencyFormatFlags; williamr@2: TUint16 iLanguageDowngrade[3]; williamr@4: TUint16 iRegionCode; williamr@2: TDigitType iDigitType; williamr@2: TDeviceTimeState iDeviceTimeState; williamr@2: TInt iSpare[0x1E]; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: TLocaleAspect williamr@2: williamr@2: Enumeration used with TExtendedLocale::LoadLocaleAspect to select which williamr@2: locale information is to be replaced from the contents of the Locale williamr@2: DLL being loaded. williamr@2: williamr@2: ELocaleLanguageSettings - Replaces everything that should change with williamr@2: language selection e.g. Month names, Day names, williamr@2: etc, williamr@2: williamr@2: ELocaleLocaleSettings - Replaces the currently selected currency symbol, williamr@2: TLocale settings, and FAT utility functions williamr@2: williamr@2: ELocaleTimeAndDateSettings - Replaces the current time and date display williamr@2: format settings. williamr@2: williamr@2: ELocaleCollateSettings - Replaces the "system" preferred Charset williamr@2: (because that's where the collation table williamr@2: is!). The "Default" charset will remain williamr@2: unchanged until after the next power williamr@2: off/on cycle williamr@2: */ williamr@2: enum TLocaleAspect williamr@2: { williamr@2: ELocaleLanguageSettings = 0x01, williamr@2: ELocaleCollateSetting = 0x02, williamr@2: ELocaleLocaleSettings = 0x04, williamr@2: ELocaleTimeDateSettings = 0x08, williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SLocaleLanguage williamr@2: { williamr@2: TLanguage iLanguage; williamr@2: const TText* iDateSuffixTable; williamr@2: const TText* iDayTable; williamr@2: const TText* iDayAbbTable; williamr@2: const TText* iMonthTable; williamr@2: const TText* iMonthAbbTable; williamr@2: const TText* iAmPmTable; williamr@2: const TText16* const* iMsgTable; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SLocaleLocaleSettings williamr@2: { williamr@2: TText iCurrencySymbol[KMaxCurrencySymbol+1]; williamr@2: TAny* iLocaleExtraSettingsDllPtr; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: struct SLocaleTimeDateFormat williamr@2: { williamr@2: TText iShortDateFormatSpec[KMaxShortDateFormatSpec+1]; williamr@2: TText iLongDateFormatSpec[KMaxLongDateFormatSpec+1]; williamr@2: TText iTimeFormatSpec[KMaxTimeFormatSpec+1]; williamr@2: TAny* iLocaleTimeDateFormatDllPtr; williamr@2: }; williamr@2: williamr@2: struct LCharSet; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Extended locale class williamr@2: williamr@2: This class holds a collection of locale information. It contains a TLocale internally. williamr@2: It has methods to load a locale DLL and to set the system wide locale information. williamr@2: williamr@2: */ williamr@2: class TExtendedLocale williamr@2: { williamr@2: public: williamr@2: williamr@2: // Default constructor, create an empty instance williamr@2: IMPORT_C TExtendedLocale(); williamr@2: williamr@2: // Initialise to (or restore from!) current system wide locale williamr@2: // settings williamr@2: IMPORT_C void LoadSystemSettings(); williamr@2: williamr@2: // Overwrite current system wide locale settings with the current williamr@2: // contents of this TExtendedLocale williamr@2: IMPORT_C TInt SaveSystemSettings(); williamr@2: williamr@4: //load a complete locale data from a single locale dll williamr@2: IMPORT_C TInt LoadLocale(const TDesC& aLocaleDllName); williamr@4: williamr@4: //load a complete locale data from three locale dlls, which are language lcoale dll, region locale dll, and collation locale dll. williamr@4: IMPORT_C TInt LoadLocale(const TDesC& aLanguageLocaleDllName, const TDesC& aRegionLocaleDllName, const TDesC& aCollationLocaleDllName); williamr@4: williamr@2: // Load an additional Locale DLL and over-ride a selected subset williamr@2: // (currently ELocaleLanguageSettings to select an alternative set williamr@2: // of language specific text strings, ELocaleCollateSetting to williamr@2: // select a new system collation table, williamr@2: // ELocaleOverRideMatchCollationTable to locally select an williamr@2: // alternative collation order for matching text strings, or williamr@2: // ELocaleOverRideSortCollationTable for ordering text strings) williamr@2: // of settings with its contents williamr@2: IMPORT_C TInt LoadLocaleAspect(TUint aAspectGroup, const TDesC& aLocaleDllName); williamr@4: williamr@4: //load a locale aspect from a locale dll. williamr@4: //Such as load language locale aspect from locale language dll; williamr@4: //load region locale aspect from locale region dll; williamr@4: //load collation locale aspect from locale collation dll. williamr@4: //There are in all three aspect, which are langauge, region, and collation. williamr@4: IMPORT_C TInt LoadLocaleAspect(const TDesC& aLocaleDllName); williamr@2: williamr@2: // Set the currency Symbol williamr@2: IMPORT_C TInt SetCurrencySymbol(const TDesC &aSymbol); williamr@2: williamr@2: // Get the name of the DLL holding the data for a particular set williamr@2: // of Locale properties williamr@2: IMPORT_C TInt GetLocaleDllName(TLocaleAspect aLocaleDataSet, TDes& aDllName); williamr@2: williamr@2: // Get the preferred collation method. williamr@2: // Note that some Charsets may contain more than one Collation williamr@2: // method (e.g "dictionary" v "phonebook" ordering) so an optional williamr@2: // index parameter can be used to select between them williamr@2: IMPORT_C TCollationMethod GetPreferredCollationMethod(TInt index = 0) ; williamr@2: williamr@2: //Get the Currency Symbol williamr@2: IMPORT_C TPtrC GetCurrencySymbol(); williamr@2: williamr@2: //Get the Long Date Format williamr@2: IMPORT_C TPtrC GetLongDateFormatSpec(); williamr@2: williamr@2: //Get the Short Date Format williamr@2: IMPORT_C TPtrC GetShortDateFormatSpec(); williamr@2: williamr@2: //Get the Time Format williamr@2: IMPORT_C TPtrC GetTimeFormatSpec(); williamr@2: williamr@2: // Retrieve a reference to the encapsulated TLocale williamr@2: inline TLocale* GetLocale(); williamr@2: williamr@2: private: williamr@2: williamr@2: TInt DoLoadLocale(const TDesC& aLocaleDllName, TLibraryFunction* aExportList); williamr@2: void DoUpdateLanguageSettings(TLibraryFunction* aExportList); williamr@2: void DoUpdateLocaleSettings(TLibraryFunction* aExportList); williamr@2: void DoUpdateTimeDateFormat(TLibraryFunction* aExportList); williamr@4: williamr@4: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL williamr@4: void DoUpdateLanguageSettingsV2(TLibraryFunction* aExportList); williamr@4: void DoUpdateLocaleSettingsV2(TLibraryFunction* aExportList); williamr@4: TInt CheckLocaleDllName(const TDesC& aLocaleDllName, TInt& languageID); williamr@4: void AddExtension(TDes& aFileName, TInt aExtension); williamr@4: #endif williamr@2: williamr@2: private: williamr@2: williamr@2: TLocale iLocale; williamr@2: SLocaleLanguage iLanguageSettings; williamr@2: SLocaleLocaleSettings iLocaleExtraSettings; williamr@2: SLocaleTimeDateFormat iLocaleTimeDateFormat; williamr@2: const LCharSet* iDefaultCharSet; williamr@2: const LCharSet* iPreferredCharSet; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Geometric rectangle. williamr@2: williamr@2: The class represents a rectangle whose sides are parallel with the axes of williamr@2: the co-ordinate system. williamr@2: williamr@2: The co-ordinates of the top-left and bottom-right corners are used to set williamr@2: the dimensions of the rectangle. The bottom right co-ordinate is outside the williamr@2: rectangle. Thus TRect(TPoint(2,2),TSize(4,4)) is equal williamr@2: to TRect(TPoint(2,2),TPoint(6,6)), williamr@2: and in both cases you get a 4x4 pixel rectangle on the screen. williamr@2: williamr@2: Functions are provided to initialise and manipulate the rectangle and to extract williamr@2: information about it. williamr@2: */ williamr@2: class TRect williamr@2: { williamr@2: public: williamr@2: enum TUninitialized { EUninitialized }; williamr@2: /** williamr@2: Constructs a default rectangle. williamr@2: williamr@2: This initialises the co-ordinates of its top williamr@2: left and bottom right corners to (0,0). williamr@2: */ williamr@2: TRect(TUninitialized) {} williamr@2: IMPORT_C TRect(); williamr@2: IMPORT_C TRect(TInt aAx,TInt aAy,TInt aBx,TInt aBy); williamr@2: IMPORT_C TRect(const TPoint& aPointA,const TPoint& aPointB); williamr@2: IMPORT_C TRect(const TPoint& aPoint,const TSize& aSize); williamr@2: IMPORT_C TRect(const TSize& aSize); williamr@2: IMPORT_C TBool operator==(const TRect& aRect) const; williamr@2: IMPORT_C TBool operator!=(const TRect& aRect) const; williamr@2: IMPORT_C void SetRect(TInt aAx,TInt aAy,TInt aBx,TInt aBy); williamr@2: IMPORT_C void SetRect(const TPoint& aPointTL,const TPoint& aPointBR); williamr@2: IMPORT_C void SetRect(const TPoint& aPoint,const TSize& aSize); williamr@2: IMPORT_C void Move(TInt aDx,TInt aDy); williamr@2: IMPORT_C void Move(const TPoint& aOffset); williamr@2: IMPORT_C void Resize(TInt aDx,TInt aDy); williamr@2: IMPORT_C void Resize(const TSize& aSize); williamr@2: IMPORT_C void Shrink(TInt aDx,TInt aDy); williamr@2: IMPORT_C void Shrink(const TSize& aSize); williamr@2: IMPORT_C void Grow(TInt aDx,TInt aDy); williamr@2: IMPORT_C void Grow(const TSize& aSize); williamr@2: IMPORT_C void BoundingRect(const TRect& aRect); williamr@2: IMPORT_C TBool IsEmpty() const; williamr@2: IMPORT_C TBool Intersects(const TRect& aRect) const; williamr@2: IMPORT_C void Intersection(const TRect& aRect); williamr@2: IMPORT_C void Normalize(); williamr@2: IMPORT_C TBool Contains(const TPoint& aPoint) const; williamr@2: IMPORT_C TSize Size() const; williamr@2: IMPORT_C TInt Width() const; williamr@2: IMPORT_C TInt Height() const; williamr@2: IMPORT_C TBool IsNormalized() const; williamr@2: IMPORT_C TPoint Center() const; williamr@2: IMPORT_C void SetSize(const TSize& aSize); williamr@2: IMPORT_C void SetWidth(TInt aWidth); williamr@2: IMPORT_C void SetHeight(TInt aHeight); williamr@2: private: williamr@2: void Adjust(TInt aDx,TInt aDy); williamr@2: public: williamr@2: /** williamr@2: The x and y co-ordinates of the top left hand corner of the rectangle. williamr@2: */ williamr@2: TPoint iTl; williamr@2: williamr@2: /** williamr@2: The x and y co-ordinates of the bottom right hand corner of the rectangle. williamr@2: */ williamr@2: TPoint iBr; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Clipping region - abstract base class. williamr@2: williamr@2: This abstract base class represents a 2-dimensional area which is used by williamr@2: Graphics, the graphics window server, and the text window server to define williamr@2: regions of the display which need to be updated, or regions within which all williamr@2: operations must occur. williamr@2: williamr@2: A TRegion is defined in terms of an array of TRects and the more complex the williamr@2: region, the more TRects are required to represent it. williamr@2: williamr@2: A clipping region initially has space allocated for five rectangles. williamr@2: If manipulations result in a region which requires more than this, an attempt williamr@2: is made to allocate more rectangles. If this cannot be done, an error flag williamr@2: is set, and all subsequent operations involving the region have no effect williamr@2: (except possibly to propagate the error flag to other regions). williamr@2: The CheckError() member function allows williamr@2: the error flag to be tested; Clear() can be used to clear it. williamr@2: williamr@2: The redraw logic of application programs may use the TRegion in various ways: williamr@2: williamr@2: 1. minimally, they pass it to the graphics context as the clipping region; when williamr@2: a graphics context is activated to a window, the clipping region is set up williamr@2: automatically williamr@2: williamr@2: 2. if they wish to avoid redrawing objects which are outside the general area williamr@2: of the region, they may use TRegion::BoundingRect() to return the rectangle williamr@2: which bounds the clipping region, and draw only primitives that lie within williamr@2: that rectangle williamr@2: williamr@2: 3. if they wish to exercise finer control, they may extract the individual rectangles williamr@2: that comprise the clipping region using Operator[](). williamr@2: williamr@2: Application programs may also manipulate clipping regions in order to constrain williamr@2: parts of their redrawing to narrower areas of the screen than the clipping williamr@2: region offered by the window server. To do this, functions that allow clipping williamr@2: region manipulation may be used; for example, adding or removing rectangles williamr@2: or finding the intersection or union of two regions. williamr@2: */ williamr@2: class TRegion williamr@2: { williamr@2: public: williamr@2: inline TInt Count() const; williamr@2: inline const TRect* RectangleList() const; williamr@2: inline TBool CheckError() const; williamr@2: IMPORT_C TBool IsEmpty() const; williamr@2: IMPORT_C TRect BoundingRect() const; williamr@2: IMPORT_C const TRect& operator[](TInt aIndex) const; williamr@2: IMPORT_C void Copy(const TRegion& aRegion); williamr@2: IMPORT_C void AddRect(const TRect& aRect); williamr@2: IMPORT_C void SubRect(const TRect& aRect,TRegion* aSubtractedRegion=NULL); williamr@2: IMPORT_C void Offset(TInt aXoffset,TInt aYoffset); williamr@2: IMPORT_C void Offset(const TPoint& aOffset); williamr@2: IMPORT_C void Union(const TRegion& aRegion); williamr@2: IMPORT_C void Intersection(const TRegion& aRegion,const TRegion& aRegion2); williamr@2: IMPORT_C void Intersect(const TRegion& aRegion); williamr@2: IMPORT_C void SubRegion(const TRegion& aRegion,TRegion* aSubtractedRegion=NULL); williamr@2: IMPORT_C void ClipRect(const TRect& aRect); williamr@2: IMPORT_C void Clear(); williamr@2: IMPORT_C void Tidy(); williamr@2: IMPORT_C TInt Sort(); williamr@2: IMPORT_C TInt Sort(const TPoint& aOffset); williamr@2: IMPORT_C void ForceError(); williamr@2: IMPORT_C TBool IsContainedBy(const TRect& aRect) const; williamr@2: IMPORT_C TBool Contains(const TPoint& aPoint) const; williamr@2: IMPORT_C TBool Intersects(const TRect& aRect) const; williamr@2: protected: williamr@2: IMPORT_C TRect* RectangleListW(); williamr@2: IMPORT_C TRegion(TInt aAllocedRects); williamr@2: inline TRegion(); williamr@2: TBool SetListSize(TInt aCount); williamr@2: void AppendRect(const TRect& aRect); williamr@2: void DeleteRect(TRect* aRect); williamr@2: void AppendRegion(TRegion& aRegion); williamr@2: void MergeRect(const TRect& aRect, TBool aEnclosed); williamr@2: void SubtractRegion(const TRegion &aRegion,TRegion *aSubtractedRegion=NULL); williamr@2: void ShrinkRegion(); williamr@2: TRect* ExpandRegion(TInt aCount); williamr@2: protected: williamr@2: TInt iCount; williamr@2: TBool iError; williamr@2: TInt iAllocedRects; williamr@2: protected: williamr@2: enum {ERRegionBuf=0x40000000}; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Expandable region. williamr@2: williamr@2: This class provides for the construction and destruction of a TRegion, including williamr@2: a granularity for expanding the region. A region;s granularity represents williamr@2: the number of memory slots allocated when the object is created, and the number williamr@2: of new memory slots allocated each time an RRegion is expanded beyond the williamr@2: number of free slots. The default granularity is five. williamr@2: */ williamr@2: class RRegion : public TRegion williamr@2: { williamr@2: private: williamr@2: enum {EDefaultGranularity=5}; williamr@2: protected: williamr@2: IMPORT_C RRegion(TInt aBuf,TInt aGran); williamr@2: public: williamr@2: IMPORT_C RRegion(); williamr@2: IMPORT_C RRegion(TInt aGran); williamr@2: IMPORT_C RRegion(const RRegion& aRegion); williamr@2: IMPORT_C RRegion(const TRect& aRect,TInt aGran=EDefaultGranularity); williamr@2: IMPORT_C RRegion(TInt aCount,TRect* aRectangleList,TInt aGran=EDefaultGranularity); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C void Destroy(); williamr@2: inline TInt CheckSpare() const; williamr@2: private: williamr@2: TInt iGranularity; williamr@2: TRect* iRectangleList; williamr@2: friend class TRegion; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Region with pre-allocated buffer. williamr@2: williamr@2: This class provides the functionality of an RRegion, but in addition, for williamr@2: optimisation purposes, uses a buffer containing pre-allocated space for as williamr@2: many rectangles as are specified in the granularity. williamr@2: williamr@2: When this buffer is full, cell allocation takes place as for an RRegion, and williamr@2: the RRegionBuf effectively becomes an RRegion. In this case, the region does williamr@2: not revert to using the buffer, even if the region were to shrink so that williamr@2: the buffer could, once again, contain the region. When the region is no longer williamr@2: required, call Close(), defined in the base class RRegion, to free up all williamr@2: memory. williamr@2: */ williamr@2: template williamr@2: class RRegionBuf : public RRegion williamr@2: { williamr@2: public: williamr@2: inline RRegionBuf(); williamr@2: inline RRegionBuf(const RRegion& aRegion); williamr@2: inline RRegionBuf(const RRegionBuf& aRegion); williamr@2: inline RRegionBuf(const TRect& aRect); williamr@2: private: williamr@2: TInt8 iRectangleBuf[S*sizeof(TRect)]; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A fixed size region. williamr@2: williamr@2: The region consists of a fixed number of rectangles; this number is specified williamr@2: in the templated argument. The region cannot be expanded to contain more than williamr@2: this number of rectangles. If an attempt is made to do so, the region's williamr@2: error flag is set, and the region is cleared. williamr@2: williamr@2: Note that when adding a rectangle to a region, if that rectangle overlaps williamr@2: an existing rectangle, the operation causes more than one rectangle to be williamr@2: created. williamr@2: */ williamr@2: template williamr@2: class TRegionFix : public TRegion williamr@2: { williamr@2: public: williamr@2: inline TRegionFix(); williamr@2: inline TRegionFix(const TRect& aRect); williamr@2: inline TRegionFix(const TRegionFix& aRegion); williamr@2: private: williamr@2: TInt8 iRectangleBuf[S*sizeof(TRect)]; 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 searching for global kernel objects. williamr@2: williamr@2: This is the base class for a number of classes which are used to find specific williamr@2: types of global kernel object such as semaphores, threads and mutexes; williamr@2: TFindSemaphore, TFindThread and TFindMutex are typical examples of such williamr@2: derived classes. williamr@2: williamr@2: The class implements the common behaviour, specifically, the storage of the williamr@2: match pattern which is used to search for object names. williamr@2: williamr@2: This class is not intended to be explicitly instantiated; it has public williamr@2: constructors but they are part of the class implementation and are described williamr@2: for information only. williamr@2: */ williamr@2: class TFindHandleBase : public TFindHandle williamr@2: { williamr@2: public: williamr@2: IMPORT_C TFindHandleBase(); williamr@2: IMPORT_C TFindHandleBase(const TDesC& aMatch); williamr@2: IMPORT_C void Find(const TDesC& aMatch); williamr@2: protected: williamr@2: TInt NextObject(TFullName& aResult,TInt aObjectType); williamr@2: private: williamr@2: williamr@2: /** williamr@2: The full name of the last kernel side object found. williamr@2: */ williamr@2: TFullName iMatch; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Finds all global semaphores whose full names match a specified pattern. williamr@2: williamr@2: The match pattern can be set into the TFindSemaphore object at construction; williamr@2: it can also be changed at any time after construction by using the Find() williamr@2: member function of the TFindHandleBase base class. williamr@2: williamr@2: After construction, the Next() member function can be used repeatedly to find williamr@2: successive global semaphores whose full names match the current pattern. williamr@2: williamr@2: A successful call to Next() means that a matching global semaphore has been williamr@2: found. To open a handle on this semaphore, call the RSemaphore::Open() function williamr@2: and pass a reference to this TFindSemaphore. williamr@2: williamr@2: Pattern matching is part of descriptor behaviour. williamr@2: williamr@2: @see TFindHandleBase::Find williamr@2: @see TFindSemaphore::Next williamr@2: @see RSemaphore::Open williamr@2: @see TDesC16::Match williamr@2: @see TDesC8::Match williamr@2: */ williamr@2: class TFindSemaphore : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindSemaphore(); williamr@2: inline TFindSemaphore(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Finds all global mutexes whose full names match a specified pattern. williamr@2: williamr@2: The match pattern can be set into the object at construction; it can also williamr@2: be changed at any time after construction by using the Find() member function williamr@2: of the base class. williamr@2: williamr@2: After construction, the Next() member function may be used repeatedly to find williamr@2: successive global mutexes whose full names match the current pattern. williamr@2: williamr@2: A successful call to Next() means that a matching global mutex has been found. williamr@2: To open a handle on this mutex, call the Open() member function of RMutex williamr@2: and pass a reference to this TFindMutex object. williamr@2: williamr@2: Pattern matching is part of descriptors behaviour. williamr@2: williamr@2: @see TFindHandleBase::Find williamr@2: @see TFindMutex::Next williamr@2: @see RMutex::Open williamr@2: @see TDesC16::Match williamr@2: @see TDesC8::Match williamr@2: */ williamr@2: class TFindMutex : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindMutex(); williamr@2: inline TFindMutex(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for all global chunks by pattern matching against the names of (Kernel williamr@2: side) chunk objects. williamr@2: williamr@2: The match pattern can be set into this object at construction; it can also williamr@2: be changed at any time after construction by using TFindHandleBase::Find(). williamr@2: williamr@2: After construction, call TFindChunk::Next() repeatedly to find successive williamr@2: chunks whose names match the current pattern. A successful call williamr@2: to TFindChunk::Next() means that a matching chunk has been found. williamr@2: williamr@2: @see TFindHandleBase williamr@2: */ williamr@2: class TFindChunk : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindChunk(); williamr@2: inline TFindChunk(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for threads by pattern matching against the names williamr@2: of thread objects. williamr@2: williamr@2: The match pattern can be set into this object at construction; it can also be williamr@2: changed at any time after construction by using TFindHandleBase::Find(). williamr@2: williamr@2: After construction, call TFindThread::Next() repeatedly to find successive williamr@2: threads whose names match the current pattern. williamr@2: A successful call to TFindThread::Next() means that a matching thread has williamr@2: been found. To open a handle on this thread, call RThread::Open() and pass williamr@2: a reference to this TFindThread. williamr@2: williamr@2: @see RThread williamr@2: */ williamr@2: class TFindThread : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindThread(); williamr@2: inline TFindThread(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for processes by pattern matching against the names williamr@2: of process objects. williamr@2: williamr@2: The match pattern can be set into this object at construction; it can also be williamr@2: changed at any time after construction by using TFindHandleBase::Find(). williamr@2: williamr@2: After construction, call TFindProcess::Next() repeatedly to find successive williamr@2: processes whose names match the current pattern. williamr@2: A successful call to TFindProcess::Next() means that a matching process has williamr@2: been found. To open a handle on this process, call RProcess::Open() and pass williamr@2: a reference to this TFindProcess. williamr@2: williamr@2: @see RProcess williamr@2: */ williamr@2: class TFindProcess : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindProcess(); williamr@2: inline TFindProcess(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for LDD factory objects by pattern matching against the names of williamr@2: LDD factory objects. williamr@2: williamr@2: An LDD factory object is an instance of a DLogicalDevice derived class. williamr@2: williamr@2: The match pattern can be set into this object at construction; it can also williamr@2: be changed at any time after construction by using TFindHandleBase::Find(). williamr@2: williamr@2: After construction, call TFindLogicalDevice::Next() repeatedly to find successive williamr@2: LDD factory objects whose names match the current pattern. A successful call to williamr@2: TFindLogicalDevice::Next() means that a matching LDD factory object has been found. williamr@2: williamr@2: The name of an LDD factory object is set by its Install() member function as williamr@2: part of the construction process. williamr@2: */ williamr@2: class TFindLogicalDevice : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindLogicalDevice(); williamr@2: inline TFindLogicalDevice(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for PDD factory objects by pattern matching against the names of williamr@2: PDD factory objects. williamr@2: williamr@2: A PDD factory object is an instance of a DPhysicalDevice derived class. williamr@2: williamr@2: The match pattern can be set into this object at construction; it can also be williamr@2: changed at any time after construction by using TFindHandleBase::Find(). williamr@2: williamr@2: After construction, call TFindPhysicalDevice::Next() repeatedly to find successive williamr@2: PDD factory objects whose names match the current pattern. A successful call to williamr@2: TFindPhysicalDevice::Next() means that a matching PDD factory object has been found. williamr@2: williamr@2: The name of a PDD factory object is set by its Install() member function as part williamr@2: of the construction process. williamr@2: */ williamr@2: class TFindPhysicalDevice : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindPhysicalDevice(); williamr@2: inline TFindPhysicalDevice(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for servers by pattern matching against the names of kernel side williamr@2: server objects. williamr@2: williamr@2: The match pattern can be set into this object at construction; it can also williamr@2: be changed at any time after construction by using the TFindHandleBase::Find() williamr@2: base class. williamr@2: williamr@2: After construction, call TFindServer::Next() repeatedly to find successive williamr@2: servers whose names match the current pattern. williamr@2: A successful call to TFindServer::Next() means that a matching server williamr@2: has been found. williamr@2: */ williamr@2: class TFindServer : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindServer(); williamr@2: inline TFindServer(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Searches for DLLs whose full names match a specified pattern. williamr@2: williamr@2: The match pattern is set at construction but can also be changed at any time williamr@2: after construction by using TFindHandleBase::Find(). williamr@2: williamr@2: After construction, use TFindLibrary::Next() to repeatedly find successive DLLs williamr@2: whose names match the current pattern. A successful call to williamr@2: TFindLibrary::Next() means that a matching DLL has been found. williamr@2: */ williamr@2: class TFindLibrary : public TFindHandleBase williamr@2: { williamr@2: public: williamr@2: inline TFindLibrary(); williamr@2: inline TFindLibrary(const TDesC& aMatch); williamr@2: IMPORT_C TInt Next(TFullName& aResult); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: User side handle to an LDD factory object, an instance of a DLogicalDevice williamr@2: derived class. williamr@2: williamr@2: The LDD factory object is a Kernel side object which is constructed on the williamr@2: Kernel heap when the logical device is opened using User::LoadLogicalDevice(). williamr@2: The handle allows the User side to get information about the logical device. williamr@2: williamr@2: To use the device, a thread must create and use an instance of an williamr@2: RBusLogicalChannel derived class. williamr@2: williamr@2: */ williamr@2: class RDevice : public RHandleBase williamr@2: { williamr@2: public: williamr@2: inline TInt Open(const TFindLogicalDevice& aFind,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(const TDesC& aName,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void GetCaps(TDes8& aDes) const; williamr@2: IMPORT_C TBool QueryVersionSupported(const TVersion& aVer) const; williamr@2: IMPORT_C TBool IsAvailable(TInt aUnit, const TDesC* aPhysicalDevice, const TDesC8* anInfo) const; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Asynchronous timer services. williamr@2: williamr@2: Five types of asynchronous request are supported by the class: williamr@2: williamr@2: 1. Requesting an event after a specified interval williamr@2: williamr@2: 2. Requesting an event at a specified system time williamr@2: williamr@2: 3. Requesting a timer event on a specific second fraction williamr@2: williamr@2: 4. Requesting an event if an interval elapses with no user activity. williamr@2: williamr@2: 5. Requesting an event after a specified interval, to a resolution of 1ms. williamr@2: williamr@2: Each of these requests can be cancelled. williamr@2: williamr@2: The timer exists from its creation, following a call to RTimer::CreateLocal(), williamr@2: until it is destroyed by a call to the Close() member function of the base williamr@2: class RHandleBase. williamr@2: williamr@2: This class is ultimately implemented in terms of the nanokernel tick, and williamr@2: therefore the granularity of the generated events is limited to the period of williamr@2: this timer. This is variant specific, but is usually 1 millisecond. williamr@2: williamr@2: Note that the CTimer active object uses an RTimer. williamr@2: */ williamr@2: class RTimer : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt CreateLocal(); williamr@2: IMPORT_C void Cancel(); williamr@2: IMPORT_C void After(TRequestStatus& aStatus,TTimeIntervalMicroSeconds32 anInterval); williamr@2: IMPORT_C void AfterTicks(TRequestStatus &aStatus, TInt aTicks); williamr@2: IMPORT_C void At(TRequestStatus& aStatus,const TTime& aTime); williamr@2: IMPORT_C void AtUTC(TRequestStatus& aStatus,const TTime& aUTCTime); williamr@2: IMPORT_C void Lock(TRequestStatus& aStatus,TTimerLockSpec aLock); williamr@2: IMPORT_C void Inactivity(TRequestStatus& aStatus, TTimeIntervalSeconds aSeconds); williamr@2: IMPORT_C void HighRes(TRequestStatus& aStatus,TTimeIntervalMicroSeconds32 anInterval); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a dynamically loadable DLL. williamr@2: williamr@2: The class is not intended for user derivation. williamr@2: */ williamr@2: class RLibrary : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TInt Load(const TDesC& aFileName, const TUidType& aType); williamr@2: IMPORT_C TInt Load(const TDesC& aFileName, const TDesC& aPath=KNullDesC); williamr@2: IMPORT_C TInt Load(const TDesC& aFileName, const TDesC& aPath, const TUidType& aType); williamr@2: IMPORT_C TInt Load(const TDesC& aFileName, const TDesC& aPath, const TUidType& aType, TUint32 aModuleVersion); williamr@2: IMPORT_C TInt LoadRomLibrary(const TDesC& aFileName, const TDesC& aPath); williamr@2: IMPORT_C TLibraryFunction Lookup(TInt anOrdinal) const; williamr@2: IMPORT_C TUidType Type() const; williamr@2: IMPORT_C TFileName FileName() const; williamr@2: IMPORT_C TInt GetRamSizes(TInt& aCodeSize, TInt& aConstDataSize); williamr@2: IMPORT_C TInt Init(); /**< @internalTechnology */ williamr@2: public: williamr@2: /** williamr@2: Class representing information about an executable binary, (DLL or EXE). williamr@2: @internalTechnology williamr@2: */ williamr@2: struct TInfo williamr@2: { williamr@2: TUint32 iModuleVersion; /**< Version number */ williamr@2: TUidType iUids; /**< UIDs */ williamr@2: TSecurityInfo iSecurityInfo; /**< Security Info */ williamr@2: }; williamr@2: williamr@2: /** williamr@2: Class representing information about an executable binary, (DLL or EXE), version 2. williamr@2: @internalTechnology williamr@2: */ williamr@2: struct TInfoV2 : public TInfo williamr@2: { williamr@2: TUint8 iHardwareFloatingPoint; /**< Which hardware floating point used, from TFloatingPointType */ williamr@2: enum TDebugAttributes williamr@2: { williamr@2: EDebugAllowed = 1<<0, ///< Flags set if executable may be debugged. williamr@2: ETraceAllowed = 1<<1 ///< Flags set if executable may be traced. williamr@2: }; williamr@2: TUint8 iDebugAttributes; ///< Bitmask of values from enum TDebugAttributes williamr@2: TUint8 iSpare[6]; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Type representing a TInfo struct packaged as a descriptor. williamr@2: @internalTechnology williamr@2: */ williamr@2: typedef TPckgBuf TInfoBuf; williamr@2: williamr@2: /** williamr@2: Type representing a TInfo struct packaged as a descriptor, version 2. williamr@2: @internalTechnology williamr@2: */ williamr@2: typedef TPckgBuf TInfoBufV2; williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: enum TRequiredImageHeaderSize williamr@2: { williamr@2: #ifdef __WINS__ williamr@2: /** williamr@2: Size of header data which should be passed to GetInfoFromHeader() williamr@2: */ williamr@2: KRequiredImageHeaderSize = KMaxTInt williamr@2: #else williamr@2: KRequiredImageHeaderSize = 9*1024 williamr@2: #endif williamr@2: }; williamr@2: williamr@2: IMPORT_C static TInt GetInfoFromHeader(const TDesC8& aHeader, TDes8& aInfoBuf); williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: @deprecated Use TInfo williamr@2: */ williamr@2: struct SInfo williamr@2: { williamr@2: TUint32 iModuleVersion; williamr@2: TUidType iUids; williamr@2: SSecurityInfo iS; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: @deprecated Use TInfoBuf williamr@2: */ williamr@2: typedef TPckgBuf SInfoBuf; williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: IMPORT_C static TInt GetInfo(const TDesC& aFileName, TDes8& aInfoBuf); williamr@2: private: williamr@2: TInt InitL(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a critical section. williamr@2: williamr@2: A critical section itself is a kernel object, and is implemented using williamr@2: a semaphore. The class RCriticalSection inherits privately from RSemaphore williamr@2: as a matter of implementation and this is, in effect, equivalent to using williamr@2: a semaphore. williamr@2: williamr@2: The public functions of RSemaphore are not part of the public API of this williamr@2: class. williamr@2: williamr@2: As with all handles, they should be closed after use. This class 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 RCriticalSection : private RSemaphore williamr@2: { williamr@2: public: williamr@2: IMPORT_C RCriticalSection(); williamr@2: IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C void Wait(); williamr@2: IMPORT_C void Signal(); williamr@2: inline TBool IsBlocked() const; williamr@2: private: williamr@2: TInt iBlocked; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a mutex. williamr@2: williamr@2: The mutex itself is a kernel side object. williamr@2: williamr@2: Handles should be closed after use. RHandleBase provides the necessary Close() williamr@2: function which should be called when the handle is no longer required. williamr@2: williamr@2: @see RHandleBase::Close williamr@2: */ williamr@2: class RMutex : public RHandleBase williamr@2: { williamr@2: public: williamr@2: inline TInt Open(const TFindMutex& aFind,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateGlobal(const TDesC& aName,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 void Signal(); williamr@2: IMPORT_C TBool IsHeld(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a condition variable. williamr@2: williamr@2: The condition variable itself is a kernel side object. williamr@2: williamr@2: Handles should be closed after use. RHandleBase provides the necessary Close() williamr@2: function which should be called when the handle is no longer required. williamr@2: williamr@2: @see RHandleBase::Close williamr@2: */ williamr@2: class RCondVar : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt CreateLocal(TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateGlobal(const TDesC& aName, 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 TInt Wait(RMutex& aMutex); williamr@2: IMPORT_C TInt TimedWait(RMutex& aMutex, TInt aTimeout); // timeout in microseconds williamr@2: IMPORT_C void Signal(); williamr@2: IMPORT_C void Broadcast(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: class UserHeap; williamr@2: class TChunkCreate; williamr@2: struct TChunkCreateInfo; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a chunk. williamr@2: williamr@2: The chunk itself is a kernel side object. williamr@2: */ williamr@2: class RChunk : public RHandleBase williamr@2: { williamr@2: public: williamr@2: /** williamr@4: Set of flags used by SetRestrictions(). williamr@4: williamr@4: @see RChunk::SetRestrictions williamr@4: */ williamr@2: enum TRestrictions williamr@2: { williamr@4: /** Prevent Adjust, Commit, Allocate and Decommit */ williamr@4: EPreventAdjust = 0x01, williamr@2: }; williamr@2: public: williamr@2: inline TInt Open(const TFindChunk& aFind,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateLocal(TInt aSize,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateLocalCode(TInt aSize,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateGlobal(const TDesC& aName,TInt aSize,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateDoubleEndedLocal(TInt aInitialBottom, TInt aInitialTop,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateDoubleEndedGlobal(const TDesC& aName,TInt aInitialBottom,TInt aInitialTop,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateDisconnectedLocal(TInt aInitialBottom, TInt aInitialTop,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt CreateDisconnectedGlobal(const TDesC& aName,TInt aInitialBottom,TInt aInitialTop,TInt aMaxSize,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Create(TChunkCreateInfo& aCreateInfo); williamr@2: IMPORT_C TInt SetRestrictions(TUint aFlags); williamr@2: IMPORT_C TInt OpenGlobal(const TDesC& aName,TBool isReadOnly,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TBool isReadOnly,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Adjust(TInt aNewSize) const; williamr@2: IMPORT_C TInt AdjustDoubleEnded(TInt aBottom, TInt aTop) const; williamr@2: IMPORT_C TInt Commit(TInt anOffset, TInt aSize) const; williamr@2: IMPORT_C TInt Allocate(TInt aSize) const; williamr@2: IMPORT_C TInt Decommit(TInt anOffset, TInt aSize) const; williamr@2: IMPORT_C TInt Unlock(TInt aOffset, TInt aSize); /**< @internalTechnology */ williamr@2: IMPORT_C TInt Lock(TInt aOffset, TInt aSize); /**< @internalTechnology */ williamr@2: IMPORT_C TUint8* Base() const; williamr@2: IMPORT_C TInt Size() const; williamr@2: IMPORT_C TInt Bottom() const; williamr@2: IMPORT_C TInt Top() const; williamr@2: IMPORT_C TInt MaxSize() const; williamr@2: inline TBool IsReadable() const; williamr@2: inline TBool IsWritable() const; williamr@4: IMPORT_C TBool IsPaged() const; williamr@2: private: williamr@2: friend class UserHeap; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: This structure specifies the type and properties of the chunk to be created. It williamr@2: is passed as a parameter to the RChunk::Create() method. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: struct TChunkCreateInfo williamr@2: { williamr@2: public : williamr@2: /** williamr@2: Currently supported version numbers williamr@2: @internalComponent williamr@2: */ williamr@2: enum TChunkCreateVersions williamr@2: { williamr@2: EVersion0, williamr@2: ESupportedVersions, williamr@2: }; williamr@2: williamr@2: friend class RChunk; williamr@2: williamr@4: /** williamr@4: Attributes that specify whether the chunk to be created is data paged or not. williamr@4: */ williamr@4: enum TChunkPagingAtt williamr@4: { williamr@4: EUnspecified, /**< The chunk will use the creating process's paging attributes.*/ williamr@4: EPaged, /**< The chunk will be data paged.*/ williamr@4: EUnpaged, /**< The chunk will not be data paged.*/ williamr@4: }; williamr@4: williamr@2: IMPORT_C TChunkCreateInfo(); williamr@2: IMPORT_C void SetNormal(TInt aInitialSize, TInt aMaxSize); williamr@2: IMPORT_C void SetCode(TInt aInitialSize, TInt aMaxSize); williamr@2: IMPORT_C void SetDoubleEnded(TInt aInitialBottom, TInt aInitialTop, TInt aMaxSize); williamr@2: IMPORT_C void SetDisconnected(TInt aInitialBottom, TInt aInitialTop, TInt aMaxSize); williamr@2: IMPORT_C void SetOwner(TOwnerType aType); williamr@2: IMPORT_C void SetGlobal(const TDesC& aName); williamr@2: IMPORT_C void SetClearByte(TUint8 aClearByte); williamr@4: IMPORT_C void SetPaging(const TChunkPagingAtt aPaging); williamr@4: IMPORT_C void SetReadOnly(); williamr@2: void SetThreadHeap(TInt aInitialSize, TInt aMaxSize, const TDesC& aName); williamr@2: williamr@4: /** williamr@4: For use by file server only. williamr@4: @internalTechnology williamr@4: */ williamr@4: IMPORT_C void SetCache(TInt aMaxSize); williamr@2: protected : williamr@2: /** The version number of this TChunkCreateInfo. williamr@2: @internalComponent williamr@2: */ williamr@2: TUint iVersionNumber; williamr@2: /** The type of the chunk to be created. williamr@2: @internalComponent williamr@2: */ williamr@2: TUint iType; williamr@2: /** Specify if chunk is global or not. williamr@2: @internalComponent williamr@2: */ williamr@2: TBool iGlobal; williamr@2: /** The maximum size in bytes of the chunk to be created. williamr@2: @internalComponent williamr@2: */ williamr@2: TInt iMaxSize; williamr@2: /** An enumeration whose enumerators define the ownership of this chunk williamr@2: handle. If not explicitly specified, EOwnerProcess is taken as default. williamr@2: @internalComponent williamr@2: */ williamr@2: TOwnerType iOwnerType; williamr@2: /** A pointer to a descriptor containing the name to be assigned to williamr@2: global chunks. The length of the descriptor must be no greater than williamr@2: that allowed for a TKName type. Must be NULL for local chunks. williamr@2: @internalComponent williamr@2: */ williamr@2: const TDesC* iName; williamr@2: /** The offset of the bottom of the region to commit to the chunk on williamr@2: creation from the base of the chunk's reserved region. williamr@2: This is only used for double ended and disconnected chunks. williamr@2: @internalComponent williamr@2: */ williamr@2: TInt iInitialBottom; williamr@2: /** The offset of the top of the region to commit to the chunk on williamr@2: creation from the base of the chunk's reserved region. williamr@2: This is only used for double ended and disconnected chunks. williamr@2: @internalComponent williamr@2: */ williamr@2: TInt iInitialTop; williamr@2: /** Attributes to the chunk to be created should have. williamr@4: Should be set from one or more the values in TChunkCreate::TChunkCreateAtt. williamr@2: @internalComponent williamr@2: */ williamr@2: TUint iAttributes; williamr@2: /** The byte to clear all the memory committed to the chunk to. williamr@2: @internalComponent williamr@2: */ williamr@2: TUint8 iClearByte; williamr@2: /** @internalComponent*/ williamr@2: TUint8 iSpare1[3]; williamr@2: /** @internalComponent*/ williamr@2: TUint iSpare2; williamr@2: }; williamr@2: williamr@4: /** williamr@4: This structure specifies the type and properties of the user heap to be created. It williamr@4: is passed as a parameter to the UserHeap::Create() method. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: struct TChunkHeapCreateInfo williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Currently supported version numbers williamr@4: @internalComponent williamr@4: */ williamr@4: enum TChunkHeapCreateVersions williamr@4: { williamr@4: EVersion0, williamr@4: ESupportedVersions, williamr@4: }; williamr@4: williamr@4: /** williamr@4: Attributes that specify whether the chunk heap to be created is data paged or not. williamr@4: */ williamr@4: enum TChunkHeapPagingAtt williamr@4: { williamr@4: EUnspecified, /**< The chunk heap will use the creating process's paging attributes.*/ williamr@4: EPaged, /**< The chunk heap will be data paged.*/ williamr@4: EUnpaged, /**< The chunk heap will not be data paged.*/ williamr@4: }; williamr@4: williamr@4: friend class UserHeap; williamr@4: williamr@4: IMPORT_C TChunkHeapCreateInfo(TInt aMinLength, TInt aMaxLength); williamr@4: IMPORT_C void SetCreateChunk(const TDesC* aName); williamr@4: IMPORT_C void SetUseChunk(const RChunk aChunk); williamr@4: inline void SetSingleThread(TBool aSingleThread); williamr@4: inline void SetAlignment(TInt aAlign); williamr@4: inline void SetGrowBy(TInt aGrowBy); williamr@4: inline void SetOffset(TInt aOffset); williamr@4: inline void SetMode(TUint aMode); williamr@4: inline void SetPaging(const TChunkHeapPagingAtt aPaging); williamr@4: williamr@4: protected: williamr@4: /** The version number of this TChunkHeapCreateInfo. williamr@4: @internalComponent williamr@4: */ williamr@4: TUint iVersionNumber; williamr@4: /** The minimum size for the heap. williamr@4: @internalConponent williamr@4: */ williamr@4: TInt iMinLength; williamr@4: /** The maximum size for the heap. williamr@4: @internalConponent williamr@4: */ williamr@4: TInt iMaxLength; williamr@4: /** The alignment of the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: TInt iAlign; williamr@4: /** The grow by value of the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: TInt iGrowBy; williamr@4: /** The single thread value of the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: TBool iSingleThread; williamr@4: /** The offset from the base of the chunk to the start of the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: TInt iOffset; williamr@4: /** The paging attributes of the chunk. williamr@4: @internalComponent williamr@4: */ williamr@4: TChunkHeapPagingAtt iPaging; williamr@4: /** The mode flags for the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: TUint iMode; williamr@4: /** The name of the chunk to be created for the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: TDesC* iName; williamr@4: /** The chunk to use for the heap. williamr@4: @internalComponent williamr@4: */ williamr@4: RChunk iChunk; williamr@4: /**@internalComponent*/ williamr@4: TInt iSpare[5]; williamr@4: }; williamr@2: williamr@2: struct SStdEpocThreadCreateInfo; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A set of static functions for constructing fixed length heaps and local or williamr@2: global heaps. williamr@2: williamr@2: @see RHeap williamr@2: @see RChunk williamr@2: */ williamr@2: class UserHeap williamr@2: { williamr@2: public: williamr@4: /** williamr@4: Flags to control the heap creation. williamr@4: */ williamr@4: enum TChunkHeapCreateMode williamr@4: { williamr@4: /** On successful creation of the heap this switches the calling thread to williamr@4: use the new heap. williamr@4: */ williamr@4: EChunkHeapSwitchTo = 0x1, williamr@4: /** On successful creation of the heap this causes the handle to the heap williamr@4: to be duplicated. williamr@4: */ williamr@4: EChunkHeapDuplicate = 0x2, williamr@4: williamr@4: /** @internalComponent*/ williamr@4: EChunkHeapMask = EChunkHeapSwitchTo | EChunkHeapDuplicate, williamr@4: }; williamr@2: IMPORT_C static RHeap* FixedHeap(TAny* aBase, TInt aMaxLength, TInt aAlign=0, TBool aSingleThread=ETrue); williamr@2: IMPORT_C static RHeap* ChunkHeap(const TDesC* aName, TInt aMinLength, TInt aMaxLength, TInt aGrowBy=1, TInt aAlign=0, TBool aSingleThread=EFalse); williamr@2: IMPORT_C static RHeap* ChunkHeap(RChunk aChunk, TInt aMinLength, TInt aGrowBy=1, TInt aMaxLength=0, TInt aAlign=0, TBool aSingleThread=EFalse, TUint32 aMode=0); williamr@2: IMPORT_C static RHeap* OffsetChunkHeap(RChunk aChunk, TInt aMinLength, TInt aOffset, TInt aGrowBy=1, TInt aMaxLength=0, TInt aAlign=0, TBool aSingleThread=EFalse, TUint32 aMode=0); williamr@4: IMPORT_C static RHeap* ChunkHeap(const TChunkHeapCreateInfo& aCreateInfo); williamr@2: IMPORT_C static TInt SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo); williamr@2: IMPORT_C static TInt CreateThreadHeap(SStdEpocThreadCreateInfo& aInfo, RHeap*& aHeap, TInt aAlign=0, TBool aSingleThread=EFalse); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Encapsulates the Id of a kernel object. williamr@2: */ williamr@2: class TObjectId williamr@2: { williamr@2: public: williamr@2: inline TObjectId(); williamr@2: inline TObjectId(TUint64 anId); williamr@2: inline TUint64 Id() const; williamr@2: inline operator TUint() const; williamr@2: inline TBool operator==(TObjectId aId) const; williamr@2: inline TBool operator!=(TObjectId aId) const; williamr@2: private: williamr@2: TUint64 iId; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Encapsulates the Id of a thread. williamr@2: williamr@2: An object of this type is not explicitly constructed in open code, williamr@2: but is returned by the Id() member function of a thread handle, williamr@2: an RThread type. williamr@2: williamr@2: @see RThread williamr@2: */ williamr@2: class TThreadId : public TObjectId williamr@2: { williamr@2: public: williamr@2: inline TThreadId(); williamr@2: inline TThreadId(TUint64 anId); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@4: /** williamr@4: This structure specifies the type and properties of the thread to be created. It williamr@4: is passed as a parameter to the RThread::Create() method. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: struct TThreadCreateInfo williamr@4: { williamr@4: public : williamr@4: /** williamr@4: Currently supported version numbers williamr@4: @internalComponent williamr@4: */ williamr@4: enum TThreadCreateVersions williamr@4: { williamr@4: EVersion0, williamr@4: ESupportedVersions, williamr@4: }; williamr@4: williamr@4: /** williamr@4: Attributes that specify whether the stack and heap of the thread to be created williamr@4: are data paged or not. williamr@4: */ williamr@4: enum TThreadPagingAtt williamr@4: { williamr@4: EUnspecified, /**< The thread will use the creating process's paging attributes.*/ williamr@4: EPaged, /**< The thread will data page its stack and heap.*/ williamr@4: EUnpaged, /**< The thread will not data page its stack and heap.*/ williamr@4: }; williamr@4: williamr@4: friend class RThread; williamr@4: williamr@4: IMPORT_C TThreadCreateInfo( const TDesC &aName, TThreadFunction aFunction, williamr@4: TInt aStackSize, TAny* aPtr); williamr@4: IMPORT_C void SetCreateHeap(TInt aHeapMinSize, TInt aHeapMaxSize); williamr@4: IMPORT_C void SetUseHeap(const RAllocator* aHeap); williamr@4: IMPORT_C void SetOwner(const TOwnerType aOwner); williamr@4: IMPORT_C void SetPaging(const TThreadPagingAtt aPaging); williamr@4: williamr@4: protected: williamr@4: /** The version number of this TChunkCreateInfo. williamr@4: @internalComponent williamr@4: */ williamr@4: TUint iVersionNumber; williamr@4: /** The Name to be given to the thread to be created williamr@4: @internalComponent williamr@4: */ williamr@4: const TDesC* iName; williamr@4: /** The function this thread will execute. williamr@4: @internalComponent williamr@4: */ williamr@4: TThreadFunction iFunction; williamr@4: /** The size of the stack of the thread to be created. williamr@4: @internalComponent williamr@4: */ williamr@4: TInt iStackSize; williamr@4: /** The parameter to be passed to the function of the thread to be created. williamr@4: @internalComponent williamr@4: */ williamr@4: TAny* iParameter; williamr@4: /** The owner of the thread to be created. williamr@4: @internalComponent williamr@4: */ williamr@4: TOwnerType iOwner; williamr@4: /** The heap for the thread to be created to use. williamr@4: NULL if a new heap is to be created. williamr@4: @internalComponent williamr@4: */ williamr@4: RAllocator* iHeap; williamr@4: /** Minimum size of any heap to be created for the thread. williamr@4: @internalComponent*/ williamr@4: TInt iHeapMinSize; williamr@4: /** Maximum size of any heap to be created for the thread. williamr@4: @internalComponent williamr@4: */ williamr@4: TInt iHeapMaxSize; williamr@4: /** The attributes of the thread williamr@4: @internalComponent williamr@4: */ williamr@4: TUint iAttributes; williamr@4: /**@internalComponent*/ williamr@4: TUint32 iSpare[6]; williamr@4: }; williamr@4: williamr@2: class RProcess; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a thread. williamr@2: williamr@2: The thread itself is a kernel object. williamr@2: */ williamr@2: class RThread : public RHandleBase williamr@2: { williamr@2: public: williamr@2: inline RThread(); williamr@2: IMPORT_C TInt Create(const TDesC& aName, TThreadFunction aFunction, TInt aStackSize, TInt aHeapMinSize, TInt aHeapMaxSize, TAny *aPtr, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Create(const TDesC& aName, TThreadFunction aFunction, TInt aStackSize, RAllocator* aHeap, TAny* aPtr, TOwnerType aType=EOwnerProcess); williamr@4: IMPORT_C TInt Create(const TThreadCreateInfo& aCreateInfo); williamr@2: IMPORT_C TInt Open(const TDesC& aFullName, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TThreadId aID, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TThreadId Id() const; williamr@2: IMPORT_C void Resume() const; williamr@2: IMPORT_C void Suspend() const; williamr@2: /** williamr@2: @publishedAll williamr@2: @deprecated Use User::RenameThread() instead williamr@2: */ williamr@2: inline static TInt RenameMe(const TDesC& aName); williamr@2: williamr@2: IMPORT_C void Kill(TInt aReason); williamr@2: IMPORT_C void Terminate(TInt aReason); williamr@2: IMPORT_C void Panic(const TDesC& aCategory,TInt aReason); williamr@2: IMPORT_C TInt Process(RProcess& aProcess) const; williamr@2: IMPORT_C TThreadPriority Priority() const; williamr@2: IMPORT_C void SetPriority(TThreadPriority aPriority) const; williamr@2: IMPORT_C TProcessPriority ProcessPriority() const; williamr@2: IMPORT_C void SetProcessPriority(TProcessPriority aPriority) const; williamr@2: IMPORT_C TInt RequestCount() const; williamr@2: IMPORT_C TExitType ExitType() const; williamr@2: IMPORT_C TInt ExitReason() const; williamr@2: IMPORT_C TExitCategoryName ExitCategory() const; williamr@2: IMPORT_C void RequestComplete(TRequestStatus*& aStatus,TInt aReason) const; williamr@2: IMPORT_C void RequestSignal() const; williamr@2: IMPORT_C void Logon(TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt LogonCancel(TRequestStatus& aStatus) const; williamr@2: IMPORT_C void HandleCount(TInt& aProcessHandleCount, TInt& aThreadHandleCount) const; williamr@2: IMPORT_C void Context(TDes8& aDes) const; williamr@2: IMPORT_C TInt StackInfo(TThreadStackInfo& aInfo) const; williamr@2: IMPORT_C TInt GetCpuTime(TTimeIntervalMicroSeconds& aCpuTime) const; williamr@2: inline TInt Open(const TFindThread& aFind,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void Rendezvous(TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt RendezvousCancel(TRequestStatus& aStatus) const; williamr@2: IMPORT_C static void Rendezvous(TInt aReason); williamr@2: williamr@2: /** williamr@2: Return the Secure ID of the process to which the thread belongs. 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: RThread& thread; williamr@2: TInt error = thread.SecureId()==KRequiredSecureId ? KErrNone : KErrPermissionDenied; williamr@2: @endcode williamr@2: williamr@2: this could be used; williamr@2: williamr@2: @code williamr@2: RThread& thread; williamr@2: static _LIT_SECURITY_POLICY_S0(mySidPolicy, KRequiredSecureId); williamr@4: TBool pass = mySidPolicy().CheckPolicy(thread); 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(RThread aThread, const char* aDiagnostic) const williamr@2: @see _LIT_SECURITY_POLICY_S0 williamr@2: williamr@2: @return The Secure ID. 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 to which the thread belongs. 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: RThread& thread; williamr@2: TInt error = thread.VendorId()==KRequiredVendorId ? KErrNone : KErrPermissionDenied; williamr@2: @endcode williamr@2: williamr@2: this could be used; williamr@2: williamr@2: @code williamr@2: RThread& thread; williamr@2: static _LIT_SECURITY_POLICY_V0(myVidPolicy, KRequiredVendorId); williamr@4: TBool pass = myVidPolicy().CheckPolicy(thread); 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(RThread aThread, 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 to which the thread belongs 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 the process to which the thread belongs 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 to which the thread belongs 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 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 the process to which the thread belongs 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 aCapability, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: /** Function only temporarily supported to aid migration to process emulation... williamr@2: williamr@2: @publishedAll williamr@2: @deprecated Use process emulation instead williamr@2: */ williamr@2: inline TInt Create(const TDesC& aName,TThreadFunction aFunction,TInt aStackSize,TAny* aPtr,RLibrary* aLibrary,RHeap* aHeap, TInt aHeapMinSize,TInt aHeapMaxSize,TOwnerType aType); 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 aCapability1, TCapability aCapability2, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoHasCapability(TCapability aCapability1, TCapability aCapability2) const; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: inline TInt RThread::Create(const TDesC& /*aName*/,TThreadFunction /*aFunction*/,TInt /*aStackSize*/,TAny* /*aPtr*/,RLibrary* /*aLibrary*/,RHeap* /*aHeap*/, TInt /*aHeapMinSize*/,TInt /*aHeapMaxSize*/,TOwnerType /*aType*/) williamr@2: {return KErrNotSupported; } williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Encapsulates the Id of a process. williamr@2: williamr@2: An object of this type is not explicitly constructed in open code, williamr@2: but is returned by the Id() member function of a process handle, williamr@2: an RProcess type. williamr@2: williamr@2: @see RProcess williamr@2: */ williamr@2: class TProcessId : public TObjectId williamr@2: { williamr@2: public: williamr@2: inline TProcessId(); williamr@2: inline TProcessId(TUint64 anId); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class RSubSessionBase; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a process. williamr@2: williamr@2: The process itself is a kernel object. williamr@2: */ williamr@2: class RProcess : public RHandleBase williamr@2: { williamr@2: public: williamr@2: inline RProcess(); williamr@2: IMPORT_C TInt Create(const TDesC& aFileName,const TDesC& aCommand,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Create(const TDesC& aFileName,const TDesC& aCommand,const TUidType &aUidType, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(const TDesC& aName,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TProcessId aId,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TUidType Type() const; williamr@2: IMPORT_C TProcessId Id() const; williamr@2: /** williamr@2: @publishedAll williamr@2: @deprecated Use User::RenameProcess() instead williamr@2: */ williamr@2: inline static TInt RenameMe(const TDesC& aName); williamr@2: williamr@2: IMPORT_C void Kill(TInt aReason); williamr@2: IMPORT_C void Terminate(TInt aReason); williamr@2: IMPORT_C void Panic(const TDesC& aCategory,TInt aReason); williamr@2: IMPORT_C void Resume(); williamr@2: IMPORT_C TFileName FileName() const; williamr@2: IMPORT_C TExitType ExitType() const; williamr@2: IMPORT_C TInt ExitReason() const; williamr@2: IMPORT_C TExitCategoryName ExitCategory() const; williamr@2: IMPORT_C TProcessPriority Priority() const; williamr@4: IMPORT_C TInt SetPriority(TProcessPriority aPriority) const; williamr@2: IMPORT_C TBool JustInTime() const; williamr@2: IMPORT_C void SetJustInTime(TBool aBoolean) const; williamr@2: IMPORT_C void Logon(TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt LogonCancel(TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt GetMemoryInfo(TModuleMemoryInfo& aInfo) const; williamr@2: inline TInt Open(const TFindProcess& aFind,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C void Rendezvous(TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt RendezvousCancel(TRequestStatus& aStatus) const; williamr@2: IMPORT_C static void Rendezvous(TInt aReason); williamr@4: IMPORT_C TBool DefaultDataPaged() const; williamr@2: williamr@2: /** williamr@2: Return the Secure ID of the process. 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: RProcess& process; williamr@2: TInt error = process.SecureId()==KRequiredSecureId ? KErrNone : KErrPermissionDenied; williamr@2: @endcode williamr@2: williamr@2: this could be used; williamr@2: williamr@2: @code williamr@2: RProcess& process; williamr@2: static _LIT_SECURITY_POLICY_S0(mySidPolicy, KRequiredSecureId); williamr@4: TBool pass = mySidPolicy().CheckPolicy(process); 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(RProcess aProcess, const char* aDiagnostic) const williamr@2: @see _LIT_SECURITY_POLICY_S0 williamr@2: williamr@2: @return The Secure ID. 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. 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: RProcess& process; williamr@2: TInt error = process.VendorId()==KRequiredVendorId ? KErrNone : KErrPermissionDenied; williamr@2: @endcode williamr@2: williamr@2: this could be used; williamr@2: williamr@2: @code williamr@2: RProcess& process; williamr@2: static _LIT_SECURITY_POLICY_V0(myVidPolicy, KRequiredVendorId); williamr@4: TBool pass = myVidPolicy().CheckPolicy(process); 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(RProcess aProcess, 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 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 the process 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 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 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 the process 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 aCapability, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress) const; williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: IMPORT_C TInt SetParameter(TInt aIndex, RHandleBase aHandle); williamr@2: IMPORT_C TInt SetParameter(TInt aSlot, const RSubSessionBase& aSession); williamr@2: IMPORT_C TInt SetParameter(TInt aSlot, const TDesC16& aDes); williamr@2: IMPORT_C TInt SetParameter(TInt aSlot, const TDesC8& aDes); williamr@2: IMPORT_C TInt SetParameter(TInt aSlot, TInt aData); williamr@2: inline RProcess(TInt aHandle); williamr@2: williamr@2: /** williamr@2: @deprecated Use RProcess::SecureId() instead williamr@2: */ williamr@2: inline TUid Identity() const { return SecureId(); } williamr@2: williamr@2: /** williamr@2: Legacy Platform Security development and migration support williamr@2: @internalAll williamr@2: @deprecated No replacement williamr@2: */ williamr@2: enum TSecureApi { ESecureApiOff, ESecureApiOn, ESecureApiQuery }; // __SECURE_API__ remove this williamr@2: williamr@2: /** williamr@2: Legacy Platform Security development and migration support williamr@2: @internalAll williamr@2: @deprecated No replacement williamr@2: */ williamr@2: IMPORT_C TInt SecureApi(TInt aState); // __SECURE_API__ remove this williamr@2: williamr@2: /** williamr@2: Legacy Platform Security development and migration support williamr@2: @internalAll williamr@2: @deprecated No replacement williamr@2: */ williamr@2: enum TDataCaging { EDataCagingOff, EDataCagingOn, EDataCagingQuery}; // __DATA_CAGING__ __SECURE_API__ remove this williamr@2: williamr@2: /** williamr@2: Legacy Platform Security development and migration support williamr@2: @internalAll williamr@2: @deprecated No replacement williamr@2: */ williamr@2: IMPORT_C TInt DataCaging(TInt aState); // __DATA_CAGING__ __SECURE_API__ remove this williamr@2: williamr@4: williamr@2: IMPORT_C TInt CreateWithStackOverride(const TDesC& aFileName,const TDesC& aCommand, const TUidType &aUidType, TInt aMinStackSize, TOwnerType aType); williamr@2: williamr@2: IMPORT_C static TAny* ExeExportData(void); 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 aCapability1, TCapability aCapability2, const char* aDiagnostic) const; williamr@2: IMPORT_C TBool DoHasCapability(TCapability aCapability1, TCapability aCapability2) const; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: class RServer2 : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt CreateGlobal(const TDesC& aName); williamr@2: IMPORT_C TInt CreateGlobal(const TDesC& aName, TInt aMode); williamr@4: IMPORT_C TInt CreateGlobal(const TDesC& aName, TInt aMode, TInt aRole, TInt aOpts); williamr@2: IMPORT_C void Receive(RMessage2& aMessage,TRequestStatus& aStatus); williamr@2: IMPORT_C void Receive(RMessage2& aMessage); williamr@2: IMPORT_C void Cancel(); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Client-side handle to a session with a server. williamr@2: williamr@2: This is the client-side interface through which communication with the server williamr@2: is channelled. williamr@2: williamr@2: Clients normally define and implement a derived class to provide williamr@2: a richer interface. williamr@2: */ williamr@2: class RSessionBase : public RHandleBase williamr@2: { williamr@2: friend class RSubSessionBase; williamr@2: public: williamr@2: /** williamr@2: Indicates whether or not threads in the process are automatically attached williamr@2: to the session when passed as a parameter to the Share() function. williamr@2: */ williamr@2: enum TAttachMode {EExplicitAttach,EAutoAttach}; williamr@2: public: williamr@2: /** williamr@2: Creates a session that can be shared by other threads in the current williamr@2: process. williamr@2: williamr@2: After calling this function the session object may be used by threads other williamr@2: than than the one that created it. williamr@2: williamr@2: Note that this can only be done with servers that mark their sessions williamr@2: as sharable. williamr@2: williamr@2: @return KErrNone, if the session is successfully shared; williamr@2: KErrNoMmemory, if the attempt fails for lack of memory. williamr@2: williamr@2: @panic KERN-EXEC 23 The session cannot be shared. williamr@2: williamr@2: @see CServer2 williamr@2: @see RSessionBase::ShareProtected() williamr@2: @see CServer2::TServerType williamr@2: */ williamr@2: inline TInt ShareAuto() { return DoShare(EAutoAttach); } williamr@2: williamr@2: williamr@2: /** williamr@2: Creates a session handle that can be be passed via IPC to another process williamr@2: as well as being shared by other threads in the current process. williamr@2: williamr@2: After calling this function the session object may be used by threads other williamr@2: than than the one that created it. williamr@2: williamr@2: Note that this can only be done with servers that mark their sessions williamr@2: as globally sharable. williamr@2: williamr@2: @return KErrNone, if the session is successfully shared; williamr@2: KErrNoMmemory, if the attempt fails for lack of memory. williamr@2: williamr@2: @panic KERN-EXEC 23 The session cannot be shared. williamr@2: williamr@2: @see CServer2 williamr@2: @see RSessionBase::ShareAuto() williamr@2: @see CServer2::TServerType williamr@2: */ williamr@2: inline TInt ShareProtected() { return DoShare(EAutoAttach|KCreateProtectedObject); } williamr@2: williamr@2: williamr@2: IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(RMessagePtr2 aMessage,TInt aParam,const TSecurityPolicy& aServerPolicy,TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess); williamr@2: IMPORT_C TInt Open(TInt aArgumentIndex, const TSecurityPolicy& aServerPolicy, TOwnerType aType=EOwnerProcess); williamr@2: inline TInt SetReturnedHandle(TInt aHandleOrError); williamr@2: IMPORT_C TInt SetReturnedHandle(TInt aHandleOrError,const TSecurityPolicy& aServerPolicy); williamr@2: protected: williamr@2: inline TInt CreateSession(const TDesC& aServer,const TVersion& aVersion); williamr@2: IMPORT_C TInt CreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots); williamr@2: IMPORT_C TInt CreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots,TIpcSessionType aType,const TSecurityPolicy* aPolicy=0, TRequestStatus* aStatus=0); williamr@2: inline TInt CreateSession(RServer2 aServer,const TVersion& aVersion); williamr@2: IMPORT_C TInt CreateSession(RServer2 aServer,const TVersion& aVersion,TInt aAsyncMessageSlots); williamr@2: IMPORT_C TInt CreateSession(RServer2 aServer,const TVersion& aVersion,TInt aAsyncMessageSlots,TIpcSessionType aType,const TSecurityPolicy* aPolicy=0, TRequestStatus* aStatus=0); williamr@2: inline static TInt SetReturnedHandle(TInt aHandleOrError,RHandleBase& aHandle); williamr@2: williamr@2: /** williamr@2: @deprecated Use CreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots,TIpcSessionType aType,const TSecurityPolicy* aPolicy=0, TRequestStatus* aStatus=0); williamr@2: */ williamr@2: inline TInt CreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots,TRequestStatus* aStatus) williamr@2: { return CreateSession(aServer, aVersion, aAsyncMessageSlots, EIpcSession_Unsharable, (TSecurityPolicy*)0, aStatus); } williamr@2: inline TInt Send(TInt aFunction,const TIpcArgs& aArgs) const; williamr@2: inline void SendReceive(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) const; williamr@2: inline TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const; williamr@2: inline TInt Send(TInt aFunction) const; williamr@2: inline void SendReceive(TInt aFunction,TRequestStatus& aStatus) const; williamr@2: inline TInt SendReceive(TInt aFunction) const; williamr@2: private: williamr@2: IMPORT_C TInt DoSend(TInt aFunction,const TIpcArgs* aArgs) const; williamr@2: IMPORT_C void DoSendReceive(TInt aFunction,const TIpcArgs* aArgs,TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt DoSendReceive(TInt aFunction,const TIpcArgs* aArgs) const; williamr@2: TInt SendAsync(TInt aFunction,const TIpcArgs* aArgs,TRequestStatus* aStatus) const; williamr@2: TInt SendSync(TInt aFunction,const TIpcArgs* aArgs) const; williamr@2: IMPORT_C TInt DoShare(TInt aAttachMode); williamr@2: TInt DoConnect(const TVersion &aVersion,TRequestStatus* aStatus); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Client-side handle to a sub-session. williamr@2: williamr@2: It represents a client-side sub-session, and has a corresponding sub-session williamr@2: object on the server-side. williamr@2: williamr@2: Clients normally define and implement a derived class to provide a richer williamr@2: interface. In particular, a derived class should: williamr@2: williamr@2: 1. provide a function to create a new sub-session with the server; williamr@2: this should call CreateSubSession(). williamr@2: williamr@2: 2. provide a function to close the current sub-session; williamr@2: this should call CloseSubSession(). williamr@2: williamr@2: A session must already exist with a server before a client can establish williamr@2: any sub-sessions. williamr@2: */ williamr@2: class RSubSessionBase williamr@2: { williamr@2: public: williamr@2: inline TInt SubSessionHandle() const; williamr@2: protected: williamr@2: inline RSubSessionBase(); williamr@2: IMPORT_C const RSessionBase Session() const; williamr@2: inline TInt CreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs); williamr@2: inline TInt CreateSubSession(const RSessionBase& aSession,TInt aFunction); williamr@2: IMPORT_C TInt CreateAutoCloseSubSession(RSessionBase& aSession,TInt aFunction,const TIpcArgs& aArgs); williamr@2: IMPORT_C void CloseSubSession(TInt aFunction); williamr@2: inline TInt Send(TInt aFunction,const TIpcArgs& aArgs) const; williamr@2: inline void SendReceive(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) const; williamr@2: inline TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const; williamr@2: inline TInt Send(TInt aFunction) const; williamr@2: inline void SendReceive(TInt aFunction,TRequestStatus& aStatus) const; williamr@2: inline TInt SendReceive(TInt aFunction) const; williamr@2: private: williamr@2: IMPORT_C TInt DoCreateSubSession(const RSessionBase& aSession,TInt aFunction,const TIpcArgs* aArgs); williamr@2: IMPORT_C TInt DoSend(TInt aFunction,const TIpcArgs* aArgs) const; williamr@2: IMPORT_C void DoSendReceive(TInt aFunction,const TIpcArgs* aArgs,TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt DoSendReceive(TInt aFunction,const TIpcArgs* aArgs) const; williamr@2: TInt DoCreateSubSession(RSessionBase& aSession,TInt aFunction,const TIpcArgs* aArgs, TBool aAutoClose); williamr@2: private: williamr@2: RSessionBase iSession; williamr@2: TInt iSubSessionHandle; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Base class that provides an implementation for the templated williamr@2: RRef class. williamr@2: williamr@2: @see RRef williamr@2: */ williamr@2: class RRefBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C void Free(); williamr@2: protected: williamr@2: inline RRefBase(); williamr@2: inline RRefBase(const RRefBase& aRef); williamr@2: IMPORT_C void DoAlloc(const TAny* aPtr,TInt aSize); williamr@2: IMPORT_C void DoAllocL(const TAny* aPtr,TInt aSize); williamr@2: IMPORT_C void Copy(const RRefBase& aRef); williamr@2: private: williamr@2: IMPORT_C void operator=(const RRefBase& aRef); williamr@2: protected: williamr@2: TInt* iPtr; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains, or packages, a copy of an instance of another class. williamr@2: williamr@2: The template parameter defines the type of the contained object. williamr@2: williamr@2: The contained object is held in allocated memory, and can be accessed williamr@2: through the member selection and dereference operators. williamr@2: */ williamr@2: template williamr@2: class RRef : public RRefBase williamr@2: { williamr@2: public: williamr@2: inline RRef(); williamr@2: inline RRef(const RRef& anObject); williamr@2: inline void operator=(const RRef& anObject); williamr@2: inline T* operator->(); williamr@2: inline operator T*(); williamr@2: inline void Alloc(const T& anObject); williamr@2: inline void Alloc(const T& anObject,TInt aSize); williamr@2: inline void AllocL(const T& anObject); williamr@2: inline void AllocL(const T& anObject,TInt aSize); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a change notifier. williamr@2: williamr@2: The change notifier itself is a kernel object. williamr@2: */ williamr@2: class RChangeNotifier : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt Create(); williamr@2: IMPORT_C TInt Logon(TRequestStatus& aStatus) const; williamr@2: IMPORT_C TInt LogonCancel() const; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Handle to a thread death notifier. williamr@2: williamr@2: The notifier allows threads to be notified of the death of another thread. williamr@2: williamr@2: The thread-death notifier itself is a kernel object. williamr@2: */ williamr@2: class RUndertaker : public RHandleBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C TInt Create(); williamr@2: IMPORT_C TInt Logon(TRequestStatus& aStatus,TInt& aThreadHandle) const; williamr@2: IMPORT_C TInt LogonCancel() const; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class HBufC16; williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A handle to a session with the extended notifier server that provides support williamr@2: for plug-in notifiers. williamr@2: williamr@2: The interface allows engines or other low level components williamr@2: to communicate with the UI. williamr@2: */ williamr@2: class RNotifier : public RSessionBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C RNotifier(); williamr@2: IMPORT_C TInt Connect(); williamr@2: IMPORT_C void Close(); williamr@2: IMPORT_C TInt StartNotifier(TUid aNotifierUid,const TDesC8& aBuffer); williamr@2: IMPORT_C TInt StartNotifier(TUid aNotifierUid,const TDesC8& aBuffer,TDes8& aResponse); williamr@2: IMPORT_C TInt StartNotifier(TUid aNotifierDllUid,TUid aNotifierUid,const TDesC8& aBuffer,TDes8& aResponse); williamr@2: IMPORT_C TInt CancelNotifier(TUid aNotifierUid); williamr@2: IMPORT_C TInt UpdateNotifier(TUid aNotifierUid,const TDesC8& aBuffer,TDes8& aResponse); williamr@2: IMPORT_C void UpdateNotifierAndGetResponse(TRequestStatus& aRs,TUid aNotifierUid,const TDesC8& aBuffer,TDes8& aResponse); williamr@2: IMPORT_C void StartNotifierAndGetResponse(TRequestStatus& aRs,TUid aNotifierUid,const TDesC8& aBuffer,TDes8& aResponse); williamr@2: IMPORT_C void StartNotifierAndGetResponse(TRequestStatus& aRs,TUid aNotifierDllUid,TUid aNotifierUid,const TDesC8& aBuffer,TDes8& aResponse); williamr@2: IMPORT_C TInt UnloadNotifiers(TUid aNotifierUid); williamr@2: IMPORT_C TInt LoadNotifiers(TUid aNotifierUid); williamr@2: IMPORT_C void Notify(const TDesC& aLine1,const TDesC& aLine2,const TDesC& aBut1,const TDesC& aBut2,TInt& aButtonVal,TRequestStatus& aStatus); williamr@2: IMPORT_C void NotifyCancel(); williamr@2: IMPORT_C TInt InfoPrint(const TDesC& aDes); williamr@2: private: williamr@2: TPtr8 iButtonVal; williamr@2: HBufC16* iCombinedBuffer; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Abstract class that defines a handler to work with the TRAP mechanism. williamr@2: williamr@2: Symbian OS provides a trap handler and this class does not normally need to be williamr@2: used or accessed directly by applications and third party code. williamr@2: */ williamr@2: class TTrapHandler williamr@2: { williamr@2: public: williamr@2: IMPORT_C TTrapHandler(); williamr@2: williamr@2: /** williamr@2: Called when a TRAP is invoked. williamr@2: */ williamr@2: IMPORT_C virtual void Trap()=0; williamr@2: williamr@2: /** williamr@2: Called when a function exits a TRAP without leaving. williamr@2: */ williamr@2: IMPORT_C virtual void UnTrap()=0; williamr@2: williamr@2: /** williamr@2: Called when a function within a TRAP leaves. williamr@2: williamr@2: @param aValue The leave value. williamr@2: */ williamr@2: IMPORT_C virtual void Leave(TInt aValue)=0; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: struct TCollationMethod; // forward declaration williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Contains a set of static functions which perform manipulation of williamr@2: data in memory. williamr@2: williamr@2: The arguments passed to the functions of this class are pointers to memory williamr@2: locations and length values. These functions are, therefore, not normally williamr@2: used in open code but are suitable for implementing data manipulation for williamr@2: other classes. Typically the interface provided by such classes is typesafe williamr@2: and hides this direct memory to memory manipulation. williamr@2: */ williamr@2: class Mem williamr@2: { williamr@2: public: williamr@2: inline static TUint8* Copy(TAny* aTrg, const TAny* aSrc, TInt aLength); williamr@2: inline static TUint8* Move(TAny* aTrg, const TAny* aSrc, TInt aLength); williamr@2: inline static void Fill(TAny* aTrg, TInt aLength, TChar aChar); williamr@2: inline static void FillZ(TAny* aTrg, TInt aLength); williamr@2: #ifndef __GCC32__ williamr@2: inline static TInt Compare(const TUint8* aLeft, TInt aLeftL, const TUint8* aRight, TInt aRightL); williamr@2: #else williamr@2: IMPORT_C static TInt Compare(const TUint8* aLeft, TInt aLeftL, const TUint8* aRight, TInt aRightL); williamr@2: #endif williamr@2: williamr@2: IMPORT_C static TInt Compare(const TUint16* aLeft, TInt aLeftL, const TUint16* aRight, TInt aRightL); williamr@2: IMPORT_C static TInt CompareF(const TUint8* aLeft, TInt aLeftL, const TUint8* aRight, TInt aRightL); williamr@2: IMPORT_C static TInt CompareF(const TUint16* aLeft, TInt aLeftL, const TUint16* aRight, TInt aRightL); williamr@2: IMPORT_C static TInt CompareC(const TUint8* aLeft, TInt aLeftL, const TUint8* aRight, TInt aRightL); williamr@2: IMPORT_C static TInt CompareC(const TUint16* aLeft, TInt aLeftL, const TUint16* aRight, TInt aRightL); williamr@2: IMPORT_C static TInt CompareC(const TUint16* aLeft, TInt aLeftL, const TUint16* aRight, TInt aRightL, williamr@2: TInt aMaxLevel, const TCollationMethod* aCollationMethod); williamr@2: IMPORT_C static TInt CollationMethods(); williamr@2: IMPORT_C static TUint CollationMethodId(TInt aIndex); williamr@2: IMPORT_C static const TCollationMethod* CollationMethodByIndex(TInt aIndex); williamr@2: IMPORT_C static const TCollationMethod* CollationMethodById(TUint aId); williamr@2: IMPORT_C static const TCollationMethod* GetDefaultMatchingTable(); williamr@2: IMPORT_C static void Swap(TAny* aPtr1, TAny* aPtr2, TInt aLength); williamr@2: IMPORT_C static void Crc(TUint16& aCrc, const TAny* aPtr, TInt aLength); williamr@2: IMPORT_C static void Crc32(TUint32& aCrc, const TAny* aPtr, TInt aLength); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Set of static user functions. williamr@2: williamr@2: These functions are related to a number of System component APIs. williamr@2: williamr@2: The majority of the functions are related to either the current thread, or williamr@2: its heap. Examples in this category include User::Exit(), which causes the williamr@2: thread to terminate, and User::Alloc(), which allocates memory from the current williamr@2: thread's heap. williamr@2: williamr@2: Some of these functions are equivalent to functions in the RThread or RHeap williamr@2: classes. In these cases, the User function is a convenient way to access the williamr@2: function without first having to get a handle to the current thread. williamr@2: williamr@2: Functions are also provided to support debugging of memory leaks. These function williamr@2: calls can be written explicitly or can be generated using a corresponding williamr@2: macro - the advantage of using a macro is that the function call is only williamr@2: generated for debug builds. williamr@2: williamr@2: A final category of functions, which includes User::BinarySearch() and User::QuickSort(), williamr@2: are just useful functions which have no other natural home. williamr@2: williamr@2: @see RThread williamr@2: @see RHeap williamr@2: */ williamr@2: class User : public UserHeap williamr@2: { williamr@2: public: williamr@2: // Execution control williamr@2: IMPORT_C static void InitProcess(); /**< @internalComponent */ williamr@2: IMPORT_C static void Exit(TInt aReason); williamr@2: IMPORT_C static void Panic(const TDesC& aCategory,TInt aReason); williamr@2: IMPORT_C static void HandleException(TAny* aInfo); /**< @internalComponent */ williamr@2: // Cleanup support williamr@2: IMPORT_C static void Leave(TInt aReason); williamr@2: IMPORT_C static void LeaveNoMemory(); williamr@2: IMPORT_C static TInt LeaveIfError(TInt aReason); williamr@2: IMPORT_C static TAny* LeaveIfNull(TAny* aPtr); williamr@4: inline static const TAny* LeaveIfNull(const TAny* aPtr); williamr@2: IMPORT_C static TTrapHandler* SetTrapHandler(TTrapHandler* aHandler); williamr@2: IMPORT_C static TTrapHandler* TrapHandler(); williamr@2: IMPORT_C static TTrapHandler* MarkCleanupStack(); /**< @internalComponent */ williamr@2: IMPORT_C static void UnMarkCleanupStack(TTrapHandler* aHandler); /**< @internalComponent */ williamr@2: IMPORT_C static void LeaveEnd(); /**< @internalComponent */ williamr@2: // Infoprint williamr@2: IMPORT_C static TInt InfoPrint(const TDesC& aDes); williamr@2: // Asynchronous service support williamr@2: IMPORT_C static void RequestComplete(TRequestStatus*& aStatus,TInt aReason); williamr@2: IMPORT_C static void WaitForAnyRequest(); williamr@2: IMPORT_C static void WaitForRequest(TRequestStatus& aStatus); williamr@2: IMPORT_C static void WaitForRequest(TRequestStatus& aStatus1,TRequestStatus& aStatus2); williamr@2: IMPORT_C static void WaitForNRequest(TRequestStatus *aStatusArray[], TInt aNum); williamr@2: // User heap management williamr@2: IMPORT_C static TInt AllocLen(const TAny* aCell); williamr@2: IMPORT_C static TAny* Alloc(TInt aSize); williamr@2: IMPORT_C static TAny* AllocL(TInt aSize); williamr@2: IMPORT_C static TAny* AllocLC(TInt aSize); williamr@2: IMPORT_C static TAny* AllocZ(TInt aSize); williamr@2: IMPORT_C static TAny* AllocZL(TInt aSize); williamr@2: IMPORT_C static TInt AllocSize(TInt& aTotalAllocSize); williamr@2: IMPORT_C static TInt Available(TInt& aBiggestBlock); williamr@2: IMPORT_C static TInt CountAllocCells(); williamr@2: IMPORT_C static TInt CountAllocCells(TInt& aFreeCount); williamr@2: IMPORT_C static void Free(TAny* aCell); williamr@2: IMPORT_C static void FreeZ(TAny*& aCell); williamr@2: IMPORT_C static RAllocator& Allocator(); williamr@2: inline static RHeap& Heap(); williamr@2: IMPORT_C static TAny* ReAlloc(TAny* aCell, TInt aSize, TInt aMode=0); williamr@2: IMPORT_C static TAny* ReAllocL(TAny* aCell, TInt aSize, TInt aMode=0); williamr@2: IMPORT_C static RAllocator* SwitchAllocator(RAllocator* aAllocator); williamr@2: inline static RHeap* SwitchHeap(RAllocator* aHeap); williamr@2: IMPORT_C static TInt CompressAllHeaps(); williamr@2: // Synchronous timer services williamr@2: IMPORT_C static void After(TTimeIntervalMicroSeconds32 aInterval); williamr@2: IMPORT_C static TInt At(const TTime& aTime); williamr@2: IMPORT_C static void AfterHighRes(TTimeIntervalMicroSeconds32 aInterval); williamr@2: // Set time and deal with timezones williamr@2: IMPORT_C static TInt SetHomeTime(const TTime& aTime); williamr@2: IMPORT_C static TInt SetHomeTimeSecure(const TTime& aTime); williamr@2: IMPORT_C static TInt SetUTCTime(const TTime& aUTCTime); williamr@2: IMPORT_C static TInt SetUTCTimeSecure(const TTime& aUTCTime); williamr@2: IMPORT_C static TTimeIntervalSeconds UTCOffset(); williamr@2: IMPORT_C static void SetUTCOffset(TTimeIntervalSeconds aOffset); williamr@2: IMPORT_C static TInt SetUTCTimeAndOffset(const TTime& aUTCTime, TTimeIntervalSeconds aOffset); williamr@2: // Set locale information williamr@2: IMPORT_C static TInt SetCurrencySymbol(const TDesC& aSymbol); williamr@2: // Set floating point mode williamr@2: IMPORT_C static TInt SetFloatingPointMode(TFloatingPointMode aMode, TFloatingPointRoundingMode aRoundingMode=EFpRoundToNearest); williamr@2: // Timers williamr@2: IMPORT_C static TUint TickCount(); williamr@2: IMPORT_C static TUint32 NTickCount(); williamr@2: IMPORT_C static TTimerLockSpec LockPeriod(); williamr@2: IMPORT_C static TTimeIntervalSeconds InactivityTime(); williamr@2: IMPORT_C static void ResetInactivityTime(); williamr@2: IMPORT_C static TUint32 FastCounter(); williamr@2: // Atomic operations williamr@2: IMPORT_C static TInt LockedInc(TInt& aValue); williamr@2: IMPORT_C static TInt LockedDec(TInt& aValue); williamr@2: IMPORT_C static TInt SafeInc(TInt& aValue); williamr@2: IMPORT_C static TInt SafeDec(TInt& aValue); williamr@2: // Beep williamr@2: IMPORT_C static TInt Beep(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration); williamr@2: // Information williamr@2: IMPORT_C static TInt IsRomAddress(TBool& aBool,TAny* aPtr); williamr@2: // Algorithms williamr@2: IMPORT_C static TInt BinarySearch(TInt aCount,const TKey& aKey,TInt& aPos); williamr@2: IMPORT_C static TInt QuickSort(TInt aCount,const TKey& aKey,const TSwap& aSwap); williamr@2: // Language-dependent character functions williamr@2: IMPORT_C static TLanguage Language(); williamr@4: IMPORT_C static TRegionCode RegionCode(); williamr@2: IMPORT_C static TUint Collate(TUint aChar); williamr@2: IMPORT_C static TUint Fold(TUint aChar); williamr@2: IMPORT_C static TUint LowerCase(TUint aChar); williamr@2: IMPORT_C static TUint UpperCase(TUint aChar); williamr@2: IMPORT_C static TUint Fold(TUint aChar,TInt aFlags); williamr@2: IMPORT_C static TUint TitleCase(TUint aChar); williamr@2: // C-style string length williamr@2: IMPORT_C static TInt StringLength(const TUint8* aString); williamr@2: IMPORT_C static TInt StringLength(const TUint16* aString); williamr@2: // Device management williamr@2: IMPORT_C static TInt FreeLogicalDevice(const TDesC& aDeviceName); williamr@2: IMPORT_C static TInt FreePhysicalDevice(const TDesC& aDriverName); williamr@2: IMPORT_C static TInt LoadLogicalDevice(const TDesC& aFileName); williamr@2: IMPORT_C static TInt LoadPhysicalDevice(const TDesC& aFileName); williamr@2: // Version information williamr@2: IMPORT_C static TBool QueryVersionSupported(const TVersion& aCurrent,const TVersion& aRequested); williamr@2: IMPORT_C static TVersion Version(); williamr@2: // Machine configuration williamr@2: IMPORT_C static TInt SetMachineConfiguration(const TDesC8& aConfig); williamr@2: IMPORT_C static TInt MachineConfiguration(TDes8& aConfig,TInt& aSize); williamr@2: // Debugging support williamr@2: IMPORT_C static void SetDebugMask(TUint32 aVal); williamr@2: IMPORT_C static void SetDebugMask(TUint32 aVal, TUint aIndex); williamr@2: IMPORT_C static void SetJustInTime(const TBool aBoolean); williamr@2: IMPORT_C static void Check(); williamr@2: IMPORT_C static void Invariant(); williamr@2: IMPORT_C static TBool JustInTime(); williamr@2: IMPORT_C static void __DbgMarkStart(TBool aKernel); williamr@2: IMPORT_C static void __DbgMarkCheck(TBool aKernel, TBool aCountAll, TInt aCount, const TUint8* aFileName, TInt aLineNum); williamr@2: IMPORT_C static TUint32 __DbgMarkEnd(TBool aKernel, TInt aCount); williamr@2: IMPORT_C static void __DbgSetAllocFail(TBool aKernel, RAllocator::TAllocFail aFail, TInt aRate); williamr@2: IMPORT_C static void __DbgSetBurstAllocFail(TBool aKernel, RAllocator::TAllocFail aFail, TUint aRate, TUint aBurst); williamr@2: IMPORT_C static TUint __DbgCheckFailure(TBool aKernel); williamr@2: IMPORT_C static void PanicUnexpectedLeave(); /**< @internalComponent */ williamr@2: // Name Validation williamr@2: IMPORT_C static TInt ValidateName(const TDesC& aName); williamr@2: // Instruction Memory Barrier williamr@2: IMPORT_C static void IMB_Range(TAny* aStart, TAny* aEnd); williamr@2: // williamr@2: IMPORT_C static TInt CommandLineLength(); williamr@2: IMPORT_C static void CommandLine(TDes &aCommand); williamr@2: IMPORT_C static TExceptionHandler ExceptionHandler(); williamr@2: IMPORT_C static TInt SetExceptionHandler(TExceptionHandler aHandler,TUint32 aMask); williamr@2: IMPORT_C static void ModifyExceptionMask(TUint32 aClearMask, TUint32 aSetMask); williamr@2: IMPORT_C static TInt RaiseException(TExcType aType); williamr@2: IMPORT_C static TBool IsExceptionHandled(TExcType aType); williamr@2: williamr@2: /** williamr@2: A set of values that defines the effect that terminating a thread williamr@2: has, either on its owning process or on the whole system. williamr@2: williamr@2: A thread is said to be critical if its owning process or the entire system williamr@2: terminates when the thread itself terminates. williamr@2: williamr@2: You pass one of these values to the functions: williamr@2: - User::SetCritical() williamr@2: - User::SetProcessCritical() williamr@2: williamr@2: The meaning of a value when passed to one function is different to williamr@2: its meaning when passed the other function. See the description of each williamr@2: individual value. williamr@2: williamr@2: @see User::SetCritical() williamr@2: @see User::SetProcessCritical() williamr@2: */ williamr@2: enum TCritical { williamr@2: williamr@2: williamr@2: /** williamr@2: This value can be passed to both: williamr@2: - User::SetCritical(), which means that the current thread williamr@2: is no longer critical, i.e. termination of the current williamr@2: thread will no longer cause termination of the current thread's williamr@2: owning process (i.e. the current process) or a reboot of the system. williamr@2: - User::SetProcessCritical(), which means that threads williamr@2: subsequently created in the current thread's owning williamr@2: process (i.e. the current process) will no longer cause termination of that williamr@2: process or a reboot of the system. Note, however, that existing williamr@2: threads are NOT affected when you call this function. williamr@2: williamr@2: @see User::SetCritical() williamr@2: @see User::SetProcessCritical() williamr@2: */ williamr@2: ENotCritical, williamr@2: williamr@2: williamr@2: /** williamr@2: This value can only be passed to User::SetCritical() and williamr@2: affects the current thread only. williamr@2: williamr@2: It means that the owning process (i.e.the current process) williamr@2: terminates if: williamr@2: - the current thread is terminated. williamr@2: - the current thread panics. williamr@2: williamr@2: @see User::SetCritical() williamr@2: */ williamr@2: EProcessCritical, williamr@2: williamr@2: williamr@2: /** williamr@2: This value can only be passed to User::SetCritical() and williamr@2: affects the current thread only. williamr@2: williamr@2: It means that the owning process (i.e.the current process) williamr@2: terminates if the current thread terminates for any reason. williamr@2: williamr@2: @see User::SetCritical() williamr@2: */ williamr@2: EProcessPermanent, williamr@2: williamr@2: williamr@2: /** williamr@2: This value can only be passed to User::SetProcessCritical() and williamr@2: affects any new threads created in the current process. williamr@2: williamr@2: It means that the current process terminates if: williamr@2: - any new thread subsequently created in the current process is terminated. williamr@2: - any new thread subsequently created in the current process panics. williamr@2: . williamr@2: Note, however, that existing threads in the current process williamr@2: are NOT affected when you call User::SetProcessCritical() williamr@2: with this value. williamr@2: williamr@2: @see EProcessCritical williamr@2: @see User::SetProcessCritical() williamr@2: */ williamr@2: EAllThreadsCritical, williamr@2: williamr@2: williamr@2: /** williamr@2: This value can be passed to both: User::SetCritical() and williamr@2: User::SetProcessCritical(). williamr@2: williamr@2: When passed to User::SetCritical(), it means that williamr@2: the entire system is rebooted if: williamr@2: - the current thread is terminated. williamr@2: - the current thread panics. williamr@2: williamr@2: When passed to User::SetProcessCritical(), it means that williamr@2: the entire system is rebooted if: williamr@2: - any new thread subsequently created in the current process is terminated. williamr@2: - any new thread subsequently created in the current process panics. williamr@2: - the process itself is terminated williamr@2: - the process itself panics williamr@2: williamr@2: Note: williamr@2: -# existing threads in the current process are NOT affected when you williamr@2: call User::SetProcessCritical() with this value. williamr@2: -# Only a process with 'Protected Server' capability can set a williamr@2: thread to system-critical. williamr@2: williamr@2: @see User::SetCritical() williamr@2: @see User::SetProcessCritical() williamr@2: */ williamr@2: ESystemCritical, williamr@2: williamr@2: williamr@2: /** williamr@2: This value can be passed to both: User::SetCritical() williamr@2: and User::SetProcessCritical(). williamr@2: williamr@2: When passed to User::SetCritical(), it means that williamr@2: the entire system is rebooted if the current thread williamr@2: exits for any reason. williamr@2: williamr@2: When passed to User::SetProcessCritical(), it means that williamr@2: the entire system is rebooted if any new thread williamr@2: subsequently created in the current process exits williamr@2: for any reason, or if the process itself exits for any reason. williamr@2: williamr@2: Note: williamr@2: -# existing threads in the current process are NOT affected when you williamr@2: call User::SetProcessCritical() with this value. williamr@2: -# Only a process with 'Protected Server' capability can set a williamr@2: thread to system-permanent. williamr@2: williamr@2: @see User::SetCritical() williamr@2: @see User::SetProcessCritical() williamr@2: */ williamr@2: ESystemPermanent williamr@2: }; williamr@2: IMPORT_C static TCritical Critical(); williamr@2: IMPORT_C static TCritical Critical(RThread aThread); williamr@2: IMPORT_C static TInt SetCritical(TCritical aCritical); williamr@2: IMPORT_C static TCritical ProcessCritical(); williamr@2: IMPORT_C static TCritical ProcessCritical(RProcess aProcess); williamr@2: IMPORT_C static TInt SetProcessCritical(TCritical aCritical); williamr@2: IMPORT_C static TBool PriorityControl(); williamr@2: IMPORT_C static void SetPriorityControl(TBool aEnable); williamr@2: williamr@2: /** williamr@2: A threads realtime state. williamr@2: Some non-realtime behaviour can be detected by the kernel. When it does so, williamr@2: action is taken depending on the thread state: williamr@2: - ERealtimeStateOff - no action. williamr@2: - ERealtimeStateOn - the the thread will be panicked with KERN-EXEC 61 (EIllegalFunctionForRealtimeThread). williamr@2: - ERealtimeStateWarn - no action. However, if the kernel trace flag KREALTIME is enabled williamr@2: then tracing will be emitted as if the thread state was ERealtimeStateOn. williamr@2: @publishedPartner williamr@4: @released williamr@2: */ williamr@2: enum TRealtimeState williamr@2: { williamr@2: ERealtimeStateOff, /**< Thread is not realtime */ williamr@2: ERealtimeStateOn, /**< Thread is realtime */ williamr@2: ERealtimeStateWarn /**< Thread is realtime but doesn't want this enforced */ williamr@2: }; williamr@2: williamr@2: /** williamr@2: Set the current threads realtime state. williamr@2: @see TRealtimeState williamr@2: @param aState The state williamr@2: @return KErrNone if successful. KErrArgument if aState is invalid. williamr@2: @publishedPartner williamr@4: @released williamr@2: */ williamr@2: IMPORT_C static TInt SetRealtimeState(TRealtimeState aState); williamr@2: williamr@2: /** williamr@2: Return the Secure ID of the process that created the current process. williamr@2: @return The Secure ID. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C static TSecureId CreatorSecureId(); williamr@2: williamr@2: /** williamr@2: Return the Vendor ID of the process that created the current process. williamr@2: @return The Vendor ID. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: IMPORT_C static TVendorId CreatorVendorId(); williamr@2: williamr@2: /** williamr@2: Check if the process that created the current process 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 the creator process has the capability, EFalse otherwise. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline static TBool CreatorHasCapability(TCapability aCapability, const char* aDiagnostic=0); williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline static TBool CreatorHasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic=NULL); williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline static TBool CreatorHasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress); williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: /** williamr@2: Check if the process that created the current process 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 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 the creator process has both the capabilities, EFalse otherwise. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: inline static TBool CreatorHasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic=0); williamr@2: #else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: // Only available to NULL arguments williamr@2: inline static TBool CreatorHasCapability(TCapability aCapability1, TCapability aCapability2, OnlyCreateWithNull aDiagnostic=NULL); williamr@2: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: // For things using KSuppressPlatSecDiagnostic williamr@2: inline static TBool CreatorHasCapability(TCapability aCapability, TCapability aCapability2, OnlyCreateWithNull aDiagnostic, OnlyCreateWithNull aSuppress); williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ williamr@2: #endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ williamr@2: williamr@2: IMPORT_C static TInt ParameterLength(TInt aSlot); williamr@2: IMPORT_C static TInt GetTIntParameter(TInt aSlot, TInt& aData); williamr@2: IMPORT_C static TInt GetDesParameter(TInt aSlot, TDes8& aDes); williamr@2: IMPORT_C static TInt GetDesParameter(TInt aSlot, TDes16& aDes); williamr@2: IMPORT_C static TInt RenameThread(const TDesC &aName); williamr@2: IMPORT_C static TInt RenameProcess(const TDesC &aName); williamr@2: /* williamr@2: User::Identity() has been deprecated and is available for backward williamr@2: compatibility purposes only. williamr@2: williamr@2: Use RProcess().SecureId() instead. williamr@2: williamr@2: @deprecated williamr@2: */ williamr@2: inline static TUid Identity() { return RProcess().SecureId(); } williamr@2: williamr@2: /* williamr@2: User::CreatorIdentity() has been deprecated and is available for backward williamr@2: compatibility purposes only. williamr@2: williamr@2: Use CreatorSecureId() instead. williamr@2: williamr@2: @deprecated williamr@2: */ williamr@2: static inline TUid CreatorIdentity() { return CreatorSecureId(); } williamr@2: williamr@2: IMPORT_C static void NotifyOnIdle(TRequestStatus& aStatus); /**< @internalTechnology */ williamr@2: IMPORT_C static void CancelMiscNotifier(TRequestStatus& aStatus); /**< @internalTechnology */ williamr@2: private: williamr@2: // Implementations of functions with diagnostics williamr@2: IMPORT_C static TBool DoCreatorHasCapability(TCapability aCapability, const char* aDiagnostic); williamr@2: IMPORT_C static TBool DoCreatorHasCapability(TCapability aCapability); williamr@2: IMPORT_C static TBool DoCreatorHasCapability(TCapability aCapability1, TCapability aCapability2, const char* aDiagnostic); williamr@2: IMPORT_C static TBool DoCreatorHasCapability(TCapability aCapability1, TCapability aCapability2); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class ExecHandler; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: @removed williamr@2: */ williamr@2: typedef void (*TTlsCleanupHandler)(TAny*); //don't use williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A collection of static functions involved in managing access to williamr@2: thread-local storage. williamr@2: williamr@2: Thread-local storage is a single machine word of static writable memory. williamr@2: The scope of this machine word is the thread, which means that there is one williamr@2: word per thread. The word is only accessible to code running in a DLL. williamr@2: williamr@2: In practice, this word is almost always used to hold a pointer to allocated williamr@2: memory; this makes that memory available to all DLL code running on behalf williamr@2: of the same thread. williamr@2: williamr@2: Note that DLL code running on behalf of one thread does not see the same word when williamr@2: running on behalf of another thread. williamr@2: williamr@2: The class in not intended for user derivation. williamr@2: */ williamr@2: class Dll williamr@2: { williamr@2: public: williamr@2: static TInt SetTls(TAny* aPtr); williamr@2: static TAny* Tls(); williamr@2: static void FreeTls(); williamr@2: static void FileName(TFileName &aFileName); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __TOOLS__ williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: A thin wrapper class for C++ arrays allowing automatic checking of index values williamr@2: to ensure that all accesses are legal. williamr@2: williamr@2: The class also supports the deletion of objects. williamr@2: williamr@2: The class is templated, based on a class type and an integer value. The class williamr@2: type defines the type of object contained in the array; the integer value williamr@2: defines the size (dimension) of the array. williamr@2: williamr@2: A wrapper object can be: williamr@2: williamr@2: 1. embedded in objects allocated on the heap. williamr@2: williamr@2: 2. used on the program stack. williamr@2: */ williamr@2: template williamr@2: class TFixedArray williamr@2: { williamr@2: typedef TFixedArray ThisClass; williamr@2: public: williamr@2: inline TFixedArray(); williamr@2: inline TFixedArray(const T* aList, TInt aLength); williamr@2: // williamr@2: inline void Copy(const T* aList, TInt aLength); williamr@2: inline void Reset(); // zero fill williamr@2: inline void DeleteAll(); williamr@2: // williamr@2: inline TInt Count() const; williamr@2: inline TInt Length() const; williamr@2: // Accessors - debug range checking williamr@2: inline T& operator[](TInt aIndex); williamr@2: inline const T& operator[] (TInt aIndex) const; williamr@2: // Accessors - always range checking williamr@2: inline T& At(TInt aIndex); williamr@2: inline const T& At(TInt aIndex) const; williamr@2: // Provides pointers to the beginning and end of the array williamr@2: inline T* Begin(); williamr@2: inline T* End(); williamr@2: inline const T* Begin() const; williamr@2: inline const T* End() const; williamr@2: // williamr@2: inline TArray Array() const; williamr@2: protected: williamr@2: inline static TBool InRange(TInt aIndex); williamr@2: inline static TInt CountFunctionR(const CBase* aThis); williamr@2: inline static const TAny* AtFunctionR(const CBase* aThis,TInt aIndex); williamr@2: protected: williamr@2: T iRep[S]; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define DECLARE_ROM_ARRAY( AName, AData, AType ) \ williamr@2: const TFixedArray& \ williamr@2: AName = *(reinterpret_cast* > (AData)) williamr@2: #endif williamr@2: williamr@2: // Global leaving operator new williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: inline TAny* operator new(TUint aSize, TLeave); williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: inline TAny* operator new(TUint aSize, TLeave, TUint aExtraSize); williamr@2: #if !defined(__VC32__) || defined (__MSVCDOTNET__) williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: inline TAny* operator new[](TUint aSize, TLeave); williamr@2: #endif williamr@2: williamr@2: williamr@2: #ifdef __LEAVE_EQUALS_THROW__ williamr@2: /** Macro to assert in all builds that code does not leave williamr@2: williamr@2: @param _s C++ statements to be executed which should not leave williamr@2: @panic USER 194 if the code being checked does leave williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define __ASSERT_ALWAYS_NO_LEAVE(_s) \ williamr@2: { \ williamr@2: try { \ williamr@2: TTrapHandler* ____t = User::MarkCleanupStack(); \ williamr@2: _s; \ williamr@2: User::UnMarkCleanupStack(____t); \ williamr@2: } \ williamr@2: catch (XLeaveException& /*l*/) \ williamr@2: { \ williamr@2: User::PanicUnexpectedLeave(); \ williamr@2: } \ williamr@2: catch (...) \ williamr@2: { \ williamr@2: User::Invariant(); \ williamr@2: } \ williamr@2: } williamr@2: williamr@2: #else williamr@2: /** Macro to assert in all builds that code does not leave williamr@2: williamr@2: @param _s C++ statements to be executed which should not leave williamr@2: @panic USER 194 if the code being checked does leave williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define __ASSERT_ALWAYS_NO_LEAVE(_s) \ williamr@2: { \ williamr@2: TInt _r; \ williamr@2: TTrap _t; \ williamr@2: if (_t.Trap(_r) == 0) \ williamr@2: { \ williamr@2: _s; \ williamr@2: TTrap::UnTrap(); \ williamr@2: } \ williamr@2: else \ williamr@2: User::PanicUnexpectedLeave(); \ williamr@2: } williamr@2: #endif williamr@2: williamr@2: /** Macro to assert in debug builds that code does not leave williamr@2: williamr@2: @param _s C++ statements to be executed which should not leave williamr@2: @panic USER 194 if the code being checked does leave williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #ifdef _DEBUG williamr@2: #define __ASSERT_DEBUG_NO_LEAVE(_s) __ASSERT_ALWAYS_NO_LEAVE(_s) williamr@2: #else williamr@2: #define __ASSERT_DEBUG_NO_LEAVE(_s) { _s; } williamr@2: #endif williamr@2: williamr@2: williamr@2: williamr@2: // Inline methods williamr@2: #include williamr@2: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@2: #endif williamr@4: williamr@4: #endif williamr@4: