Hosted by
|
with Ada.Unchecked_Deallocation;
package body String_Lists is
function Push
(This : access String_List)
return Item_Access
renames Inner_Lists.Push;
procedure Push
(This : access String_List;
Content : in String) is
begin
To_String_Access(Content, Push(This).Content);
end Push;
function Unshift
(This : access String_List)
return Item_Access
renames Inner_Lists.Unshift;
procedure Unshift
(This : access String_List;
Content : in String) is
begin
To_String_Access(Content, Unshift(This).Content);
end Unshift;
procedure Free is new Ada.Unchecked_Deallocation(Item, Item_Access);
function Pop
(This : access String_List)
return Item_Access
renames Inner_Lists.Pop;
function Pop
(This : access String_List)
return String
is
Item : Item_Access := Pop(This);
Result : String := To_String(Item.Content);
begin
Free(Item.Content);
Free(Item);
return Result;
end Pop;
function Shift
(This : access String_List)
return Item_Access
renames Inner_Lists.Shift;
function Shift
(This : access String_List)
return String
is
Item : Item_Access := Shift(This);
Result : String := To_String(Item.Content);
begin
Free(Item.Content);
Free(Item);
return Result;
end Shift;
function Insert_Before_Current
(This : access String_List)
return Item_Access
renames Inner_Lists.Insert_Before_Current;
function Insert_After_Current
(This : access String_List)
return Item_Access
renames Inner_Lists.Insert_After_Current;
function First
(This : access String_List)
return String is
begin
return To_String(Inner_Lists.First(This));
end First;
function Last
(This : access String_List)
return String is
begin
return To_String(Inner_Lists.Last(This));
end Last;
function Next_Content
(This : access String_List)
return String is
begin
return To_String(Inner_Lists.Next_Content(This));
end Next_Content;
function Current
(This : access String_List)
return String is
begin
return To_String(Inner_Lists.Current(This));
end Current;
procedure Update_Current
(This : access String_List;
Content : in String) is
begin
To_String_Access(Content, Current_Item(This).Content);
end Update_Current;
procedure Insert_Before_Current
(This : access String_List;
Content : in String) is
begin
To_String_Access(Content, Insert_Before_Current(This).Content);
end Insert_Before_Current;
procedure Insert_After_Current
(This : access String_List;
Content : in String) is
begin
To_String_Access(Content, Insert_After_Current(This).Content);
end Insert_After_Current;
function Item_Content
(This : access Item)
return String is
begin
return To_String(Inner_Lists.Item_Content(This));
end Item_Content;
procedure Update_Item
(This : access Item;
Content : in String) is
begin
To_String_Access(Content, This.Content);
end Update_Item;
end String_Lists;
|