OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-wtedit.ads
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 --                                                                          --
10 --          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the  contents of the part following the private keyword. --
15 --                                                                          --
16 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
17 -- terms of the  GNU General Public License as published  by the Free Soft- --
18 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
19 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
22 -- for  more details.  You should have  received  a copy of the GNU General --
23 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
24 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
25 -- MA 02111-1307, USA.                                                      --
26 --                                                                          --
27 -- As a special exception,  if other files  instantiate  generics from this --
28 -- unit, or you link  this unit with other files  to produce an executable, --
29 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
30 -- covered  by the  GNU  General  Public  License.  This exception does not --
31 -- however invalidate  any other reasons why  the executable file  might be --
32 -- covered by the  GNU Public License.                                      --
33 --                                                                          --
34 -- GNAT was originally developed  by the GNAT team at  New York University. --
35 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
36 --                                                                          --
37 ------------------------------------------------------------------------------
38
39 package Ada.Wide_Text_IO.Editing is
40
41    type Picture is private;
42
43    function Valid
44      (Pic_String      : in String;
45       Blank_When_Zero : in Boolean := False)
46       return            Boolean;
47
48    function To_Picture
49      (Pic_String      : in String;
50       Blank_When_Zero : in Boolean := False)
51       return            Picture;
52
53    function Pic_String      (Pic : in Picture) return String;
54    function Blank_When_Zero (Pic : in Picture) return Boolean;
55
56    Max_Picture_Length : constant := 64;
57
58    Picture_Error : exception;
59
60    Default_Currency   : constant Wide_String    := "$";
61    Default_Fill       : constant Wide_Character := ' ';
62    Default_Separator  : constant Wide_Character := ',';
63    Default_Radix_Mark : constant Wide_Character := '.';
64
65    generic
66       type Num is delta <> digits <>;
67       Default_Currency   : in Wide_String :=
68                                 Wide_Text_IO.Editing.Default_Currency;
69       Default_Fill       : in Wide_Character :=
70                                 Wide_Text_IO.Editing.Default_Fill;
71       Default_Separator  : in Wide_Character :=
72                                 Wide_Text_IO.Editing.Default_Separator;
73       Default_Radix_Mark : in Wide_Character :=
74                                 Wide_Text_IO.Editing.Default_Radix_Mark;
75
76    package Decimal_Output is
77
78       function Length
79         (Pic      : in Picture;
80          Currency : in Wide_String := Default_Currency)
81          return     Natural;
82
83       function Valid
84         (Item     : Num;
85          Pic      : in Picture;
86          Currency : in Wide_String := Default_Currency)
87          return     Boolean;
88
89       function Image
90         (Item       : Num;
91          Pic        : in Picture;
92          Currency   : in Wide_String    := Default_Currency;
93          Fill       : in Wide_Character := Default_Fill;
94          Separator  : in Wide_Character := Default_Separator;
95          Radix_Mark : in Wide_Character := Default_Radix_Mark)
96          return       Wide_String;
97
98       procedure Put
99         (File       : in File_Type;
100          Item       : Num;
101          Pic        : in Picture;
102          Currency   : in Wide_String    := Default_Currency;
103          Fill       : in Wide_Character := Default_Fill;
104          Separator  : in Wide_Character := Default_Separator;
105          Radix_Mark : in Wide_Character := Default_Radix_Mark);
106
107       procedure Put
108         (Item       : Num;
109          Pic        : in Picture;
110          Currency   : in Wide_String    := Default_Currency;
111          Fill       : in Wide_Character := Default_Fill;
112          Separator  : in Wide_Character := Default_Separator;
113          Radix_Mark : in Wide_Character := Default_Radix_Mark);
114
115       procedure Put
116         (To         : out Wide_String;
117          Item       : Num;
118          Pic        : in Picture;
119          Currency   : in Wide_String    := Default_Currency;
120          Fill       : in Wide_Character := Default_Fill;
121          Separator  : in Wide_Character := Default_Separator;
122          Radix_Mark : in Wide_Character := Default_Radix_Mark);
123
124    end Decimal_Output;
125
126 private
127    MAX_PICSIZE      : constant := 50;
128    MAX_MONEYSIZE    : constant := 10;
129    Invalid_Position : constant := -1;
130
131    subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
132
133    type Picture_Record (Length : Pic_Index := 0) is record
134       Expanded : String (1 .. Length);
135    end record;
136
137    type Format_Record is record
138       Picture              : Picture_Record;
139       --  Read only
140
141       Blank_When_Zero      : Boolean;
142       --  Read/write
143
144       Original_BWZ         : Boolean;
145
146       --  The following components get written
147
148       Star_Fill            : Boolean := False;
149
150       Radix_Position       : Integer := Invalid_Position;
151
152       Sign_Position,
153       Second_Sign          : Integer := Invalid_Position;
154
155       Start_Float,
156       End_Float            : Integer := Invalid_Position;
157
158       Start_Currency,
159       End_Currency         : Integer := Invalid_Position;
160
161       Max_Leading_Digits   : Integer := 0;
162
163       Max_Trailing_Digits  : Integer := 0;
164
165       Max_Currency_Digits  : Integer := 0;
166
167       Floater              : Wide_Character := '!';
168       --  Initialized to illegal value
169
170    end record;
171
172    type Picture is record
173       Contents : Format_Record;
174    end record;
175
176    type Number_Attributes is record
177       Negative     : Boolean := False;
178
179       Has_Fraction : Boolean := False;
180
181       Start_Of_Int,
182       End_Of_Int,
183       Start_Of_Fraction,
184       End_Of_Fraction : Integer := Invalid_Position;    -- invalid value
185    end record;
186
187    function Parse_Number_String (Str : String) return Number_Attributes;
188    --  Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
189    --  trailing blanks...)
190
191    procedure Precalculate (Pic : in out Format_Record);
192    --  Precalculates fields from the user supplied data
193
194    function Format_Number
195      (Pic                 : Format_Record;
196       Number              : String;
197       Currency_Symbol     : Wide_String;
198       Fill_Character      : Wide_Character;
199       Separator_Character : Wide_Character;
200       Radix_Point         : Wide_Character)
201       return                Wide_String;
202    --  Formats number according to Pic
203
204    function Expand (Picture : in String) return String;
205
206 end Ada.Wide_Text_IO.Editing;