Symbian3/SDK/Source/GUID-11BF98BD-814A-5CB8-B83E-6D14F38F1783.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-11BF98BD-814A-5CB8-B83E-6D14F38F1783" xml:lang="en"><title>ENUM
statement</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<codeblock xml:space="preserve">&lt;enum-statement&gt;
enum-statement ::= 
enum [&lt;enum-label&gt; ] { &lt;enum-list&gt; };</codeblock>
<p>Use an <codeph>enum</codeph> (or an <codeph>ENUM</codeph>) statement to
define a set of integer values. The values are associated with symbols defined
in the <codeph>enum-list</codeph>; the syntax and the semantics are compatible
with those of C++ enumerations. Note that the final semi-colon in an <codeph>enum</codeph> may
be omitted; however, to retain compatibility with the C++ compiler, it is
advisable to retain it.</p>
<p>Each member of the <codeph>enum-list</codeph> is followed by a comma except
for the last one. The syntax of a member is defined as:</p>
<codeblock xml:space="preserve">&lt;enum-member&gt;
enum-member ::= 
&lt;member-name&gt; [ = &lt;initialiser&gt; ] </codeblock>
<p>The defined enumerator symbols can be used in both C++ code and resource
scripts and are commonly defined in files which have the conventional file
extension <filepath>hrh</filepath>. The <filepath>.hrh</filepath> files are
included in both C++ files and resource source files.</p>
<p>In general, each enumerator can be assigned a specific value. If no value
is explicitly assigned, the value generated by the resource compiler is the
value of the previous enumerator plus one. If the first enumerator is not
assigned an explicit value, it defaults to <codeph>0</codeph>.</p>
<p>The assigned value can be coded in either hexadecimal or plain decimal
notation.</p>
<example><p>The <codeph>enum</codeph> definition:</p><codeblock id="GUID-838045EF-9C35-5864-B327-D486D8A87E3D" xml:space="preserve">enum
 {
 EExampleCmdIdFirst=0x100,
 EExampleCmdIdSecond,
 EExampleCmdIdThird,
 EExampleCmdIdFourth
 };</codeblock><p>defines the enumerators <codeph>EExampleCmdIdFirst</codeph>, <codeph>EExampleCmdIdSecond</codeph> etc.
and assigns values to them. <codeph>EExampleCmdIdFirst</codeph> is assigned
the value <codeph>0x100</codeph> (decimal 256), <codeph>EExampleCmdIdSecond</codeph> is
assigned the value <codeph>0x101</codeph> (decimal 257) etc.</p><codeblock id="GUID-47858CC6-812E-5668-A82E-612C9708D2E2" xml:space="preserve">enum {
 testvalue1=10,
 testvalue2,
 testvalue3=20,
 testvalue4
 }; 

STRUCT TEST1
 {
 BYTE b1;
 BYTE b2;
 BYTE b3;
 BYTE b4;
 } 

RESOURCE TEST1 test
 {
 b1=testvalue1;
 b2=testvalue2;
 b3=testvalue3;
 b4=testvalue4;
 }</codeblock><p>In this example the resource generated is: <codeph>0x0A 0x0B
0x14 0x15</codeph> </p></example>
</conbody></concept>