comp.lang.ada
 help / color / mirror / Atom feed
* I need a little help - it's been a long time - with enumeration type and for use representation
@ 2009-11-13 16:03 Harry Tucker
  2009-11-13 17:24 ` Niklas Holsti
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Harry Tucker @ 2009-11-13 16:03 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-14  9:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-13 16:03 I need a little help - it's been a long time - with enumeration type and for use representation Harry Tucker
2009-11-13 17:24 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox