DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Ada.Text_IO.Wide_Generic

The shared implementation of Ada.Wide_Text_IO and Ada.Wide_Wide_Text_IO (RM A.11): all of Text_IO's operations with characters and strings of the generic's Char and Text, a file's characters held as UTF-8.

Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.

Availability and ownership

A generic child of Ada.Text_IO that Verada adds: Ada.Wide_Text_IO and Ada.Wide_Wide_Text_IO are its instances, so a program names those. Its bodies are proved once for every instance (test/programs/prove/library-ada-wide_text_io). Its files, their settings (Text_IO's Settings: which files are current, every file's line and page lengths) and its contracts are Text_IO's (family guide).

A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.

Import and instantiate

with Ada.Text_IO.Wide_Generic;
import Ada.Text_IO.Wide_Generic;

A Vibe module imports this unit's names with from Ada.Text_IO.Wide_Generic import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.

Contract and lifecycle reading

A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.

API 001

Char (declaration) — The character type, and Text its string type (an array of Char indexed by Positive): Wide_Character and Wide_String, or Wide_Wide_Character and Wide_Wide_String.

Declared interface:

generic
   type Char is (<>);
   type Text is array (Positive range <>) of Char;

API 002

File_Type (declaration) — A file: limited, so passed by reference, and closed until Create or Open opens it; it is not closed when its object's scope ends.

Declared interface:

type File_Type is limited private
  with Default_Initial_Condition => not Is_Open (File_Type);

API 003

File_Mode (declaration) — Reading (In_File), writing from the start (Out_File) or after what the file holds (Append_File).

Declared interface:

type File_Mode is (In_File, Out_File, Append_File);

API 004

Count (declaration) — Columns, lines and pages, and the line and page lengths.

Declared interface:

type Count is range 0 .. Natural'Last;

API 005

Positive_Count (declaration) — A column, line or page, from 1.

Declared interface:

subtype Positive_Count is Count range 1 .. Count'Last;

API 006

Unbounded (declaration) — A line or page length of none.

Declared interface:

Unbounded : constant Count := 0;

API 007

Field (declaration) — A width, or a count of digits.

Declared interface:

subtype Field is Integer range 0 .. Integer'Last;

API 008

Number_Base (declaration) — The bases Integer_IO and Modular_IO write in.

Declared interface:

subtype Number_Base is Integer range 2 .. 16;

API 009

Type_Set (declaration) — The case Enumeration_IO writes identifiers in.

Declared interface:

type Type_Set is (Lower_Case, Upper_Case);

API 010

Status_Error (declaration) — A file that is not open given to an operation that needs it open, or an open one to Create or Open.

Declared interface:

Status_Error : exception renames Ada.IO_Exceptions.Status_Error;

API 011

Mode_Error (declaration) — A file open in a mode the operation cannot use (Get from an output file, Put to an input file).

Declared interface:

Mode_Error   : exception renames Ada.IO_Exceptions.Mode_Error;

API 012

Name_Error (declaration) — Create or Open cannot find or make a file of that name.

Declared interface:

Name_Error   : exception renames Ada.IO_Exceptions.Name_Error;

API 013

Use_Error (declaration) — A file cannot be made, opened, reset or deleted for another reason.

Declared interface:

Use_Error    : exception renames Ada.IO_Exceptions.Use_Error;

API 014

Device_Error (declaration) — Ada.IO_Exceptions' device failure.

Declared interface:

Device_Error : exception renames Ada.IO_Exceptions.Device_Error;

API 015

End_Error (declaration) — Input has ended before what was asked for.

Declared interface:

End_Error    : exception renames Ada.IO_Exceptions.End_Error;

API 016

Data_Error (declaration) — The characters a numeric or enumeration Get read are not a value of the type.

Declared interface:

Data_Error   : exception renames Ada.IO_Exceptions.Data_Error;

API 017

Layout_Error (declaration) — A value does not fit where it is put, or a column or line is beyond its length.

Declared interface:

Layout_Error : exception renames Ada.IO_Exceptions.Layout_Error;

API 018

Is_Open (declaration) — Whether the file is open.

Declared interface:

function Is_Open (File : File_Type) return Boolean
  with Global => null;

API 019

Mode (declaration) — An open file's mode.

Declared interface:

function Mode (File : File_Type) return File_Mode
  with Pre => Is_Open (File), Global => null;

API 020

Create (declaration) — A new file, open in Mode (an empty Name: a temporary one, deleted when it is closed); Name_Error or Use_Error, the file still closed, when it cannot be made. Its line and page lengths are unbounded, and it is not a current file.

Declared interface:

