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-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
.Wide_Wide_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 Wide_Wide_String
:= "$";
56 Default_Fill
: constant Wide_Wide_Character
:= ' ';
57 Default_Separator
: constant Wide_Wide_Character
:= ',';
58 Default_Radix_Mark
: constant Wide_Wide_Character
:= '.';
61 type Num
is delta <> digits <>;
62 Default_Currency
: Wide_Wide_String
:=
63 Wide_Wide_Text_IO
.Editing
.Default_Currency
;
64 Default_Fill
: Wide_Wide_Character
:=
65 Wide_Wide_Text_IO
.Editing
.Default_Fill
;
66 Default_Separator
: Wide_Wide_Character
:=
67 Wide_Wide_Text_IO
.Editing
.Default_Separator
;
68 Default_Radix_Mark
: Wide_Wide_Character
:=
69 Wide_Wide_Text_IO
.Editing
.Default_Radix_Mark
;
71 package Decimal_Output
is
75 Currency
: Wide_Wide_String
:= Default_Currency
) return Natural;
80 Currency
: Wide_Wide_String
:= Default_Currency
) return Boolean;
85 Currency
: Wide_Wide_String
:= Default_Currency
;
86 Fill
: Wide_Wide_Character
:= Default_Fill
;
87 Separator
: Wide_Wide_Character
:= Default_Separator
;
88 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
)
89 return Wide_Wide_String
;
95 Currency
: Wide_Wide_String
:= Default_Currency
;
96 Fill
: Wide_Wide_Character
:= Default_Fill
;
97 Separator
: Wide_Wide_Character
:= Default_Separator
;
98 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
);
103 Currency
: Wide_Wide_String
:= Default_Currency
;
104 Fill
: Wide_Wide_Character
:= Default_Fill
;
105 Separator
: Wide_Wide_Character
:= Default_Separator
;
106 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
);
109 (To
: out Wide_Wide_String
;
112 Currency
: Wide_Wide_String
:= Default_Currency
;
113 Fill
: Wide_Wide_Character
:= Default_Fill
;
114 Separator
: Wide_Wide_Character
:= Default_Separator
;
115 Radix_Mark
: Wide_Wide_Character
:= Default_Radix_Mark
);
120 MAX_PICSIZE
: constant := 50;
121 MAX_MONEYSIZE
: constant := 10;
122 Invalid_Position
: constant := -1;
124 subtype Pic_Index
is Natural range 0 .. MAX_PICSIZE
;
126 type Picture_Record
(Length
: Pic_Index
:= 0) is record
127 Expanded
: String (1 .. Length
);
130 type Format_Record
is record
131 Picture
: Picture_Record
;
134 Blank_When_Zero
: Boolean;
137 Original_BWZ
: Boolean;
139 -- The following components get written
141 Star_Fill
: Boolean := False;
143 Radix_Position
: Integer := Invalid_Position
;
146 Second_Sign
: Integer := Invalid_Position
;
149 End_Float
: Integer := Invalid_Position
;
152 End_Currency
: Integer := Invalid_Position
;
154 Max_Leading_Digits
: Integer := 0;
156 Max_Trailing_Digits
: Integer := 0;
158 Max_Currency_Digits
: Integer := 0;
160 Floater
: Wide_Wide_Character
:= '!';
161 -- Initialized to illegal value
165 type Picture
is record
166 Contents
: Format_Record
;
169 type Number_Attributes
is record
170 Negative
: Boolean := False;
172 Has_Fraction
: Boolean := False;
177 End_Of_Fraction
: Integer := Invalid_Position
; -- invalid value
180 function Parse_Number_String
(Str
: String) return Number_Attributes
;
181 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
182 -- trailing blanks...)
184 procedure Precalculate
(Pic
: in out Format_Record
);
185 -- Precalculates fields from the user supplied data
187 function Format_Number
188 (Pic
: Format_Record
;
190 Currency_Symbol
: Wide_Wide_String
;
191 Fill_Character
: Wide_Wide_Character
;
192 Separator_Character
: Wide_Wide_Character
;
193 Radix_Point
: Wide_Wide_Character
) return Wide_Wide_String
;
194 -- Formats number according to Pic
196 function Expand
(Picture
: String) return String;
198 end Ada
.Wide_Wide_Text_IO
.Editing
;