Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class User

User

Support

Supported from 5.0

Description

Set of static user functions. These functions are related to a number of System component APIs.

The majority of the functions are related to either the current thread, or its heap. Examples in this category include User::Exit(), which causes the thread to terminate, and User::Alloc(), which allocates memory from the current thread's heap.

Some of these functions are equivalent to functions in the RThread or RHeap classes. In these cases, the User function is a convenient way to access the function without first having to get a handle to the current thread.

Functions are also provided to support debugging of memory leaks. These function calls can be written explicitly or can be generated using a corresponding macro — the advantage of using a macro is that the function call is only generated for debug builds.

A final category of functions, which includes User::BinarySearch() and User::QuickSort(), are just useful functions which have no other natural home.

Derivation

UserSet of static user functions
UserHeapA set of static functions for constructing fixed length heaps and local or global heaps

Defined in User:
Abort(), Adjust(), AdjustL(), After(), Alloc(), AllocL(), AllocLC(), AllocLen(), AllocSize(), At(), Available(), Beep(), BinarySearch(), Check(), Collate(), CompressAllHeaps(), CountAllocCells(), Dying(), Exit(), Fold(), Free(), FreeLogicalDevice(), FreePhysicalDevice(), FreeZ(), HandleException(), Heap(), InactivityTime(), InfoPrint(), Invariant(), IsRomAddress(), JustInTime(), Language(), Leave(), LeaveIfError(), LeaveIfNull(), LeaveNoMemory(), LoadLogicalDevice(), LoadPhysicalDevice(), LockPeriod(), LockedDec(), LockedInc(), LowerCase(), Panic(), QueryVersionSupported(), QuickSort(), ReAlloc(), ReAllocL(), RequestComplete(), ResetInactivityTime(), SetCurrencySymbol(), SetHomeTime(), SetJustInTime(), SetTrapHandler(), StringLength(), SwitchHeap(), TickCount(), TitleCase(), TrapHandler(), UpperCase(), ValidateName(), Version(), WaitForAnyRequest(), WaitForRequest(), __DbgMarkCheck(), __DbgMarkEnd(), __DbgMarkStart(), __DbgSetAllocFail()

Inherited from UserHeap:
ChunkHeap(), FixedHeap()


Address information


IsRomAddress()

static TInt IsRomAddress(TBool& aBool,TAny* aPtr);

Description

Tests whether a specified address is in the ROM.

Parameters

TBool& aBool

True, if the address provided by aPtr is within the ROM. False, otherwise.

TAny* aPtr

The address to be tested.

Return value

TInt

Always KErrNone.

[Top]


Algorithms


BinarySearch()

static TInt BinarySearch(TInt aCount,const TKey& aKey,TInt& aPos);

Description

Performs a binary search for an array element containing a specified key. It can be used on any kind of array where elements can be identified by key. It is used by those standard EPOC arrays having CArrayFix, CArrayVar or CArrayPak in their class hierarchy in the implementation of the various functions for inserting, deleting and finding elements by key. The function can be used by other arrays.

The function returns a zero value if the search is successful and a non-zero value otherwise.

If the search is successful, the function puts the position (i.e. the index) of the element into aPos. If the search is unsuccessful, then the function puts into aPos the position of the first element in the array whose key is greater than the search key.

If the array is empty, i.e. aCount is zero, then the search is unsuccessful and aPos is not defined.

Parameters

TInt aCount

The number of elements in the array. If this value is negative, the function raises a USER 97 panic.

const TKey& aKey

A reference to a suitably initialised TKey derived object. In particular, the object will have been initialised with a pointer to a sample element containing the search key.

TInt& aPos

If the element is found, the reference is set to the position of that element within the array. The position is relative to zero, (i.e. the first element in the array is at position 0). If the element is not found and the array is not empty, then the reference is set to the position of the first element in the array with a key which is greater than the search key. If the element is not found and the array is empty, then the reference is undefined.

Return value

TInt

Zero, if the element with the specified key is found. Non-zero, if the element with the specified key is not found.


QuickSort()

static TInt QuickSort(TInt aCount,const TKey& aKey,const TSwap& aSwap);

Description

Quick sorts array elements. It is used by those standard EPOC arrays having CArrayFixBase, CArrayVarBase or CArrayPakBase in their class hierarchy in the implementation of their sort functions. The function can be used by other arrays.

The function returns KErrNone if the operation is successful otherwise it returns KErrGeneral.

Parameters

TInt aCount

