From 866565c42134dbe8828c9a9b8140a90598df4069 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Sat, 6 Nov 2021 00:53:55 +1300 Subject: Factored out deck datatypes into their own package --- src/fmd.adb | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/fmd.adb') diff --git a/src/fmd.adb b/src/fmd.adb index cd512cb..9fbb4e5 100644 --- a/src/fmd.adb +++ b/src/fmd.adb @@ -5,7 +5,8 @@ with Ada.Characters.Latin_1, Ada.Strings.Fixed, Ada.Strings.Maps, - Ada.Text_IO; + Ada.Text_IO, + Datatypes; use @@ -42,13 +43,13 @@ package body FMD is procedure Put_Fields (File_Handle : in Ada.Text_IO.File_Type; - Field_IDs : in Data_Vectors.Vector) + Field_IDs : in Datatypes.Field_ID_Vector) is Text : SU.Unbounded_String; begin Put_Line (File_Handle, (4 * ' ') & ""); for FID of Field_IDs loop - Text := Prep (To_Unbounded_String (FID)); + Text := Prep (SU.Unbounded_String (FID)); Put_Line (File_Handle, (8 * ' ') & "" & (-Text) & ""); end loop; Put_Line (File_Handle, (4 * ' ') & ""); @@ -66,21 +67,23 @@ package body FMD is procedure Put_Pack (File_Handle : in Ada.Text_IO.File_Type; - Q_Data : in Data_Vectors.Vector; - A_Data : in Data_Vectors.Vector) + Q_Data : in Datatypes.Field_ID_Vector; + A_Data : in Datatypes.Field_ID_Vector) is Text : SU.Unbounded_String; begin Put_Line (File_Handle, (8 * ' ') & ""); - Text := Prep (To_Unbounded_String (Q_Data.First_Element)); + Text := Prep (SU.Unbounded_String (Q_Data.First_Element)); Put_Line (File_Handle, (12 * ' ') & "" & (-Text) & ""); - for I in Vector_Index range Vector_Index'Succ (Q_Data.First_Index) .. Q_Data.Last_Index loop - Text := Prep (To_Unbounded_String (Q_Data.Element (I))); + for I in Datatypes.Field_Ordinal range + Datatypes.Field_Ordinal'Succ (Q_Data.First_Index) .. Q_Data.Last_Index + loop + Text := Prep (SU.Unbounded_String (Q_Data.Element (I))); -- Fresh Memory unfortunately cannot cope with multiple question fields Put_Line (File_Handle, (12 * ' ') & ""); end loop; for FID of A_Data loop - Text := Prep (To_Unbounded_String (FID)); + Text := Prep (SU.Unbounded_String (FID)); Put_Line (File_Handle, (12 * ' ') & "" & (-Text) & ""); end loop; Put_Line (File_Handle, (8 * ' ') & ""); @@ -105,22 +108,23 @@ package body FMD is procedure Put_Entry (File_Handle : in Ada.Text_IO.File_Type; - Data : in Data_Vectors.Vector; + Data : in Datatypes.Field_Vector; Quantity : in Positive) is + use type Datatypes.Field_Ordinal; Counter : Positive := 1; - Position : Vector_Index := Data.First_Index; + Position : Datatypes.Field_Ordinal := Data.First_Index; Text : SU.Unbounded_String; begin Put_Line (File_Handle, (8 * ' ') & ""); while Counter <= Quantity loop if Position <= Data.Last_Index then - Text := Prep (To_Unbounded_String (Data.Element (Position))); + Text := Prep (SU.Unbounded_String (Data.Element (Position))); Put_Line (File_Handle, (12 * ' ') & "" & (-Text) & ""); else Put_Line (File_Handle, (12 * ' ') & ""); end if; - Position := Vector_Index'Succ (Position); + Position := Datatypes.Field_Ordinal'Succ (Position); Counter := Counter + 1; end loop; Put_Line (File_Handle, (8 * ' ') & ""); -- cgit