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 --
10 -- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the contents of the part following the private keyword. --
16 -- GNAT is free software; you can redistribute it and/or modify it under --
17 -- terms of the GNU General Public License as published by the Free Soft- --
18 -- ware Foundation; either version 2, or (at your option) any later ver- --
19 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
22 -- for more details. You should have received a copy of the GNU General --
23 -- Public License distributed with GNAT; see file COPYING. If not, write --
24 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
25 -- MA 02111-1307, USA. --
27 -- As a special exception, if other files instantiate generics from this --
28 -- unit, or you link this unit with other files to produce an executable, --
29 -- this unit does not by itself cause the resulting executable to be --
30 -- covered by the GNU General Public License. This exception does not --
31 -- however invalidate any other reasons why the executable file might be --
32 -- covered by the GNU Public License. --
34 -- GNAT was originally developed by the GNAT team at New York University. --
35 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
37 ------------------------------------------------------------------------------
39 package Ada
.Wide_Text_IO
.Editing
is
41 type Picture
is private;
44 (Pic_String
: in String;
45 Blank_When_Zero
: in Boolean := False)
49 (Pic_String
: in String;
50 Blank_When_Zero
: in Boolean := False)
53 function Pic_String
(Pic
: in Picture
) return String;
54 function Blank_When_Zero
(Pic
: in Picture
) return Boolean;
56 Max_Picture_Length
: constant := 64;
58 Picture_Error
: exception;
60 Default_Currency
: constant Wide_String := "$";
61 Default_Fill
: constant Wide_Character := ' ';
62 Default_Separator
: constant Wide_Character := ',';
63 Default_Radix_Mark
: constant Wide_Character := '.';
66 type Num
is delta <> digits <>;
67 Default_Currency
: in Wide_String :=
68 Wide_Text_IO
.Editing
.Default_Currency
;
69 Default_Fill
: in Wide_Character :=
70 Wide_Text_IO
.Editing
.Default_Fill
;
71 Default_Separator
: in Wide_Character :=
72 Wide_Text_IO
.Editing
.Default_Separator
;
73 Default_Radix_Mark
: in Wide_Character :=
74 Wide_Text_IO
.Editing
.Default_Radix_Mark
;
76 package Decimal_Output
is
80 Currency
: in Wide_String := Default_Currency
)
86 Currency
: in Wide_String := Default_Currency
)
92 Currency
: in Wide_String := Default_Currency
;
93 Fill
: in Wide_Character := Default_Fill
;
94 Separator
: in Wide_Character := Default_Separator
;
95 Radix_Mark
: in Wide_Character := Default_Radix_Mark
)
102 Currency
: in Wide_String := Default_Currency
;
103 Fill
: in Wide_Character := Default_Fill
;
104 Separator
: in Wide_Character := Default_Separator
;
105 Radix_Mark
: in Wide_Character := Default_Radix_Mark
);
110 Currency
: in Wide_String := Default_Currency
;
111 Fill
: in Wide_Character := Default_Fill
;
112 Separator
: in Wide_Character := Default_Separator
;
113 Radix_Mark
: in Wide_Character := Default_Radix_Mark
);
116 (To
: out Wide_String;
119 Currency
: in Wide_String := Default_Currency
;
120 Fill
: in Wide_Character := Default_Fill
;
121 Separator
: in Wide_Character := Default_Separator
;
122 Radix_Mark
: in Wide_Character := Default_Radix_Mark
);
127 MAX_PICSIZE
: constant := 50;
128 MAX_MONEYSIZE
: constant := 10;
129 Invalid_Position
: constant := -1;
131 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
133 type Picture_Record
(Length
: Pic_Index
:= 0) is record
134 Expanded
: String (1 .. Length
);
137 type Format_Record
is record
138 Picture
: Picture_Record
;
141 Blank_When_Zero
: Boolean;
144 Original_BWZ
: Boolean;
146 -- The following components get written
148 Star_Fill
: Boolean := False;
150 Radix_Position
: Integer := Invalid_Position
;
153 Second_Sign
: Integer := Invalid_Position
;
156 End_Float
: Integer := Invalid_Position
;
159 End_Currency
: Integer := Invalid_Position
;
161 Max_Leading_Digits
: Integer := 0;
163 Max_Trailing_Digits
: Integer := 0;
165 Max_Currency_Digits
: Integer := 0;
167 Floater
: Wide_Character := '!';
168 -- Initialized to illegal value
172 type Picture
is record
173 Contents
: Format_Record
;
176 type Number_Attributes
is record
177 Negative
: Boolean := False;
179 Has_Fraction
: Boolean := False;
184 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
187 function Parse_Number_String
(Str
: String) return Number_Attributes
;
188 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
189 -- trailing blanks...)
191 procedure Precalculate
(Pic
: in out Format_Record
);
192 -- Precalculates fields from the user supplied data
194 function Format_Number
195 (Pic
: Format_Record
;
197 Currency_Symbol
: Wide_String;
198 Fill_Character
: Wide_Character;
199 Separator_Character
: Wide_Character;
200 Radix_Point
: Wide_Character)
202 -- Formats number according to Pic
204 function Expand
(Picture
: in String) return String;
206 end Ada
.Wide_Text_IO
.Editing
;