The number of elements in the array. If this value is negative, the function raises a USER 96 panic.

const TKey& aKey

A reference to a suitably initialised TKey derived object.

const TSwap& aSwap

A reference to a suitably initialised TSwap derived object.

Return value

TInt

KErrNone if the operation is successful; KErrGeneral otherwise.

[Top]


Asynchronous service support


WaitForAnyRequest()

static void WaitForAnyRequest();

Description

Waits for any asynchronous request to complete. The current thread waits on its request semaphore.

The function completes and control returns to the caller when the current thread's request semaphore is signalled by any of the service providers which handle these asynchronous requests.

The request status of all outstanding asynchronous requests must be examined to determine which request is complete.

See also:


WaitForRequest()

static void WaitForRequest(TRequestStatus& aStatus);

Description

Waits for a specific asynchronous request to complete. The current thread waits on its request semaphore.

The function completes and control returns to the caller when the current thread's request semaphore is signalled by the service provider handling the request associated with aStatus. Before signalling, the service provider sets an appropriate value in aStatus — other than KRequestPending.

Note:

Parameters

TRequestStatus& aStatus

A reference to the request status object associated with the specific asynchronous request.


WaitForRequest()

static void WaitForRequest(TRequestStatus& aStatus1,TRequestStatus& aStatus2);

Description

Waits for either of two specific asynchronous requests to complete. The current thread waits on its request semaphore.

The function completes and control returns to the caller when the current thread's request semaphore is signalled by either the service provider handling the request associated with aStatus1 or the service provider handling the request associated with aStatus2. Before signalling, the completing service provider sets an appropriate value in the status object — other than KRequestPending.

Note:

Parameters

TRequestStatus& aStatus1

A reference to the request status object associated with the first specific asynchronous request.

TRequestStatus& aStatus2

A reference to the request status object associated with the second specific asynchronous request.


RequestComplete()

static void RequestComplete(TRequestStatus*& aStatus,TInt aReason);

Description

Signals the current thread that the asynchronous request associated with the specified request status object is complete.

This function is used to complete an asynchronous request originating in the same thread as the code that is currently executing. If a request originates in another thread, then executing code must use RThread::RequestComplete() to signal the completion of that request.

The request is completed with the completion code passed in aReason. This value is copied into the request status — pointed to by aStatus — before signalling the current thread's request semaphore.

The meaning of the completion code passed in aReason is a matter of convention to be decided between the service requester and the service provider.

Parameters

TRequestStatus*& aStatus

A reference to a pointer to the request status object. This is a pointer into the current thread's address space. On return, the pointer to the request status is set to NULL.

TInt aReason

The completion code of this request.

Notes:

[Top]


Beep


Beep()

static TInt Beep(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration);

Description

Makes a beep tone with a specified frequency and duration. The duration of the beep can be supplied as a positive or a negative value.

If the duration is passed as a positive value:

If the duration is passed as a negative value, the function completes immediately, whether or not the hardware responsible for producing the sound is busy. If the hardware is busy, no sound is produced.

Parameters

TInt aFrequency

The frequency at which the beep is to be sounded (hertz).

TTimeIntervalMicroSeconds32 aDuration

The duration for which the beep is to be sounded (microseconds). This value may be positive or negative.

Return value

TInt

KErrAccessDenied, if sound production is disabled. KErrGeneral, if the caller has supplied a negative value and the hardware is busy. KErrNone otherwise.

[Top]


Cleanup support


Leave()

static void Leave(TInt aReason);

Description

Leaves the currently executing function, unwinds the call stack, and returns from the most recently entered trap harness.

Parameters

TInt aReason

The value returned from the most recent call to TRAP or TRAPD. This is known as the reason code and, typically, it gives the reason for the environment or user error causing this leave to occur.

See also:


LeaveNoMemory()

static void LeaveNoMemory();

Description

Leaves with the specific reason code KErrNoMemory.


LeaveIfError()

static TInt LeaveIfError(TInt aReason);

Description

Leaves or returns with a specified reason code.

If the reason code is negative the function leaves, and the reason code is returned through the trap harness.

If the reason code is zero or positive, the function simply returns with the reason value.

Parameters

TInt aReason

The reason code.

Return value

TInt

If the function returns, the reason code which is either zero or positive.


LeaveIfNull()

static TAny* LeaveIfNull(TAny* aPtr);

Description

Leaves with the reason code KErrNoMemory, if the specified pointer is NULL. If the pointer is not NULL, the function simply returns with the value of the pointer.

