From 5a8a3749f46828f1db5cbd6bd55d22ea9e188ab1 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 5 Feb 2017 00:43:59 +1100 Subject: CSV package done, sketched out Candidates package --- src/candidates.ads | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/candidates.ads (limited to 'src/candidates.ads') diff --git a/src/candidates.ads b/src/candidates.ads new file mode 100644 index 0000000..90b2425 --- /dev/null +++ b/src/candidates.ads @@ -0,0 +1,75 @@ + + +with Ada.Containers.Vectors; + + +package Candidates is + + + type Candidate is private; + type CandidateID is Natural; + + + type Above_Line_Ballot is private; + type Below_Line_Ballot is private; + + + package Candidate_Vectors is new Ada.Containers.Vectors + (Index_Type => CandidateID, + Element_Type => Candidate); + + + package CandidateID_Vectors is new Ada.Containers.Vectors + (Index_Type => Natural, + Element_Type => CandidateID); + + + procedure Read_Candidates + (Data_File, State : in String; + Above_Ballot : out Above_Line_Ballot; + Below_Ballot : out Below_Line_Ballot; + Candidate_List : out Candidate_Vectors.Vector); + + + function Lookup + (Above_Ballot : in Above_Line_Ballot; + Index : in Natural) + return CandidateID_Vectors.Vector; + + + function Lookup + (Below_Ballot : in Below_Line_Ballot; + Index : in Natural) + return CandidateID; + + +private + + + type Candidate is record + ID : CandidateID; + First_Name : String; + Last_Name : String; + Group : String; + Group_Rank : Natural; + Party : String; + end record; + + + package Above_Line_Ballots is new Ada.Containers.Vectors + (Index_Type => Natural, + Element_Type => CandidateID_Vectors.Vector); + + + package Below_Line_Ballots is new Ada.Containers.Vectors + (Index_Type => Natural, + Element_Type => CandidateID); + + + type Above_Line_Ballot is Above_Line_Ballots.Vector; + type Below_Line_Ballot is Below_Line_Ballots.Vector; + + +end Candidates; + + -- cgit