Ada Programming/Libraries/Ada.Strings.Unbounded
From Wikibooks, the open-content textbooks collection
Contents |
The package Ada.Strings.Unbounded defines the operations for unbounded string handling.
[edit] 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.
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));
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;

