Custom and parsing of Symbian resources in Symbian Development

Source: Internet
Author: User

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

 
  1. STRUCTDATA  
  2. {  
  3. WORDwrd;  
  4. LONGlng;  
  5. LTEXTltxt;//variablelength  
  6. BYTEbyt;  
  7. DOUBLEdbl;  
  8. }  
  9.  
  10. STRUCTDATAARRAY  
  11. {  
  12. STRUCTdataelement[];  
  13. }  
  14.  
  15. STRUCTMYCUSTOM  
  16. {  
  17. WORDwrd;  
  18. LONGlng;  
  19. LLINKdatas;  
  20. }  
  21.  
  22.  
  23. //  
  24. //-----  
  25.  
  26. RESOURCEDATAARRAYr_data_array  
  27. {  
  28. dataelement=  
  29. {  
  30. DATA  
  31. {  
  32. wrd=11;  
  33. lng=22;  
  34. ltxt="data1";  
  35. byt=1;  
  36. dbl=2.11;  
  37. },  
  38. DATA  
  39. {  
  40. wrd=33;  
  41. lng=44;  
  42. ltxt="data2";  
  43. byt=2;  
  44. dbl=3.11;  
  45. },  
  46. DATA  
  47. {  
  48. wrd=55;  
  49. lng=66;  
  50. ltxt="data3";  
  51. byt=3;  
  52. dbl=4.11;  
  53. }  
  54. };  
  55. }  
  56.  
  57. RESOURCEMYCUSTOMr_mycustom_data  
  58. {  
  59. wrd=10;  
  60. lng=1000;  
  61. datas=r_data_array;  
  62. }  
  63.  


Read the above self-written resources in cpp

 
  1. HBufC8 * resource = CCoeEnv: Static ()-> AllocReadResourceAsDes8LC (R_MYCUSTOM_DATA );
  2. TResourceReaderreader;
  3. Reader. SetBuffer (resource );
  4. TInta = reader. ReadInt16 ();
  5. TIntb = reader. ReadInt32 ();
  6. TIntres = reader. ReadInt32 ();
  7. HBufC8 * res1 = CCoeEnv: Static ()-> AllocReadResourceAsDes8LC (res); // The resource address for transferring to LLINK
  8. Reader. SetBuffer (res1 );
  9.  
  10. TIntcount = reader. ReadInt16 (); // The array uses the first two bytes to identify the array length.
  11. For (TInti = 0; I <count; I ++)
  12. {
  13. TIntwrd = reader. ReadInt16 ();
  14. TIntlng = reader. ReadInt32 ();
  15. TPtrCptr = reader. ReadTPtrC ();
  16. TIntbte = reader. ReadUint8 ();
  17. TRealdbl = reader. ReadReal64 ();
  18. }
  19. CleanupStack: PopAndDestroy (2 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.