]>
Commit | Line | Data |
---|---|---|
d23b8f57 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3084fecd | 3 | -- GNAT RUN-TIME COMPONENTS -- |
d23b8f57 RK |
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 | -- -- | |
748086b7 | 9 | -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- |
d23b8f57 RK |
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- -- | |
748086b7 | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
d23b8f57 RK |
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 -- | |
748086b7 JJ |
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/>. -- | |
d23b8f57 RK |
26 | -- -- |
27 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 28 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
d23b8f57 RK |
29 | -- -- |
30 | ------------------------------------------------------------------------------ | |
31 | ||
32 | with Ada.Text_IO.Decimal_Aux; | |
33 | ||
34 | package body Ada.Text_IO.Decimal_IO is | |
35 | ||
36 | package Aux renames Ada.Text_IO.Decimal_Aux; | |
37 | ||
38 | Scale : constant Integer := Num'Scale; | |
39 | ||
40 | --------- | |
41 | -- Get -- | |
42 | --------- | |
43 | ||
44 | procedure Get | |
0ae9f22f | 45 | (File : File_Type; |
d23b8f57 | 46 | Item : out Num; |
0ae9f22f | 47 | Width : Field := 0) |
d23b8f57 RK |
48 | is |
49 | pragma Unsuppress (Range_Check); | |
50 | ||
51 | begin | |
52 | if Num'Size > Integer'Size then | |
53 | Item := Num'Fixed_Value (Aux.Get_LLD (File, Width, Scale)); | |
54 | ||
55 | else | |
56 | Item := Num'Fixed_Value (Aux.Get_Dec (File, Width, Scale)); | |
57 | end if; | |
58 | ||
59 | exception | |
60 | when Constraint_Error => raise Data_Error; | |
61 | end Get; | |
62 | ||
63 | procedure Get | |
64 | (Item : out Num; | |
0ae9f22f | 65 | Width : Field := 0) |
d23b8f57 RK |
66 | is |
67 | begin | |
68 | Get (Current_In, Item, Width); | |
69 | end Get; | |
70 | ||
71 | procedure Get | |
0ae9f22f | 72 | (From : String; |
d23b8f57 RK |
73 | Item : out Num; |
74 | Last : out Positive) | |
75 | is | |
76 | pragma Unsuppress (Range_Check); | |
77 | ||
78 | begin | |
79 | if Num'Size > Integer'Size then | |
80 | Item := Num'Fixed_Value | |
81 | (Aux.Gets_LLD (From, Last'Unrestricted_Access, Scale)); | |
82 | else | |
83 | Item := Num'Fixed_Value | |
84 | (Aux.Gets_Dec (From, Last'Unrestricted_Access, Scale)); | |
85 | end if; | |
86 | ||
87 | exception | |
88 | when Constraint_Error => raise Data_Error; | |
89 | end Get; | |
90 | ||
91 | --------- | |
92 | -- Put -- | |
93 | --------- | |
94 | ||
95 | procedure Put | |
0ae9f22f RD |
96 | (File : File_Type; |
97 | Item : Num; | |
98 | Fore : Field := Default_Fore; | |
99 | Aft : Field := Default_Aft; | |
100 | Exp : Field := Default_Exp) | |
d23b8f57 RK |
101 | is |
102 | begin | |
103 | if Num'Size > Integer'Size then | |
104 | Aux.Put_LLD | |
105 | (File, Long_Long_Integer'Integer_Value (Item), | |
106 | Fore, Aft, Exp, Scale); | |
107 | else | |
108 | Aux.Put_Dec | |
109 | (File, Integer'Integer_Value (Item), Fore, Aft, Exp, Scale); | |
110 | end if; | |
111 | end Put; | |
112 | ||
113 | procedure Put | |
0ae9f22f RD |
114 | (Item : Num; |
115 | Fore : Field := Default_Fore; | |
116 | Aft : Field := Default_Aft; | |
117 | Exp : Field := Default_Exp) | |
d23b8f57 RK |
118 | is |
119 | begin | |
120 | Put (Current_Out, Item, Fore, Aft, Exp); | |
121 | end Put; | |
122 | ||
123 | procedure Put | |
124 | (To : out String; | |
0ae9f22f RD |
125 | Item : Num; |
126 | Aft : Field := Default_Aft; | |
127 | Exp : Field := Default_Exp) | |
d23b8f57 RK |
128 | is |
129 | begin | |
130 | if Num'Size > Integer'Size then | |
131 | Aux.Puts_LLD | |
132 | (To, Long_Long_Integer'Integer_Value (Item), Aft, Exp, Scale); | |
133 | else | |
134 | Aux.Puts_Dec (To, Integer'Integer_Value (Item), Aft, Exp, Scale); | |
135 | end if; | |
136 | end Put; | |
137 | ||
138 | end Ada.Text_IO.Decimal_IO; |