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-wtenio.adb < prev    next >
Text File  |  2000-07-19  |  4KB  |  115 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --       A D A . W I D E _ T E X T _ I O . E N U M E R A T I O N _ I O      --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.3 $                              --
  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.Enumeration_Aux;
  37.  
  38. package body Ada.Wide_Text_IO.Enumeration_IO is
  39.  
  40.    package Aux renames Ada.Wide_Text_IO.Enumeration_Aux;
  41.  
  42.    ---------
  43.    -- Get --
  44.    ---------
  45.  
  46.    procedure Get (File : in File_Type; Item : out Enum) is
  47.       Buf    : Wide_String (1 .. Enum'Width);
  48.       Buflen : Natural;
  49.  
  50.    begin
  51.       Aux.Get_Enum_Lit (File, Buf, Buflen);
  52.       Item := Enum'Wide_Value (Buf (1 .. Buflen));
  53.  
  54.    exception
  55.       when Constraint_Error => raise Data_Error;
  56.    end Get;
  57.  
  58.    procedure Get (Item : out Enum) is
  59.    begin
  60.       Get (Current_Input, Item);
  61.    end Get;
  62.  
  63.    procedure Get
  64.      (From : in Wide_String;
  65.       Item : out Enum;
  66.       Last : out positive)
  67.    is
  68.       Start : Natural;
  69.  
  70.    begin
  71.       Aux.Scan_Enum_Lit (From, Start, Last);
  72.       Item := Enum'Wide_Value (From (Start .. Last));
  73.  
  74.    exception
  75.       when Constraint_Error => raise Data_Error;
  76.    end Get;
  77.  
  78.    ---------
  79.    -- Put --
  80.    ---------
  81.  
  82.    procedure Put
  83.      (File  : in File_Type;
  84.       Item  : in Enum;
  85.       Width : in Field := Default_Width;
  86.       Set   : in Type_Set := Default_Setting)
  87.    is
  88.       Image : constant Wide_String := Enum'Wide_Image (Item);
  89.  
  90.    begin
  91.       Aux.Put (File, Image, Width, Set);
  92.    end Put;
  93.  
  94.    procedure Put
  95.      (Item  : in Enum;
  96.       Width : in Field := Default_Width;
  97.       Set   : in Type_Set := Default_Setting)
  98.    is
  99.    begin
  100.       Put (Current_Output, Item, Width, Set);
  101.    end Put;
  102.  
  103.    procedure Put
  104.      (To   : out Wide_String;
  105.       Item : in Enum;
  106.       Set  : in Type_Set := Default_Setting)
  107.    is
  108.       Image : constant Wide_String := Enum'Wide_Image (Item);
  109.  
  110.    begin
  111.       Aux.Puts (To, Image, Set);
  112.    end Put;
  113.  
  114. end Ada.Wide_Text_IO.Enumeration_IO;
  115.