OSDN Git Service

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