2003-11-27 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / a-wtedit.ads
blob06e30a75eb0e1e4b91d1789d65e63618b9984a60
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . W I D E _ T E X T _ I O . E D I T I N G --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
10 -- --
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. --
14 -- --
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, 59 Temple Place - Suite 330, Boston, --
24 -- MA 02111-1307, USA. --
25 -- --
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. --
32 -- --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
35 -- --
36 ------------------------------------------------------------------------------
38 package Ada.Wide_Text_IO.Editing is
40 type Picture is private;
42 function Valid
43 (Pic_String : in String;
44 Blank_When_Zero : in Boolean := False)
45 return Boolean;
47 function To_Picture
48 (Pic_String : in String;
49 Blank_When_Zero : in Boolean := False)
50 return Picture;
52 function Pic_String (Pic : in Picture) return String;
53 function Blank_When_Zero (Pic : in Picture) return Boolean;
55 Max_Picture_Length : constant := 64;
57 Picture_Error : exception;
59 Default_Currency : constant Wide_String := "$";
60 Default_Fill : constant Wide_Character := ' ';
61 Default_Separator : constant Wide_Character := ',';
62 Default_Radix_Mark : constant Wide_Character := '.';
64 generic
65 type Num is delta <> digits <>;
66 Default_Currency : in Wide_String :=
67 Wide_Text_IO.Editing.Default_Currency;
68 Default_Fill : in Wide_Character :=
69 Wide_Text_IO.Editing.Default_Fill;
70 Default_Separator : in Wide_Character :=
71 Wide_Text_IO.Editing.Default_Separator;
72 Default_Radix_Mark : in Wide_Character :=
73 Wide_Text_IO.Editing.Default_Radix_Mark;
75 package Decimal_Output is
77 function Length
78 (Pic : in Picture;
79 Currency : in Wide_String := Default_Currency)
80 return Natural;
82 function Valid
83 (Item : Num;
84 Pic : in Picture;
85 Currency : in Wide_String := Default_Currency)
86 return Boolean;
88 function Image
89 (Item : Num;
90 Pic : in Picture;
91 Currency : in Wide_String := Default_Currency;
92 Fill : in Wide_Character := Default_Fill;
93 Separator : in Wide_Character := Default_Separator;
94 Radix_Mark : in Wide_Character := Default_Radix_Mark)
95 return Wide_String;
97 procedure Put
98 (File : in File_Type;
99 Item : Num;
100 Pic : in Picture;
101 Currency : in Wide_String := Default_Currency;
102 Fill : in Wide_Character := Default_Fill;
103 Separator : in Wide_Character := Default_Separator;
104 Radix_Mark : in Wide_Character := Default_Radix_Mark);
106 procedure Put
107 (Item : Num;
108 Pic : in Picture;
109 Currency : in Wide_String := Default_Currency;
110 Fill : in Wide_Character := Default_Fill;
111 Separator : in Wide_Character := Default_Separator;
112 Radix_Mark : in Wide_Character := Default_Radix_Mark);
114 procedure Put
115 (To : out Wide_String;
116 Item : Num;
117 Pic : in Picture;
118 Currency : in Wide_String := Default_Currency;
119 Fill : in Wide_Character := Default_Fill;
120 Separator : in Wide_Character := Default_Separator;
121 Radix_Mark : in Wide_Character := Default_Radix_Mark);
123 end Decimal_Output;
125 private
126 MAX_PICSIZE : constant := 50;
127 MAX_MONEYSIZE : constant := 10;
128 Invalid_Position : constant := -1;
130 subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
132 type Picture_Record (Length : Pic_Index := 0) is record
133 Expanded : String (1 .. Length);
134 end record;
136 type Format_Record is record
137 Picture : Picture_Record;
138 -- Read only
140 Blank_When_Zero : Boolean;
141 -- Read/write
143 Original_BWZ : Boolean;
145 -- The following components get written
147 Star_Fill : Boolean := False;
149 Radix_Position : Integer := Invalid_Position;
151 Sign_Position,
152 Second_Sign : Integer := Invalid_Position;
154 Start_Float,
155 End_Float : Integer := Invalid_Position;
157 Start_Currency,
158 End_Currency : Integer := Invalid_Position;
160 Max_Leading_Digits : Integer := 0;
162 Max_Trailing_Digits : Integer := 0;
164 Max_Currency_Digits : Integer := 0;
166 Floater : Wide_Character := '!';
167 -- Initialized to illegal value
169 end record;
171 type Picture is record
172 Contents : Format_Record;
173 end record;
175 type Number_Attributes is record
176 Negative : Boolean := False;
178 Has_Fraction : Boolean := False;
180 Start_Of_Int,
181 End_Of_Int,
182 Start_Of_Fraction,
183 End_Of_Fraction : Integer := Invalid_Position; -- invalid value
184 end record;
186 function Parse_Number_String (Str : String) return Number_Attributes;
187 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
188 -- trailing blanks...)
190 procedure Precalculate (Pic : in out Format_Record);
191 -- Precalculates fields from the user supplied data
193 function Format_Number
194 (Pic : Format_Record;
195 Number : String;
196 Currency_Symbol : Wide_String;
197 Fill_Character : Wide_Character;
198 Separator_Character : Wide_Character;
199 Radix_Point : Wide_Character)
200 return Wide_String;
201 -- Formats number according to Pic
203 function Expand (Picture : in String) return String;
205 end Ada.Wide_Text_IO.Editing;