Parameters

TAny* aPtr

The pointer to be tested.

Return value

TAny*

If the function returns, the value of aPtr.


SetTrapHandler()

static TTrapHandler* SetTrapHandler(TTrapHandler* aHandler);

Description

Sets the current thread's trap handler and returns a pointer to any pre-existing trap handler. Pass a NULL pointer to this function to clear the trap handler.

The trap handler works with the TRAP mechanism to handle the effects of a leave.

Note:

Parameters

TTrapHandler* aHandler

A pointer to the trap handler which is to be installed as the current thread's trap handler.

Return value

TTrapHandler*

A pointer to the current thread's pre-existing trap handler, if any. NULL, if no pre-existing trap handler is set.

See also:


TrapHandler()

static TTrapHandler* TrapHandler();

Description

Gets a pointer to the current thread's trap handler.

Note:

Return value

TTrapHandler*

A pointer to the current thread's trap handler, if any. NULL, if no pre-existing trap handler is set.

[Top]


Cobject name validation


ValidateName()

static TInt ValidateName(const TDesC& aName);

Description

Checks whether a specified name is a valid CObject name. A name is deemed to be invalid, if it contains any of the characters: "*", "?", ":" i.e. the characters: asterisk, question mark and single colon.

Parameters

const TDesC& aName

A reference to the descriptor containing the name to be checked.

Return value

TInt

KErrBadName, if the name is invalid. KErrNone, otherwise.

[Top]


C-style string length


StringLength()

static TInt StringLength(const TUint8* aString);

Description

Gets the length of a C style, null terminated, string of single-byte valued characters. The length does not include the null terminator.

Parameters

const TUint8* aString

A pointer to the single byte valued, null terminated, string.

Return value

TInt

The length of the string.


StringLength()

static TInt StringLength(const TUint16* aString);

Description

Gets the length of a C style, null terminated, string of double-byte valued characters. The length does not include the null terminator.

Parameters

const TUint16* aString

A pointer to the double-byte valued, null terminated, string.

Return value

TInt

The length of the string.

[Top]


Debugging support


SetJustInTime()

static void SetJustInTime(const TBool aBoolean);

Description

Sets just-in-time debugging on or off. While the function can be called by code running on both the Emulator and ARM platforms, it only has an effect on the Emulator. The function applies to the whole machine. Turning just-in-time debugging off prevents the debug Emulator closing down when a panic occurs.

By default, just-in-time debugging is on.

Note that the emulator handles panics in the nomal manner, i.e. by killing the thread.

Parameters

const TBool aBoolean

ETrue, if just-in-time debugging is to be set on. EFalse, if just-in-time debugging is to be set off. EFalse causes _asm 3 calls to be disabled.


JustInTime()

static TBool JustInTime();

Description

Tests whether just-in-time debugging is on or off. The function is used by the Kernel, on the EPOC Emulator, to decide whether to do just-in-time debugging for panics. The function applies to the whole machine.

Unless overridden by calling User::SetJustInTime(EFalse), just-in-time debugging is on by default.

Return value

TBool

True, if just-in-time debugging is on. False otherwise.


Check()

static void Check();

Description

Checks the validity of the current thread's heap. The function walks through the list of allocated cells and the list of free cells checking that the heap is consistent and complete.

If any corruption is found, the function raises either a USER 48 or a USER 49 panic.


Invariant()

static void Invariant();

Description

Panics the current thread with a USER 0 panic. Typically, this is called when a test for a class invariant fails, i.e. when a test which checks that the internal data of an object is self-consistent, fails.

Such tests are almost always done in debug builds, commonly using the __ASSERT_DEBUG macro.

See also:

[Top]


Device management


FreeLogicalDevice()

static TInt FreeLogicalDevice(const TDesC& aDeviceName);

Description

Frees the logical device driver DLL associated with a specified driver name.

Parameters

const TDesC& aDeviceName

The name of the logical device driver object. This must match the name set during installation of the logical device. Typically, this is done in an implementation of DLogicalDevice::Install() through a call to SetName(). Note that the name is rarely the same as the device's filename. The name of a logical device driver object can be discovered by using TFindLogicalDevice.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.

See also:


FreePhysicalDevice()

static TInt FreePhysicalDevice(const TDesC& aDriverName);

Description

Frees the physical device driver DLL associated with a specified driver name.

Parameters

const TDesC& aDriverName

The name of the physical device driver object. This must match the name set during installation of the physical device. Typically, this is done in an implementation of DPhysicalDevice::Install() through a call to SetName(). Note that the name is rarely the same as the device's filename. The name of a physical device driver object can be discovered by using TFindPhysicalDevice.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.

See also:


LoadLogicalDevice()

static TInt LoadLogicalDevice(const TDesC& aFileName);

Description

Loads the logical device driver (LDD) DLL with the specified filename.

The function searches the system path for the LDD DLL, and loads it. It then makes a Kernel server call that:

Parameters

const TDesC& aFileName

A reference to the descriptor containing the name of the physical device driver DLL. If the filename has no extension, .LDD is assumed by default.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.


LoadPhysicalDevice()

static TInt LoadPhysicalDevice(const TDesC& aFileName);

Description

Loads the physical device driver (PDD) DLL with the specified filename.

The function searches the system path for the PDD DLL, and loads it. It then makes a Kernel server call that:

Parameters

const TDesC& aFileName

A reference to the descriptor containing the name of the physical device driver DLL. If the filename has no extension, .PDD is assumed by default.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.

[Top]


Execution control


Abort()

static void Abort();

Support

Withdrawn in 6.0

Description

Raises an exception of type TExcType::EExcAbort on the current thread.

If the thread has an exception handler for this exception type, it is called to handle the exception, otherwise a USER-EXEC 3 panic is raised.


Dying()

static void Dying();

Support

Withdrawn in 6.0

Description

Thread called by the Kernel when any thread is terminated, panicked, aborted etc. For this reason, it is a good place for setting a breakpoint when debugging. The function has an empty implementation.


Exit()

static void Exit(TInt aReason);

Description

Terminates the current thread, specifying a reason. All child threads are terminated and all resources are cleaned up.

If the current thread is the main thread in a process, the process is also terminated.

Parameters

TInt aReason

The reason code.


Panic()

static void Panic(const TDesC& aCategory,TInt aReason);

Description

Panics the current thread, specifying a category name and panic number.

Keep the length of the category name small; a length of 16 is ideal.

Parameters

const TDesC& aCategory

A reference to the descriptor containing the text which defines the category for this panic.

TInt aReason

The panic number.


HandleException()

static void HandleException(TExceptionHandler* aHandler, TExcType anException);

Description

Enables the current thread to handle an exception of type TExcType.

The function is called by:

Parameters

TExceptionHandler* aHandler

A pointer to the exception handler function.

TExcType anException

The type of exception for which the exception handler is called.

[Top]


Heap debugging support


__DbgMarkStart()

static void __DbgMarkStart(RHeap::TDbgHeapType aHeapType);

Description

Marks the start of heap cell checking for the current thread's heap.

If earlier calls to __DbgMarkStart() have been made, then this call to __DbgMarkStart() marks the start of a new nested level of heap cell checking.

Every call to __DbgMarkStart() should be matched by a later call to __DbgMarkEnd() to verify that the number of heap cells allocated, at the current nested level, is as expected. This expected number of heap cells is passed to __DbgMarkEnd() as a parameter; however, the most common expected number is zero, reflecting the fact that most developers check that all memory allocated since a previous call to __DbgStartCheck() has been freed.

Notes:

Parameters

RHeap::TDbgHeapType aHeapType

An enumeration which indicates the type of heap for which checking is to be done.


__DbgMarkEnd()

static TUint32 __DbgMarkEnd(RHeap::TDbgHeapType aHeapType,TInt aCount);

Description

Marks the end of heap cell checking at the current nested level for the current thread's heap. The function checks that the number of heap cells allocated, at the current nested level, is aCount. The most common value for aCount is zero, reflecting the fact that most developers check that all memory allocated since a previous call to __DbgStartCheck() has been freed.

A call to this function should match an earlier call to __DbgMarkStart(). If there are more calls to this function than calls to __DbgMarkStart(), then this function raises a USER 51 panic.

If the check fails for a user heap, the function raises an ALLOC: nnnnnnnn panic, where nnnnnnnn is a hexadecimal pointer to the first orphaned heap cell.

If the check fails for the Kernel heap, the Kernel server raises a KERN-SVR 17 panic.

Notes:

Parameters

RHeap::TDbgHeapType aHeapType

An enumeration which indicates the type of heap for which checking is to be done.

TInt aCount

The number of allocated heap cells expected.

Return value

TUint32

A pointer to the first orphaned heap cell, if verification fails; zero otherwise.


__DbgMarkCheck()