procedure Create (File : in out File_Type; Mode : File_Mode := Out_File; Name : String := ""; Form : String := "")
  with Post => Settings = Settings'Old and then Is_Open (File) and then Wide_Generic.Mode (File) = Mode
               and then Line_Bound (File) = 0 and then Page_Bound (File) = 0
               and then not Is_Current (File),
       Global => (In_Out => File_System),
       Exceptional_Cases => (Status_Error => Is_Open (File)'Old,
                             Name_Error | Use_Error => Settings = Settings'Old and then not Is_Open (File));

API 021

Open (declaration) — An existing file, open in Mode; Name_Error when there is no such file, Use_Error otherwise, the file still closed. Its line and page lengths are unbounded, and it is not a current file.

Declared interface:

procedure Open (File : in out File_Type; Mode : File_Mode; Name : String; Form : String := "")
  with Post => Settings = Settings'Old and then Is_Open (File) and then Wide_Generic.Mode (File) = Mode
               and then Line_Bound (File) = 0 and then Page_Bound (File) = 0
               and then not Is_Current (File),
       Global => (In_Out => File_System),
       Exceptional_Cases => (Status_Error => Is_Open (File)'Old,
                             Name_Error | Use_Error => Settings = Settings'Old and then not Is_Open (File));

API 022

Close (declaration) — The file closed, an output file's last line and page ended first; where it was the current input, output or error file, the standard one is current again.

Declared interface:

procedure Close (File : in out File_Type)
  with Post => Settings = Without (Settings, File)'Old and then not Is_Open (File),
       Global => (In_Out => File_System),
       Exceptional_Cases => (Status_Error => not Is_Open (File)'Old);

API 023

Delete (declaration) — The file closed and deleted; Use_Error when it cannot be deleted.

Declared interface:

procedure Delete (File : in out File_Type)
  with Post => Settings = Without (Settings, File)'Old and then not Is_Open (File),
       Global => (In_Out => File_System),
       Exceptional_Cases => (Status_Error => not Is_Open (File)'Old,
                             Use_Error => Settings = Without (Settings, File)'Old and then not Is_Open (File));

API 024

Reset (declaration) — The file again from its start, in Mode, its line and page lengths unbounded; Use_Error, the file then closed, when it cannot be; Mode_Error, the file left as it was, when the file is a current default file and Mode is not its mode (RM A.10.2(4)): a program that never makes it current proves that it does not happen.

Declared interface:

procedure Reset (File : in out File_Type; Mode : File_Mode)
  with Post => Settings = Reset_Of (Settings, File)'Old and Is_Current (File) = Is_Current (File)'Old
               and (Is_Open (File) and then Wide_Generic.Mode (File) = Mode
                    and then Line_Bound (File) = 0 and then Page_Bound (File) = 0),
       Global => (In_Out => File_System),
       Exceptional_Cases => (Status_Error => not Is_Open (File)'Old,
                             Mode_Error => Is_Current (File)'Old and then Is_Open (File)
                                           and then Mode /= Wide_Generic.Mode (File),
                             Use_Error => Settings = Without (Settings, File)'Old and then not Is_Open (File));

API 025

Reset (declaration) — The file again from its start, in its mode, its line and page lengths unbounded.

Declared interface:

procedure Reset (File : in out File_Type)
  with Post => Settings = Reset_Of (Settings, File)'Old and Is_Current (File) = Is_Current (File)'Old
               and (Mode (File)'Old = Mode (File) and then Is_Open (File)
                    and then Line_Bound (File) = 0 and then Page_Bound (File) = 0),
       Global => (In_Out => File_System),
       Exceptional_Cases => (Status_Error => not Is_Open (File)'Old,
                             Use_Error => Settings = Without (Settings, File)'Old and then not Is_Open (File));

API 026

Name (declaration) — The file's name (a temporary file's own).

Declared interface:

function Name (File : File_Type) return String
  with Pre => Is_Open (File), Global => File_System,
       Post => Name'Result'Length < Verada.Storage.Length_Bound;

API 027

Form (declaration) — The file's form: Verada takes none, so it is empty.

Declared interface:

function Form (File : File_Type) return String
  with Pre => Is_Open (File), Global => null,
       Post => Form'Result'Length = 0;

API 028

Standard_Input (declaration) — Standard input, open for reading.

Declared interface:

function Standard_Input return File_Type
  with Global => null,
       Post => Is_Open (Standard_Input'Result) and then Mode (Standard_Input'Result) = In_File;

API 029

Standard_Output (declaration) — Standard output, open for writing.

Declared interface:

function Standard_Output return File_Type
  with Global => null,
       Post => Is_Open (Standard_Output'Result) and then Mode (Standard_Output'Result) = Out_File;

API 030

Standard_Error (declaration) — Standard error, open for writing.

Declared interface:

function Standard_Error return File_Type
  with Global => null,
       Post => Is_Open (Standard_Error'Result) and then Mode (Standard_Error'Result) = Out_File;

API 031

Current_Input (declaration) — The file the forms without a File read: standard input unless Set_Input chose another.

Declared interface:

function Current_Input return File_Type
  with Global => File_System,
       Post => Is_Open (Current_Input'Result) and then Mode (Current_Input'Result) = In_File;

API 032

Current_Output (declaration) — The file the forms without a File write: standard output unless Set_Output chose another.

Declared interface:

function Current_Output return File_Type
  with Global => File_System,
       Post => Is_Open (Current_Output'Result) and then Mode (Current_Output'Result) /= In_File;

API 033

Current_Error (declaration) — The current error file: standard error unless Set_Error chose another.

Declared interface:

function Current_Error return File_Type
  with Global => File_System,
       Post => Is_Open (Current_Error'Result) and then Mode (Current_Error'Result) /= In_File;

API 034

Set_Input (declaration) — The current input becomes File, open for reading.

Declared interface:

procedure Set_Input (File : File_Type)
  with Global => (In_Out => File_System),
       Post => Settings = With_Input (Settings'Old, File),
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) /= In_File);

API 035

Set_Output (declaration) — The current output becomes File, open for writing.

Declared interface:

procedure Set_Output (File : File_Type)
  with Global => (In_Out => File_System),
       Post => Settings = With_Output (Settings'Old, File),
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 036

Set_Error (declaration) — The current error file becomes File, open for writing.

Declared interface:

procedure Set_Error (File : File_Type)
  with Global => (In_Out => File_System),
       Post => Settings = With_Error (Settings'Old, File),
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 037

Flush (declaration) — What the file holds written out.

Declared interface:

procedure Flush (File : File_Type)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 038

Flush (declaration) — The current output's held characters written out.

Declared interface:

procedure Flush
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 039

Set_Line_Length (declaration) — The file's line length (Unbounded for none): output ends a line when it is full. The page length stays as it was.

Declared interface:

procedure Set_Line_Length (File : File_Type; To : Count)
  with Global => (In_Out => File_System),
       Post => Settings = With_Line_Length (Settings, File, To)'Old
               and Line_Bound (File) = To and Page_Bound (File) = Page_Bound (File)'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 040

Set_Line_Length (declaration) — The current output's line length.

Declared interface:

procedure Set_Line_Length (To : Count)
  with Global => (In_Out => File_System),
       Post => Settings = With_Line_Length (Settings'Old, To)
               and then Wide_Generic.Line_Length = To;

API 041

Set_Page_Length (declaration) — The file's page length (Unbounded for none): output ends a page when it is full. The line length stays as it was.

Declared interface:

procedure Set_Page_Length (File : File_Type; To : Count)
  with Global => (In_Out => File_System),
       Post => Settings = With_Page_Length (Settings, File, To)'Old
               and Page_Bound (File) = To and Line_Bound (File) = Line_Bound (File)'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 042

Set_Page_Length (declaration) — The current output's page length.

Declared interface:

procedure Set_Page_Length (To : Count)
  with Global => (In_Out => File_System),
       Post => Settings = With_Page_Length (Settings'Old, To)
               and then Wide_Generic.Page_Length = To;

API 043

Line_Length (declaration) — The file's line length.

Declared interface:

function Line_Length (File : File_Type) return Count
  with Pre => Is_Open (File) and then Mode (File) /= In_File, Global => File_System,
       Post => (if Is_Current_Output (File) then Line_Length'Result = Wide_Generic.Line_Length);

API 044

Line_Length (declaration) — The current output's line length.

Declared interface:

function Line_Length return Count
  with Global => File_System;

API 045

Page_Length (declaration) — The file's page length.

Declared interface:

function Page_Length (File : File_Type) return Count
  with Pre => Is_Open (File) and then Mode (File) /= In_File, Global => File_System,
       Post => (if Is_Current_Output (File) then Page_Length'Result = Wide_Generic.Page_Length);

API 046

Page_Length (declaration) — The current output's page length.

Declared interface:

function Page_Length return Count
  with Global => File_System;

API 047

New_Line (declaration) — Spacing line terminators (a page terminator too when a page fills).

Declared interface:

procedure New_Line (File : File_Type; Spacing : Positive_Count := 1)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 048

New_Line (declaration) — Spacing line terminators on the current output.

Declared interface:

procedure New_Line (Spacing : Positive_Count := 1)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 049

Skip_Line (declaration) — Past Spacing line terminators (and a page terminator after one); End_Error when the file is at its end on entry, or ends before the last of more than one.

Declared interface:

procedure Skip_Line (File : File_Type; Spacing : Positive_Count := 1)
  with Pre => Is_Open (File) and then Mode (File) = In_File,
       Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old and (End_Of_File (File)'Old or else Spacing > 1));

API 050

Skip_Line (declaration) — The same on the current input.

Declared interface:

procedure Skip_Line (Spacing : Positive_Count := 1)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old and (End_Of_File'Old or else Spacing > 1));

API 051

End_Of_Line (declaration) — Whether a line terminator, or the end of the file, comes next.

Declared interface:

function End_Of_Line (File : File_Type) return Boolean
  with Pre => Is_Open (File) and then Mode (File) = In_File, Global => File_System,
       Post => (if Is_Current_Input (File) then End_Of_Line'Result = Wide_Generic.End_Of_Line);

API 052

End_Of_Line (declaration) — The same on the current input.

Declared interface:

function End_Of_Line return Boolean
  with Global => File_System;

API 053

New_Page (declaration) — A page terminator, the current line ended first.

Declared interface:

procedure New_Page (File : File_Type)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 054

New_Page (declaration) — A page terminator on the current output.

Declared interface:

procedure New_Page
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 055

Skip_Page (declaration) — Past the next page terminator, or to the end of the file; End_Error when the file is at its end on entry.

Declared interface:

procedure Skip_Page (File : File_Type)
  with Pre => Is_Open (File) and then Mode (File) = In_File,
       Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old and End_Of_File (File)'Old);

API 056

Skip_Page (declaration) — The same on the current input.

Declared interface:

procedure Skip_Page
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old and End_Of_File'Old);

API 057

End_Of_Page (declaration) — Whether a page terminator, alone or after a line terminator, or the end of the file, comes next.

Declared interface:

function End_Of_Page (File : File_Type) return Boolean
  with Pre => Is_Open (File) and then Mode (File) = In_File, Global => File_System,
       Post => (if Is_Current_Input (File) then End_Of_Page'Result = Wide_Generic.End_Of_Page);

API 058

End_Of_Page (declaration) — The same on the current input.

Declared interface:

function End_Of_Page return Boolean
  with Global => File_System;

API 059

End_Of_File (declaration) — Whether nothing but a last line and page terminator remains.

Declared interface:

function End_Of_File (File : File_Type) return Boolean
  with Pre => Is_Open (File) and then Mode (File) = In_File, Global => File_System,
       Post => (if Is_Current_Input (File) then End_Of_File'Result = Wide_Generic.End_Of_File);

API 060

End_Of_File (declaration) — The same on the current input.

Declared interface:

function End_Of_File return Boolean
  with Global => File_System;

API 061

Line_Bound (declaration) — Ghost, for contracts: the line length of a file open for output, 0 (no bound) for any other file; Set_Col's Layout_Error case names it.

Declared interface:

function Line_Bound (File : File_Type) return Count
  with Ghost, Global => File_System,
       Post => Line_Bound'Result = (if Is_Open (File) and then Mode (File) /= In_File then Line_Length (File) else 0);

API 062

Page_Bound (declaration) — Ghost, for contracts: the page length of a file open for output, 0 (no bound) for any other file; Set_Line's Layout_Error case names it.

Declared interface:

function Page_Bound (File : File_Type) return Count
  with Ghost, Global => File_System,
       Post => Page_Bound'Result = (if Is_Open (File) and then Mode (File) /= In_File then Page_Length (File) else 0);

API 063

Is_Current (declaration) — Ghost, for contracts: whether File is the current default input, output or error file (Text_IO's, of the file's Text_IO file), so open. A file Create or Open makes is not; only a current file's Reset to another mode propagates Mode_Error.

Declared interface:

function Is_Current (File : File_Type) return Boolean
  with Ghost, Global => File_System;

API 064

Is_Current_Input (declaration) — Ghost: whether File is the current default input (Text_IO's, of the file's Text_IO file): End_Of_Line, End_Of_Page and End_Of_File of File are then the default forms'.

Declared interface:

function Is_Current_Input (File : File_Type) return Boolean
  with Ghost, Global => File_System;

API 065

Is_Current_Output (declaration) — Ghost: whether File is the current default output (Text_IO's, of the file's Text_IO file): Line_Length, Page_Length, Col, Line and Page of File are then the default forms'.

Declared interface:

function Is_Current_Output (File : File_Type) return Boolean
  with Ghost, Global => File_System;

API 066

With_Input (declaration) — Ghost: the settings after Set_Input of File.

Declared interface:

function With_Input (Files : File_Settings; File : File_Type) return File_Settings
  with Ghost, Global => null;

API 067

With_Output (declaration) — Ghost: the settings after Set_Output of File.

Declared interface:

function With_Output (Files : File_Settings; File : File_Type) return File_Settings
  with Ghost, Global => null;

API 068

With_Error (declaration) — Ghost: the settings after Set_Error of File.

Declared interface:

function With_Error (Files : File_Settings; File : File_Type) return File_Settings
  with Ghost, Global => null;

API 069

With_Line_Length (declaration) — Ghost: the settings after Set_Line_Length of File: its line length To, the rest as they were.

Declared interface:

function With_Line_Length (Files : File_Settings; File : File_Type; To : Count) return File_Settings
  with Ghost, Global => null;

API 070

With_Page_Length (declaration) — Ghost: the settings after Set_Page_Length of File: its page length To, the rest as they were.

Declared interface:

function With_Page_Length (Files : File_Settings; File : File_Type; To : Count) return File_Settings
  with Ghost, Global => null;

API 071

With_Line_Length (declaration) — Ghost: the settings after Set_Line_Length of the current output.

Declared interface:

function With_Line_Length (Files : File_Settings; To : Count) return File_Settings
  with Ghost, Global => null;

API 072

With_Page_Length (declaration) — Ghost: the settings after Set_Page_Length of the current output.

Declared interface:

function With_Page_Length (Files : File_Settings; To : Count) return File_Settings
  with Ghost, Global => null;

API 073

Reset_Of (declaration) — Ghost: the settings after File is reset: its lengths unbounded, the rest as they were.

Declared interface:

function Reset_Of (Files : File_Settings; File : File_Type) return File_Settings
  with Ghost, Global => null;

API 074

Without (declaration) — Ghost: the settings after File is closed: its lengths unbounded and, where it was a current file, the standard file current again.

Declared interface:

function Without (Files : File_Settings; File : File_Type) return File_Settings
  with Ghost, Global => null;

API 075

Set_Col (declaration) — On output, spaces (a new line first when the column is passed) to column To; Layout_Error only when the line length is bounded and To is beyond it, so never for column 1. On input, characters skipped to column To; End_Error when the file ends first.

Declared interface:

procedure Set_Col (File : File_Type; To : Positive_Count)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Layout_Error => Settings = Settings'Old and (Line_Bound (File)'Old /= 0 and then To > Line_Bound (File)'Old),
                             End_Error => Settings = Settings'Old and then Is_Open (File) and then Mode (File) = In_File);

API 076

Set_Col (declaration) — The same on the current output: Layout_Error only when its line length is bounded and To is beyond it.

Declared interface:

procedure Set_Col (To : Positive_Count)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Layout_Error => Settings = Settings'Old and (Wide_Generic.Line_Length'Old /= 0 and then To > Wide_Generic.Line_Length'Old));

API 077

Set_Line (declaration) — On output, new lines (a new page first when the line is passed) to line To; Layout_Error only when the page length is bounded and To is beyond it, so never for line 1. On input, lines skipped to line To; End_Error when the file ends first.

Declared interface:

procedure Set_Line (File : File_Type; To : Positive_Count)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Layout_Error => Settings = Settings'Old and (Page_Bound (File)'Old /= 0 and then To > Page_Bound (File)'Old),
                             End_Error => Settings = Settings'Old and then Is_Open (File) and then Mode (File) = In_File);

API 078

Set_Line (declaration) — The same on the current output: Layout_Error only when its page length is bounded and To is beyond it.

Declared interface:

procedure Set_Line (To : Positive_Count)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Layout_Error => Settings = Settings'Old and (Wide_Generic.Page_Length'Old /= 0 and then To > Wide_Generic.Page_Length'Old));

API 079

Col (declaration) — The file's column.

Declared interface:

function Col (File : File_Type) return Positive_Count
  with Pre => Is_Open (File), Global => File_System,
       Post => (if Is_Current_Output (File) then Col'Result = Wide_Generic.Col);

API 080

Col (declaration) — The current output's column.

Declared interface:

function Col return Positive_Count
  with Global => File_System;

API 081

Line (declaration) — The file's line.

Declared interface:

function Line (File : File_Type) return Positive_Count
  with Pre => Is_Open (File), Global => File_System,
       Post => (if Is_Current_Output (File) then Line'Result = Wide_Generic.Line);

API 082

Line (declaration) — The current output's line.

Declared interface:

function Line return Positive_Count
  with Global => File_System;

API 083

Page (declaration) — The file's page.

Declared interface:

function Page (File : File_Type) return Positive_Count
  with Pre => Is_Open (File), Global => File_System,
       Post => (if Is_Current_Output (File) then Page'Result = Wide_Generic.Page);

API 084

Page (declaration) — The current output's page.

Declared interface:

function Page return Positive_Count
  with Global => File_System;

API 085

Get (declaration) — The next character, line and page terminators skipped; End_Error at the end.

Declared interface:

procedure Get (File : File_Type; Item : out Char)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                             End_Error => Settings = Settings'Old);

API 086

Get (declaration) — The same from the current input.

Declared interface:

procedure Get (Item : out Char)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old);

API 087

Put (declaration) — A character, after a line terminator when the line is full.

Declared interface:

procedure Put (File : File_Type; Item : Char)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 088

Put (declaration) — A character on the current output.

Declared interface:

procedure Put (Item : Char)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 089

Look_Ahead (declaration) — The next character, not taken, or End_Of_Line when a line terminator or the end comes next.

Declared interface:

procedure Look_Ahead (File : File_Type; Item : out Char; End_Of_Line : out Boolean)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) /= In_File);

API 090

Look_Ahead (declaration) — The same on the current input.

Declared interface:

procedure Look_Ahead (Item : out Char; End_Of_Line : out Boolean)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 091

Get (declaration) — Item'Length characters, read as Get reads one; End_Error at the end.

Declared interface:

procedure Get (File : File_Type; Item : out Text)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                             End_Error => Settings = Settings'Old);

API 092

Get (declaration) — The same from the current input.

Declared interface:

procedure Get (Item : out Text)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old);

API 093

Put (declaration) — A string's characters.

Declared interface:

procedure Put (File : File_Type; Item : Text)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 094

Put (declaration) — A string on the current output.

Declared interface:

procedure Put (Item : Text)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 095

Put_Line (declaration) — A string and a line terminator.

Declared interface:

procedure Put_Line (File : File_Type; Item : Text)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) = In_File);

API 096

Put_Line (declaration) — The same on the current output.

Declared interface:

procedure Put_Line (Item : Text)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old;

API 097

Get_Line (declaration) — A line's characters to Item from Item'First, Last the last one's index (Item'First - 1 for none), the terminator skipped when it is reached (not when Item fills just before it); End_Error when the file is at its end on entry (an empty Item reads nothing).

Declared interface:

procedure Get_Line (File : File_Type; Item : out Text; Last : out Natural)
  with Pre => Is_Open (File) and then Mode (File) = In_File and then Item'First > 0,
       Post => Settings = Settings'Old
               and then (if Item'Length > 0 then Last in Item'First - 1 .. Item'Last else Last = Item'First - 1),
       Global => (In_Out => File_System),
       Exceptional_Cases => (End_Error => Settings = Settings'Old and End_Of_File (File)'Old);

API 098

Get_Line (declaration) — The same from the current input.

Declared interface:

procedure Get_Line (Item : out Text; Last : out Natural)
  with Pre => Item'First > 0,
       Post => Settings = Settings'Old
               and then (if Item'Length > 0 then Last in Item'First - 1 .. Item'Last else Last = Item'First - 1),
       Global => (In_Out => File_System),
       Exceptional_Cases => (End_Error => Settings = Settings'Old and End_Of_File'Old);

API 099

Get_Line (declaration) — A whole line of the current input, of any length: a function with side effects, called as a declaration's or an assignment's value; a line must be left to read (not End_Of_File).

Declared interface:

function Get_Line return Text
  with Side_Effects, Pre => not End_Of_File, Global => (In_Out => File_System),
       Post => Settings = Settings'Old
               and then Get_Line'Result'Length < Verada.Storage.Length_Bound;

API 100

Get_Line (declaration) — A whole line of a file, likewise.

Declared interface:

function Get_Line (File : File_Type) return Text
  with Side_Effects, Pre => Is_Open (File) and then Mode (File) = In_File and then not End_Of_File (File),
       Global => (In_Out => File_System),
       Post => Settings = Settings'Old
               and then Get_Line'Result'Length < Verada.Storage.Length_Bound;

API 101

Get_Immediate (declaration) — The next character as it is, a terminator's too; End_Error at the end.

Declared interface:

procedure Get_Immediate (File : File_Type; Item : out Char)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                             End_Error => Settings = Settings'Old);

API 102

Get_Immediate (declaration) — The same from the current input.

Declared interface:

procedure Get_Immediate (Item : out Char)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old);

API 103

Get_Immediate (declaration) — The same without waiting: Available is False when no character has arrived (only standard input waits).

Declared interface:

procedure Get_Immediate (File : File_Type; Item : out Char; Available : out Boolean)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (Status_Error => not Is_Open (File),
                             Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                             End_Error => Settings = Settings'Old);

API 104

Get_Immediate (declaration) — The same on the current input.

Declared interface:

procedure Get_Immediate (Item : out Char; Available : out Boolean)
  with Global => (In_Out => File_System),
       Post => Settings = Settings'Old,
       Exceptional_Cases => (End_Error => Settings = Settings'Old);

API 105

Num (declaration) — Integer_IO: Get and Put of an integer type's values, in a base from 2 to 16, on a file, the current input and output, or a string; Get reads as 'Value does (Verada.Scanning). Put writes the item whole (RM A.10.6(8)): on a line with a length, on a new line when it does not fit in what is left of it, and Layout_Error, nothing written, when Put_Length is beyond the line length.

Declared interface:

generic
   type Num is range <>;
package Integer_IO is
   Default_Width : Field := Num'Width;
   Default_Base : Number_Base := 10;

   procedure Get (File : File_Type; Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                                Data_Error | End_Error => Settings = Settings'Old);
   procedure Get (Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Data_Error | End_Error => Settings = Settings'Old);

   --  (for contracts: how many characters Put writes for Item, Width and Base)
   function Put_Length (Item : Num; Width : Field; Base : Number_Base) return Count
     with Ghost, Global => null,
          Post => Put_Length'Result >= Count (Width) and then Put_Length'Result <= Count (Integer'Max (Width, 133));

   procedure Put (File : File_Type; Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) = In_File,
                                Layout_Error => Settings = Settings'Old
                                                and (Line_Bound (File)'Old /= 0
                                                     and then Put_Length (Item, Width, Base) > Line_Bound (File)'Old));
   procedure Put (Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Layout_Error => Settings = Settings'Old
                                                and (Count'(Line_Length)'Old /= 0
                                                     and then Put_Length (Item, Width, Base) > Count'(Line_Length)'Old));

   procedure Get (From : Text; Item : out Num; Last : out Positive)
     with Global => null,
          Post => Last in From'Range,
          Exceptional_Cases => (Data_Error | End_Error => True);
   procedure Put (To : out Text; Item : Num; Base : Number_Base := Default_Base)
     with Global => null,
          Exceptional_Cases => (Layout_Error => True);
end Integer_IO;

API 106

Num (declaration) — Modular_IO: the same for a modular type.

Declared interface:

generic
   type Num is mod <>;
package Modular_IO is
   Default_Width : Field := Num'Width;
   Default_Base : Number_Base := 10;

   procedure Get (File : File_Type; Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                                Data_Error | End_Error => Settings = Settings'Old);
   procedure Get (Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Data_Error | End_Error => Settings = Settings'Old);

   --  (for contracts: how many characters Put writes for Item, Width and Base)
   function Put_Length (Item : Num; Width : Field; Base : Number_Base) return Count
     with Ghost, Global => null,
          Post => Put_Length'Result >= Count (Width) and then Put_Length'Result <= Count (Integer'Max (Width, 133));

   procedure Put (File : File_Type; Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) = In_File,
                                Layout_Error => Settings = Settings'Old
                                                and (Line_Bound (File)'Old /= 0
                                                     and then Put_Length (Item, Width, Base) > Line_Bound (File)'Old));
   procedure Put (Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Layout_Error => Settings = Settings'Old
                                                and (Count'(Line_Length)'Old /= 0
                                                     and then Put_Length (Item, Width, Base) > Count'(Line_Length)'Old));

   procedure Get (From : Text; Item : out Num; Last : out Positive)
     with Global => null,
          Post => Last in From'Range,
          Exceptional_Cases => (Data_Error | End_Error => True);
   procedure Put (To : out Text; Item : Num; Base : Number_Base := Default_Base)
     with Global => null,
          Exceptional_Cases => (Layout_Error => True);
end Modular_IO;

API 107

Num (declaration) — Float_IO: Get and Put of a floating point type's values, written with Fore, Aft and Exp, its digits correctly rounded. Put writes the item whole (RM A.10.6(8)): on a line with a length, on a new line when it does not fit in what is left of it, and Layout_Error, nothing written, when Put_Length is beyond the line length.

Declared interface:

generic
   type Num is digits <>;
package Float_IO is
   Default_Fore : Field := 2;
   Default_Aft : Field := Num'Digits - 1;
   Default_Exp : Field := 3;

   procedure Get (File : File_Type; Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                                Data_Error | End_Error => Settings = Settings'Old);
   procedure Get (Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Data_Error | End_Error => Settings = Settings'Old);

   --  (for contracts: how many characters Put writes for Item, Fore, Aft and Exp)
   function Put_Length (Item : Num; Fore, Aft, Exp : Field) return Count
     with Ghost, Global => null;

   procedure Put (File : File_Type; Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) = In_File,
                                Layout_Error => Settings = Settings'Old
                                                and (Line_Bound (File)'Old /= 0
                                                     and then Put_Length (Item, Fore, Aft, Exp) > Line_Bound (File)'Old));
   procedure Put (Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Layout_Error => Settings = Settings'Old
                                                and (Count'(Line_Length)'Old /= 0
                                                     and then Put_Length (Item, Fore, Aft, Exp) > Count'(Line_Length)'Old));

   procedure Get (From : Text; Item : out Num; Last : out Positive)
     with Global => null,
          Post => Last in From'Range,
          Exceptional_Cases => (Data_Error | End_Error => True);
   procedure Put (To : out Text; Item : Num; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => null,
          Exceptional_Cases => (Layout_Error => True);
end Float_IO;

API 108

Num (declaration) — Fixed_IO: Get and Put of a fixed-point type's values, written with Fore, Aft and Exp, its digits exact and rounded to the nearest (halves away from zero); a value read is truncated to a multiple of the small. Put writes the item whole (RM A.10.6(8)): on a line with a length, on a new line when it does not fit in what is left of it, and Layout_Error, nothing written, when Put_Length is beyond the line length.

Declared interface:

generic
   type Num is delta <>;
package Fixed_IO is
   Default_Fore : Field := Num'Fore;
   Default_Aft : Field := Num'Aft;
   Default_Exp : Field := 0;

   procedure Get (File : File_Type; Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                                Data_Error | End_Error => Settings = Settings'Old);
   procedure Get (Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Data_Error | End_Error => Settings = Settings'Old);

   --  (for contracts: how many characters Put writes for Item, Fore, Aft and Exp)
   function Put_Length (Item : Num; Fore, Aft, Exp : Field) return Count
     with Ghost, Global => null;

   procedure Put (File : File_Type; Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) = In_File,
                                Layout_Error => Settings = Settings'Old
                                                and (Line_Bound (File)'Old /= 0
                                                     and then Put_Length (Item, Fore, Aft, Exp) > Line_Bound (File)'Old));
   procedure Put (Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Layout_Error => Settings = Settings'Old
                                                and (Count'(Line_Length)'Old /= 0
                                                     and then Put_Length (Item, Fore, Aft, Exp) > Count'(Line_Length)'Old));

   procedure Get (From : Text; Item : out Num; Last : out Positive)
     with Global => null,
          Post => Last in From'Range,
          Exceptional_Cases => (Data_Error | End_Error => True);
   procedure Put (To : out Text; Item : Num; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => null,
          Exceptional_Cases => (Layout_Error => True);
end Fixed_IO;

API 109

Num (declaration) — Decimal_IO: Get and Put of a decimal fixed-point type's values, as Fixed_IO's.

Declared interface:

generic
   type Num is delta <> digits <>;
package Decimal_IO is
   Default_Fore : Field := Num'Fore;
   Default_Aft : Field := Num'Aft;
   Default_Exp : Field := 0;

   procedure Get (File : File_Type; Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                                Data_Error | End_Error => Settings = Settings'Old);
   procedure Get (Item : out Num; Width : Field := 0)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Data_Error | End_Error => Settings = Settings'Old);

   --  (for contracts: how many characters Put writes for Item, Fore, Aft and Exp)
   function Put_Length (Item : Num; Fore, Aft, Exp : Field) return Count
     with Ghost, Global => null;

   procedure Put (File : File_Type; Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) = In_File,
                                Layout_Error => Settings = Settings'Old
                                                and (Line_Bound (File)'Old /= 0
                                                     and then Put_Length (Item, Fore, Aft, Exp) > Line_Bound (File)'Old));
   procedure Put (Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Layout_Error => Settings = Settings'Old
                                                and (Count'(Line_Length)'Old /= 0
                                                     and then Put_Length (Item, Fore, Aft, Exp) > Count'(Line_Length)'Old));

   procedure Get (From : Text; Item : out Num; Last : out Positive)
     with Global => null,
          Post => Last in From'Range,
          Exceptional_Cases => (Data_Error | End_Error => True);
   procedure Put (To : out Text; Item : Num; Aft : Field := Default_Aft; Exp : Field := Default_Exp)
     with Global => null,
          Exceptional_Cases => (Layout_Error => True);
end Decimal_IO;

API 110

Enum (declaration) — Enumeration_IO: Get and Put of an enumeration type's literals, written in Set's case, left-justified. Put writes the item whole (RM A.10.6(8)): on a line with a length, on a new line when it does not fit in what is left of it, and Layout_Error, nothing written, when Put_Length is beyond the line length.

Declared interface:

generic
   type Enum is (<>);
package Enumeration_IO is
   Default_Width : Field := 0;
   Default_Setting : Type_Set := Upper_Case;

   procedure Get (File : File_Type; Item : out Enum)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) /= In_File,
                                Data_Error | End_Error => Settings = Settings'Old);
   procedure Get (Item : out Enum)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Data_Error | End_Error => Settings = Settings'Old);

   --  (for contracts: how many characters Put writes for Item and Width)
   function Put_Length (Item : Enum; Width : Field) return Count
     with Ghost, Global => null,
          Post => Put_Length'Result >= Count (Width);

   procedure Put (File : File_Type; Item : Enum; Width : Field := Default_Width; Set : Type_Set := Default_Setting)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Status_Error => not Is_Open (File),
                                Mode_Error => Is_Open (File) and then Mode (File) = In_File,
                                Layout_Error => Settings = Settings'Old
                                                and (Line_Bound (File)'Old /= 0
                                                     and then Put_Length (Item, Width) > Line_Bound (File)'Old));
   procedure Put (Item : Enum; Width : Field := Default_Width; Set : Type_Set := Default_Setting)
     with Global => (In_Out => File_System),
          Post => Settings = Settings'Old,
          Exceptional_Cases => (Layout_Error => Settings = Settings'Old
                                                and (Count'(Line_Length)'Old /= 0
                                                     and then Put_Length (Item, Width) > Count'(Line_Length)'Old));

   procedure Get (From : Text; Item : out Enum; Last : out Positive)
     with Global => null,
          Post => Last in From'Range,
          Exceptional_Cases => (Data_Error | End_Error => True);
   procedure Put (To : out Text; Item : Enum; Set : Type_Set := Default_Setting)
     with Global => null,
          Exceptional_Cases => (Layout_Error => True);
end Enumeration_IO;