comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcqada@earthlink.net>
Subject: Re: accesing internal codes used for an enumeration
Date: Tue, 08 May 2001 03:51:49 GMT
Date: 2001-05-08T03:51:49+00:00	[thread overview]
Message-ID: <3AF76021.14CF06A9@earthlink.net> (raw)
In-Reply-To: mailman.989244246.26083.comp.lang.ada@ada.eu.org

Marius Amado Alves wrote:
> 
> I am trying to implement a lexicon (in the database sense) as an
> enumeration with a representation clause.
> 
> Example lexicon:
> 
>   Name <-> Code
>   -------------
>   Ping      123
>   Pong      456
> 
> Implementation:
> 
>   type Names is (Ping, Pong);
>   for Names use (Ping => 123, Pong => 456);
> 
> I found out the hardway that attribute Pos does not return the internal
> code.  The ARM says this at 13.4(11), and tells you to use
> Unchecked_Conversion instead--but does not instruct you on the types of
> the conversion.  Where might one learn that?  Thanks.

If you're using GNAT and don't mind going non-portable, GNAT provides
the 'Enum_Rep attribute to extract the specified enumeration
representation.  (See the GNAT Reference Manual.)

Marc A. Criley
Senior Staff Engineer
Quadrus Corporation
www.quadruscorp.com



  parent reply	other threads:[~2001-05-08  3:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-07 16:03 accesing internal codes used for an enumeration Marius Amado Alves
2001-05-07 15:33 ` Jacob Sparre Andersen
2001-05-07 15:54 ` Ted Dennison
2001-05-08  3:51 ` Marc A. Criley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-05-07 18:53 Beard, Frank
2001-05-08  5:56 ` Jacob Sparre Andersen
     [not found] <Pine.LNX.4.21.0105071543050.9145-100000@lux38>
2001-05-07 21:18 ` Marius Amado Alves
2001-05-10 18:45 Beard, Frank
replies disabled

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