static void __DbgMarkCheck(RHeap::TDbgHeapType aHeapType,TBool aCountAll,TInt aCount,const TDesC8& aFileName,TInt aLineNum);

Description

Checks the current number of allocated heap cells for the current thread's heap. If aCountAll is true, the function checks that the total number of allocated cells on the heap is the same as aCount. If aCountAll is false, the function checks that the number of allocated cells at the current nested level is the same as aCount.

If checking fails, the function raises a panic. Information about the failure is put into the panic category, which takes the form:

ALLOC COUNT\rExpected aaa\rAllocated bbb\rLn: ccc ddd

Where aaa is the value aCount, bbb is the number of allocated heap cells, ccc is a line number, copied from aLineNum, and ddd is a file name, copied from the descriptor aFileName.

Notes:

Parameters

RHeap::TDbgHeapType aHeapType

An enumeration which indicates the type of heap for which checking is to be done.

TBool aCountAll

If true, the function checks that the total number of allocated cells on the heap is the same as aCount. If false, the function checks that the number of allocated cells at the current nested level is the same as aCount.

TInt aCount

The expected number of allocated cells.

const TDesC8& aFileName

A filename; this is displayed as part of the panic category, if the check fails.

TInt aLineNum

A line number; this is displayed as part of the panic category, if the check fails.


__DbgSetAllocFail()

static void __DbgSetAllocFail(RHeap::TDbgHeapType aHeapType,RHeap::TAllocFail aType,TInt aRate);

Description

Simulates a heap allocation failure for the current thread's heap. The failure occurs on subsequent calls to new or any of the functions which allocate memory from the heap.

The timing of the allocation failure depends on the type of allocation failure requested, i.e. on the value of aType.

The simulation of heap allocation failure is cancelled if aType is given the value RHeap::ENone.

Notes:

Parameters

RHeap::TDbgHeapType aHeapType

An enumeration which indicates the type of heap for which checking is to be done.

RHeap::TAllocFail aType

An enumeration which indicates how to simulate heap allocation failure.

TInt aRate

The rate of failure; when aType is RHeap::EDeterministic, heap allocation fails every aRate attempt

[Top]


Language-dependent character functions


Language()

static TLanguage Language();

Description

Returns the language of the current locale.

Return value

TLanguage

A TLanguage enumerator identifying the language of the current locale.


Collate()

static TUint Collate(TUint aChar);

Description

Converts the character to its collated form.

Collating is the process of removing differences between characters that are deemed unimportant for the purposes of ordering characters. The result of the conversion depends on the locale and on whether this is a UNICODE build or not.

Note:

Parameters

TUint aChar

The character to be folded.

Return value

TUint

The converted character.


Fold()

static TUint Fold(TUint aChar);

Description

Folds the specified character. Folding converts the character to a form which can be used in tolerant comparisons without control over the operations performed. Tolerant comparisons are those which ignore character differences like case and accents.

The result of folding a character depends on the locale and on whether this is a UNICODE build or not.

Note:

Parameters

TUint aChar

The character to be folded.

Return value

TUint

The folded character.

See also:


Fold()

static TUint Fold(TUint aChar,TInt aFlags);

Description

Folds the character according to a specified folding method.

In ER5, this function is only defined for UNICODE builds.

Parameters

TUint aChar

The character to be folded.

TInt aFlags

A set of flags defining the folding method. They are:TChar::EFoldCase, convert characters to their lower case form if any TChar::EFoldAccents, strip accents TChar::EFoldDigits, convert digits representing values 0..9 to characters '0'..'9' TChar::EFoldSpaces, convert all spaces (ordinary, fixed-width, ideographic, etc.) to ' ' TChar::EFoldKana, convert hiragana to katakana TChar::EFoldWidth, fold full width and half width variants to their standard forms TChar::EFoldAll, use all of the above folding methods.

Return value

TUint

The folded character.

See also:


LowerCase()

static TUint LowerCase(TUint aChar);

Description

Converts the specified character to lower case. The result of the conversion depends on the locale and on whether this is a UNICODE build or not.

Note:

Parameters

TUint aChar

The character to be converted to lower case.

Return value

TUint

The lower case character.


UpperCase()

static TUint UpperCase(TUint aChar);

Description

Converts a specified character to upper case. The result of the conversion depends on the locale and on whether this is a UNICODE build or not.

Note:

Parameters

TUint aChar

The character to be converted to upper case.

Return value

TUint

The upper case character.


TitleCase()

