OSDN Git Service

2005-02-09 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-stwiun.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --           A D A . S T R I N G S . W I D E _ U N B O U N D E D            --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2005 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 2,  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.  See the GNU General Public License --
21 -- for  more details.  You should have  received  a copy of the GNU General --
22 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
23 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
24 -- MA 02111-1307, USA.                                                      --
25 --                                                                          --
26 -- As a special exception,  if other files  instantiate  generics from this --
27 -- unit, or you link  this unit with other files  to produce an executable, --
28 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
29 -- covered  by the  GNU  General  Public  License.  This exception does not --
30 -- however invalidate  any other reasons why  the executable file  might be --
31 -- covered by the  GNU Public License.                                      --
32 --                                                                          --
33 -- GNAT was originally developed  by the GNAT team at  New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
35 --                                                                          --
36 ------------------------------------------------------------------------------
37
38 with Ada.Strings.Wide_Maps;
39 with Ada.Finalization;
40
41 package Ada.Strings.Wide_Unbounded is
42 pragma Preelaborate (Wide_Unbounded);
43
44    type Unbounded_Wide_String is private;
45
46    Null_Unbounded_Wide_String : constant Unbounded_Wide_String;
47
48    function Length (Source : Unbounded_Wide_String) return Natural;
49
50    type Wide_String_Access is access all Wide_String;
51
52    procedure Free (X : in out Wide_String_Access);
53
54    --------------------------------------------------------
55    -- Conversion, Concatenation, and Selection Functions --
56    --------------------------------------------------------
57
58    function To_Unbounded_Wide_String
59      (Source : Wide_String) return Unbounded_Wide_String;
60
61    function To_Unbounded_Wide_String
62      (Length : Natural) return Unbounded_Wide_String;
63
64    function To_Wide_String
65      (Source : Unbounded_Wide_String) return Wide_String;
66
67    procedure Append
68      (Source   : in out Unbounded_Wide_String;
69       New_Item : Unbounded_Wide_String);
70
71    procedure Append
72      (Source   : in out Unbounded_Wide_String;
73       New_Item : Wide_String);
74
75    procedure Append
76      (Source   : in out Unbounded_Wide_String;
77       New_Item : Wide_Character);
78
79    function "&"
80      (Left, Right : Unbounded_Wide_String) return Unbounded_Wide_String;
81
82    function "&"
83      (Left  : Unbounded_Wide_String;
84       Right : Wide_String) return Unbounded_Wide_String;
85
86    function "&"
87      (Left  : Wide_String;
88       Right : Unbounded_Wide_String) return Unbounded_Wide_String;
89
90    function "&"
91      (Left  : Unbounded_Wide_String;
92       Right : Wide_Character) return Unbounded_Wide_String;
93
94    function "&"
95      (Left  : Wide_Character;
96       Right : Unbounded_Wide_String) return Unbounded_Wide_String;
97
98    function Element
99      (Source : Unbounded_Wide_String;
100       Index  : Positive) return Wide_Character;
101
102    procedure Replace_Element
103      (Source : in out Unbounded_Wide_String;
104       Index  : Positive;
105       By     : Wide_Character);
106
107    function Slice
108      (Source : Unbounded_Wide_String;
109       Low    : Positive;
110       High   : Natural) return Wide_String;
111
112    function "="
113      (Left  : Unbounded_Wide_String;
114       Right : Unbounded_Wide_String) return Boolean;
115
116    function "="
117      (Left  : Unbounded_Wide_String;
118       Right : Wide_String) return Boolean;
119
120    function "="
121      (Left  : Wide_String;
122       Right : Unbounded_Wide_String) return Boolean;
123
124    function "<"
125      (Left  : Unbounded_Wide_String;
126       Right : Unbounded_Wide_String) return Boolean;
127
128    function "<"
129      (Left  : Unbounded_Wide_String;
130       Right : Wide_String) return Boolean;
131
132    function "<"
133      (Left  : Wide_String;
134       Right : Unbounded_Wide_String) return Boolean;
135
136    function "<="
137      (Left  : Unbounded_Wide_String;
138       Right : Unbounded_Wide_String) return Boolean;
139
140    function "<="
141      (Left  : Unbounded_Wide_String;
142       Right : Wide_String) return Boolean;
143
144    function "<="
145      (Left  : Wide_String;
146       Right : Unbounded_Wide_String) return Boolean;
147
148    function ">"
149      (Left  : Unbounded_Wide_String;
150       Right : Unbounded_Wide_String) return Boolean;
151
152    function ">"
153      (Left  : Unbounded_Wide_String;
154       Right : Wide_String) return Boolean;
155
156    function ">"
157      (Left  : Wide_String;
158       Right : Unbounded_Wide_String) return Boolean;
159
160    function ">="
161      (Left  : Unbounded_Wide_String;
162       Right : Unbounded_Wide_String) return Boolean;
163
164    function ">="
165      (Left  : Unbounded_Wide_String;
166       Right : Wide_String) return Boolean;
167
168    function ">="
169      (Left  : Wide_String;
170       Right : Unbounded_Wide_String) return Boolean;
171
172    ------------------------
173    -- Search Subprograms --
174    ------------------------
175
176    function Index
177      (Source  : Unbounded_Wide_String;
178       Pattern : Wide_String;
179       Going   : Direction := Forward;
180       Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
181       return Natural;
182
183    function Index
184      (Source  : Unbounded_Wide_String;
185       Pattern : Wide_String;
186       Going   : Direction := Forward;
187       Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
188
189    function Index
190      (Source : Unbounded_Wide_String;
191       Set    : Wide_Maps.Wide_Character_Set;
192       Test   : Membership := Inside;
193       Going  : Direction  := Forward) return Natural;
194
195    function Index_Non_Blank
196      (Source : Unbounded_Wide_String;
197       Going  : Direction := Forward) return Natural;
198
199    function Count
200      (Source  : Unbounded_Wide_String;
201       Pattern : Wide_String;
202       Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
203       return Natural;
204
205    function Count
206      (Source  : Unbounded_Wide_String;
207       Pattern : Wide_String;
208       Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
209
210    function Count
211      (Source : Unbounded_Wide_String;
212       Set    : Wide_Maps.Wide_Character_Set) return Natural;
213
214    procedure Find_Token
215      (Source : Unbounded_Wide_String;
216       Set    : Wide_Maps.Wide_Character_Set;
217       Test   : Membership;
218       First  : out Positive;
219       Last   : out Natural);
220
221    ------------------------------------
222    -- Wide_String Translation Subprograms --
223    ------------------------------------
224
225    function Translate
226      (Source  : Unbounded_Wide_String;
227       Mapping : Wide_Maps.Wide_Character_Mapping) return Unbounded_Wide_String;
228
229    procedure Translate
230      (Source  : in out Unbounded_Wide_String;
231       Mapping : Wide_Maps.Wide_Character_Mapping);
232
233    function Translate
234      (Source  : Unbounded_Wide_String;
235       Mapping : Wide_Maps.Wide_Character_Mapping_Function)
236       return Unbounded_Wide_String;
237
238    procedure Translate
239      (Source  : in out Unbounded_Wide_String;
240       Mapping : Wide_Maps.Wide_Character_Mapping_Function);
241
242    ---------------------------------------
243    -- Wide_String Transformation Subprograms --
244    ---------------------------------------
245
246    function Replace_Slice
247      (Source : Unbounded_Wide_String;
248       Low    : Positive;
249       High   : Natural;
250       By     : Wide_String) return Unbounded_Wide_String;
251
252    procedure Replace_Slice
253      (Source   : in out Unbounded_Wide_String;
254       Low      : Positive;
255       High     : Natural;
256       By       : Wide_String);
257
258    function Insert
259      (Source   : Unbounded_Wide_String;
260       Before   : Positive;
261       New_Item : Wide_String) return Unbounded_Wide_String;
262
263    procedure Insert
264      (Source   : in out Unbounded_Wide_String;
265       Before   : Positive;
266       New_Item : Wide_String);
267
268    function Overwrite
269      (Source   : Unbounded_Wide_String;
270       Position : Positive;
271       New_Item : Wide_String) return Unbounded_Wide_String;
272
273    procedure Overwrite
274      (Source    : in out Unbounded_Wide_String;
275       Position  : Positive;
276       New_Item  : Wide_String);
277
278    function Delete
279      (Source  : Unbounded_Wide_String;
280       From    : Positive;
281       Through : Natural) return Unbounded_Wide_String;
282
283    procedure Delete
284      (Source  : in out Unbounded_Wide_String;
285       From    : Positive;
286       Through : Natural);
287
288    function Trim
289      (Source : Unbounded_Wide_String;
290       Side   : Trim_End) return Unbounded_Wide_String;
291
292    procedure Trim
293      (Source : in out Unbounded_Wide_String;
294       Side   : Trim_End);
295
296    function Trim
297      (Source : Unbounded_Wide_String;
298       Left   : Wide_Maps.Wide_Character_Set;
299       Right  : Wide_Maps.Wide_Character_Set) return Unbounded_Wide_String;
300
301    procedure Trim
302      (Source : in out Unbounded_Wide_String;
303       Left   : Wide_Maps.Wide_Character_Set;
304       Right  : Wide_Maps.Wide_Character_Set);
305
306    function Head
307      (Source : Unbounded_Wide_String;
308       Count  : Natural;
309       Pad    : Wide_Character := Wide_Space) return Unbounded_Wide_String;
310
311    procedure Head
312      (Source : in out Unbounded_Wide_String;
313       Count  : Natural;
314       Pad    : Wide_Character := Wide_Space);
315
316    function Tail
317      (Source : Unbounded_Wide_String;
318       Count  : Natural;
319       Pad    : Wide_Character := Wide_Space) return Unbounded_Wide_String;
320
321    procedure Tail
322      (Source : in out Unbounded_Wide_String;
323       Count  : Natural;
324       Pad    : Wide_Character := Wide_Space);
325
326    function "*"
327      (Left  : Natural;
328       Right : Wide_Character) return Unbounded_Wide_String;
329
330    function "*"
331      (Left  : Natural;
332       Right : Wide_String) return Unbounded_Wide_String;
333
334    function "*"
335      (Left  : Natural;
336       Right : Unbounded_Wide_String) return Unbounded_Wide_String;
337
338 private
339    pragma Inline (Length);
340
341    package AF renames Ada.Finalization;
342
343    Null_Wide_String : aliased Wide_String := "";
344
345    function To_Unbounded_Wide (S : Wide_String) return Unbounded_Wide_String
346      renames To_Unbounded_Wide_String;
347
348    type Unbounded_Wide_String is new AF.Controlled with record
349       Reference : Wide_String_Access := Null_Wide_String'Access;
350       Last      : Natural            := 0;
351    end record;
352
353    --  The Unbounded_Wide_String is using a buffered implementation to increase
354    --  speed of the Append/Delete/Insert procedures. The Reference string
355    --  pointer above contains the current string value and extra room at the
356    --  end to be used by the next Append routine. Last is the index of the
357    --  string ending character. So the current string value is really
358    --  Reference (1 .. Last).
359
360    pragma Stream_Convert
361      (Unbounded_Wide_String, To_Unbounded_Wide, To_Wide_String);
362
363    pragma Finalize_Storage_Only (Unbounded_Wide_String);
364
365    procedure Initialize (Object : in out Unbounded_Wide_String);
366    procedure Adjust     (Object : in out Unbounded_Wide_String);
367    procedure Finalize   (Object : in out Unbounded_Wide_String);
368
369    Null_Unbounded_Wide_String : constant Unbounded_Wide_String :=
370      (AF.Controlled with Reference => Null_Wide_String'Access, Last => 0);
371
372 end Ada.Strings.Wide_Unbounded;