PR target/16201
[official-gcc.git] / gcc / ada / a-teioed.ads
blob37ad4a0d2ac2ec70fd38c963e3ea25a693591496
1 ------------------------------------------------------------------------------
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-1997 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 2, 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. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
24 -- MA 02111-1307, USA. --
25 -- --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
32 -- --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
35 -- --
36 ------------------------------------------------------------------------------
38 package Ada.Text_IO.Editing is
40 type Picture is private;
42 function Valid
43 (Pic_String : in String;
44 Blank_When_Zero : in Boolean := False)
45 return Boolean;
47 function To_Picture
48 (Pic_String : in String;
49 Blank_When_Zero : in Boolean := False)
50 return Picture;
52 function Pic_String (Pic : in Picture) return String;
53 function Blank_When_Zero (Pic : in Picture) return Boolean;
55 Max_Picture_Length : constant := 64;
57 Picture_Error : exception;
59 Default_Currency : constant String := "$";
60 Default_Fill : constant Character := ' ';
61 Default_Separator : constant Character := ',';
62 Default_Radix_Mark : constant Character := '.';
64 generic
65 type Num is delta <> digits <>;
66 Default_Currency : in String := Editing.Default_Currency;
67 Default_Fill : in Character := Editing.Default_Fill;
68 Default_Separator : in Character := Editing.Default_Separator;
69 Default_Radix_Mark : in Character := Editing.Default_Radix_Mark;
71 package Decimal_Output is
73 function Length
74 (Pic : in Picture;
75 Currency : in String := Default_Currency)
76 return Natural;
78 function Valid
79 (Item : Num;
80 Pic : in Picture;
81 Currency : in String := Default_Currency)
82 return Boolean;
84 function Image
85 (Item : Num;
86 Pic : in Picture;
87 Currency : in String := Default_Currency;
88 Fill : in Character := Default_Fill;
89 Separator : in Character := Default_Separator;
90 Radix_Mark : in Character := Default_Radix_Mark)
91 return String;
93 procedure Put
94 (File : in Ada.Text_IO.File_Type;
95 Item : Num;
96 Pic : in Picture;
97 Currency : in String := Default_Currency;
98 Fill : in Character := Default_Fill;
99 Separator : in Character := Default_Separator;
100 Radix_Mark : in Character := Default_Radix_Mark);
102 procedure Put
103 (Item : Num;
104 Pic : in Picture;
105 Currency : in String := Default_Currency;
106 Fill : in Character := Default_Fill;
107 Separator : in Character := Default_Separator;
108 Radix_Mark : in Character := Default_Radix_Mark);
110 procedure Put
111 (To : out String;
112 Item : Num;
113 Pic : in Picture;
114 Currency : in String := Default_Currency;
115 Fill : in Character := Default_Fill;
116 Separator : in Character := Default_Separator;
117 Radix_Mark : in Character := Default_Radix_Mark);
119 end Decimal_Output;
121 private
123 MAX_PICSIZE : constant := 50;
124 MAX_MONEYSIZE : constant := 10;
125 Invalid_Position : constant := -1;
127 subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
129 type Picture_Record (Length : Pic_Index := 0) is record
130 Expanded : String (1 .. Length);
131 end record;
133 type Format_Record is record
134 Picture : Picture_Record;
135 -- Read only
137 Blank_When_Zero : Boolean;
138 -- Read/write
140 Original_BWZ : Boolean;
142 -- The following components get written
144 Star_Fill : Boolean := False;
146 Radix_Position : Integer := Invalid_Position;
148 Sign_Position,
149 Second_Sign : Integer := Invalid_Position;
151 Start_Float,
152 End_Float : Integer := Invalid_Position;
154 Start_Currency,
155 End_Currency : Integer := Invalid_Position;
157 Max_Leading_Digits : Integer := 0;
159 Max_Trailing_Digits : Integer := 0;
161 Max_Currency_Digits : Integer := 0;
163 Floater : Character := '!';
164 -- Initialized to illegal value
166 end record;
168 type Picture is record
169 Contents : Format_Record;
170 end record;
172 type Number_Attributes is record
173 Negative : Boolean := False;
175 Has_Fraction : Boolean := False;
177 Start_Of_Int,
178 End_Of_Int,
179 Start_Of_Fraction,
180 End_Of_Fraction : Integer := Invalid_Position; -- invalid value
181 end record;
183 function Parse_Number_String (Str : String) return Number_Attributes;
184 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
185 -- trailing blanks...)
187 procedure Precalculate (Pic : in out Format_Record);
188 -- Precalculates fields from the user supplied data
190 function Format_Number
191 (Pic : Format_Record;
192 Number : String;
193 Currency_Symbol : String;
194 Fill_Character : Character;
195 Separator_Character : Character;
196 Radix_Point : Character)
197 return String;
198 -- Formats number according to Pic
200 function Expand (Picture : in String) return String;
202 end Ada.Text_IO.Editing;