static TUint TitleCase(TUint aChar);

Description

Converts a specified character to its title case version.

In ER5, this function is only defined for UNICODE builds.

Parameters

TUint aChar

The character to be converted.

Return value

TUint

The converted character.

[Top]


Locked incrementer and decrementer


LockedInc()

static TInt LockedInc(TInt& aValue);

Description

Increments a TInt value by 1 when the current thread is locked.

The increment to aValue is done while the current thread is locked; i.e. no other thread is permitted to run until the sequence of instructions which increment aValue have completed. Hence the function gives controlled access to a TInt variable which may be in a memory location accessible to more than one thread.

Notes:

Parameters

TInt& aValue

A reference to an integer whose value is to be incremented. On return contains the incremented value.

Return value

TInt

The value of aValue before it is incremented.


LockedDec()

static TInt LockedDec(TInt& aValue);

Description

Decrements a TInt value by 1 when the current thread is locked.

The decrement from aValue is done while the current thread is locked; i.e. no other thread is permitted to run until the sequence of instructions which decrement aValue have completed. Hence the function gives controlled access to a TInt variable which may be in a memory location accessible to more than one thread.

Notes:

Parameters

TInt& aValue

A reference to TInt whose value is to be decremented. On return contains the decremented value.

Return value

TInt

The value of aValue before it is decremented.

[Top]


Notification service


InfoPrint()

static TInt InfoPrint(const TDesC& aDes);

Description

Invokes the notify server to display a text message on the screen for a short time.

Parameters

const TDesC& aDes

A reference to the descriptor containing the text to be sent to the notifier server.

Return value

TInt

KErrNone if successful — otherwise one of the system-wide error codes.

See also:

[Top]


Set time


SetHomeTime()

static TInt SetHomeTime(const TTime& aTime);

Description

Sets the machine's home time to a specified time value.

Parameters

const TTime& aTime

A reference to a time representation object containing the time value.

Return value

TInt

KErrNone if successful or one of the system-wide error codes.

[Top]


Synchronous timer services


After()

static void After(TTimeIntervalMicroSeconds32 anInterval);

Description

Suspends the current thread until a specified time interval has expired.

Parameters

TTimeIntervalMicroSeconds32 anInterval

The time interval for which the current thread is to be suspended (microseconds).


At()

static TInt At(const TTime& aTime);

Description

Suspends the current thread until the specified absolute time. If the machine is off at that time, the machine will be turned on again.

Parameters

const TTime& aTime

The absolute time until which the current thread is to be suspended.

Return value

TInt

On completion, contains the status of the request to suspend the current thread: KErrNone - suspension of the current thread completed normally at the requested time. KErrAbort - suspension of the current thread was aborted because the system time changed. KErrUnderflow - the requested completion time is in the past. KErrOverFlow - the requested completion time is too far in the future.

[Top]


System wide locale


SetCurrencySymbol()

static void SetCurrencySymbol(const TDesC& aSymbol);

Description

Sets the system wide currency symbol.

Note:

Parameters

const TDesC& aSymbol

A reference to the descriptor containing the currency symbol to be set. The length of the descriptor aSymbol cannot be greater than KMaxCurrencySymbol otherwise a USER 119 panic is raised.

See also:

[Top]


Inactivity timing


InactivityTime()

TTimeIntervalSeconds InactivityTime();

Support

Supported from 6.0

Description

Returns the time since the last user activity.

Return value

TTimeIntervalSeconds

The time interval.


ResetInactivityTime()

void ResetInactivityTime();

Support

Supported from 6.0

Description

Resets all user inactivity timers.

[Top]


Timing


TickCount()

static TUint TickCount();

Description

Returns the machine's current tick count.

The period between ticks is platform dependent.

Return value

TUint

The machine dependent tick count.


LockPeriod()

static TTimerLockSpec LockPeriod();

Description

Returns which of the periods the clock is currently in.

Return value

TTimerLockSpec

The fraction of a second at which the timer completes.

[Top]


User heap management


Heap()

static RHeap& Heap();

Description

Returns a reference to the handle to the current thread's heap.

Return value

RHeap&

A reference to the handle to the current thread's heap.


SwitchHeap()

static RHeap* SwitchHeap(RHeap* aHeap);

Description

Changes the current thread's heap.

Parameters

RHeap* aHeap

A pointer to the new heap handle.

Return value

RHeap*

A pointer to the old heap handle.


Alloc()

static TAny* Alloc(TInt aSize);

Description

