2015-06-23 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / gcc / ada / a-ztedit.ads
blobdb840d04d29cc9d9c5d3b70952c1af743068a79c
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . W I D E _ 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-2009, 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 3, 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. --
21 -- --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception, --
24 -- version 3.1, as published by the Free Software Foundation. --
25 -- --
26 -- You should have received a copy of the GNU General Public License and --
27 -- a copy of the GCC Runtime Library Exception along with this program; --
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
29 -- <http://www.gnu.org/licenses/>. --
30 -- --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 -- --
34 ------------------------------------------------------------------------------
36 package Ada.Wide_Wide_Text_IO.Editing is
38 type Picture is private;
40 function Valid
41 (Pic_String : String;
42 Blank_When_Zero : Boolean := False) return Boolean;
44 function To_Picture
45 (Pic_String : String;
46 Blank_When_Zero : Boolean := False) return Picture;
48 function Pic_String (Pic : Picture) return String;
49 function Blank_When_Zero (Pic : Picture) return Boolean;
51 Max_Picture_Length : constant := 64;
53 Picture_Error : exception;
55 Default_Currency : constant Wide_Wide_String := "$";
56 Default_Fill : constant Wide_Wide_Character := ' ';
57 Default_Separator : constant Wide_Wide_Character := ',';
58 Default_Radix_Mark : constant Wide_Wide_Character := '.';
60 generic
61 type Num is delta <> digits <>;
62 Default_Currency : Wide_Wide_String :=
63 Wide_Wide_Text_IO.Editing.Default_Currency;
64 Default_Fill : Wide_Wide_Character :=
65 Wide_Wide_Text_IO.Editing.Default_Fill;
66 Default_Separator : Wide_Wide_Character :=
67 Wide_Wide_Text_IO.Editing.Default_Separator;
68 Default_Radix_Mark : Wide_Wide_Character :=
69 Wide_Wide_Text_IO.Editing.Default_Radix_Mark;
71 package Decimal_Output is
73 function Length
74 (Pic : Picture;
75 Currency : Wide_Wide_String := Default_Currency) return Natural;
77 function Valid
78 (Item : Num;
79 Pic : Picture;
80 Currency : Wide_Wide_String := Default_Currency) return Boolean;
82 function Image
83 (Item : Num;
84 Pic : Picture;
85 Currency : Wide_Wide_String := Default_Currency;
86 Fill : Wide_Wide_Character := Default_Fill;
87 Separator : Wide_Wide_Character := Default_Separator;
88 Radix_Mark : Wide_Wide_Character := Default_Radix_Mark)
89 return Wide_Wide_String;
91 procedure Put
92 (File : File_Type;
93 Item : Num;
94 Pic : Picture;
95 Currency : Wide_Wide_String := Default_Currency;
96 Fill : Wide_Wide_Character := Default_Fill;
97 Separator : Wide_Wide_Character := Default_Separator;
98 Radix_Mark : Wide_Wide_Character := Default_Radix_Mark);
100 procedure Put
101 (Item : Num;
102 Pic : Picture;
103 Currency : Wide_Wide_String := Default_Currency;
104 Fill : Wide_Wide_Character := Default_Fill;
105 Separator : Wide_Wide_Character := Default_Separator;
106 Radix_Mark : Wide_Wide_Character := Default_Radix_Mark);
108 procedure Put
109 (To : out Wide_Wide_String;
110 Item : Num;
111 Pic : Picture;
112 Currency : Wide_Wide_String := Default_Currency;
113 Fill : Wide_Wide_Character := Default_Fill;
114 Separator : Wide_Wide_Character := Default_Separator;
115 Radix_Mark : Wide_Wide_Character := Default_Radix_Mark);
117 end Decimal_Output;
119 private
120 MAX_PICSIZE : constant := 50;
121 MAX_MONEYSIZE : constant := 10;
122 Invalid_Position : constant := -1;
124 subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
126 type Picture_Record (Length : Pic_Index := 0) is record
127 Expanded : String (1 .. Length);
128 end record;
130 type Format_Record is record
131 Picture : Picture_Record;
132 -- Read only
134 Blank_When_Zero : Boolean;
135 -- Read/write
137 Original_BWZ : Boolean;
139 -- The following components get written
141 Star_Fill : Boolean := False;
143 Radix_Position : Integer := Invalid_Position;
145 Sign_Position,
146 Second_Sign : Integer := Invalid_Position;
148 Start_Float,
149 End_Float : Integer := Invalid_Position;
151 Start_Currency,
152 End_Currency : Integer := Invalid_Position;
154 Max_Leading_Digits : Integer := 0;
156 Max_Trailing_Digits : Integer := 0;
158 Max_Currency_Digits : Integer := 0;
160 Floater : Wide_Wide_Character := '!';
161 -- Initialized to illegal value
163 end record;
165 type Picture is record
166 Contents : Format_Record;
167 end record;
169 type Number_Attributes is record
170 Negative : Boolean := False;
172 Has_Fraction : Boolean := False;
174 Start_Of_Int,
175 End_Of_Int,
176 Start_Of_Fraction,
177 End_Of_Fraction : Integer := Invalid_Position; -- invalid value
178 end record;
180 function Parse_Number_String (Str : String) return Number_Attributes;
181 -- Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
182 -- trailing blanks...)
184 procedure Precalculate (Pic : in out Format_Record);
185 -- Precalculates fields from the user supplied data
187 function Format_Number
188 (Pic : Format_Record;
189 Number : String;
190 Currency_Symbol : Wide_Wide_String;
191 Fill_Character : Wide_Wide_Character;
192 Separator_Character : Wide_Wide_Character;
193 Radix_Point : Wide_Wide_Character) return Wide_Wide_String;
194 -- Formats number according to Pic
196 function Expand (Picture : String) return String;
198 end Ada.Wide_Wide_Text_IO.Editing;