Symbian3/SDK/Source/GUID-11BF98BD-814A-5CB8-B83E-6D14F38F1783.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 16 Jul 2010 17:23:46 +0100
changeset 12 80ef3a206772
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 1897, Bug 344, Bug 2681, Bug 463, Bug 1522.

<?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>