Allocates a cell of specified size from the current thread's heap. If there is insufficient memory available on the heap from which to allocate a cell of the required size the function returns NULL.

Note:

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's heap.

Return value

TAny*

A pointer to the allocated cell. NULL, if there is insufficient memory available.


AllocL()

static TAny* AllocL(TInt aSize);

Description

Allocates a cell of specified size from the current thread's heap and leaves if there is insufficient memory in the heap.

Notes:

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's heap.

Return value

TAny*

A pointer to the allocated cell.


AllocLC()

static TAny* AllocLC(TInt aSize);

Description

Allocates a cell of specified size from the current thread's heap, and if successful places a pointer to the cell on the cleanup stack. The function leaves if there is insufficient memory in the heap.

Notes:

Parameters

TInt aSize

The size of the cell to be allocated from the current thread's heap.

Return value

TAny*

A pointer to the allocated cell.


Adjust()

static TAny* Adjust(TAny* aCell,TInt anOffset,TInt aDelta);

Description

Stretches or shrinks an existing cell by a specified amount at a specified offset from the start of the cell.

If successful, the function returns a pointer to the adjusted cell. The adjusted cell may be at a different location from the original cell, i.e. the returned pointer may be different to the value of aCell. If adjustment fails, the content of the original cell is preserved.

Shrinking of the cell occurs when aDelta is negative and means the removal of (the magnitude of) aDelta bytes from the cell, starting at offset anOffset from the start of the cell.

Stretching a cell occurs when aDelta is positive and means the insertion of aDelta bytes into the cell at offset anOffset from the start of the cell and copying the original content of the cell at offset anOffset to offset anOffset+aDelta.

If necessary, the cell is reallocated. If there is insufficient memory available in the heap from which to reallocate the cell to the required size the function returns NULL.

Note:

Parameters

TAny* aCell

A pointer to the cell to be adjusted. This cannot be NULL.

TInt anOffset

The offset from the start of the cell where adjustment is to be made. The value of must not be negative, otherwise the functions raises a USER 52 panic

TInt aDelta

The amount by which the cell is to be stretched, if positive, or shrunk, if negative. The value may be zero, but this does not result in any change to the allocated cell.

Return value

TAny*

A pointer to the adjusted cell.NULL if there is insufficient memory available.


AdjustL()

static TAny* AdjustL(TAny* aCell,TInt anOffset,TInt aDelta);

Description

Stretches or shrinks an existing cell by a specified amount at a specified offset from the start of the cell and leaves if there is insufficient memory in the heap to adjust or reallocate the cell.

If successful, the function returns a pointer to the adjusted cell. The returned pointer may be different to the value of aCell since the cell is re-allocated if there is insufficient room for adjustment at the current cell position. If adjustment fails, the content of the original cell is preserved.

Shrinking of the cell occurs when aDelta is negative and means the removal of (the magnitude of) aDelta bytes from the cell, starting at offset anOffset from the start of the cell.

Stretching a cell occurs when aDelta is positive and means the insertion of aDelta bytes into the cell at offset anOffset from the start of the cell and copying the original content of the cell at offset anOffset to offset anOffset+aDelta.

Note:

Parameters

TAny* aCell

A pointer to the cell to be adjusted. This cannot be NULL.

TInt anOffset

The offset from the start of the cell where adjustment is to be made. The value of must not be negative, otherwise the functions raises a USER 52 panic

TInt aDelta

The amount by which the cell is to be stretched, if positive, or shrunk, if negative. The value may be zero, but this does not result in any change to the allocated cell.

Return value

TAny*

A pointer to the adjusted cell.


AllocLen()

static TInt AllocLen(const TAny* aCell);

Description

Returns the length of the specified allocated heap cell. The cell is assumed to be in the current thread’s heap.

Parameters

const TAny* aCell

A pointer to the allocated cell whose length is to be fetched.

Return value

TInt

The length of the allocated cell.


AllocSize()

static TInt AllocSize(TInt& aTotalAllocSize);

Description

Returns the total number of cells allocated on the current thread’s heap and the total space allocated to them.

Parameters

TInt& aTotalAllocSize

On return, this reference contains the total space allocated to the cells.

Return value

TInt

The number of cells currently allocated on the current thread's heap.


Available()

static TInt Available(TInt& aBiggestBlock);

Description

Returns the total free space currently available on the current thread's heap and the space available in the largest free block.

The space available represents the total space which can be allocated.

Note:

Parameters

TInt& aBiggestBlock

