September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,39 +0,0 @@
|
|||
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;
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
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;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
with Config; use Config;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Rosetta_Read_Cfg is
|
||||
cfg: Configuration:= Init("rosetta_read.cfg", Case_Sensitive => False, Variable_Terminator => ' ');
|
||||
fullname : String := cfg.Value_Of("*", "fullname");
|
||||
favouritefruit : String := cfg.Value_Of("*", "favouritefruit");
|
||||
needspeeling : Boolean := cfg.Is_Set("*", "needspeeling");
|
||||
seedsremoved : Boolean := cfg.Is_Set("*", "seedsremoved");
|
||||
otherfamily : String := cfg.Value_Of("*", "otherfamily");
|
||||
begin
|
||||
Put_Line("fullname = " & fullname);
|
||||
Put_Line("favouritefruit = " & favouritefruit);
|
||||
Put_Line("needspeeling = " & Boolean'Image(needspeeling));
|
||||
Put_Line("seedsremoved = " & Boolean'Image(seedsremoved));
|
||||
Put_Line("otherfamily = " & otherfamily);
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue