1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . E D I T I N G --
9 -- Copyright (C) 1992-2009, 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
.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 String := "$";
56 Default_Fill
: constant Character := '*';
57 Default_Separator
: constant Character := ',';
58 Default_Radix_Mark
: constant Character := '.';
61 type Num
is delta <> digits <>;
62 Default_Currency
: String := Editing
.Default_Currency
;
63 Default_Fill
: Character := Editing
.Default_Fill
;
64 Default_Separator
: Character := Editing
.Default_Separator
;
65 Default_Radix_Mark
: Character := Editing
.Default_Radix_Mark
;
67 package Decimal_Output
is
71 Currency
: String := Default_Currency
) return Natural;
76 Currency
: String := Default_Currency
) return Boolean;
81 Currency
: String := Default_Currency
;
82 Fill
: Character := Default_Fill
;
83 Separator
: Character := Default_Separator
;
84 Radix_Mark
: Character := Default_Radix_Mark
) return String;
87 (File
: Ada
.Text_IO
.File_Type
;
90 Currency
: String := Default_Currency
;
91 Fill
: Character := Default_Fill
;
92 Separator
: Character := Default_Separator
;
93 Radix_Mark
: Character := Default_Radix_Mark
);
98 Currency
: String := Default_Currency
;
99 Fill
: Character := Default_Fill
;
100 Separator
: Character := Default_Separator
;
101 Radix_Mark
: Character := Default_Radix_Mark
);
107 Currency
: String := Default_Currency
;
108 Fill
: Character := Default_Fill
;
109 Separator
: Character := Default_Separator
;
110 Radix_Mark
: Character := Default_Radix_Mark
);
116 MAX_PICSIZE
: constant := 50;
117 MAX_MONEYSIZE
: constant := 10;
118 Invalid_Position
: constant := -1;
120 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
122 type Picture_Record
(Length
: Pic_Index
:= 0) is record
123 Expanded
: String (1 .. Length
);
126 type Format_Record
is record
127 Picture
: Picture_Record
;
130 Blank_When_Zero
: Boolean;
133 Original_BWZ
: Boolean;
135 -- The following components get written
137 Star_Fill
: Boolean := False;
139 Radix_Position
: Integer := Invalid_Position
;
142 Second_Sign
: Integer := Invalid_Position
;
145 End_Float
: Integer := Invalid_Position
;
148 End_Currency
: Integer := Invalid_Position
;
150 Max_Leading_Digits
: Integer := 0;
152 Max_Trailing_Digits
: Integer := 0;
154 Max_Currency_Digits
: Integer := 0;
156 Floater
: Character := '!';
157 -- Initialized to illegal value
161 type Picture
is record
162 Contents
: Format_Record
;
165 type Number_Attributes
is record
166 Negative
: Boolean := False;
168 Has_Fraction
: Boolean := False;
173 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
176 function Parse_Number_String
(Str
: String) return Number_Attributes
;
177 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
178 -- trailing blanks...)
180 procedure Precalculate
(Pic
: in out Format_Record
);
181 -- Precalculates fields from the user supplied data
183 function Format_Number
184 (Pic
: Format_Record
;
186 Currency_Symbol
: String;
187 Fill_Character
: Character;
188 Separator_Character
: Character;
189 Radix_Point
: Character) return String;
190 -- Formats number according to Pic
192 function Expand
(Picture
: String) return String;
194 end Ada
.Text_IO
.Editing
;