Ada Programming/Libraries/Ada.Strings.Unbounded

From Wikibooks, open books for an open world
Jump to: navigation, search

Ada Lovelace 1838.jpg

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

Usage[edit]

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 also[edit]

Wikibook[edit]

Ada Reference Manual[edit]

Ada 95[edit]

Ada 2005[edit]