Symbian string operation

xiaoxiao2021-03-06  102

Excerpt from the Internet:

In the Symbian system, there is no well-known type and function to process strings and binary buffers, which may be a bit unfamiliar for beginners. A lot of programming people spend a lot of time in the process of exploring TBUF, TBUFC, and HBUFC ... :)

Descriptor in Symbian (Descriptors) mainly has the following characteristics: 1, to treat strings and binary data in the same manner. 2, data can be stored on any area of ​​memory --ROM or RAM, can be on the stack or stack. 3. Descriptor uses pointers and length information to describe the data it contains, and some descriptors also include the maximum length of information.

The figure below shows the inheritance relationship of the descriptor-related class:

All descriptors are derived from abstract class TDESC, they can be divided into three large categories: 1, buffer descriptor - data is existed as part of the descriptor object, the descriptor object is placed in the program In the stack: TBUF and TBUFC, 2, Heap Descriptor - Data As part of the descriptor object, the descriptor object is stored in the heap: HBUFC, 3, pointer descriptor - descriptor object and it The actual data is stored separately: TPTR and TPTRC.

If the control C / C syntax is coming: 1, TPTRC can be seen as use of const char * 2, TBUFC can be seen as char []

Other classes do not have a corresponding comparison statement.

The following shows how the data in each class is organized:

TDES and TDESC are abstract classes, so you can't instantiate them. Their main use is to do parameters of functions to describe strings and binary data. In such a function, you should use the following rules: 1. Const TDesc & Represents read-only data and strings. 2, TDES & indicates the data and strings that can be modified.

All of these descriptors can specify data scales: TDES8, TDES16, TDESC8, TDESC16, TBUF8, TBUF16, etc. 8 indicating that the descriptor processing is 8bit, and 16 is 16 bit data. In general, you only need to use a general form (TDES, TDESC, ...) to represent the text data to represent binary content using the 8Bit version (TDESC8, etc.).

Litterals -------------- String constant can be defined using _l () or _lit () macro.

_L () can generate an address (TPTRC) that points to the character value, which is often used to deliver string to function: NeikonEnvironment :: MessageBox (_l ("error: init file not found!"))

_LIT () can generate a constant name for reuse in later: _LIT (Kmyfile, "C: /System/apps/myapp/myfile.jpg");

_Lit () macro's result (that is, the Kmyfile) is actually a literal descriptor (LITERAL DESCRIPTOR) TLITC, which can be used in any TDESC & place.

Usage --------- TDESC is the most commonly used function as follows: 1, PTR (), used to get pointers in the descriptor data. 2, length (), used to get the number of characters in the descriptor data. 3, size (), used to get the number of bytes in the descriptor data. 4, cpmpare () or operator ==,! =,> = And <= or the like for comparison descriptor data. 5, operator [], can be used as in C / C , used to obtain a single character in the descriptor string.

The following functions have specializies: 1. Append () and Num () have many overloaded forms, specific to SDK2, Compare () has 2 variants: Comparec () and Comparef (), and copy () , Find (), locate () and match () (), these functions have the form of C / F, C represents collated and f represents folded.colilating and folding ------------- --------- Folding is a simple way to format the text, mainly used in comparison not too accurate.

COLLATION is a better way to compare strings, which can generate a sequence similar to a dictionary.

转载请注明原文地址:https://www.9cbs.com/read-124354.html

New Post(0)