-- $Date: 2004/01/25 09:17:19 $
-- $Revision: 1.1 $
-- $Author: jcrocholl $

with Ada.Unchecked_Deallocation;

package body Line_Readers is

   -----------------
   -- Initialization
   -----------------

   -- Initialize a newly created reader instance.
   procedure Initialize_Line_Reader
     (This : access Line_Reader'Class) is
   begin
      Initialize_Token_Reader(This);
   end Initialize_Line_Reader;

   -- Initialize a newly created reader instance with a file to read.
   procedure Initialize_Line_Reader
     (This     : access Line_Reader'Class;
      Filename : in String) is -- Open this file for reading.
   begin
      Initialize_Token_Reader(This, Filename);
   end Initialize_Line_Reader;

   -- Close the input file.
   procedure Finalize_Line_Reader
     (This : access Line_Reader'Class) is -- Object instance.
   begin
      Finalize_Token_Reader(This);
   end Finalize_Line_Reader;

   -------------------
   -- Creating readers
   -------------------

   -- Create an Line reader for current input (stdin).
   function Current_Input
     return Line_Reader_Access -- The newly created Line reader instance.
   is
      Result : Line_Reader_Access := new Line_Reader;
   begin
      Initialize_Line_Reader(Result);
      return Result;
   end Current_Input;

   -- Create an Line reader for file input.
   function Open
     (Filename : in String)    -- Open this file.
     return Line_Reader_Access -- The newly created Line reader instance.
   is
      Result : Line_Reader_Access := new Line_Reader;
   begin
      Initialize_Line_Reader(Result, Filename);
      return Result;
   end Open;