1with Ada.Characters.Handling;
2with Ada.Containers;
3with Ada.Containers.Indefinite_Hashed_Maps;
4with Ada.Strings.Hash;
5
6package body Opt50_Pkg is
7
8   type Enum_Name is array (Enum) of access constant String;
9
10   Enum_Name_Table : constant Enum_Name := (
11      One   => new String'("one"),
12      Two   => new String'("two"),
13      Three => new String'("three"));
14
15   package String_To_Enum_Map is new Ada.Containers.Indefinite_Hashed_Maps
16      (Key_Type => String, Element_Type => Enum,
17       Hash => Ada.Strings.Hash, Equivalent_Keys => "=");
18
19   function Fill_Hashed_Map return String_To_Enum_Map.Map is
20      Res : String_To_Enum_Map.Map;
21      use String_To_Enum_Map;
22   begin
23      for I in Enum_Name_Table'Range loop
24         declare
25            Kind : constant String := Enum_Name_Table (I).all;
26         begin
27            Res.Insert(Key => Kind, New_Item => I);
28         end;
29      end loop;
30      return Res;
31   end;
32
33   String_To_Enum : constant String_To_Enum_Map.Map := Fill_Hashed_Map;
34
35   procedure Get (Kind : String; Result : out Enum; Success : out Boolean) is
36      X : constant String := Ada.Characters.Handling.To_Lower (Kind);
37      use String_To_Enum_Map;
38      Curs : constant Cursor := String_To_Enum.Find (X);
39   begin
40      Success := Curs /= No_Element;
41      if Success then
42         Result := Element(Curs);
43      end if;
44   end;
45
46   procedure Set (A : Enum_Boolean_Array) is null;
47
48end Opt50_Pkg;
49