1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . W I D E _ W I D E _ T E X T _ I O . E D I T I N G --
9 -- Copyright (C) 1992-2006, 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 2, 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. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
36 ------------------------------------------------------------------------------
38 package Ada
.Wide_Wide_Text_IO
.Editing
is
40 type Picture
is private;
44 Blank_When_Zero
: Boolean := False) return Boolean;
48 Blank_When_Zero
: Boolean := False) return Picture
;
50 function Pic_String
(Pic
: Picture
) return String;
51 function Blank_When_Zero
(Pic
: Picture
) return Boolean;
53 Max_Picture_Length
: constant := 64;
55 Picture_Error
: exception;
57 Default_Currency
: constant Wide_Wide_String
:= "$";
58 Default_Fill
: constant Wide_Wide_Character
:= ' ';
59 Default_Separator
: constant Wide_Wide_Character
:= ',';
60 Default_Radix_Mark
: constant Wide_Wide_Character
:= '.';
63 type Num
is delta <> digits <>;
64 Default_Currency
: Wide_Wide_String
:=
65 Wide_Wide_Text_IO
.Editing
.Default_Currency
;
66 Default_Fill
: Wide_Wide_Character
:=
67 Wide_Wide_Text_IO
.Editing
.Default_Fill
;
68 Default_Separator
: Wide_Wide_Character
:=
69 Wide_Wide_Text_IO
.Editing
.Default_Separator
;
70 Default_Radix_Mark
: Wide_Wide_Character
:=
71 Wide_Wide_Text_IO
.Editing
.Default_Radix_Mark
;
73 package Decimal_Output
is
77 Currency
: Wide_Wide_String
:= Default_Currency
) return Natural;
82 Currency
: Wide_Wide_String
:= Default_Currency
) return Boolean;
87 Currency
: Wide_Wide_String
:= Default_Currency
;
88 Fill
: Wide_Wide_Character
:= Default_Fill
;
89 Separator
: Wide_Wide_Character
:= Default_Separator
;
90 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
)
91 return Wide_Wide_String
;
97 Currency
: Wide_Wide_String
:= Default_Currency
;
98 Fill
: Wide_Wide_Character
:= Default_Fill
;
99 Separator
: Wide_Wide_Character
:= Default_Separator
;
100 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
);
105 Currency
: Wide_Wide_String
:= Default_Currency
;
106 Fill
: Wide_Wide_Character
:= Default_Fill
;
107 Separator
: Wide_Wide_Character
:= Default_Separator
;
108 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
);
111 (To
: out Wide_Wide_String
;
114 Currency
: Wide_Wide_String
:= Default_Currency
;
115 Fill
: Wide_Wide_Character
:= Default_Fill
;
116 Separator
: Wide_Wide_Character
:= Default_Separator
;
117 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
);
122 MAX_PICSIZE
: constant := 50;
123 MAX_MONEYSIZE
: constant := 10;
124 Invalid_Position
: constant := -1;
126 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
128 type Picture_Record
(Length
: Pic_Index
:= 0) is record
129 Expanded
: String (1 .. Length
);
132 type Format_Record
is record
133 Picture
: Picture_Record
;
136 Blank_When_Zero
: Boolean;
139 Original_BWZ
: Boolean;
141 -- The following components get written
143 Star_Fill
: Boolean := False;
145 Radix_Position
: Integer := Invalid_Position
;
148 Second_Sign
: Integer := Invalid_Position
;
151 End_Float
: Integer := Invalid_Position
;
154 End_Currency
: Integer := Invalid_Position
;
156 Max_Leading_Digits
: Integer := 0;
158 Max_Trailing_Digits
: Integer := 0;
160 Max_Currency_Digits
: Integer := 0;
162 Floater
: Wide_Wide_Character
:= '!';
163 -- Initialized to illegal value
167 type Picture
is record
168 Contents
: Format_Record
;
171 type Number_Attributes
is record
172 Negative
: Boolean := False;
174 Has_Fraction
: Boolean := False;
179 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
182 function Parse_Number_String
(Str
: String) return Number_Attributes
;
183 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
184 -- trailing blanks...)
186 procedure Precalculate
(Pic
: in out Format_Record
);
187 -- Precalculates fields from the user supplied data
189 function Format_Number
190 (Pic
: Format_Record
;
192 Currency_Symbol
: Wide_Wide_String
;
193 Fill_Character
: Wide_Wide_Character
;
194 Separator_Character
: Wide_Wide_Character
;
195 Radix_Point
: Wide_Wide_Character
) return Wide_Wide_String
;
196 -- Formats number according to Pic
198 function Expand
(Picture
: String) return String;
200 end Ada
.Wide_Wide_Text_IO
.Editing
;