New Language: Ada
[platform/upstream/gcc.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 --                            $Revision: 1.8 $
10 --                                                                          --
11 --          Copyright (C) 1992-2000 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 with Ada.Strings.Wide_Maps;
41 with Ada.Finalization;
42
43 package Ada.Strings.Wide_Unbounded is
44 pragma Preelaborate (Wide_Unbounded);
45
46    type Unbounded_Wide_String is private;
47
48    Null_Unbounded_Wide_String : constant Unbounded_Wide_String;
49
50    function Length (Source : Unbounded_Wide_String) return Natural;
51
52    type Wide_String_Access is access all Wide_String;
53
54    procedure Free (X : in out Wide_String_Access);
55
56    --------------------------------------------------------
57    -- Conversion, Concatenation, and Selection Functions --
58    --------------------------------------------------------
59
60    function To_Unbounded_Wide_String
61      (Source : Wide_String)
62       return   Unbounded_Wide_String;
63
64    function To_Unbounded_Wide_String
65      (Length : in Natural)
66       return   Unbounded_Wide_String;
67
68    function To_Wide_String
69      (Source : Unbounded_Wide_String)
70       return   Wide_String;
71
72    procedure Append
73      (Source   : in out Unbounded_Wide_String;
74       New_Item : in Unbounded_Wide_String);
75
76    procedure Append
77      (Source   : in out Unbounded_Wide_String;
78       New_Item : in Wide_String);
79
80    procedure Append
81      (Source   : in out Unbounded_Wide_String;
82       New_Item : in Wide_Character);
83
84    function "&"
85      (Left, Right : Unbounded_Wide_String)
86       return        Unbounded_Wide_String;
87
88    function "&"
89      (Left  : in Unbounded_Wide_String;
90       Right : in Wide_String)
91       return  Unbounded_Wide_String;
92
93    function "&"
94      (Left  : in Wide_String;
95       Right : in Unbounded_Wide_String)
96       return  Unbounded_Wide_String;
97
98    function "&"
99      (Left  : in Unbounded_Wide_String;
100       Right : in Wide_Character)
101       return  Unbounded_Wide_String;
102
103    function "&"
104      (Left  : in Wide_Character;
105       Right : in Unbounded_Wide_String)
106       return  Unbounded_Wide_String;
107
108    function Element
109      (Source : in Unbounded_Wide_String;
110       Index  : in Positive)
111       return   Wide_Character;
112
113    procedure Replace_Element
114      (Source : in out Unbounded_Wide_String;
115       Index  : in Positive;
116       By     : Wide_Character);
117
118    function Slice
119      (Source : in Unbounded_Wide_String;
120       Low    : in Positive;
121       High   : in Natural)
122       return   Wide_String;
123
124    function "="
125      (Left  : in Unbounded_Wide_String;
126       Right : in Unbounded_Wide_String)
127       return  Boolean;
128
129    function "="
130      (Left  : in Unbounded_Wide_String;
131       Right : in Wide_String)
132       return  Boolean;
133
134    function "="
135      (Left  : in Wide_String;
136       Right : in Unbounded_Wide_String)
137       return  Boolean;
138
139    function "<"
140      (Left  : in Unbounded_Wide_String;
141       Right : in Unbounded_Wide_String)
142       return  Boolean;
143
144    function "<"
145      (Left  : in Unbounded_Wide_String;
146       Right : in Wide_String)
147       return  Boolean;
148
149    function "<"
150      (Left  : in Wide_String;
151       Right : in Unbounded_Wide_String)
152       return  Boolean;
153
154    function "<="
155      (Left  : in Unbounded_Wide_String;
156       Right : in Unbounded_Wide_String)
157       return  Boolean;
158
159    function "<="
160      (Left  : in Unbounded_Wide_String;
161       Right : in Wide_String)
162       return  Boolean;
163
164    function "<="
165      (Left  : in Wide_String;
166       Right : in Unbounded_Wide_String)
167       return  Boolean;
168
169    function ">"
170      (Left  : in Unbounded_Wide_String;
171       Right : in Unbounded_Wide_String)
172       return  Boolean;
173
174    function ">"
175      (Left  : in Unbounded_Wide_String;
176       Right : in Wide_String)
177       return  Boolean;
178
179    function ">"
180      (Left  : in Wide_String;
181       Right : in Unbounded_Wide_String)
182       return  Boolean;
183
184    function ">="
185      (Left  : in Unbounded_Wide_String;
186       Right : in Unbounded_Wide_String)
187       return  Boolean;
188
189    function ">="
190      (Left  : in Unbounded_Wide_String;
191       Right : in Wide_String)
192       return  Boolean;
193
194    function ">="
195      (Left  : in Wide_String;
196       Right : in Unbounded_Wide_String)
197       return  Boolean;
198
199    ------------------------
200    -- Search Subprograms --
201    ------------------------
202
203    function Index
204      (Source   : in Unbounded_Wide_String;
205       Pattern  : in Wide_String;
206       Going    : in Direction := Forward;
207       Mapping  : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
208       return     Natural;
209
210    function Index
211      (Source   : in Unbounded_Wide_String;
212       Pattern  : in Wide_String;
213       Going    : in Direction := Forward;
214       Mapping  : in Wide_Maps.Wide_Character_Mapping_Function)
215       return     Natural;
216
217    function Index
218      (Source : in Unbounded_Wide_String;
219       Set    : in Wide_Maps.Wide_Character_Set;
220       Test   : in Membership := Inside;
221       Going  : in Direction  := Forward)
222       return   Natural;
223
224    function Index_Non_Blank
225      (Source : in Unbounded_Wide_String;
226       Going  : in Direction := Forward)
227       return   Natural;
228
229    function Count
230      (Source  : in Unbounded_Wide_String;
231       Pattern : in Wide_String;
232       Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
233       return    Natural;
234
235    function Count
236      (Source   : in Unbounded_Wide_String;
237       Pattern  : in Wide_String;
238       Mapping  : in Wide_Maps.Wide_Character_Mapping_Function)
239       return     Natural;
240
241    function Count
242      (Source : in Unbounded_Wide_String;
243       Set    : in Wide_Maps.Wide_Character_Set)
244       return   Natural;
245
246    procedure Find_Token
247      (Source : in Unbounded_Wide_String;
248       Set    : in Wide_Maps.Wide_Character_Set;
249       Test   : in Membership;
250       First  : out Positive;
251       Last   : out Natural);
252
253    ------------------------------------
254    -- Wide_String Translation Subprograms --
255    ------------------------------------
256
257    function Translate
258      (Source  : in Unbounded_Wide_String;
259       Mapping : in Wide_Maps.Wide_Character_Mapping)
260       return    Unbounded_Wide_String;
261
262    procedure Translate
263      (Source  : in out Unbounded_Wide_String;
264       Mapping : Wide_Maps.Wide_Character_Mapping);
265
266    function Translate
267      (Source  : in Unbounded_Wide_String;
268       Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
269       return    Unbounded_Wide_String;
270
271    procedure Translate
272      (Source  : in out Unbounded_Wide_String;
273       Mapping : in Wide_Maps.Wide_Character_Mapping_Function);
274
275    ---------------------------------------
276    -- Wide_String Transformation Subprograms --
277    ---------------------------------------
278
279    function Replace_Slice
280      (Source : in Unbounded_Wide_String;
281       Low    : in Positive;
282       High   : in Natural;
283       By     : in Wide_String)
284       return   Unbounded_Wide_String;
285
286    procedure Replace_Slice
287      (Source   : in out Unbounded_Wide_String;
288       Low      : in Positive;
289       High     : in Natural;
290       By       : in Wide_String);
291
292    function Insert
293      (Source   : in Unbounded_Wide_String;
294       Before   : in Positive;
295       New_Item : in Wide_String)
296       return     Unbounded_Wide_String;
297
298    procedure Insert
299      (Source   : in out Unbounded_Wide_String;
300       Before   : in Positive;
301       New_Item : in Wide_String);
302
303    function Overwrite
304      (Source   : in Unbounded_Wide_String;
305       Position : in Positive;
306       New_Item : in Wide_String)
307       return     Unbounded_Wide_String;
308
309    procedure Overwrite
310      (Source    : in out Unbounded_Wide_String;
311       Position  : in Positive;
312       New_Item  : in Wide_String);
313
314    function Delete
315      (Source  : in Unbounded_Wide_String;
316       From    : in Positive;
317       Through : in Natural)
318       return    Unbounded_Wide_String;
319
320    procedure Delete
321      (Source  : in out Unbounded_Wide_String;
322       From    : in Positive;
323       Through : in Natural);
324
325    function Trim
326      (Source : in Unbounded_Wide_String;
327       Side   : in Trim_End)
328       return   Unbounded_Wide_String;
329
330    procedure Trim
331      (Source : in out Unbounded_Wide_String;
332       Side   : in Trim_End);
333
334    function Trim
335      (Source : in Unbounded_Wide_String;
336       Left   : in Wide_Maps.Wide_Character_Set;
337       Right  : in Wide_Maps.Wide_Character_Set)
338       return   Unbounded_Wide_String;
339
340    procedure Trim
341      (Source : in out Unbounded_Wide_String;
342       Left   : in Wide_Maps.Wide_Character_Set;
343       Right  : in Wide_Maps.Wide_Character_Set);
344
345    function Head
346      (Source : in Unbounded_Wide_String;
347       Count  : in Natural;
348       Pad    : in Wide_Character := Wide_Space)
349       return   Unbounded_Wide_String;
350
351    procedure Head
352      (Source : in out Unbounded_Wide_String;
353       Count  : in Natural;
354       Pad    : in Wide_Character := Wide_Space);
355
356    function Tail
357      (Source : in Unbounded_Wide_String;
358       Count  : in Natural;
359       Pad    : in Wide_Character := Wide_Space)
360       return   Unbounded_Wide_String;
361
362    procedure Tail
363      (Source : in out Unbounded_Wide_String;
364       Count  : in Natural;
365       Pad    : in Wide_Character := Wide_Space);
366
367    function "*"
368      (Left  : in Natural;
369       Right : in Wide_Character)
370       return  Unbounded_Wide_String;
371
372    function "*"
373      (Left  : in Natural;
374       Right : in Wide_String)
375       return  Unbounded_Wide_String;
376
377    function "*"
378      (Left  : in Natural;
379       Right : in Unbounded_Wide_String)
380       return  Unbounded_Wide_String;
381
382 private
383    pragma Inline (Length);
384
385    package AF renames Ada.Finalization;
386
387    Null_Wide_String : aliased Wide_String := "";
388
389    function To_Unbounded_Wide (S : Wide_String) return Unbounded_Wide_String
390      renames To_Unbounded_Wide_String;
391
392    type Unbounded_Wide_String is new AF.Controlled with record
393       Reference : Wide_String_Access := Null_Wide_String'Access;
394    end record;
395
396    pragma Stream_Convert
397      (Unbounded_Wide_String, To_Unbounded_Wide, To_Wide_String);
398
399    pragma Finalize_Storage_Only (Unbounded_Wide_String);
400
401    procedure Initialize (Object : in out Unbounded_Wide_String);
402    procedure Adjust     (Object : in out Unbounded_Wide_String);
403    procedure Finalize   (Object : in out Unbounded_Wide_String);
404
405    Null_Unbounded_Wide_String : constant Unbounded_Wide_String :=
406      (AF.Controlled with Reference => Null_Wide_String'Access);
407
408 end Ada.Strings.Wide_Unbounded;