From: Harry Tucker <harry.tucker@sbcglobal.net>
Subject: I need a little help - it's been a long time - with enumeration type and for use representation
Date: Fri, 13 Nov 2009 08:03:23 -0800 (PST)
Date: 2009-11-13T08:03:23-08:00 [thread overview]
Message-ID: <7495d29e-0361-4eba-9e22-a770ae50f113@d5g2000yqm.googlegroups.com> (raw)
I haven't played with Ada for many years. I've read John Barnes' book,
Programming in Ada 2005, and picked through the ARM on my problem.
I have a piece of data which represents a enumeration as a hexadecimal
value. It is a bit field but I see the data most usefull as an
enumeration. for example in the CSV file the data is represented as
'0x1'. So I defined the enum as:
<code>
type Spell_School_Type is (
UNKNOWN,
PHYSICAL,
HOLY,
FIRE,
...
</code>
And since the data has a value I use a represetation clause as:
<code>
for Spell_School_Type use
(UNKNOWN => 2#0000_0000#,
PHYSICAL => 2#0000_0001#,
HOLY => 2#0000_0010#,
FIRE => 2#0000_0100#,
...
</code>
Is the best way to parse the raw info (i.e. 0x1) into the enumeration
(i.e PHYSICAL) to use a if/elsif and assign the enum position or is
there an attribute which works best.
Harry
next reply other threads:[~2009-11-13 16:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 16:03 Harry Tucker [this message]
2009-11-13 17:24 ` I need a little help - it's been a long time - with enumeration type and for use representation Niklas Holsti
2009-11-13 17:24 ` Dmitry A. Kazakov
2009-11-13 18:48 ` Jeffrey R. Carter
2009-11-13 19:13 ` Dmitry A. Kazakov
2009-11-13 20:32 ` Jeffrey R. Carter
2009-11-13 20:53 ` Dmitry A. Kazakov
2009-11-13 21:30 ` Jeffrey R. Carter
2009-11-14 9:24 ` Dmitry A. Kazakov
2009-11-13 18:46 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox