1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-11BF98BD-814A-5CB8-B83E-6D14F38F1783" xml:lang="en"><title>ENUM |
|
13 statement</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <codeblock xml:space="preserve"><enum-statement> |
|
15 enum-statement ::= |
|
16 enum [<enum-label> ] { <enum-list> };</codeblock> |
|
17 <p>Use an <codeph>enum</codeph> (or an <codeph>ENUM</codeph>) statement to |
|
18 define a set of integer values. The values are associated with symbols defined |
|
19 in the <codeph>enum-list</codeph>; the syntax and the semantics are compatible |
|
20 with those of C++ enumerations. Note that the final semi-colon in an <codeph>enum</codeph> may |
|
21 be omitted; however, to retain compatibility with the C++ compiler, it is |
|
22 advisable to retain it.</p> |
|
23 <p>Each member of the <codeph>enum-list</codeph> is followed by a comma except |
|
24 for the last one. The syntax of a member is defined as:</p> |
|
25 <codeblock xml:space="preserve"><enum-member> |
|
26 enum-member ::= |
|
27 <member-name> [ = <initialiser> ] </codeblock> |
|
28 <p>The defined enumerator symbols can be used in both C++ code and resource |
|
29 scripts and are commonly defined in files which have the conventional file |
|
30 extension <filepath>hrh</filepath>. The <filepath>.hrh</filepath> files are |
|
31 included in both C++ files and resource source files.</p> |
|
32 <p>In general, each enumerator can be assigned a specific value. If no value |
|
33 is explicitly assigned, the value generated by the resource compiler is the |
|
34 value of the previous enumerator plus one. If the first enumerator is not |
|
35 assigned an explicit value, it defaults to <codeph>0</codeph>.</p> |
|
36 <p>The assigned value can be coded in either hexadecimal or plain decimal |
|
37 notation.</p> |
|
38 <example><p>The <codeph>enum</codeph> definition:</p><codeblock id="GUID-838045EF-9C35-5864-B327-D486D8A87E3D" xml:space="preserve">enum |
|
39 { |
|
40 EExampleCmdIdFirst=0x100, |
|
41 EExampleCmdIdSecond, |
|
42 EExampleCmdIdThird, |
|
43 EExampleCmdIdFourth |
|
44 };</codeblock><p>defines the enumerators <codeph>EExampleCmdIdFirst</codeph>, <codeph>EExampleCmdIdSecond</codeph> etc. |
|
45 and assigns values to them. <codeph>EExampleCmdIdFirst</codeph> is assigned |
|
46 the value <codeph>0x100</codeph> (decimal 256), <codeph>EExampleCmdIdSecond</codeph> is |
|
47 assigned the value <codeph>0x101</codeph> (decimal 257) etc.</p><codeblock id="GUID-47858CC6-812E-5668-A82E-612C9708D2E2" xml:space="preserve">enum { |
|
48 testvalue1=10, |
|
49 testvalue2, |
|
50 testvalue3=20, |
|
51 testvalue4 |
|
52 }; |
|
53 |
|
54 STRUCT TEST1 |
|
55 { |
|
56 BYTE b1; |
|
57 BYTE b2; |
|
58 BYTE b3; |
|
59 BYTE b4; |
|
60 } |
|
61 |
|
62 RESOURCE TEST1 test |
|
63 { |
|
64 b1=testvalue1; |
|
65 b2=testvalue2; |
|
66 b3=testvalue3; |
|
67 b4=testvalue4; |
|
68 }</codeblock><p>In this example the resource generated is: <codeph>0x0A 0x0B |
|
69 0x14 0x15</codeph> </p></example> |
|
70 </conbody></concept> |
|