1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . 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 -- Extensive contributions were provided by Ada Core Technologies Inc. --
37 ------------------------------------------------------------------------------
39 package Ada
.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 String := "$";
61 Default_Fill
: constant Character := ' ';
62 Default_Separator
: constant Character := ',';
63 Default_Radix_Mark
: constant Character := '.';
66 type Num
is delta <> digits <>;
67 Default_Currency
: in String := Editing
.Default_Currency
;
68 Default_Fill
: in Character := Editing
.Default_Fill
;
69 Default_Separator
: in Character := Editing
.Default_Separator
;
70 Default_Radix_Mark
: in Character := Editing
.Default_Radix_Mark
;
72 package Decimal_Output
is
76 Currency
: in String := Default_Currency
)
82 Currency
: in String := Default_Currency
)
88 Currency
: in String := Default_Currency
;
89 Fill
: in Character := Default_Fill
;
90 Separator
: in Character := Default_Separator
;
91 Radix_Mark
: in Character := Default_Radix_Mark
)
95 (File
: in Ada
.Text_IO
.File_Type
;
98 Currency
: in String := Default_Currency
;
99 Fill
: in Character := Default_Fill
;
100 Separator
: in Character := Default_Separator
;
101 Radix_Mark
: in Character := Default_Radix_Mark
);
106 Currency
: in String := Default_Currency
;
107 Fill
: in Character := Default_Fill
;
108 Separator
: in Character := Default_Separator
;
109 Radix_Mark
: in Character := Default_Radix_Mark
);
115 Currency
: in String := Default_Currency
;
116 Fill
: in Character := Default_Fill
;
117 Separator
: in Character := Default_Separator
;
118 Radix_Mark
: in Character := Default_Radix_Mark
);
124 MAX_PICSIZE
: constant := 50;
125 MAX_MONEYSIZE
: constant := 10;
126 Invalid_Position
: constant := -1;
128 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
130 type Picture_Record
(Length
: Pic_Index
:= 0) is record
131 Expanded
: String (1 .. Length
);
134 type Format_Record
is record
135 Picture
: Picture_Record
;
138 Blank_When_Zero
: Boolean;
141 Original_BWZ
: Boolean;
143 -- The following components get written
145 Star_Fill
: Boolean := False;
147 Radix_Position
: Integer := Invalid_Position
;
150 Second_Sign
: Integer := Invalid_Position
;
153 End_Float
: Integer := Invalid_Position
;
156 End_Currency
: Integer := Invalid_Position
;
158 Max_Leading_Digits
: Integer := 0;
160 Max_Trailing_Digits
: Integer := 0;
162 Max_Currency_Digits
: Integer := 0;
164 Floater
: Character := '!';
165 -- Initialized to illegal value
169 type Picture
is record
170 Contents
: Format_Record
;
173 type Number_Attributes
is record
174 Negative
: Boolean := False;
176 Has_Fraction
: Boolean := False;
181 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
184 function Parse_Number_String
(Str
: String) return Number_Attributes
;
185 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
186 -- trailing blanks...)
188 procedure Precalculate
(Pic
: in out Format_Record
);
189 -- Precalculates fields from the user supplied data
191 function Format_Number
192 (Pic
: Format_Record
;
194 Currency_Symbol
: String;
195 Fill_Character
: Character;
196 Separator_Character
: Character;
197 Radix_Point
: Character)
199 -- Formats number according to Pic
201 function Expand
(Picture
: in String) return String;
203 end Ada
.Text_IO
.Editing
;