Hosted by
|
with Ada.Unchecked_Deallocation;
with Integer_Strings; use Integer_Strings;
package body Readers is
procedure Initialize_Reader
(This : access Reader'Class) is
begin
Get(This); -- Read the first look-ahead character.
end Initialize_Reader;
procedure Initialize_Reader
(This : access Reader'Class;
Filename : in String) is
begin
Open(This.File, In_File, Filename);
To_String_Access(Filename, This.Filename);
Initialize_Reader(This); -- Standard initialization.
end Initialize_Reader;
procedure Finalize_Reader
(This : access Reader'Class) is
begin
if not Is_Null(This.Filename) then
Close(This.File);
end if;
Free(This.Filename);
end Finalize_Reader;
function Current_Input
return Reader_Access
is
Result : Reader_Access := new Reader;
begin
Initialize_Reader(Result);
return Result;
end Current_Input;
function Open
(Filename : in String)
return Reader_Access
is
Result : Reader_Access := new Reader;
begin
Initialize_Reader(Result, Filename);
return Result;
end Open;
|