On return, this reference contains the space available in the largest free block on the current thread’s heap.

Return value

TInt

The total free space currently available on the current thread's heap.


CountAllocCells()

static TInt CountAllocCells();

Description

Returns the total number of cells allocated on the current thread's heap.

If the TInt& argument is passed, then, on return, aFreeCount contains the number of free cells on the heap.

Return value

TInt

The number of cells allocated on the current thread’s heap


CountAllocCells()

static TInt CountAllocCells(TInt& aFreeCount);

Description

Returns the total number of cells allocated, and the number of free cells, on the current thread's heap.

Parameters

TInt& aFreeCount

On return, this reference contains the number of free cells on the current thread's heap.

Return value

TInt

The number of cells allocated on the current thread's heap


Free()

static void Free(TAny* aCell);

Description

Frees a specified cell and returns it to the current thread's heap.

If aCell is not NULL, it must point to a valid cell, otherwise the function raises a USER 42 panic.

Parameters

TAny* aCell

A pointer to a valid cell to be freed. If NULL this function call will be ignored.


FreeZ()

static void FreeZ(TAny*& aCell);

Description

Frees a specified cell, returns it to the current thread's heap, and resets the pointer to NULL.

If aCell is not NULL, it must point to a valid cell, otherwise the function raises a USER 42 panic.

Parameters

TAny*& aCell

A reference to a pointer to a valid cell to be freed. If NULL this function call will be ignored.


ReAlloc()

static TAny* ReAlloc(TAny* aCell,TInt aSize);

Description

Increases or decreases the size of an existing cell. If there is insufficient memory available in the heap from which to reallocate the cell to the required size the function returns NULL.

If successful, the functions return a pointer to the reallocated cell. The reallocated cell may be at a different location from the original cell, i.e. the returned pointer may be different to the value of aCell. However, if the cell is smaller than the original, it is guaranteed not to move.

If the location of the new cell is different to that of the original cell, the content of the original cell is copied to the reallocated cell.

If reallocation fails, the content of the original cell is preserved.

Notes:

Parameters

TAny* aCell

A pointer to the cell to be reallocated. This may be NULL, in which case the function allocates a new cell from the heap and its behaviour is the same as Alloc(). If it is not NULL, it must point to a valid cell, otherwise the function raises a USER 42 panic.

TInt aSize

The new size of the cell. This value must not be negative, otherwise the functions raise a USER 54 panic.

Return value

TAny*

A pointer to the reallocated cell.NULL if there is insufficient memory available.


ReAllocL()

static TAny* ReAllocL(TAny* aCell,TInt aSize);

Description

Increases or decreases the size of an existing cell and leaves if there is insufficient memory available in the heap from which to reallocate the cell to the required size.

If successful, the functions return a pointer to the reallocated cell. The reallocated cell may be at a different location from the original cell, i.e. the returned pointer may be different to the value of aCell. However, if the cell is smaller than the original, it is guaranteed not to move.

If the location of the new cell is different to that of the original cell, the content of the original cell is copied to the reallocated cell.

If reallocation fails, the content of the original cell is preserved.

Notes:

Parameters

TAny* aCell

A pointer to the cell to be reallocated. This may be NULL, in which case the function allocates a new cell from the heap and its behaviour is the same as Alloc(). If it is not NULL, it must point to a valid cell, otherwise the function raises a USER 42 panic.

TInt aSize

The new size of the cell. This value must not be negative, otherwise the functions raise a USER 54 panic.

Return value

TAny*

A pointer to the reallocated cell.


CompressAllHeaps()

static TInt CompressAllHeaps();

Description

Compresses all the chunks containing heaps

Return value

TInt

KErrNone, if successful, otherwise one of the other system-wide codes.

[Top]


Version information and comparisons


QueryVersionSupported()

static TBool QueryVersionSupported(const TVersion& aCurrent,const TVersion& aRequested);

Description

Compares two version objects and returns a true if the test version is less than the current version. Version information is encapsulated by a TVersion type object and consists of a major version number, a minor version number and a build number.

The function returns true if one of the following conditions is true:

If neither condition is true, the function returns false.

Parameters

const TVersion& aCurrent

A reference to the current version against which aRequestedis compared.

const TVersion& aRequested

A reference to the test version to be compared against aCurrent.

Return value

TBool

True, if one or both conditions are true. False otherwise.


Version()

static TVersion Version();

Description

Gets the version of the operating system.

Return value

TVersion

The version of the operating system.