Ada Programming/Libraries/Ada.Strings.Unbounded
< Ada Programming < LibrariesComputing » Computer Science » Computer Programming » Ada Programming

The package Ada.Strings.Unbounded defines the operations for unbounded string handling.
Usage
Ada.Strings.Unbounded is used in several places. Here some relevant extracts. As always you can follow the download links to see the full examples.
Conversion between unbounded and bounded strings:
with Ada.Strings.Unbounded; package SU renames Ada.Strings.Unbounded; X : SU.Unbounded_String := SU.To_Unbounded_String (CL.Argument (1)); T_IO.Put_Line (SU.To_String (X)); X := SU.To_Unbounded_String (CL.Argument (2)); T_IO.Put_Line (SU.To_String (X));
Another example:
with
Ada.Text_IO,
Ada.Integer_Text_IO,
Ada.Strings.Unbounded,
Ada.Text_IO.Unbounded_IO;
procedure User_Input2 is
S : Ada.Strings.Unbounded.Unbounded_String;
I : Integer;
begin
Ada.Text_IO.Put("Enter a string: ");
S := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line);
Ada.Text_IO.Put_Line(Ada.Strings.Unbounded.To_String(S));
Ada.Text_IO.Unbounded_IO.Put_Line(S);
Ada.Text_IO.Put("Enter an integer: ");
Ada.Integer_Text_IO.Get(I);
Ada.Text_IO.Put_Line(Integer'Image(I));
end User_Input2;
with Ada.Strings.Unbounded; package Str renames Ada.Strings.Unbounded; function Get_Line return Str.Unbounded_String; use type Str.Unbounded_String; Operation : Str.Unbounded_String; function Get_Line return Str.Unbounded_String is BufferSize : constant := 2000; Retval : Str.Unbounded_String := Str.Null_Unbounded_String; Item : String (1 .. BufferSize); Last : Natural; begin Get_Whole_Line : loop T_IO.Get_Line (Item => Item, Last => Last); Str.Append (Source => Retval, New_Item => Item (1 .. Last)); exit Get_Whole_Line when Last < Item'Last; end loop Get_Whole_Line; return Retval; end Get_Line;
See also
Wikibook
Ada Reference Manual
Ada 95
Ada 2005
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.