Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
 
Ada Reference Manual (Ada 2022)Legal Information
Contents   Index   References   Search   Previous   Next 

A.10.1 The Package Text_IO

Static Semantics

1
The library package Text_IO has the following declaration: 
2/5
with Ada.IO_Exceptions;
package Ada.Text_IO
   with Global => in out synchronized is
3
   type File_Type is limited private;
4
   type File_Mode is (In_File, Out_File, Append_File);
5
   type Count is range 0 .. implementation-defined;
   subtype Positive_Count is Count range 1 .. Count'Last;
   Unbounded : constant Count := 0; -- line and page length
6
   subtype Field       is Integer range 0 .. implementation-defined;
   subtype Number_Base is Integer range 2 .. 16;
7
   type Type_Set is (Lower_Case, Upper_Case);
8
   -- File Management
9
   procedure Create (File : in out File_Type;
                     Mode : in File_Mode := Out_File;
                     Name : in String    := "";
                     Form : in String    := "");
10
   procedure Open   (File : in out File_Type;
                     Mode : in File_Mode;
                     Name : in String;
                     Form : in String := "");
11
   procedure Close  (File : in out File_Type);
   procedure Delete (File : in out File_Type);
   procedure Reset  (File : in out File_Type; Mode : in File_Mode);
   procedure Reset  (File : in out File_Type);
12
   function  Mode   (File : in File_Type) return File_Mode;
   function  Name   (File : in File_Type) return String;
   function  Form   (File : in File_Type) return String;
13
   function  Is_Open(File : in File_Type) return Boolean;
14
   -- Control of default input and output files
15
   procedure Set_Input (File : in File_Type);
   procedure Set_Output(File : in File_Type);
   procedure Set_Error (File : in File_Type);
16
   function Standard_Input  return File_Type;
   function Standard_Output return File_Type;
   function Standard_Error  return File_Type;
17
   function Current_Input   return File_Type;
   function Current_Output  return File_Type;
   function Current_Error   return File_Type;
18
   type File_Access is access constant File_Type;
19
   function Standard_Input  return File_Access;
   function Standard_Output return File_Access;
   function Standard_Error  return File_Access;
20
   function Current_Input   return File_Access;
   function Current_Output  return File_Access;
   function Current_Error   return File_Access;
21/5
--Buffer control
   procedure Flush (File : in File_Type)
      with Global => overriding in out File;
   procedure Flush
      with Global => in out all;
22
   -- Specification of line and page lengths
23/5
   procedure Set_Line_Length(File : in File_Type; To : in Count)
      with Global => overriding in out File;
   procedure Set_Line_Length(To   : in Count)
      with Global => in out all;
24/5
   procedure Set_Page_Length(File : in File_Type; To : in Count)
      with Global => overriding in out File;
   procedure Set_Page_Length(To   : in Count)
      with Global => in out all;
25/5
   function  Line_Length(File : in File_Type) return Count;
   function  Line_Length return Count
      with Global => in all;
26/5
   function  Page_Length(File : in File_Type) return Count;
   function  Page_Length return Count
      with Global => in all;
27
   -- Column, Line, and Page Control
28/5
   procedure New_Line   (File    : in File_Type;
                         Spacing : in Positive_Count := 1)
      with Global => overriding in out File;
   procedure New_Line   (Spacing : in Positive_Count := 1)
      with Global => in out all;
29/5
   procedure Skip_Line  (File    : in File_Type;
                         Spacing : in Positive_Count := 1)
      with Global => overriding in out File;
   procedure Skip_Line  (Spacing : in Positive_Count := 1)
      with Global => in out all;
30/5
   function  End_Of_Line(File : in File_Type) return Boolean;
   function  End_Of_Line return Boolean;
31/5
   procedure New_Page   (File : in File_Type)
      with Global => overriding in out File;
   procedure New_Page
      with Global => in out all;
32/5
   procedure Skip_Page  (File : in File_Type)
      with Global => overriding in out File;
   procedure Skip_Page
      with Global => in out all;
33/5
   function  End_Of_Page(File : in File_Type) return Boolean;
   function  End_Of_Page return Boolean
      with Global => in all;
34/5
   function  End_Of_File(File : in File_Type) return Boolean;
   function  End_Of_File return Boolean
      with Global => in all;
35/5
   procedure Set_Col (File : in File_Type; To : in Positive_Count)
      with Global => overriding in out File;
   procedure Set_Col (To   : in Positive_Count)
      with Global => in out all;
36/5
   procedure Set_Line(File : in File_Type; To : in Positive_Count)
      with Global => overriding in out File;
   procedure Set_Line(To   : in Positive_Count)
      with Global => in out all;
37/5
   function Col (File : in File_Type) return Positive_Count;
   function Col  return Positive_Count
      with Global => in all;
38/5
   function Line(File : in File_Type) return Positive_Count;
   function Line return Positive_Count
      with Global => in all;
39/5
   function Page(File : in File_Type) return Positive_Count;
   function Page return Positive_Count
      with Global => in all;
40
   -- Character Input-Output
