2016-01-15 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / ada / a-timoio.adb
blobb000cd517cb0998e93158dd14d2577198f32fc5d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . T E X T _ I O . M O D U L A R _ I O --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2009, 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 ------------------------------------------------------------------------------
32 with Ada.Text_IO.Modular_Aux;
34 with System.Unsigned_Types; use System.Unsigned_Types;
36 package body Ada.Text_IO.Modular_IO is
38 package Aux renames Ada.Text_IO.Modular_Aux;
40 ---------
41 -- Get --
42 ---------
44 procedure Get
45 (File : File_Type;
46 Item : out Num;
47 Width : Field := 0)
49 pragma Unsuppress (Range_Check);
51 begin
52 if Num'Size > Unsigned'Size then
53 Aux.Get_LLU (File, Long_Long_Unsigned (Item), Width);
54 else
55 Aux.Get_Uns (File, Unsigned (Item), Width);
56 end if;
58 exception
59 when Constraint_Error => raise Data_Error;
60 end Get;
62 procedure Get
63 (Item : out Num;
64 Width : Field := 0)
66 pragma Unsuppress (Range_Check);
68 begin
69 if Num'Size > Unsigned'Size then
70 Aux.Get_LLU (Current_In, Long_Long_Unsigned (Item), Width);
71 else
72 Aux.Get_Uns (Current_In, Unsigned (Item), Width);
73 end if;
75 exception
76 when Constraint_Error => raise Data_Error;
77 end Get;
79 procedure Get
80 (From : String;
81 Item : out Num;
82 Last : out Positive)
84 pragma Unsuppress (Range_Check);
86 begin
87 if Num'Size > Unsigned'Size then
88 Aux.Gets_LLU (From, Long_Long_Unsigned (Item), Last);
89 else
90 Aux.Gets_Uns (From, Unsigned (Item), Last);
91 end if;
93 exception
94 when Constraint_Error => raise Data_Error;
95 end Get;
97 ---------
98 -- Put --
99 ---------
101 procedure Put
102 (File : File_Type;
103 Item : Num;
104 Width : Field := Default_Width;
105 Base : Number_Base := Default_Base)
107 begin
108 if Num'Size > Unsigned'Size then
109 Aux.Put_LLU (File, Long_Long_Unsigned (Item), Width, Base);
110 else
111 Aux.Put_Uns (File, Unsigned (Item), Width, Base);
112 end if;
113 end Put;
115 procedure Put
116 (Item : Num;
117 Width : Field := Default_Width;
118 Base : Number_Base := Default_Base)
120 begin
121 if Num'Size > Unsigned'Size then
122 Aux.Put_LLU (Current_Out, Long_Long_Unsigned (Item), Width, Base);
123 else
124 Aux.Put_Uns (Current_Out, Unsigned (Item), Width, Base);
125 end if;
126 end Put;
128 procedure Put
129 (To : out String;
130 Item : Num;
131 Base : Number_Base := Default_Base)
133 begin
134 if Num'Size > Unsigned'Size then
135 Aux.Puts_LLU (To, Long_Long_Unsigned (Item), Base);
136 else
137 Aux.Puts_Uns (To, Unsigned (Item), Base);
138 end if;
139 end Put;
141 end Ada.Text_IO.Modular_IO;