diff options
Diffstat (limited to 'src/deck_io.adb')
-rw-r--r-- | src/deck_io.adb | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/deck_io.adb b/src/deck_io.adb index 9e5b4b7..8a3637e 100644 --- a/src/deck_io.adb +++ b/src/deck_io.adb @@ -8,6 +8,7 @@ with Ada.Strings.Maps, Ada.Text_IO, CSV, + FMD, GNAT.Regpat, GNATCOLL.JSON, UnZip; @@ -377,6 +378,7 @@ package body Deck_IO is end if; end loop; Close (File_Handle); + Counter := Counter + 1; end loop; end Write_CSV; @@ -391,8 +393,44 @@ package body Deck_IO is Media : in Media_Maps.Map; Overwrite : in Boolean := False) is + procedure Put_Fields is new FMD.Put_Fields (Field_Ordinal, Field_ID, Field_ID_Vectors); + procedure Put_Pack is new FMD.Put_Pack (Field_Ordinal, Field_ID, Field_ID_Vectors); + procedure Put_Entry is new FMD.Put_Entry (Field_Ordinal, Field, Field_Vectors); + + Counter : Positive := 1; + Outname : SU.Unbounded_String; + File_Handle : File_Type; + Entry_Size : Positive; begin - null; + for C in Models.Iterate loop + Outname := Compose_Name (Directory, Basename, "fmd", Counter); + if FD.Exists (-Outname) then + if not Overwrite then + raise FD.Name_Error; + else + FD.Delete_File (-Outname); + end if; + end if; + Create (File_Handle, Out_File, -Outname); + Entry_Size := Positive (Model_Maps.Element (C).Fields.Length); + FMD.Put_Header (File_Handle); + Put_Fields (File_Handle, Model_Maps.Element (C).Fields); + FMD.Start_Pack_Section (File_Handle); + for Tmpl of Model_Maps.Element (C).Templates loop + Put_Pack (File_Handle, Tmpl.Question, Tmpl.Answer); + end loop; + FMD.End_Pack_Section (File_Handle); + FMD.Start_Entry_Section (File_Handle); + for N of Notes loop + if N.Model = Model_Maps.Key (C) then + Put_Entry (File_Handle, N.Fields, Entry_Size); + end if; + end loop; + FMD.End_Entry_Section (File_Handle); + FMD.Put_Footer (File_Handle); + Close (File_Handle); + Counter := Counter + 1; + end loop; end Write_FMD; |