* c-decl.c (duplicate_decls): Conditionalize DECL_SAVED_TREE copy.
[official-gcc.git] / gcc / ada / a-wtedit.ads
blob1c4e57d328a8dd8ea85db6a4576b56e73e3c4dce
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 -- $Revision: 1.3 $ --
10 -- --
11 -- Copyright (C) 1992-1997 Free Software Foundation, Inc. --
12 -- --
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. --
16 -- --
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. --
27 -- --
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. --
34 -- --
35 -- GNAT was originally developed by the GNAT team at New York University. --
36 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
37 -- --
38 ------------------------------------------------------------------------------
40 package Ada.Wide_Text_IO.Editing is
42 type Picture is private;
44 function Valid
45 (Pic_String : in String;
46 Blank_When_Zero : in Boolean := False)
47 return Boolean;
49 function To_Picture
50 (Pic_String : in String;
51 Blank_When_Zero : in Boolean := False)
52 return Picture;
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 Wide_String := "$";
62 Default_Fill : constant Wide_Character := ' ';
63 Default_Separator : constant Wide_Character := ',';
64 Default_Radix_Mark : constant Wide_Character := '.';
66 generic
67 type Num is delta <> digits <>;
68 Default_Currency : in Wide_String :=
69 Wide_Text_IO.Editing.Default_Currency;
70 Default_Fill : in Wide_Character :=
71 Wide_Text_IO.Editing.Default_Fill;
72 Default_Separator : in Wide_Character :=
73 Wide_Text_IO.Editing.Default_Separator;
74 Default_Radix_Mark : in Wide_Character :=
75 Wide_Text_IO.Editing.Default_Radix_Mark;
77 package Decimal_Output is
79 function Length
80 (Pic : in Picture;
81 Currency : in Wide_String := Default_Currency)
82 return Natural;
84 function Valid
85 (Item : Num;
86 Pic : in Picture;
87 Currency : in Wide_String := Default_Currency)
88 return Boolean;
90 function Image
91 (Item : Num;
92 Pic : in Picture;
93 Currency : in Wide_String := Default_Currency;
94 Fill : in Wide_Character := Default_Fill;
95 Separator : in Wide_Character := Default_Separator;
96 Radix_Mark : in Wide_Character := Default_Radix_Mark)
97 return Wide_String;
99 procedure Put
100 (File : in File_Type;
101 Item : Num;
102 Pic : in Picture;
103 Currency : in Wide_String := Default_Currency;
104 Fill : in Wide_Character := Default_Fill;
105 Separator : in Wide_Character := Default_Separator;
106 Radix_Mark : in Wide_Character := Default_Radix_Mark);
108 procedure Put
109 (Item : Num;
110 Pic : in Picture;
111 Currency : in Wide_String := Default_Currency;
112 Fill : in Wide_Character := Default_Fill;
113 Separator : in Wide_Character := Default_Separator;
114 Radix_Mark : in Wide_Character := Default_Radix_Mark);
116 procedure Put
117 (To : out Wide_String;
118 Item : Num;
119 Pic : in Picture;
120 Currency : in Wide_String := Default_Currency;
121 Fill : in Wide_Character := Default_Fill;
122 Separator : in Wide_Character := Default_Separator;
123 Radix_Mark : in Wide_Character := Default_Radix_Mark);
125 end Decimal_Output;
127 private
128 MAX_PICSIZE : constant := 50;
129 MAX_MONEYSIZE : constant := 10;
130 Invalid_Position : constant := -1;
132 subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
134 type Picture_Record (Length : Pic_Index := 0) is record
135 Expanded : String (1 .. Length);
136 end record;
138 type Format_Record is record
139 Picture : Picture_Record;
140 -- Read only
142 Blank_When_Zero : Boolean;
143 -- Read/write
145 Original_BWZ : Boolean;
147 -- The following components get written
149 Star_Fill : Boolean := False;
151 Radix_Position : Integer := Invalid_Position;
153 Sign_Position,
154 Second_Sign : Integer := Invalid_Position;
156 Start_Float,
157 End_Float : Integer := Invalid_Position;
159 Start_Currency,
160 End_Currency : Integer := Invalid_Position;
162 Max_Leading_Digits : Integer := 0;
164 Max_Trailing_Digits : Integer := 0;
166 Max_Currency_Digits : Integer := 0;
168 Floater : Wide_Character := '!';
169 -- Initialized to illegal value
171 end record;
173 type Picture is record
174 Contents : Format_Record;
175 end record;
177 type Number_Attributes is record
178 Negative : Boolean := False;
180 Has_Fraction : Boolean := False;
182 Start_Of_Int,
183 End_Of_Int,
184 Start_Of_Fraction,
185 End_Of_Fraction : Integer := Invalid_Position; -- invalid value
186 end record;
188 function Parse_Number_String (Str : String) return Number_Attributes;
189 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
190 -- trailing blanks...)
192 procedure Precalculate (Pic : in out Format_Record);
193 -- Precalculates fields from the user supplied data
195 function Format_Number
196 (Pic : Format_Record;
197 Number : String;
198 Currency_Symbol : Wide_String;
199 Fill_Character : Wide_Character;
200 Separator_Character : Wide_Character;
201 Radix_Point : Wide_Character)
202 return Wide_String;
203 -- Formats number according to Pic
205 function Expand (Picture : in String) return String;
207 end Ada.Wide_Text_IO.Editing;