41/5
   procedure Get(File : in  File_Type; Item : out Character)
      with Global => overriding in out File;
   procedure Get(Item : out Character)
      with Global => in out all;
42/5
   procedure Put(File : in  File_Type; Item : in Character)
      with Global => overriding in out File;
   procedure Put(Item : in  Character)
      with Global => in out all;
43/5
   procedure Look_Ahead (File        : in  File_Type;
                         Item        : out Character;
                         End_Of_Line : out Boolean)
      with Global => overriding in out File;
   procedure Look_Ahead (Item        : out Character;
                         End_Of_Line : out Boolean)
      with Global => in out all;
44/5
   procedure Get_Immediate(File      : in  File_Type;
                           Item      : out Character)
      with Global => overriding in out File;
   procedure Get_Immediate(Item      : out Character)
      with Global => in out all;
45/5
   procedure Get_Immediate(File      : in  File_Type;
                           Item      : out Character;
                           Available : out Boolean)
      with Global => overriding in out File;
   procedure Get_Immediate(Item      : out Character;
                           Available : out Boolean)
      with Global => in out all;
46
   -- String Input-Output
47/5
   procedure Get(File : in  File_Type; Item : out String)
      with Global => overriding in out File;
   procedure Get(Item : out String)
      with Global => in out all;
48/5
   procedure Put(File : in  File_Type; Item : in String)
      with Global => overriding in out File;
   procedure Put(Item : in  String)
      with Global => in out all;
49/5
   procedure Get_Line(File : in  File_Type;
                      Item : out String;
                      Last : out Natural)
      with Global => overriding in out File;
   procedure Get_Line(Item : out String; Last : out Natural)
      with Global => in out all;
49.1/5
   function Get_Line(File : in  File_Type) return String
      with Global => overriding in out File;
   function Get_Line return String
      with Global => in out all;
50/5
   procedure Put_Line(File : in  File_Type; Item : in String)
      with Global => overriding in out File;
   procedure Put_Line(Item : in  String)
      with Global => in out all;
51
-- Generic packages for Input-Output of Integer Types
52
   generic
      type Num is range <>;
   package Integer_IO is
53
      Default_Width : Field := Num'Width;
      Default_Base  : Number_Base := 10;
54/5
      procedure Get(File  : in  File_Type;
                    Item  : out Num;
                    Width : in Field := 0)
         with Global => overriding in out File;
      procedure Get(Item  : out Num;
                    Width : in  Field := 0)
         with Global => in out all;
55/5
      procedure Put(File  : in File_Type;
                    Item  : in Num;
                    Width : in Field := Default_Width;
                    Base  : in Number_Base := Default_Base)
         with Global => overriding in out File;
      procedure Put(Item  : in Num;
                    Width : in Field := Default_Width;
                    Base  : in Number_Base := Default_Base)
         with Global => in out all;
      procedure Get(From : in  String;
                    Item : out Num;
                    Last : out Positive)
         with Nonblocking;
      procedure Put(To   : out String;
                    Item : in Num;
                    Base : in Number_Base := Default_Base)
         with Nonblocking;
56
   end Integer_IO;
57
   generic
      type Num is mod <>;
   package Modular_IO is
58
      Default_Width : Field := Num'Width;
      Default_Base  : Number_Base := 10;
59/5
      procedure Get(File  : in  File_Type;
                    Item  : out Num;
                    Width : in Field := 0)
         with Global => overriding in out File;
      procedure Get(Item  : out Num;
                    Width : in  Field := 0)
         with Global => in out all;
60/5
      procedure Put(File  : in File_Type;
                    Item  : in Num;
                    Width : in Field := Default_Width;
                    Base  : in Number_Base := Default_Base)
         with Global => overriding in out File;
      procedure Put(Item  : in Num;
                    Width : in Field := Default_Width;
                    Base  : in Number_Base := Default_Base)
         with Global => in out all;
      procedure Get(From : in  String;
                    Item : out Num;
                    Last : out Positive)
         with Nonblocking;
      procedure Put(To   : out String;
                    Item : in Num;
                    Base : in Number_Base := Default_Base)
         with Nonblocking;
61
   end Modular_IO;
62
   -- Generic packages for Input-Output of Real Types
63
   generic
      type Num is digits <>;
   package Float_IO is
64
      Default_Fore : Field := 2;
      Default_Aft  : Field := Num'Digits-1;
      Default_Exp  : Field := 3;
65/5
      procedure Get(File  : in  File_Type;
                    Item  : out Num;
                    Width : in  Field := 0)
         with Global => overriding in out File;
      procedure Get(Item  : out Num;
                    Width : in  Field := 0)
         with Global => in out all;
