The following table summarizes the methods to set and get a Runtime::Value:
| m type | C++ type | Getter | Setter/Creator |
| Number | TReal | GetNumberL() | SetNumber() |
| Number | TInt | GetIntL() | SetNumber() |
| Number | TTime | GetTimeL() | SetTime() |
| Number | TTimeIntervalMicroSeconds32 | GetTimeoutL() | SetTimeout() |
| Number | TUid | GetUidL() | |
| Boolean | TBool | GetBooleanL() | SetBoolean() |
| String | Runtime::String | GetStringL() | NewStringL() |
| String | TPtrC | GetPtrCL() | |
| Array | Runtime::Array | GetArrayL() | NewArrayL() |
| null | IsNull() | SetNull() | |
For most datatypes, there are also constructors or equivalent static methods, e.g. Runtime::BooleanValue.
The getters all leave if the type of the value is not the requested one. You can use IsNumber(), IsString() etc. to check for the type of a value.
GetTimeoutL() and SetTimeout() convert a millisecond number to a microsecond timeout value and vice versa. GetTimeoutL() also checks for the number not exceeding 231-1 microseconds (2147483 milliseconds).
GetUidL() correctly handles the signed/unsigned problems caused by Symbian's inconsistent definition of the TUid type: numbers in the ranges 0x80000000 to 0xffffffff and -0x7fffffff to -1 are both mapped to the correct TUid instance.
|
// count this call Runtime::Value &calls = runtime->GetVariableL(WORLD, CALLS); calls.SetNumber(calls.GetNumberL() + 1); switch (index) { case CountFunction: // directly set the result result.SetNumber(server.NumberCities()); break; |
Furthermore, even though we don't know yet how to create the m array containing a city's data, we can declare the following function whic