blob: c0c310f9cd048e1d35ec1e21a610177cc06c3905 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
private with Ada.Strings.Unbounded;
-- This source is licensed under Creative Commons CC0 v1.0.
--
-- To read the full text, see license.txt in the main directory of this repository
-- or go to https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt
--
-- For a human readable summary, go to https://creativecommons.org/publicdomain/zero/1.0/
package Candidates is
type State_Name is (ACT, NT, TAS, SA, WA, VIC, QLD, NSW);
type Candidate is private;
-- This is restricted to 255 values for memory conservation reasons.
-- Should fit into a single byte each when Pragma Pack is applied
-- to an array of them.
type CandidateID is new Positive range 1 .. 255;
subtype Extended_CandidateID is CandidateID'Base
range CandidateID'First - 1 .. CandidateID'Last;
No_Candidate : constant Extended_CandidateID := Extended_CandidateID'First;
-- The lack of getters/setters is intentional, to ensure that election
-- code cannot change Candidate data once initally read.
-- Returns the Candidate's fields in csv format for logging purposes.
function To_String
(Input_Candidate : in Candidate;
Delimiter : in Character := ',')
return String;
-- Returns field labels corresponding to the field order
-- used in To_String. Used for logging purposes.
function Candidate_Header
(Delimiter : in Character := ',')
return String;
-- Used for verbose console messages about a particular Candidate.
function Name_And_Party
(Input_Candidate : in Candidate)
return String;
private
package SU renames Ada.Strings.Unbounded;
type Candidate is record
First_Name : SU.Unbounded_String;
Last_Name : SU.Unbounded_String;
Group : SU.Unbounded_String;
Group_Rank : SU.Unbounded_String;
Party : SU.Unbounded_String;
end record;
end Candidates;
|