!standard A.10.11(1) 05-05-05 AI95-00428/02
!class amendment 05-04-10
!status Amendment 200Y 05-05-05
!status WG9 Approved 06-06-09
!status ARG Approved 10-0-1 05-04-16
!status work item 05-04-10
!status received 05-04-10
!priority High
!difficulty Easy
!subject Input-output for bounded strings
!summary
A package for the input and output of bounded strings is added as a generic
child of Text_IO.
!problem
AI-301 adds a package for the input-output of unbounded strings. It claims
that it is hard for bounded strings but it was probably the case that the
ARG was too idle to do it. Probably because it was too hot in Vienna.
The asymmetry of providing the facility for unbounded strings but not
for bounded strings is offensive.
!proposal
(See summary.)
!wording
Add a new clause:
A.10.12 Input-output for Bounded Strings
The package Text_IO.Bounded_IO provides input-output in human-readable
form for Bounded_Strings.
Static Semantics
The generic library package Text_IO.Bounded_IO has the following
declaration:
with Ada.Strings.Bounded;
generic
with package Bounded is
new Ada.Strings.Bounded.Generic_Bounded_Length (<>);
package Ada.Text_IO.Bounded_IO is
procedure Put
(File : in File_Type;
Item : in Bounded.Bounded_String);
procedure Put
(Item : in Bounded.Bounded_String);
procedure Put_Line
(File : in Text_IO.File_Type;
Item : in Bounded.Bounded_String);
procedure Put_Line
(Item : in Bounded.Bounded_String);
function Get_Line
(File : in File_Type)
return Bounded.Bounded_String;
function Get_Line
return Bounded.Bounded_String;
procedure Get_Line
(File : in File_Type; Item : out Bounded.Bounded_String);
procedure Get_Line
(Item : out Bounded.Bounded_String);
end Ada.Text_IO.Bounded_IO;
For an item of type Bounded_String exported from a package Bounded
being an instantiation of Strings.Bounded.Generic_Bounded_Length, the
following subprograms are provided:
procedure Put
(File : in File_Type;
Item : in Bounded.Bounded_String);
Equivalent to Text_IO.Put (File, Bounded.To_String(Item));
procedure Put
(Item : in Bounded.Bounded_String);
Equivalent to Text_IO.Put (Bounded.To_String(Item));
procedure Put_Line
(File : in Text_IO.File_Type;
Item : in Bounded.Bounded_String);
Equivalent to Text_IO.Put_Line (File, Bounded.To_String(Item));
procedure Put_Line
(Item : in Bounded.Bounded_String);
Equivalent to Text_IO.Put_Line (Bounded.To_String(Item));
function Get_Line
(File : in File_Type)
return Bounded.Bounded_String;
Returns Bounded.To_Bounded_String(Text_IO.Get_Line(File));
function Get_Line
return Bounded.Bounded_String;
Returns Bounded.To_Bounded_String(Text_IO.Get_Line);
procedure Get_Line
(File : in File_Type; Item : out Bounded.Bounded_String);
Equivalent to Item := Get_Line (File);
procedure Get_Line
(Item : out Bounded.Bounded_String);
Equivalent to Item := Get_Line;
Add after A.11(3):
The specification of package Wide_Text_IO.Wide_Bounded_IO is the same as
that for Text_IO.Bounded_IO, except that any occurrence of Bounded_String
is replaced by Wide_Bounded_String, and any occurrence of package Bounded
is replaced by Wide_Bounded. The specification of package
Wide_Wide_Text_IO.Wide_Wide_Bounded_IO is the same as
that for Text_IO.Bounded_IO, except that any occurrence of Bounded_String
is replaced by Wide_Wide_Bounded_String, and any occurrence of package Bounded
is replaced by Wide_Wide_Bounded.
Amend the AARM notes in A.11 accordingly.
!discussion
This follows the pattern of Unbounded_IO with obvious changes because of
the genericity of bounded strings.
!example
(See discussion.)
!corrigendum A.10.11(01)
@dinsc
The package Text_IO.Bounded_IO provides input-output in
human-readable form for Bounded_Strings.
@i<@s8>
The generic library package Text_IO.Bounded_IO has the following declaration:
@xcode<@b Ada.Strings.Bounded;
@b
@b Bounded @b
@b Ada.Strings.Bounded.Generic_Bounded_Length (<@>);
@b Ada.Text_IO.Bounded_IO @b
@b Put
(File : @b File_Type;
Item : @b Bounded.Bounded_String);
@b Put
(Item : @b Bounded.Bounded_String);
@b Put_Line
(File : @b File_Type;
Item : @b Bounded.Bounded_String);
@b Put_Line
(Item : @b Bounded.Bounded_String);
@b Get_Line
(File : @b File_Type)
@b Bounded.Bounded_String;
@b Get_Line
@b Bounded.Bounded_String;
@b Get_Line
(File : @b File_Type; Item : @b Bounded.Bounded_String);
@b Get_Line
(Item : @b Bounded.Bounded_String);
@b Ada.Text_IO.Bounded_IO;>
For an item of type Bounded_String, the following subprograms are provided:
@xcode<@b Put
(File : @b File_Type;
Item : @b Bounded.Bounded_String);>
@xindent
@xcode<@b Put
(Item : @b Bounded.Bounded_String);>
@xindent
@xcode<@b Put_Line
(File : @b File_Type;
Item : @b Bounded.Bounded_String);>
@xindent
@xcode<@b Put_Line
(Item : @b Bounded.Bounded_String);>
@xindent
@xcode<@b Get_Line
(File : @b File_Type)
@b Bounded.Bounded_String;>
@xindent
@xcode<@b Get_Line
@b Bounded.Bounded_String;>
@xindent
@xcode<@b Get_Line
(File : @b File_Type; Item : @b Bounded.Bounded_String);>
@xindent
@xcode<@b Get_Line
(Item : @b Bounded.Bounded_String);>
@xindent
!corrigendum A.11(3)
@dinsa
Nongeneric equivalents of Wide_Text_IO.Integer_IO and Wide_Text_IO.Float_IO are
provided (as for Text_IO) for each predefined numeric type, with names such as
Ada.Integer_Wide_Text_IO, Ada.Long_Integer_Wide_Text_IO,
Ada.Float_Wide_Text_IO, Ada.Long_Float_Wide_Text_IO.
@dinst
The specification of package Wide_Text_IO.Wide_Bounded_IO is the same as
that for Text_IO.Bounded_IO, except that any occurrence of Bounded_String
is replaced by Wide_Bounded_String, and any occurrence of package Bounded
is replaced by Wide_Bounded.
!ACATS test
!appendix
*************************************************************