66/5
      procedure Put(File : in File_Type;
                    Item : in Num;
                    Fore : in Field := Default_Fore;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Global => overriding in out File;
      procedure Put(Item : in Num;
                    Fore : in Field := Default_Fore;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Global => in out all;
67/5
      procedure Get(From : in String;
                    Item : out Num;
                    Last : out Positive)
         with Nonblocking;
      procedure Put(To   : out String;
                    Item : in Num;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Nonblocking;
   end Float_IO;
68
   generic
      type Num is delta <>;
   package Fixed_IO is
69
      Default_Fore : Field := Num'Fore;
      Default_Aft  : Field := Num'Aft;
      Default_Exp  : Field := 0;
70/5
      procedure Get(File  : in  File_Type;
                    Item  : out Num;
                    Width : in  Field := 0)
         with Global => overriding in out File;
      procedure Get(Item  : out Num;
                    Width : in  Field := 0)
         with Global => in out all;
71/5
      procedure Put(File : in File_Type;
                    Item : in Num;
                    Fore : in Field := Default_Fore;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Global => overriding in out File;
      procedure Put(Item : in Num;
                    Fore : in Field := Default_Fore;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Global => in out all;
72/5
      procedure Get(From : in  String;
                    Item : out Num;
                    Last : out Positive)
         with Nonblocking;
      procedure Put(To   : out String;
                    Item : in Num;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Nonblocking;
   end Fixed_IO;
73
   generic
      type Num is delta <> digits <>;
   package Decimal_IO is
74
      Default_Fore : Field := Num'Fore;
      Default_Aft  : Field := Num'Aft;
      Default_Exp  : Field := 0;
75/5
      procedure Get(File  : in  File_Type;
                    Item  : out Num;
                    Width : in  Field := 0)
         with Global => overriding in out File;
      procedure Get(Item  : out Num;
                    Width : in  Field := 0)
         with Global => in out all;
76/5
      procedure Put(File : in File_Type;
                    Item : in Num;
                    Fore : in Field := Default_Fore;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Global => overriding in out File;
      procedure Put(Item : in Num;
                    Fore : in Field := Default_Fore;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Global => in out all;
77/5
      procedure Get(From : in  String;
                    Item : out Num;
                    Last : out Positive)
         with Nonblocking;
      procedure Put(To   : out String;
                    Item : in Num;
                    Aft  : in Field := Default_Aft;
                    Exp  : in Field := Default_Exp)
         with Nonblocking;
   end Decimal_IO;
78
   -- Generic package for Input-Output of Enumeration Types
79
   generic
      type Enum is (<>);
   package Enumeration_IO is
80
      Default_Width   : Field := 0;
      Default_Setting : Type_Set := Upper_Case;
81/5
      procedure Get(File : in  File_Type;
                    Item : out Enum)
         with Global => overriding in out File;
      procedure Get(Item : out Enum)
         with Global => in out all;
82/5
      procedure Put(File  : in File_Type;
                    Item  : in Enum;
                    Width : in Field    := Default_Width;
                    Set   : in Type_Set := Default_Setting)
         with Global => overriding in out File;
      procedure Put(Item  : in Enum;
                    Width : in Field    := Default_Width;
                    Set   : in Type_Set := Default_Setting)
         with Global => in out all;
83/5
      procedure Get(From : in  String;
                    Item : out Enum;
                    Last : out Positive)
         with Nonblocking;
      procedure Put(To   : out String;
                    Item : in  Enum;
                    Set  : in  Type_Set := Default_Setting)
         with Nonblocking;
   end Enumeration_IO;
84
-- Exceptions
85/5
   Status_Error : exception renames IO_Exceptions.Status_Error;
   Mode_Error   : exception renames IO_Exceptions.Mode_Error;
   Name_Error   : exception renames IO_Exceptions.Name_Error;
   Use_Error    : exception renames IO_Exceptions.Use_Error;
   Device_Error : exception renames IO_Exceptions.Device_Error;
   End_Error    : exception renames IO_Exceptions.End_Error;
   Data_Error   : exception renames IO_Exceptions.Data_Error;
   Layout_Error : exception renames IO_Exceptions.Layout_Error;
85.1/5
   package Wide_File_Names is
85.2/5
      -- File management
85.3/5
      procedure Create (File : in out File_Type;
                        Mode : in File_Mode := Out_File;
                        Name : in Wide_String := "";
                        Form : in Wide_String := "");
85.4/5
      procedure Open   (File : in out File_Type;
                        Mode : in File_Mode;
                        Name : in Wide_String;
                        Form : in Wide_String := "");
85.5/5
      function Name    (File : in File_Type) return Wide_String;
85.6/5
      function Form    (File : in File_Type) return Wide_String;
85.7/5
   end Wide_File_Names;
85.8/5
   package Wide_Wide_File_Names is
85.9/5
      -- File management
85.10/5
      procedure Create (File : in out File_Type;
                        Mode : in File_Mode := Out_File;
                        Name : in Wide_Wide_String := "";
                        Form : in Wide_Wide_String := "");
85.11/5
      procedure Open   (File : in out File_Type;
                        Mode : in File_Mode;
                        Name : in Wide_Wide_String;
                        Form : in Wide_Wide_String := "");
85.12/5
      function Name    (File : in File_Type) return Wide_Wide_String;
85.13/5
      function Form    (File : in File_Type) return Wide_Wide_String;
85.14/5
   end Wide_Wide_File_Names;
85.15/5
private
   ... -- not specified by the language
end Ada.Text_IO;
86/2
The type File_Type needs finalization (see 7.6).

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe