with Ada.Containers.Vectors, Ada.Containers.Ordered_Maps, Ada.Strings.Unbounded; private with Ada.Finalization, SQLite3; package Deck_IO is package SU renames Ada.Strings.Unbounded; use type SU.Unbounded_String; type Deck_Handle is limited private; type Field_Ordinal is new Positive; type Field_ID is new SU.Unbounded_String; package Field_ID_Vectors is new Ada.Containers.Vectors (Index_Type => Field_Ordinal, Element_Type => Field_ID); type Template is record Question : Field_ID_Vectors.Vector; Answer : Field_ID_Vectors.Vector; end record; package Template_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Template); type Model_ID is new SU.Unbounded_String; type Model is record Fields : Field_ID_Vectors.Vector; Templates : Template_Vectors.Vector; end record; package Model_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Model_ID, Element_Type => Model); type Field is new SU.Unbounded_String; package Field_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Field); type Note is record Model : Model_ID; Fields : Field_Vectors.Vector; end record; package Note_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Note); function Matches (Models : in Model_Maps.Map; Notes : in Note_Vectors.Vector) return Boolean; type Media_ID is new SU.Unbounded_String; subtype Media_Name is SU.Unbounded_String; package Media_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Media_ID, Element_Type => Media_Name); procedure Read_Media_Map (Filename : in String; Media_Map : out Media_Maps.Map); procedure Open_Database (Filename : in String; Deck : in out Deck_Handle) with Post => Is_Open (Deck); function Is_Open (Deck : in Deck_Handle) return Boolean; procedure Close_Database (Deck : in out Deck_Handle) with Post => not Is_Open (Deck); procedure Query_Models (Deck : in out Deck_Handle; Models : out Model_Maps.Map) with Pre => Is_Open (Deck); procedure Query_Notes (Deck : in out Deck_Handle; Notes : out Note_Vectors.Vector) with Pre => Is_Open (Deck); procedure Write_CSV (Directory : in String; Basename : in String; Models : in Model_Maps.Map; Notes : in Note_Vectors.Vector) with Pre => Matches (Models, Notes); procedure Write_FMD (Directory : in String; Basename : in String; Models : in Model_Maps.Map; Notes : in Note_Vectors.Vector; Media : in Media_Maps.Map) with Pre => Matches (Models, Notes); private type Deck_Handle is new Ada.Finalization.Limited_Controlled with record SQL_Handle : SQLite3.SQLite3_DB; Status : SQLite3.Status_Code := SQLite3.SQLITE_OK; Opened : Boolean := False; Tempfile : SU.Unbounded_String := SU.To_Unbounded_String (""); end record; overriding procedure Finalize (This : in out Deck_Handle); end Deck_IO;