DocAda(tm) is a productivity tool of KSCE

Prev | Up | ____ | Back | Forward
About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News

A.10.10 Input-Output for Enumeration Types

Static Semantics

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).

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.

   
       type Type_Set is (Lower_Case, Upper_Case);

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:

   
       Default_Width   : Field := 0;
       Default_Setting : Type_Set := Upper_Case;

The following procedures are provided:

   
       procedure Get(File : in File_Type; Item : out Enum);
       procedure Get(Item : out Enum);
    
       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);
    
       procedure Get(From : in String; Item : out Enum; Last : out Positive);
    
       procedure Put(To   : out String;
                     Item : in Enum;
                     Set  : in Type_Set := Default_Setting);

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.

    
          Ada.Text_IO.Put('A');  --  outputs the character A

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

About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News
Prev | Up | ____ | Back | Forward


Copyright © 1994-1997 by Kempe Software Capital Enterprises. All Rights Reserved. For comments on this DocAda(tm) hypertext document, please write to KSCE, at docada@ksce.com