--  Verada predefined library: Ada.Strings.Wide_Wide_Fixed (Ada RM A.4.8), the subset of
--  Ada.Strings.Fixed that Verada has, for Wide_Wide_String, written in Ada and proved like any
--  other unit. Results are indexed from 1.
package Ada.Strings.Wide_Wide_Fixed is
   --  the first (or last) place where Pattern occurs in Source, or 0 when it does not occur
   function Index (Source : Wide_Wide_String; Pattern : Wide_Wide_String; Going : Direction := Forward) return Natural
     with Global => null,
          Pre => Pattern'Length > 0,
          Post => (if Index'Result = 0
                   then (if Pattern'Length <= Source'Length
                         then (for all I in Source'First .. Source'Last - (Pattern'Length - 1) => Source (I .. I + (Pattern'Length - 1)) /= Pattern))
                   else Index'Result in Source'Range
                        and then Index'Result <= Source'Last - (Pattern'Length - 1)
                        and then Source (Index'Result .. Index'Result + (Pattern'Length - 1)) = Pattern);

   --  the first (or last) character of Source that is not a space, or 0
   function Index_Non_Blank (Source : Wide_Wide_String; Going : Direction := Forward) return Natural
     with Global => null,
          Post => (if Index_Non_Blank'Result = 0
                   then (for all I in Source'Range => Source (I) = Wide_Wide_Space)
                   else Index_Non_Blank'Result in Source'Range
                        and then Source (Index_Non_Blank'Result) /= Wide_Wide_Space
                        and then (if Going = Forward
                                  then (for all I in Source'Range => (if I < Index_Non_Blank'Result then Source (I) = Wide_Wide_Space))
                                  else (for all I in Source'Range => (if I > Index_Non_Blank'Result then Source (I) = Wide_Wide_Space))));

   --  Source without its leading spaces, trailing spaces or both
   function Trim (Source : Wide_Wide_String; Side : Trim_End) return Wide_Wide_String
     with Global => null,
          Post => Trim'Result'Length <= Source'Length;

   --  the first Count characters of Source, padded with Pad
   function Head (Source : Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) return Wide_Wide_String
     with Global => null,
          Post => Head'Result'Length = Count;

   --  the last Count characters of Source, padded on the left with Pad
   function Tail (Source : Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) return Wide_Wide_String
     with Global => null,
          Post => Tail'Result'Length = Count;

   --  Left copies of Right
   function "*" (Left : Natural; Right : Wide_Wide_Character) return Wide_Wide_String
     with Global => null,
          Post => "*"'Result'Length = Left;
end Ada.Strings.Wide_Wide_Fixed;
