--  Ada.Strings.Fixed's operations as RM A.4.3 defines them: Move's fitting and padding,
--  searches from a position, counts, tokens, translations and the slice operations, in both
--  their function and procedure forms; Ada.Strings.Maps' new operations; and a bounded string.
--  (Count is qualified: Ada.Text_IO's type Count hides the use-visible functions, RM 8.4(11).)
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Bounded;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
   package B10 is new Ada.Strings.Bounded.Generic_Bounded_Length (10);
   T : String (1 .. 7);
   S : String (1 .. 9) := "abcabcabc";
   First : Positive;
   Last : Natural;
   Upper : constant Character_Mapping := To_Mapping ("abc", "ABC");
   R : constant Character_Ranges := To_Ranges (To_Set ("abcxz") or To_Set (Character_Range'(Low => 'e', High => 'g')));
   X : B10.Bounded_String := B10.To_Bounded_String ("hello");
begin
   Move ("abc", T, Pad => '.');
   Put_Line ("[" & T & "]");
   Move ("abc", T, Justify => Right, Pad => '.');
   Put_Line ("[" & T & "]");
   Move ("abcd", T, Justify => Center, Pad => '.');
   Put_Line ("[" & T & "]");
   Move ("0123456789", T, Drop => Left);
   Put_Line ("[" & T & "]");
   Move ("0123456789", T, Drop => Right);
   Put_Line ("[" & T & "]");
   Move ("abcdefg   ", T, Drop => Error);
   Put_Line ("[" & T & "]");
   Put_Line (Natural'Image (Index (S, "bc")) & Natural'Image (Index (S, "bc", Backward))
             & Natural'Image (Index (S, "bc", 4)) & Natural'Image (Index (S, "bc", 7, Backward))
             & Natural'Image (Index (S, "BC", Forward, Upper)));
   Put_Line (Natural'Image (Index (S, To_Set ("c"))) & Natural'Image (Index (S, To_Set ("a"), Outside, Backward))
             & Natural'Image (Index_Non_Blank ("  x ", 4, Backward)));
   Put_Line (Natural'Image (Fixed.Count (S, "abc")) & Natural'Image (Fixed.Count ("aaaa", "aa")) & Natural'Image (Fixed.Count (S, To_Set ("ab"))));
   Find_Token ("  word  more", To_Set (' '), Outside, First, Last);
   Put_Line (Positive'Image (First) & Natural'Image (Last));
   Find_Token ("  word  more", To_Set (' '), 7, Outside, First, Last);
   Put_Line (Positive'Image (First) & Natural'Image (Last));
   Put_Line (Translate (S, Upper));
   Translate (S, Upper);
   Put_Line (S);
   Put (Replace_Slice ("abcdef", 2, 4, "XY") & " ");
   Put (Replace_Slice ("abcdef", 3, 2, "XY") & " ");
   Put (Insert ("abc", 4, "!") & " ");
   Put (Overwrite ("abcdef", 5, "XYZ") & " ");
   Put (Delete ("abcdef", 2, 3) & " ");
   Put_Line (Delete ("abc", 3, 2));
   T := "abcdefg";
   Delete (T, 2, 3, Justify => Right, Pad => '-');
   Put_Line (T);
   T := "  ab   ";
   Trim (T, Both, Justify => Center, Pad => '*');
   Put_Line (T);
   Put_Line ("[" & Trim ("xxabcyy", To_Set ("x"), To_Set ("y")) & "]" & "[" & Head ("ab", 4, '*') & "][" & Tail ("ab", 4, '*') & "]["
             & Tail ("abcdef", 3) & "][" & 3 * "ab" & "]");
   for K in R'Range loop
      Put (R (K).Low & R (K).High & " ");
   end loop;
   New_Line;
   Put_Line (To_Sequence (To_Set ("hello") xor To_Set ("world")) & " " & To_Domain (Upper) & To_Range (Upper));
   Put_Line (Boolean'Image (To_Set ("ab") <= To_Set ("abc")) & " " & Boolean'Image (To_Set ("ab") = To_Set ("ba")));
   B10.Append (X, ", you");
   Put_Line (B10.To_String (X) & Natural'Image (B10.Length (X)) & Natural'Image (B10.Index (X, "o", Backward)));
   X := B10.Replace_Slice (X, 1, 5, "bye");
   Put_Line (B10.To_String (X) & " " & B10.To_String (B10.Trim (B10."&" ("  ", X), Left)) & " " & Boolean'Image (B10."=" (X, "bye, you")));
   Put_Line (B10.To_String (B10.Head (X, 3)) & B10.To_String (B10.Tail (X, 3)) & B10.Slice (X, 2, 4) & B10.Element (X, 1));
end Main;
