1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ T E X T _ I O . E D I T I N G --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
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. --
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. --
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. --
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/>. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
34 ------------------------------------------------------------------------------
36 package Ada
.Wide_Text_IO
.Editing
is
38 type Picture
is private;
42 Blank_When_Zero
: Boolean := False) return Boolean;
46 Blank_When_Zero
: Boolean := False) return Picture
;
48 function Pic_String
(Pic
: Picture
) return String;
49 function Blank_When_Zero
(Pic
: Picture
) return Boolean;
51 Max_Picture_Length
: constant := 64;
53 Picture_Error
: exception;
55 Default_Currency
: constant Wide_String := "$";
56 Default_Fill
: constant Wide_Character := ' ';
57 Default_Separator
: constant Wide_Character := ',';
58 Default_Radix_Mark
: constant Wide_Character := '.';
61 type Num
is delta <> digits <>;
62 Default_Currency
: Wide_String :=
63 Wide_Text_IO
.Editing
.Default_Currency
;
64 Default_Fill
: Wide_Character :=
65 Wide_Text_IO
.Editing
.Default_Fill
;
66 Default_Separator
: Wide_Character :=
67 Wide_Text_IO
.Editing
.Default_Separator
;
68 Default_Radix_Mark
: Wide_Character :=
69 Wide_Text_IO
.Editing
.Default_Radix_Mark
;
71 package Decimal_Output
is
75 Currency
: Wide_String := Default_Currency
) return Natural;
80 Currency
: Wide_String := Default_Currency
) return Boolean;
85 Currency
: Wide_String := Default_Currency
;
86 Fill
: Wide_Character := Default_Fill
;
87 Separator
: Wide_Character := Default_Separator
;
88 Radix_Mark
: Wide_Character := Default_Radix_Mark
) return Wide_String;
94 Currency
: Wide_String := Default_Currency
;
95 Fill
: Wide_Character := Default_Fill
;
96 Separator
: Wide_Character := Default_Separator
;
97 Radix_Mark
: Wide_Character := Default_Radix_Mark
);
102 Currency
: Wide_String := Default_Currency
;
103 Fill
: Wide_Character := Default_Fill
;
104 Separator
: Wide_Character := Default_Separator
;
105 Radix_Mark
: Wide_Character := Default_Radix_Mark
);
108 (To
: out Wide_String;
111 Currency
: Wide_String := Default_Currency
;
112 Fill
: Wide_Character := Default_Fill
;
113 Separator
: Wide_Character := Default_Separator
;
114 Radix_Mark
: Wide_Character := Default_Radix_Mark
);
119 MAX_PICSIZE
: constant := 50;
120 MAX_MONEYSIZE
: constant := 10;
121 Invalid_Position
: constant := -1;
123 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
125 type Picture_Record
(Length
: Pic_Index
:= 0) is record
126 Expanded
: String (1 .. Length
);
129 type Format_Record
is record
130 Picture
: Picture_Record
;
133 Blank_When_Zero
: Boolean;
136 Original_BWZ
: Boolean;
138 -- The following components get written
140 Star_Fill
: Boolean := False;
142 Radix_Position
: Integer := Invalid_Position
;
145 Second_Sign
: Integer := Invalid_Position
;
148 End_Float
: Integer := Invalid_Position
;
151 End_Currency
: Integer := Invalid_Position
;
153 Max_Leading_Digits
: Integer := 0;
155 Max_Trailing_Digits
: Integer := 0;
157 Max_Currency_Digits
: Integer := 0;
159 Floater
: Wide_Character := '!';
160 -- Initialized to illegal value
164 type Picture
is record
165 Contents
: Format_Record
;
168 type Number_Attributes
is record
169 Negative
: Boolean := False;
171 Has_Fraction
: Boolean := False;
176 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
179 function Parse_Number_String
(Str
: String) return Number_Attributes
;
180 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
181 -- trailing blanks...)
183 procedure Precalculate
(Pic
: in out Format_Record
);
184 -- Precalculates fields from the user supplied data
186 function Format_Number
187 (Pic
: Format_Record
;
189 Currency_Symbol
: Wide_String;
190 Fill_Character
: Wide_Character;
191 Separator_Character
: Wide_Character;
192 Radix_Point
: Wide_Character) return Wide_String;
193 -- Formats number according to Pic
195 function Expand
(Picture
: String) return String;
197 end Ada
.Wide_Text_IO
.Editing
;