messages.ads


a------------------------------------------------------------------------------
--
--  package Messages (spec)
--
------------------------------------------------------------------------------
--  Update information:
--
--  1996.04.24 (Jacob Sparre Andersen)
--    Written.
--
--  1996.05.15 (Jacob Sparre Andersen)
--    Added function versions of Load.
--
--  1996.05.20 (Jacob Sparre Andersen)
--    Added procedure Append_Message.
--
--  1996.06.19 (Jacob Sparre Andersen)
--    Exchanged the order of the formal parameters for the Load procedures.
--
--  1996.07.09 (Jacob Sparre Andersen)
--    Added comments.
--
--  (Additional update information should be inserted above this line.)
------------------------------------------------------------------------------

with Ada.Strings.Unbounded;
with Ada.Text_IO;

generic

   type Message_ID_Type is (<>);

package Messages is

   type Message_Type is private;
   type Message_List is array (Message_ID_Type) of Message_Type;

   ---------------------------------------------------------------------------
   --  procedure Load:
   --
   --  Reads a list of messages from Source.

   procedure Load (Source             : in     Ada.Text_IO.File_Type;
                   Messages           :    out Message_List;
                   Exception_On_Error : in     Boolean := False);

   ---------------------------------------------------------------------------
   --  procedure Load:
   --
   --  Reads a list of messages from the file named Source_Name.

   procedure Load (Source_Name        : in     String;
                   Messages           :    out Message_List;
                   Exception_On_Error : in     Boolean := False);

   ---------------------------------------------------------------------------
   --  function Load:
   --
   --  Reads a list of messages from Source.

   function Load (Source             : in Ada.Text_IO.File_Type;
                  Exception_On_Error : in     Boolean := False)
     return Message_List;

   ---------------------------------------------------------------------------
   --  function Load:
   --
   --  Reads a list of messages from the file named Source_Name.

   function Load (Source_Name        : in String;
                  Exception_On_Error : in     Boolean := False)
     return Message_List;

   ---------------------------------------------------------------------------
   --  function Message:
   --
   --  Translates the raw message to a readable one using the variable parser
   --  Parse. The argument Trim is used to control whether spaces and special
   --  characters should be trimmed from the end of the message or not.
   --
   --  Exceptions:
   --    Constraint_Error  --  In case of un-even count of '$' in Raw_Message.
   --    (+ execptions propagated from Parse)

   generic

      with function Parse (Variable_Name : in String) return String;

   function Message (Raw_Message : in Message_Type;
                     Trim        : in Boolean := False) return String;

   ---------------------------------------------------------------------------
   --  procedure Append_Message:

   generic

      with procedure Append_Variable
        (Target        : in out Ada.Strings.Unbounded.Unbounded_String;
         Variable_Name : in     String);

   procedure Append_Message
     (Target      : in out Ada.Strings.Unbounded.Unbounded_String;
      Raw_Message : in     Message_Type);

   ---------------------------------------------------------------------------
   --  procedure Put:

   generic

      with function Parse (Variable_Name : in String) return String;

   procedure Put (File        : in     Ada.Text_IO.File_Type;
                  Raw_Message : in     Message_Type);

   ---------------------------------------------------------------------------

private

   type Message_Type is
      record
         Text : Ada.Strings.Unbounded.Unbounded_String;
      end record;

end Messages;

Typeset with Ada_To_HTML (Jacob and Jesper)