OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-teioed.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --                  A D A . 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.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 String    := "$";
61    Default_Fill       : constant Character := ' ';
62    Default_Separator  : constant Character := ',';
63    Default_Radix_Mark : constant Character := '.';
64
65    generic
66       type Num is delta <> digits <>;
67       Default_Currency   : in String := Editing.Default_Currency;
68       Default_Fill       : in Character := Editing.Default_Fill;
69       Default_Separator  : in Character := Editing.Default_Separator;
70       Default_Radix_Mark : in Character := Editing.Default_Radix_Mark;
71
72    package Decimal_Output is
73
74       function Length
75         (Pic      : in Picture;
76          Currency : in String := Default_Currency)
77          return     Natural;
78
79       function Valid
80         (Item     : Num;
81          Pic      : in Picture;
82          Currency : in String := Default_Currency)
83          return     Boolean;
84
85       function Image
86         (Item       : Num;
87          Pic        : in Picture;
88          Currency   : in String    := Default_Currency;
89          Fill       : in Character := Default_Fill;
90          Separator  : in Character := Default_Separator;
91          Radix_Mark : in Character := Default_Radix_Mark)
92          return       String;
93
94       procedure Put
95         (File       : in Ada.Text_IO.File_Type;
96          Item       : Num;
97          Pic        : in Picture;
98          Currency   : in String    := Default_Currency;
99          Fill       : in Character := Default_Fill;
100          Separator  : in Character := Default_Separator;
101          Radix_Mark : in Character := Default_Radix_Mark);
102
103       procedure Put
104         (Item       : Num;
105          Pic        : in Picture;
106          Currency   : in String    := Default_Currency;
107          Fill       : in Character := Default_Fill;
108          Separator  : in Character := Default_Separator;
109          Radix_Mark : in Character := Default_Radix_Mark);
110
111       procedure Put
112         (To         : out String;
113          Item       : Num;
114          Pic        : in Picture;
115          Currency   : in String    := Default_Currency;
116          Fill       : in Character := Default_Fill;
117          Separator  : in Character := Default_Separator;
118          Radix_Mark : in Character := Default_Radix_Mark);
119
120    end Decimal_Output;
121
122 private
123
124    MAX_PICSIZE      : constant := 50;
125    MAX_MONEYSIZE    : constant := 10;
126    Invalid_Position : constant := -1;
127
128    subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
129
130    type Picture_Record (Length : Pic_Index := 0) is record
131       Expanded : String (1 .. Length);
132    end record;
133
134    type Format_Record is record
135       Picture              : Picture_Record;
136       --  Read only
137
138       Blank_When_Zero      : Boolean;
139       --  Read/write
140
141       Original_BWZ         : Boolean;
142
143       --  The following components get written
144
145       Star_Fill            : Boolean := False;
146
147       Radix_Position       : Integer := Invalid_Position;
148
149       Sign_Position,
150       Second_Sign          : Integer := Invalid_Position;
151
152       Start_Float,
153       End_Float            : Integer := Invalid_Position;
154
155       Start_Currency,
156       End_Currency         : Integer := Invalid_Position;
157
158       Max_Leading_Digits   : Integer := 0;
159
160       Max_Trailing_Digits  : Integer := 0;
161
162       Max_Currency_Digits  : Integer := 0;
163
164       Floater              : Character := '!';
165       --  Initialized to illegal value
166
167    end record;
168
169    type Picture is record
170       Contents : Format_Record;
171    end record;
172
173    type Number_Attributes is record
174       Negative     : Boolean := False;
175
176       Has_Fraction : Boolean := False;
177
178       Start_Of_Int,
179       End_Of_Int,
180       Start_Of_Fraction,
181       End_Of_Fraction : Integer := Invalid_Position;    -- invalid value
182    end record;
183
184    function Parse_Number_String (Str : String) return Number_Attributes;
185    --  Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
186    --  trailing blanks...)
187
188    procedure Precalculate (Pic : in out Format_Record);
189    --  Precalculates fields from the user supplied data
190
191    function Format_Number
192      (Pic                 : Format_Record;
193       Number              : String;
194       Currency_Symbol     : String;
195       Fill_Character      : Character;
196       Separator_Character : Character;
197       Radix_Point         : Character)
198       return                String;
199    --  Formats number according to Pic
200
201    function Expand (Picture : in String) return String;
202
203 end Ada.Text_IO.Editing;