OSDN Git Service

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