home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / a-tiinio.adb < prev    next >
Text File  |  2000-07-19  |  6KB  |  160 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --               A D A . T E X T _ I O . I N T E G E R _ I O                --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.7 $
  10. --                                                                          --
  11. --          Copyright (C) 1992-1999 Free Software Foundation, Inc.          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with Ada.Text_IO.Integer_Aux;
  37.  
  38. package body Ada.Text_IO.Integer_IO is
  39.  
  40.    package Aux renames Ada.Text_IO.Integer_Aux;
  41.  
  42.    Need_LLI : constant Boolean := Num'Base'Size > Integer'Size;
  43.    --  Throughout this generic body, we distinguish between the case
  44.    --  where type Integer is acceptable, and where a Long_Long_Integer
  45.    --  is needed. This constant Boolean is used to test for these cases
  46.    --  and since it is a constant, only the code for the relevant case
  47.    --  will be included in the instance.
  48.  
  49.    ---------
  50.    -- Get --
  51.    ---------
  52.  
  53.    procedure Get
  54.      (File  : in File_Type;
  55.       Item  : out Num;
  56.       Width : in Field := 0)
  57.    is
  58.       --  We depend on a range check to get Data_Error
  59.  
  60.       pragma Unsuppress (Range_Check);
  61.       pragma Unsuppress (Overflow_Check);
  62.  
  63.    begin
  64.       if Need_LLI then
  65.          Aux.Get_LLI (File, Long_Long_Integer (Item), Width);
  66.       else
  67.          Aux.Get_Int (File, Integer (Item), Width);
  68.       end if;
  69.  
  70.    exception
  71.       when Constraint_Error => raise Data_Error;
  72.    end Get;
  73.  
  74.    procedure Get
  75.      (Item  : out Num;
  76.       Width : in Field := 0)
  77.    is
  78.       --  We depend on a range check to get Data_Error
  79.  
  80.       pragma Unsuppress (Range_Check);
  81.       pragma Unsuppress (Overflow_Check);
  82.  
  83.    begin
  84.       if Need_LLI then
  85.          Aux.Get_LLI (Current_In, Long_Long_Integer (Item), Width);
  86.       else
  87.          Aux.Get_Int (Current_In, Integer (Item), Width);
  88.       end if;
  89.  
  90.    exception
  91.       when Constraint_Error => raise Data_Error;
  92.    end Get;
  93.  
  94.    procedure Get
  95.      (From : in String;
  96.       Item : out Num;
  97.       Last : out Positive)
  98.    is
  99.       --  We depend on a range check to get Data_Error
  100.  
  101.       pragma Unsuppress (Range_Check);
  102.       pragma Unsuppress (Overflow_Check);
  103.  
  104.    begin
  105.       if Need_LLI then
  106.          Aux.Gets_LLI (From, Long_Long_Integer (Item), Last);
  107.       else
  108.          Aux.Gets_Int (From, Integer (Item), Last);
  109.       end if;
  110.  
  111.    exception
  112.       when Constraint_Error => raise Data_Error;
  113.    end Get;
  114.  
  115.    ---------
  116.    -- Put --
  117.    ---------
  118.  
  119.    procedure Put
  120.      (File  : in File_Type;
  121.       Item  : in Num;
  122.       Width : in Field := Default_Width;
  123.       Base  : in Number_Base := Default_Base)
  124.    is
  125.    begin
  126.       if Need_LLI then
  127.          Aux.Put_LLI (File, Long_Long_Integer (Item), Width, Base);
  128.       else
  129.          Aux.Put_Int (File, Integer (Item), Width, Base);
  130.       end if;
  131.    end Put;
  132.  
  133.    procedure Put
  134.      (Item  : in Num;
  135.       Width : in Field := Default_Width;
  136.       Base  : in Number_Base := Default_Base)
  137.    is
  138.    begin
  139.       if Need_LLI then
  140.          Aux.Put_LLI (Current_Out, Long_Long_Integer (Item), Width, Base);
  141.       else
  142.          Aux.Put_Int (Current_Out, Integer (Item), Width, Base);
  143.       end if;
  144.    end Put;
  145.  
  146.    procedure Put
  147.      (To   : out String;
  148.       Item : in Num;
  149.       Base : in Number_Base := Default_Base)
  150.    is
  151.    begin
  152.       if Need_LLI then
  153.          Aux.Puts_LLI (To, Long_Long_Integer (Item), Base);
  154.       else
  155.          Aux.Puts_Int (To, Integer (Item), Base);
  156.       end if;
  157.    end Put;
  158.  
  159. end Ada.Text_IO.Integer_IO;
  160.