home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada / a-tienio.adb < prev    next >
Text File  |  1996-09-28  |  4KB  |  105 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --           A D A . 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 NYU, All Rights Reserved       --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with Ada.Text_IO.Enumeration_Aux;
  27.  
  28. package body Ada.Text_IO.Enumeration_IO is
  29.  
  30.    package Aux renames Ada.Text_IO.Enumeration_Aux;
  31.  
  32.    ---------
  33.    -- Get --
  34.    ---------
  35.  
  36.    procedure Get (File : in File_Type; Item : out Enum) is
  37.       Buf    : String (1 .. Enum'Width);
  38.       Buflen : Natural;
  39.  
  40.    begin
  41.       Aux.Get_Enum_Lit (File, Buf, Buflen);
  42.       Item := Enum'Value (Buf (1 .. Buflen));
  43.  
  44.    exception
  45.       when Constraint_Error => raise Data_Error;
  46.    end Get;
  47.  
  48.    procedure Get (Item : out Enum) is
  49.    begin
  50.       Get (Current_In, Item);
  51.    end Get;
  52.  
  53.    procedure Get
  54.      (From : in String;
  55.       Item : out Enum;
  56.       Last : out positive)
  57.    is
  58.       Start : Natural;
  59.  
  60.    begin
  61.       Aux.Scan_Enum_Lit (From, Start, Last);
  62.       Item := Enum'Value (From (Start .. Last));
  63.  
  64.    exception
  65.       when Constraint_Error => raise Data_Error;
  66.    end Get;
  67.  
  68.    ---------
  69.    -- Put --
  70.    ---------
  71.  
  72.    procedure Put
  73.      (File  : in File_Type;
  74.       Item  : in Enum;
  75.       Width : in Field := Default_Width;
  76.       Set   : in Type_Set := Default_Setting)
  77.    is
  78.       Image : constant String := Enum'Image (Item);
  79.  
  80.    begin
  81.       Aux.Put (File, Image, Width, Set);
  82.    end Put;
  83.  
  84.    procedure Put
  85.      (Item  : in Enum;
  86.       Width : in Field := Default_Width;
  87.       Set   : in Type_Set := Default_Setting)
  88.    is
  89.    begin
  90.       Put (Current_Out, Item, Width, Set);
  91.    end Put;
  92.  
  93.    procedure Put
  94.      (To   : out String;
  95.       Item : in Enum;
  96.       Set  : in Type_Set := Default_Setting)
  97.    is
  98.       Image : constant String := Enum'Image (Item);
  99.  
  100.    begin
  101.       Aux.Puts (To, Image, Set);
  102.    end Put;
  103.  
  104. end Ada.Text_IO.Enumeration_IO;
  105.