Last modified on 22 March 2013, at 15:22

Ada Programming/Libraries/Ada.Strings.Unbounded


Ada Lovelace 1838.jpg

The package Ada.Strings.Unbounded defines the operations for unbounded string handling.

UsageEdit

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.

File: show_commandline_4.adb (view, plain text, download page, browse all)
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));
File: numeric_4.adb (view, plain text, download page, browse all)
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 alsoEdit

WikibookEdit

Ada Reference ManualEdit

Ada 95Edit

Ada 2005Edit