tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,39 @@
with Ada.Strings.Unbounded;
with Config_File_Parser;
pragma Elaborate_All (Config_File_Parser);
package Config is
function TUS (S : String) return Ada.Strings.Unbounded.Unbounded_String
renames Ada.Strings.Unbounded.To_Unbounded_String;
-- Convenience rename. TUS is much shorter than To_Unbounded_String.
type Keys is (
FULLNAME,
FAVOURITEFRUIT,
NEEDSPEELING,
SEEDSREMOVED,
OTHERFAMILY);
-- These are the valid configuration keys.
type Defaults_Array is
array (Keys) of Ada.Strings.Unbounded.Unbounded_String;
-- The array type we'll use to hold our default configuration settings.
Defaults_Conf : Defaults_Array :=
(FULLNAME => TUS ("John Doe"),
FAVOURITEFRUIT => TUS ("blackberry"),
NEEDSPEELING => TUS ("False"),
SEEDSREMOVED => TUS ("False"),
OTHERFAMILY => TUS ("Daniel Defoe, Ada Byron"));
-- Default values for the Program object. These can be overwritten by
-- the contents of the rosetta.cfg file(see below).
package Rosetta_Config is new Config_File_Parser (
Keys => Keys,
Defaults_Array => Defaults_Array,
Defaults => Defaults_Conf,
Config_File => "rosetta.cfg");
-- Instantiate the Config configuration object.
end Config;

View file

@ -0,0 +1,24 @@
with Ada.Text_IO;
with Config; use Config;
procedure Read_Config is
use Ada.Text_IO;
use Rosetta_Config;
begin
New_Line;
Put_Line ("Reading Configuration File.");
Put_Line ("Fullname := " & Get (Key => FULLNAME));
Put_Line ("Favorite Fruit := " & Get (Key => FAVOURITEFRUIT));
Put_Line ("Other Family := " & Get (Key => OTHERFAMILY));
if Has_Value (Key => NEEDSPEELING) then
Put_Line ("NEEDSPEELLING := " & Get (Key => NEEDSPEELING));
else
Put_Line ("NEEDSPEELLING := True");
end if;
if Has_Value (Key => SEEDSREMOVED) then
Put_Line ("SEEDSREMOVED := " & Get (Key => SEEDSREMOVED));
else
Put_Line ("SEEDSREMOVED := True");
end if;
end Read_Config;