1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- A D A . T E X T _ I O . E D I T I N G --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
|
10 |
|
|
-- --
|
11 |
|
|
-- This specification is derived from the Ada Reference Manual for use with --
|
12 |
|
|
-- GNAT. The copyright notice above, and the license provisions that follow --
|
13 |
|
|
-- apply solely to the contents of the part following the private keyword. --
|
14 |
|
|
-- --
|
15 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
16 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
17 |
|
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
18 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
19 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
20 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. --
|
21 |
|
|
-- --
|
22 |
|
|
-- As a special exception under Section 7 of GPL version 3, you are granted --
|
23 |
|
|
-- additional permissions described in the GCC Runtime Library Exception, --
|
24 |
|
|
-- version 3.1, as published by the Free Software Foundation. --
|
25 |
|
|
-- --
|
26 |
|
|
-- You should have received a copy of the GNU General Public License and --
|
27 |
|
|
-- a copy of the GCC Runtime Library Exception along with this program; --
|
28 |
|
|
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
29 |
|
|
-- <http://www.gnu.org/licenses/>. --
|
30 |
|
|
-- --
|
31 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
32 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
33 |
|
|
-- --
|
34 |
|
|
------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
package Ada.Text_IO.Editing is
|
37 |
|
|
|
38 |
|
|
type Picture is private;
|
39 |
|
|
|
40 |
|
|
function Valid
|
41 |
|
|
(Pic_String : String;
|
42 |
|
|
Blank_When_Zero : Boolean := False) return Boolean;
|
43 |
|
|
|
44 |
|
|
function To_Picture
|
45 |
|
|
(Pic_String : String;
|
46 |
|
|
Blank_When_Zero : Boolean := False) return Picture;
|
47 |
|
|
|
48 |
|
|
function Pic_String (Pic : Picture) return String;
|
49 |
|
|
function Blank_When_Zero (Pic : Picture) return Boolean;
|
50 |
|
|
|
51 |
|
|
Max_Picture_Length : constant := 64;
|
52 |
|
|
|
53 |
|
|
Picture_Error : exception;
|
54 |
|
|
|
55 |
|
|
Default_Currency : constant String := "$";
|
56 |
|
|
Default_Fill : constant Character := '*';
|
57 |
|
|
Default_Separator : constant Character := ',';
|
58 |
|
|
Default_Radix_Mark : constant Character := '.';
|
59 |
|
|
|
60 |
|
|
generic
|
61 |
|
|
type Num is delta <> digits <>;
|
62 |
|
|
Default_Currency : String := Editing.Default_Currency;
|
63 |
|
|
Default_Fill : Character := Editing.Default_Fill;
|
64 |
|
|
Default_Separator : Character := Editing.Default_Separator;
|
65 |
|
|
Default_Radix_Mark : Character := Editing.Default_Radix_Mark;
|
66 |
|
|
|
67 |
|
|
package Decimal_Output is
|
68 |
|
|
|
69 |
|
|
function Length
|
70 |
|
|
(Pic : Picture;
|
71 |
|
|
Currency : String := Default_Currency) return Natural;
|
72 |
|
|
|
73 |
|
|
function Valid
|
74 |
|
|
(Item : Num;
|
75 |
|
|
Pic : Picture;
|
76 |
|
|
Currency : String := Default_Currency) return Boolean;
|
77 |
|
|
|
78 |
|
|
function Image
|
79 |
|
|
(Item : Num;
|
80 |
|
|
Pic : Picture;
|
81 |
|
|
Currency : String := Default_Currency;
|
82 |
|
|
Fill : Character := Default_Fill;
|
83 |
|
|
Separator : Character := Default_Separator;
|
84 |
|
|
Radix_Mark : Character := Default_Radix_Mark) return String;
|
85 |
|
|
|
86 |
|
|
procedure Put
|
87 |
|
|
(File : Ada.Text_IO.File_Type;
|
88 |
|
|
Item : Num;
|
89 |
|
|
Pic : Picture;
|
90 |
|
|
Currency : String := Default_Currency;
|
91 |
|
|
Fill : Character := Default_Fill;
|
92 |
|
|
Separator : Character := Default_Separator;
|
93 |
|
|
Radix_Mark : Character := Default_Radix_Mark);
|
94 |
|
|
|
95 |
|
|
procedure Put
|
96 |
|
|
(Item : Num;
|
97 |
|
|
Pic : Picture;
|
98 |
|
|
Currency : String := Default_Currency;
|
99 |
|
|
Fill : Character := Default_Fill;
|
100 |
|
|
Separator : Character := Default_Separator;
|
101 |
|
|
Radix_Mark : Character := Default_Radix_Mark);
|
102 |
|
|
|
103 |
|
|
procedure Put
|
104 |
|
|
(To : out String;
|
105 |
|
|
Item : Num;
|
106 |
|
|
Pic : Picture;
|
107 |
|
|
Currency : String := Default_Currency;
|
108 |
|
|
Fill : Character := Default_Fill;
|
109 |
|
|
Separator : Character := Default_Separator;
|
110 |
|
|
Radix_Mark : Character := Default_Radix_Mark);
|
111 |
|
|
|
112 |
|
|
end Decimal_Output;
|
113 |
|
|
|
114 |
|
|
private
|
115 |
|
|
|
116 |
|
|
MAX_PICSIZE : constant := 50;
|
117 |
|
|
MAX_MONEYSIZE : constant := 10;
|
118 |
|
|
Invalid_Position : constant := -1;
|
119 |
|
|
|
120 |
|
|
subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
|
121 |
|
|
|
122 |
|
|
type Picture_Record (Length : Pic_Index := 0) is record
|
123 |
|
|
Expanded : String (1 .. Length);
|
124 |
|
|
end record;
|
125 |
|
|
|
126 |
|
|
type Format_Record is record
|
127 |
|
|
Picture : Picture_Record;
|
128 |
|
|
-- Read only
|
129 |
|
|
|
130 |
|
|
Blank_When_Zero : Boolean;
|
131 |
|
|
-- Read/write
|
132 |
|
|
|
133 |
|
|
Original_BWZ : Boolean;
|
134 |
|
|
|
135 |
|
|
-- The following components get written
|
136 |
|
|
|
137 |
|
|
Star_Fill : Boolean := False;
|
138 |
|
|
|
139 |
|
|
Radix_Position : Integer := Invalid_Position;
|
140 |
|
|
|
141 |
|
|
Sign_Position,
|
142 |
|
|
Second_Sign : Integer := Invalid_Position;
|
143 |
|
|
|
144 |
|
|
Start_Float,
|
145 |
|
|
End_Float : Integer := Invalid_Position;
|
146 |
|
|
|
147 |
|
|
Start_Currency,
|
148 |
|
|
End_Currency : Integer := Invalid_Position;
|
149 |
|
|
|
150 |
|
|
Max_Leading_Digits : Integer := 0;
|
151 |
|
|
|
152 |
|
|
Max_Trailing_Digits : Integer := 0;
|
153 |
|
|
|
154 |
|
|
Max_Currency_Digits : Integer := 0;
|
155 |
|
|
|
156 |
|
|
Floater : Character := '!';
|
157 |
|
|
-- Initialized to illegal value
|
158 |
|
|
|
159 |
|
|
end record;
|
160 |
|
|
|
161 |
|
|
type Picture is record
|
162 |
|
|
Contents : Format_Record;
|
163 |
|
|
end record;
|
164 |
|
|
|
165 |
|
|
type Number_Attributes is record
|
166 |
|
|
Negative : Boolean := False;
|
167 |
|
|
|
168 |
|
|
Has_Fraction : Boolean := False;
|
169 |
|
|
|
170 |
|
|
Start_Of_Int,
|
171 |
|
|
End_Of_Int,
|
172 |
|
|
Start_Of_Fraction,
|
173 |
|
|
End_Of_Fraction : Integer := Invalid_Position; -- invalid value
|
174 |
|
|
end record;
|
175 |
|
|
|
176 |
|
|
function Parse_Number_String (Str : String) return Number_Attributes;
|
177 |
|
|
-- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
|
178 |
|
|
-- trailing blanks...)
|
179 |
|
|
|
180 |
|
|
procedure Precalculate (Pic : in out Format_Record);
|
181 |
|
|
-- Precalculates fields from the user supplied data
|
182 |
|
|
|
183 |
|
|
function Format_Number
|
184 |
|
|
(Pic : Format_Record;
|
185 |
|
|
Number : String;
|
186 |
|
|
Currency_Symbol : String;
|
187 |
|
|
Fill_Character : Character;
|
188 |
|
|
Separator_Character : Character;
|
189 |
|
|
Radix_Point : Character) return String;
|
190 |
|
|
-- Formats number according to Pic
|
191 |
|
|
|
192 |
|
|
function Expand (Picture : String) return String;
|
193 |
|
|
|
194 |
|
|
end Ada.Text_IO.Editing;
|