Basic Types

The basic types used throughout Symbian OS are shown in Table 3-1. They are mainly defined in the system include file e32defs.h (which is often #include d implicitly, as part of e32base.h ), and they all have a T -class interface, so they do not require complex construction or explicit destructors. Many of them are actually implemented as compiler-specific typedef s of standard C++ types, providing guaranteed platform independence. Some are implemented as actual simple C++ classes. Note that the Symbian OS types should always be used in preference to built-in C++ types. For example, you should always use TInt instead of int .

Note that the implementation of TBool seems very wasteful , considering that 32 bits are used to store one of two possible values. There are several reasons for this, including:

  • Ease of passing as an argument, since individual bits cannot be passed.

  • Lack of ratified native boolean type when Symbian OS was developed.

  • Necessity of a direct mapping onto int for use in conditional expressions.

However, note that you should never compare a TBool directly to Etrue , as any nonzero value is also considered "true." For example:

 TInt b = 2; if (b == ETrue)    {    // This statement is "false"!    } if (b) // Will return "true" as required.    {    // Use this form instead.    } 

Similarly, you should not compare TBool values to EFalse ”even though the code will work, it is inefficient and inconsistent. Instead use the following form:

 if (!b)    {    // b is "false".    } 

If your class uses a lot of Boolean attributes, and if minimum memory usage is a goal, then you might consider using bit packing. However, this is beyond the scope of this book.

Table 3-1. The Basic Types in Symbian OS

Name

Type

Size (bytes)

Comments

TInt

Integer

At least 4

Signed and unsigned integers, guaranteed to give at least 32 bits of precision, independent of the compiler.

TUInt

Integer

At least 4

TInt64

Integer

8

64-bit integer, implemented as two 32-bit integers.

TInt8

Integer

1

Explicitly sized signed integers.

TInt16

Integer

2

TInt32

Integer

4

TUInt8

Integer

1

Explicitly sized unsigned integers.

TUInt16

Integer

2

TUInt32

Integer

4

TReal

Floating point

8

Double-precision floating-point value.

treal32

Floating point

4

Explicitly sized floating-point values.

treal64

Floating point

8

TRealX

Floating point

12

Extended-precision floating-point values, with a dynamic range from as small as ~ ±1 x 10 -9863 to as large as ~ ±1 x 10 9863 .

TText8

Character

1

Unsigned char for narrow (8-bit) character storage.

TText

Character

2

Unsigned short int for Unicode character storage. Note these cannot be used for storing characters in the extended Unicode range.

TText16

Character

2

TChar

Character

4

A 32-bit character that can be used for storing extended Unicode characters. Used in a host of character- related helper functions.

TBool

Boolean

4

Enumerated values of ETRue and EFalse are defined, but naturally any nonzero value is considered true.

TAny

Void

N/A

Used exclusively as TAny * ( implying a pointer to anything ), which is more meaningful than void * (implying a pointer to nothing ).




Developing Series 60 Applications. A Guide for Symbian OS C++ Developers
Developing Series 60 Applications: A Guide for Symbian OS C++ Developers: A Guide for Symbian OS C++ Developers
ISBN: 0321227220
EAN: 2147483647
Year: 2003
Pages: 139

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net