-- $Date: 2004/03/04 05:15:29 $
-- $Revision: 1.7 $
-- $Author: jcrocholl $

with Ada.Unchecked_Deallocation;

-- Light-weight text output file writers.
package body Writers is

   -------------------------------------------
   -- Internal initialization and finalization
   -------------------------------------------

   -- Initialize a newly created writer instance.
   procedure Initialize
     (This : access Writer'Class) is -- Writer instance.
   begin
      null;
   end Initialize;

   -- Initialize a newly created writer instance with a file to write.
   procedure Initialize
     (This     : access Writer'Class-- Writer instance.
      Filename : in String) is             -- Open this file for writing.
   begin
      null;
   end Initialize;

   -- Close the output file.
   procedure Finalize
     (This : access Writer'Class-- Object instance.
   is
   begin
      null;
   end Finalize;

   -------------------
   -- Creating writers
   -------------------

   -- Create a writer for current output (stdout).
   function Current_Output
     return Writer_Access -- The newly created writer instance.
   is
      Result : Writer_Access := new Writer;
   begin
      Initialize(Result);
      return Result;
   end Current_Output;

   -- Create a writer for file output.
   function Create
     (Filename : in String-- Create this file.
     return Writer_Access   -- The newly created writer instance.
   is
      Result : Writer_Access := new Writer;
   begin
      Initialize(Result, Filename);
      return Result;
   end Create;