text
stringlengths
0
234
Value : constant String := Get_Value (Plugin, Data, Key);
begin
if Value = "formatted" then
return Formatted;
elsif Value = "free" then
return Free;
else
raise Constraint_Error;
end if;
end Get_Value;
function Get_Value
(Plugin : Plugin_Ptr;
Data : Hashtable_Ptr;
Key : String) return Notify_Level
is
Value : constant Integer := Get_Value (Plugin, Data, Key);
begin
return
(case Value is
when -1 => None,
when 0 => Low,
when 1 => Message,
when 2 => Private_Message,
when 3 => Highlight,
when others => raise Constraint_Error);
end Get_Value;
function Unix_Time_To_Ada (Value : Duration) return Ada.Calendar.Time is
use Ada.Calendar;
Time_Epoch : constant Time := Time_Of (Year => 1970, Month => 1, Day => 1);
Time_Offset : constant Duration := Duration (Time_Zones.UTC_Time_Offset (Time_Epoch)) * 60;
begin
return Time_Epoch + Time_Offset + Value;
end Unix_Time_To_Ada;
function Ada_To_Unix_Time (Value : Ada.Calendar.Time) return Duration is
use Ada.Calendar;
Time_Epoch : constant Time := Time_Of (Year => 1970, Month => 1, Day => 1);
Time_Offset : constant Duration := Duration (Time_Zones.UTC_Time_Offset (Time_Epoch)) * 60;
begin
return Value - (Time_Epoch + Time_Offset);
end Ada_To_Unix_Time;
function Get_Value
(Plugin : Plugin_Ptr;
Table : Hashtable_Ptr;
Key : String) return Ada.Calendar.Time
is
Value : constant Integer := Get_Value (Plugin, Table, Key);
begin
return Unix_Time_To_Ada (Duration (Value));
end Get_Value;
procedure Set_Value
(Plugin : Plugin_Ptr;
Table : Hashtable_Ptr;
Key : String;
Value : String)
is
Unused_Item : constant System.Address :=
Plugin.Hashtable_Set (Table, Key & L1.NUL, Value & L1.NUL);
begin
null;
end Set_Value;
procedure Set_Value
(Plugin : Plugin_Ptr;
Table : Hashtable_Ptr;
Key : String;
Value : Ada.Calendar.Time) is
begin
Set_Value (Plugin, Table, Key, Integer'Image (Integer (Ada_To_Unix_Time (Value))));
end Set_Value;
procedure Set_Value
(Plugin : Plugin_Ptr;
Table : Hashtable_Ptr;
Key : String;
Value : Notify_Level) is
begin
Set_Value (Plugin, Table, Key,
(case Value is
when None => "-1",
when Low => "0",
when Message => "1",
when Private_Message => "2",
when Highlight => "3"));
end Set_Value;
procedure Set_Value
(Plugin : Plugin_Ptr;
Table : Hashtable_Ptr;
Key : String;
Value : Boolean) is
begin
Set_Value (Plugin, Table, Key, (if Value then "1" else "0"));
end Set_Value;