diff options
Diffstat (limited to 'src/csv.adb')
-rw-r--r-- | src/csv.adb | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/csv.adb b/src/csv.adb index 9d4f498..036401b 100644 --- a/src/csv.adb +++ b/src/csv.adb @@ -5,7 +5,8 @@ with Ada.Characters.Latin_1, Ada.Strings.Fixed, Ada.Strings.Maps, - Ada.Text_IO; + Ada.Text_IO, + Datatypes; use @@ -63,24 +64,40 @@ package body CSV is end Put_Cell; + procedure Put_Header + (File_Handle : in Ada.Text_IO.File_Type; + Titles : in Datatypes.Field_ID_Vector) is + begin + for Position in Datatypes.Field_Ordinal range + Titles.First_Index .. Datatypes.Field_Ordinal'Pred (Titles.Last_Index) + loop + Put_Cell (File_Handle, SU.Unbounded_String (Titles.Element (Position))); + Put (File_Handle, Separator_Char); + end loop; + Put_Cell (File_Handle, SU.Unbounded_String (Titles.Last_Element)); + New_Line (File_Handle); + end Put_Header; + + procedure Put_Row (File_Handle : in Ada.Text_IO.File_Type; - Cells : in Data_Vectors.Vector; + Cells : in Datatypes.Field_Vector; Quantity : in Positive) is + use type Datatypes.Field_Ordinal; Counter : Positive := 1; - Position : Vector_Index := Cells.First_Index; + Position : Datatypes.Field_Ordinal := Cells.First_Index; begin while Counter < Quantity loop if Position <= Cells.Last_Index then - Put_Cell (File_Handle, To_Unbounded_String (Cells.Element (Position))); + Put_Cell (File_Handle, SU.Unbounded_String (Cells.Element (Position))); end if; Put (File_Handle, Separator_Char); - Position := Vector_Index'Succ (Position); + Position := Datatypes.Field_Ordinal'Succ (Position); Counter := Counter + 1; end loop; if Position <= Cells.Last_Index then - Put_Cell (File_Handle, To_Unbounded_String (Cells.Element (Position))); + Put_Cell (File_Handle, SU.Unbounded_String (Cells.Element (Position))); end if; New_Line (File_Handle); end Put_Row; |