This article focuses on the customization and parsing of Symbian resources in Symbian development. There are many things worth learning about in Symbian development. I will share with you here, I believe that you will have a clear understanding of the concept of Symbian development through the study in this article.
Custom and parsing of Symbian resources in Symbian Development
In the system CCoeEnv, there is an AllocReadResourceAsDes16LC function that reads resource files into the array. In the previous project, there are many String constant arrays. I just want to define resources by myself, then I read it. It's really hard to find a piece of broken information on the Internet. I have a little free time today. I tested it and can customize it, read it, and record it.
Data types defined by Symbian Resources
Field Type
BYTE
A single byte, interpreted as a signed or unsigned integer.
WORD
Double Byte, interpreted as a signed or unsigned integer
LONG
Four bytes, interpreted as a signed or unsigned integer
DOUBLE
Double-precision floating point number.
TEXT
The string ending with NULL is obsolete. We recommend that you use LTEXT
LTEXT
Unicode string with a length of leading bytes, without terminating NULL
BUF
Unicode string, no leading bytes, no termination NULL
BUF8
A string consisting of 8 characters without leading or terminating data. It is used to put 8-bit data.
BUF <n>
Unicode string with a maximum length of n without leading or terminating
LINK
The 16-bit ID of another resource, similar to a reference with a specified resource
LLINK
32-bit ID of another resource
SRLINK
Self-referenced LINK. The value of this type of field is automatically allocated by the resource compiler and cannot be provided by the resource compiler. It is a 32-bit ID.
STRUCT
Structure, which is the field of STRUCT. It can be used to embed STRUCT into STRUCT.
◆ Use these types to define your own custom resources for Symbian development. You can go to the rh file of the system to view and analyze the resources defined by the operating system.
Below are the resources I wrote in rss
- STRUCTDATA
- {
- WORDwrd;
- LONGlng;
- LTEXTltxt;//variablelength
- BYTEbyt;
- DOUBLEdbl;
- }
-
- STRUCTDATAARRAY
- {
- STRUCTdataelement[];
- }
-
- STRUCTMYCUSTOM
- {
- WORDwrd;
- LONGlng;
- LLINKdatas;
- }
-
-
- //
- //-----
-
- RESOURCEDATAARRAYr_data_array
- {
- dataelement=
- {
- DATA
- {
- wrd=11;
- lng=22;
- ltxt="data1";
- byt=1;
- dbl=2.11;
- },
- DATA
- {
- wrd=33;
- lng=44;
- ltxt="data2";
- byt=2;
- dbl=3.11;
- },
- DATA
- {
- wrd=55;
- lng=66;
- ltxt="data3";
- byt=3;
- dbl=4.11;
- }
- };
- }
-
- RESOURCEMYCUSTOMr_mycustom_data
- {
- wrd=10;
- lng=1000;
- datas=r_data_array;
- }
-
Read the above self-written resources in cpp
- HBufC8 * resource = CCoeEnv: Static ()-> AllocReadResourceAsDes8LC (R_MYCUSTOM_DATA );
- TResourceReaderreader;
- Reader. SetBuffer (resource );
- TInta = reader. ReadInt16 ();
- TIntb = reader. ReadInt32 ();
- TIntres = reader. ReadInt32 ();
- HBufC8 * res1 = CCoeEnv: Static ()-> AllocReadResourceAsDes8LC (res); // The resource address for transferring to LLINK
- Reader. SetBuffer (res1 );
-
- TIntcount = reader. ReadInt16 (); // The array uses the first two bytes to identify the array length.
- For (TInti = 0; I <count; I ++)
- {
- TIntwrd = reader. ReadInt16 ();
- TIntlng = reader. ReadInt32 ();
- TPtrCptr = reader. ReadTPtrC ();
- TIntbte = reader. ReadUint8 ();
- TRealdbl = reader. ReadReal64 ();
- }
- CleanupStack: PopAndDestroy (2 );