text stringlengths 0 234 |
|---|
end loop; |
Load (Name, Default, Value); |
Item := new Setting_Data; |
Item.Name := Ada.Strings.Unbounded.To_Unbounded_String (Name); |
Item.Value := Value; |
Item.Next_Setting := First; |
First := Item; |
end Get; |
procedure Set (Name : in String; |
Value : in String) is |
Item : Setting_Data_Access := First; |
Previous : Setting_Data_Access := null; |
begin |
while Item /= null loop |
if Item.Name = Name then |
if Previous /= null then |
Previous.Next_Setting := Item.Next_Setting; |
First := Item; |
end if; |
if Item.Value = Value then |
return; |
end if; |
Item.Value := Ada.Strings.Unbounded.To_Unbounded_String (Value); |
Save (Name, Value); |
return; |
end if; |
Previous := Item; |
Item := Item.Next_Setting; |
end loop; |
Item := new Setting_Data; |
Item.Name := Ada.Strings.Unbounded.To_Unbounded_String (Name); |
Item.Value := Ada.Strings.Unbounded.To_Unbounded_String (Value); |
Item.Next_Setting := First; |
First := Item; |
Save (Name, Value); |
end Set; |
procedure Clear is |
begin |
while First /= null loop |
declare |
Item : Setting_Data_Access := First; |
begin |
First := Item.Next_Setting; |
Free (Item); |
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation |
Function Body: (Setting_Impl, Setting_Impl_Ptr); |
pragma Warnings (Off, "*redundant conversion*"); |
Ptr : Setting_Impl_Ptr := Setting_Impl (Object.all)'Access; |
pragma Warnings (On, "*redundant conversion*"); |
begin |
Unchecked_Free (Ptr); |
end Destroy; |
procedure Find (Object : in out Setting_Impl; |
Session : in out ADO.Sessions.Session'Class; |
Query : in ADO.SQL.Query'Class; |
Found : out Boolean) is |
Stmt : ADO.Statements.Query_Statement |
:= Session.Create_Statement (Query, SETTING_DEF'Access); |
begin |
Stmt.Execute; |
if Stmt.Has_Elements then |
Object.Load (Stmt, Session); |
Stmt.Next; |
Found := not Stmt.Has_Elements; |
else |
Found := False; |
end if; |
end Find; |
overriding |
procedure Load (Object : in out Setting_Impl; |
Session : in out ADO.Sessions.Session'Class) is |
Found : Boolean; |
Query : ADO.SQL.Query; |
Id : constant ADO.Identifier := Object.Get_Key_Value; |
begin |
Query.Bind_Param (Position => 1, Value => Id); |
Query.Set_Filter ("id = ?"); |
Object.Find (Session, Query, Found); |
if not Found then |
raise ADO.Objects.NOT_FOUND; |
end if; |
end Load; |
procedure Save (Object : in out Setting_Impl; |
Session : in out ADO.Sessions.Master_Session'Class) is |
Stmt : ADO.Statements.Update_Statement |
:= Session.Create_Statement (SETTING_DEF'Access); |
begin |
if Object.Is_Modified (1) then |
Stmt.Save_Field (Name => COL_0_1_NAME, -- id |
Value => Object.Get_Key); |
Object.Clear_Modified (1); |
end if; |
if Object.Is_Modified (2) then |
Stmt.Save_Field (Name => COL_1_1_NAME, -- name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.