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-wtflio.adb < prev    next >
Text File  |  2000-07-19  |  5KB  |  133 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --             A D A . W I D E _ T E X T _ I O . F L O A T _ I O            --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.4 $                              --
  10. --                                                                          --
  11. --   Copyright (C) 1992,1993,1994,1995,1996 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.Wide_Text_IO.Float_Aux;
  37. with System.WCh_Con; use System.WCh_Con;
  38. with System.WCh_WtS; use System.WCh_WtS;
  39.  
  40. with Ada.Unchecked_Conversion;
  41.  
  42. package body Ada.Wide_Text_IO.Float_IO is
  43.  
  44.    subtype TFT is Ada.Wide_Text_IO.File_Type;
  45.    --  File type required for calls to routines in Aux
  46.  
  47.    package Aux renames Ada.Wide_Text_IO.Float_Aux;
  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.    begin
  59.       Aux.Get (TFT (File), Long_Long_Float (Item), Width);
  60.  
  61.    exception
  62.       when Constraint_Error => raise Data_Error;
  63.    end Get;
  64.  
  65.    procedure Get
  66.      (Item  : out Num;
  67.       Width : in Field := 0)
  68.    is
  69.    begin
  70.       Get (Current_Input, Item, Width);
  71.    end Get;
  72.  
  73.    procedure Get
  74.      (From : in Wide_String;
  75.       Item : out Num;
  76.       Last : out Positive)
  77.    is
  78.       S : constant String := Wide_String_To_String (From, WCEM_Upper);
  79.       --  String on which we do the actual conversion. Note that the method
  80.       --  used for wide character encoding is irrelevant, since if there is
  81.       --  a character outside the Standard.Character range then the call to
  82.       --  Aux.Gets will raise Data_Error in any case.
  83.  
  84.    begin
  85.       Aux.Gets (S, Long_Long_Float (Item), Last);
  86.  
  87.    exception
  88.       when Constraint_Error => raise Data_Error;
  89.    end Get;
  90.  
  91.    ---------
  92.    -- Put --
  93.    ---------
  94.  
  95.    procedure Put
  96.      (File : in File_Type;
  97.       Item : in Num;
  98.       Fore : in Field := Default_Fore;
  99.       Aft  : in Field := Default_Aft;
  100.       Exp  : in Field := Default_Exp)
  101.    is
  102.    begin
  103.       Aux.Put (TFT (File), Long_Long_Float (Item), Fore, Aft, Exp);
  104.    end Put;
  105.  
  106.    procedure Put
  107.      (Item : in Num;
  108.       Fore : in Field := Default_Fore;
  109.       Aft  : in Field := Default_Aft;
  110.       Exp  : in Field := Default_Exp)
  111.    is
  112.    begin
  113.       Put (Current_Output, Item, Fore, Aft, Exp);
  114.    end Put;
  115.  
  116.    procedure Put
  117.      (To   : out Wide_String;
  118.       Item : in Num;
  119.       Aft  : in Field := Default_Aft;
  120.       Exp  : in Field := Default_Exp)
  121.    is
  122.       S : String (To'First .. To'Last);
  123.  
  124.    begin
  125.       Aux.Puts (S, Long_Long_Float (Item), Aft, Exp);
  126.  
  127.       for J in S'Range loop
  128.          To (J) := Wide_Character'Val (Character'Pos (S (J)));
  129.       end loop;
  130.    end Put;
  131.  
  132. end Ada.Wide_Text_IO.Float_IO;
  133.