1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . E N U M E R A T I O N _ I O --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Text_IO
.Enumeration_Aux
;
34 package body Ada
.Text_IO
.Enumeration_IO
is
36 package Aux
renames Ada
.Text_IO
.Enumeration_Aux
;
42 procedure Get
(File
: File_Type
; Item
: out Enum
) is
43 Buf
: String (1 .. Enum
'Width + 1);
47 Aux
.Get_Enum_Lit
(File
, Buf
, Buflen
);
50 Buf_Str
: String renames Buf
(1 .. Buflen
);
51 pragma Unsuppress
(Range_Check
);
53 Item
:= Enum
'Value (Buf_Str
);
57 when Constraint_Error
=> raise Data_Error
;
60 procedure Get
(Item
: out Enum
) is
61 pragma Unsuppress
(Range_Check
);
63 Get
(Current_In
, Item
);
74 Aux
.Scan_Enum_Lit
(From
, Start
, Last
);
77 From_Str
: String renames From
(Start
.. Last
);
78 pragma Unsuppress
(Range_Check
);
80 Item
:= Enum
'Value (From_Str
);
84 when Constraint_Error
=> raise Data_Error
;
94 Width
: Field
:= Default_Width
;
95 Set
: Type_Set
:= Default_Setting
)
97 Image
: constant String := Enum
'Image (Item
);
99 Aux
.Put
(File
, Image
, Width
, Set
);
104 Width
: Field
:= Default_Width
;
105 Set
: Type_Set
:= Default_Setting
)
108 Put
(Current_Out
, Item
, Width
, Set
);
114 Set
: Type_Set
:= Default_Setting
)
116 Image
: constant String := Enum
'Image (Item
);
118 Aux
.Puts
(To
, Image
, Set
);
121 end Ada
.Text_IO
.Enumeration_IO
;