comparison gcc/ada/libgnat/a-wtenio.adb @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME 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 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 with Ada.Wide_Text_IO.Enumeration_Aux;
33
34 package body Ada.Wide_Text_IO.Enumeration_IO is
35
36 package Aux renames Ada.Wide_Text_IO.Enumeration_Aux;
37
38 ---------
39 -- Get --
40 ---------
41
42 procedure Get (File : File_Type; Item : out Enum) is
43 Buf : Wide_String (1 .. Enum'Width);
44 Buflen : Natural;
45 begin
46 Aux.Get_Enum_Lit (File, Buf, Buflen);
47 Item := Enum'Wide_Value (Buf (1 .. Buflen));
48 exception
49 when Constraint_Error => raise Data_Error;
50 end Get;
51
52 procedure Get (Item : out Enum) is
53 begin
54 Get (Current_Input, Item);
55 end Get;
56
57 procedure Get
58 (From : Wide_String;
59 Item : out Enum;
60 Last : out Positive)
61 is
62 Start : Natural;
63 begin
64 Aux.Scan_Enum_Lit (From, Start, Last);
65 Item := Enum'Wide_Value (From (Start .. Last));
66 exception
67 when Constraint_Error => raise Data_Error;
68 end Get;
69
70 ---------
71 -- Put --
72 ---------
73
74 procedure Put
75 (File : File_Type;
76 Item : Enum;
77 Width : Field := Default_Width;
78 Set : Type_Set := Default_Setting)
79 is
80 Image : constant Wide_String := Enum'Wide_Image (Item);
81 begin
82 Aux.Put (File, Image, Width, Set);
83 end Put;
84
85 procedure Put
86 (Item : Enum;
87 Width : Field := Default_Width;
88 Set : Type_Set := Default_Setting)
89 is
90 begin
91 Put (Current_Output, Item, Width, Set);
92 end Put;
93
94 procedure Put
95 (To : out Wide_String;
96 Item : Enum;
97 Set : Type_Set := Default_Setting)
98 is
99 Image : constant Wide_String := Enum'Wide_Image (Item);
100 begin
101 Aux.Puts (To, Image, Set);
102 end Put;
103
104 end Ada.Wide_Text_IO.Enumeration_IO;