2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / a-tideio.adb
blob71e44a3eef1b956d00b4f52d420f49d73e8ecead
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUNTIME COMPONENTS --
4 -- --
5 -- A D A . T E X T _ I O . D E C I M A L _ I O --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-1999 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 with Ada.Text_IO.Decimal_Aux;
36 package body Ada.Text_IO.Decimal_IO is
38 package Aux renames Ada.Text_IO.Decimal_Aux;
40 Scale : constant Integer := Num'Scale;
42 ---------
43 -- Get --
44 ---------
46 procedure Get
47 (File : in File_Type;
48 Item : out Num;
49 Width : in Field := 0)
51 pragma Unsuppress (Range_Check);
53 begin
54 if Num'Size > Integer'Size then
55 Item := Num'Fixed_Value (Aux.Get_LLD (File, Width, Scale));
57 else
58 Item := Num'Fixed_Value (Aux.Get_Dec (File, Width, Scale));
59 end if;
61 exception
62 when Constraint_Error => raise Data_Error;
63 end Get;
65 procedure Get
66 (Item : out Num;
67 Width : in Field := 0)
69 begin
70 Get (Current_In, Item, Width);
71 end Get;
73 procedure Get
74 (From : in String;
75 Item : out Num;
76 Last : out Positive)
78 pragma Unsuppress (Range_Check);
80 begin
81 if Num'Size > Integer'Size then
82 Item := Num'Fixed_Value
83 (Aux.Gets_LLD (From, Last'Unrestricted_Access, Scale));
84 else
85 Item := Num'Fixed_Value
86 (Aux.Gets_Dec (From, Last'Unrestricted_Access, Scale));
87 end if;
89 exception
90 when Constraint_Error => raise Data_Error;
91 end Get;
93 ---------
94 -- Put --
95 ---------
97 procedure Put
98 (File : in File_Type;
99 Item : in Num;
100 Fore : in Field := Default_Fore;
101 Aft : in Field := Default_Aft;
102 Exp : in Field := Default_Exp)
104 begin
105 if Num'Size > Integer'Size then
106 Aux.Put_LLD
107 (File, Long_Long_Integer'Integer_Value (Item),
108 Fore, Aft, Exp, Scale);
109 else
110 Aux.Put_Dec
111 (File, Integer'Integer_Value (Item), Fore, Aft, Exp, Scale);
112 end if;
113 end Put;
115 procedure Put
116 (Item : in Num;
117 Fore : in Field := Default_Fore;
118 Aft : in Field := Default_Aft;
119 Exp : in Field := Default_Exp)
121 begin
122 Put (Current_Out, Item, Fore, Aft, Exp);
123 end Put;
125 procedure Put
126 (To : out String;
127 Item : in Num;
128 Aft : in Field := Default_Aft;
129 Exp : in Field := Default_Exp)
131 begin
132 if Num'Size > Integer'Size then
133 Aux.Puts_LLD
134 (To, Long_Long_Integer'Integer_Value (Item), Aft, Exp, Scale);
135 else
136 Aux.Puts_Dec (To, Integer'Integer_Value (Item), Aft, Exp, Scale);
137 end if;
138 end Put;
140 end Ada.Text_IO.Decimal_IO;