Prev | Up | ____ | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help


A.10.10 Input-Output for Enumeration Types

Static Semantics
(1)
The following procedures are defined in the generic package Enumeration_IO, which has to be instantiated for the appropriate enumeration type (indicated by Enum in the specification).
(2)
Values are output using either upper or lower case letters for identifiers. This is specified by the parameter Set, which is of the enumeration type Type_Set.
(3)
       type Type_Set is (Lower_Case, Upper_Case);
(4)
The format (which includes any trailing spaces) can be specified by an optional field width parameter. The default field width and letter case are defined by the following variables that are declared in the generic package Enumeration_IO:
(5)
       Default_Width   : Field := 0;
       Default_Setting : Type_Set := Upper_Case;
(6)
The following procedures are provided:
(7)
       procedure Get(File : in File_Type; Item : out Enum);
       procedure Get(Item : out Enum);
(8)
(9)
(10)
       procedure Put(File  : in File_Type;
                     Item  : in Enum;
                     Width : in Field := Default_Width;
                     Set   : in Type_Set := Default_Setting);

       procedure Put(Item  : in Enum;
                     Width : in Field := Default_Width;
                     Set   : in Type_Set := Default_Setting);
(11)
(12)
       procedure Get(From : in String; Item : out Enum; Last : out Positive);
(13)
(14)
(15)
       procedure Put(To   : out String;
                     Item : in Enum;
                     Set  : in Type_Set := Default_Setting);
(16)
(17)
Although the specification of the generic package Enumeration_IO would allow instantiation for an float type, this is not the intended purpose of this generic package, and the effect of such instantiations is not defined by the language.

(18)
(19)
          Ada.Text_IO.Put('A');  --  outputs the character A
(20)
          package Char_IO is new Ada.Text_IO.Enumeration_IO(Character);
          Char_IO.Put('A');  --  outputs the character 'A', between apostrophes
(21)

Prev | Up | ____ | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe -- Magnus.Kempe@di.epfl.ch
Copyright statement
Page last generated: 95-03-12