Tutorials to .com

Tutorials to .com » Os » Mobile » Symbian basic norms: descriptor

Symbian basic norms: descriptor

Print View , by: iSee ,Total views: 10 ,Word Count: 707 ,Date: Mon, 8 Jun 2009 Time: 12:29 PM

Summary of descriptors in Symbian os is the basic things, but also relatively non-object-oriented (non-OO) and object-oriented (OO) design an excellent example. String in the c language is like the following: char * hello = "hello";

The above statement so that the memory settings so that it contains a number of 'h', 'e', 'l', 'l', 'o', '/ 0'6 characters. strlen () function from the beginning until the byte of memory to scan space character ( '/ 0') at the end. If you want to extend the string, you need to know to how much memory it allocated.

Abstract descriptor expressed through two abstract class of the basic needs of the string: TDesC and TDes. TDesC is a constant that can not be modified or descriptor, which contains the address and length information. In the following cases, you can use this class: the need to do a lot of data but it does not need to change its operations, it provides many TDesC data without modifying the function. Can be modified TDes descriptor, which contains the maximum length of the other information, it allows data to expand or reduce (do not exceed the maximum length), therefore, TDes provide many of the function can modify the data. Descriptor is to amend the basic characteristics of the operation have been allocated can not exceed the length, but there are some type of permit to do so, for example, CBufBase and its derived class. If a trigger function TDes will have a system error overflow (panic). TDes because TDesC and includes access to all the functions needed to operate the data string and memory functions, many only need to access the data using the function as const TDesC & parameter, those who need to modify the data as a function of the parameters used TDes &. Abstract descriptor pointer descriptor to achieve a variety of categories, which is the simplest descriptor pointer. TPtrC contains only the length and address information: it needs words to express the two machines. TPtrC can be set to any existing data. TPtr an increase of the maximum length of information, so it can be used to express the distribution of those who have not fully buffer (buffer). TPtrC and TPtr with C++ language somewhat similar to the char *, but because the descriptor contains the length of their information, so no longer need to scan at the end of the space character ( '/ 0') or the allocation of space for it. Buffer descriptor

TBufC buffer descriptor TBuf the data and is part of their own, just like C language array of characters (char []).

This descriptor to use C + + template mechanism, through an integer parameter that the buffer length.

Heap descriptor

HbufC heap descriptor containing the data is stored in the heap.

This is like C language (char *) malloc (length +1) can not be the same as used in pre-determined length. Because it is allocated in the heap, it is always through the use of HBufC * rather than directly HBufC object definition.

Type descriptor

Elegant use of object-oriented. TBufCBase only to consider the convenience of the achievement, this is often object-oriented habits (although it needs to be careful with the use). Descriptor that allows a simple serial data change. When the descriptor for the string should be used TDes (TDesC, TBuf ...) and so on, as compiled in Unicode, these categories through the typedef is defined as TDes16 (TDesC16, TBuf16 ...) and so on.

Because the descriptor can contain any data, including the null character, so it can be used to reference data and common byte buffer. 8 needed data (no matter what the conditions of the compiler, the compiler may be the conditions of Unicode), you should always TDes8 the form of direct access.


Mobile OS Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.