1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . E D I T I N G --
9 -- $Revision: 1.1.16.1 $
11 -- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
13 -- This specification is derived from the Ada Reference Manual for use with --
14 -- GNAT. The copyright notice above, and the license provisions that follow --
15 -- apply solely to the contents of the part following the private keyword. --
17 -- GNAT is free software; you can redistribute it and/or modify it under --
18 -- terms of the GNU General Public License as published by the Free Soft- --
19 -- ware Foundation; either version 2, or (at your option) any later ver- --
20 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
21 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
22 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
23 -- for more details. You should have received a copy of the GNU General --
24 -- Public License distributed with GNAT; see file COPYING. If not, write --
25 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
26 -- MA 02111-1307, USA. --
28 -- As a special exception, if other files instantiate generics from this --
29 -- unit, or you link this unit with other files to produce an executable, --
30 -- this unit does not by itself cause the resulting executable to be --
31 -- covered by the GNU General Public License. This exception does not --
32 -- however invalidate any other reasons why the executable file might be --
33 -- covered by the GNU Public License. --
35 -- GNAT was originally developed by the GNAT team at New York University. --
36 -- Extensive contributions were provided by Ada Core Technologies Inc. --
38 ------------------------------------------------------------------------------
40 package Ada
.Text_IO
.Editing
is
42 type Picture
is private;
45 (Pic_String
: in String;
46 Blank_When_Zero
: in Boolean := False)
50 (Pic_String
: in String;
51 Blank_When_Zero
: in Boolean := False)
54 function Pic_String
(Pic
: in Picture
) return String;
55 function Blank_When_Zero
(Pic
: in Picture
) return Boolean;
57 Max_Picture_Length
: constant := 64;
59 Picture_Error
: exception;
61 Default_Currency
: constant String := "$";
62 Default_Fill
: constant Character := ' ';
63 Default_Separator
: constant Character := ',';
64 Default_Radix_Mark
: constant Character := '.';
67 type Num
is delta <> digits <>;
68 Default_Currency
: in String := Editing
.Default_Currency
;
69 Default_Fill
: in Character := Editing
.Default_Fill
;
70 Default_Separator
: in Character := Editing
.Default_Separator
;
71 Default_Radix_Mark
: in Character := Editing
.Default_Radix_Mark
;
73 package Decimal_Output
is
77 Currency
: in String := Default_Currency
)
83 Currency
: in String := Default_Currency
)
89 Currency
: in String := Default_Currency
;
90 Fill
: in Character := Default_Fill
;
91 Separator
: in Character := Default_Separator
;
92 Radix_Mark
: in Character := Default_Radix_Mark
)
96 (File
: in Ada
.Text_IO
.File_Type
;
99 Currency
: in String := Default_Currency
;
100 Fill
: in Character := Default_Fill
;
101 Separator
: in Character := Default_Separator
;
102 Radix_Mark
: in Character := Default_Radix_Mark
);
107 Currency
: in String := Default_Currency
;
108 Fill
: in Character := Default_Fill
;
109 Separator
: in Character := Default_Separator
;
110 Radix_Mark
: in Character := Default_Radix_Mark
);
116 Currency
: in String := Default_Currency
;
117 Fill
: in Character := Default_Fill
;
118 Separator
: in Character := Default_Separator
;
119 Radix_Mark
: in Character := Default_Radix_Mark
);
125 MAX_PICSIZE
: constant := 50;
126 MAX_MONEYSIZE
: constant := 10;
127 Invalid_Position
: constant := -1;
129 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
131 type Picture_Record
(Length
: Pic_Index
:= 0) is record
132 Expanded
: String (1 .. Length
);
135 type Format_Record
is record
136 Picture
: Picture_Record
;
139 Blank_When_Zero
: Boolean;
142 Original_BWZ
: Boolean;
144 -- The following components get written
146 Star_Fill
: Boolean := False;
148 Radix_Position
: Integer := Invalid_Position
;
151 Second_Sign
: Integer := Invalid_Position
;
154 End_Float
: Integer := Invalid_Position
;
157 End_Currency
: Integer := Invalid_Position
;
159 Max_Leading_Digits
: Integer := 0;
161 Max_Trailing_Digits
: Integer := 0;
163 Max_Currency_Digits
: Integer := 0;
165 Floater
: Character := '!';
166 -- Initialized to illegal value
170 type Picture
is record
171 Contents
: Format_Record
;
174 type Number_Attributes
is record
175 Negative
: Boolean := False;
177 Has_Fraction
: Boolean := False;
182 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
185 function Parse_Number_String
(Str
: String) return Number_Attributes
;
186 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
187 -- trailing blanks...)
189 procedure Precalculate
(Pic
: in out Format_Record
);
190 -- Precalculates fields from the user supplied data
192 function Format_Number
193 (Pic
: Format_Record
;
195 Currency_Symbol
: String;
196 Fill_Character
: Character;
197 Separator_Character
: Character;
198 Radix_Point
: Character)
200 -- Formats number according to Pic
202 function Expand
(Picture
: in String) return String;
204 end Ada
.Text_IO
.Editing
;