OSDN Git Service

* sem_ch3.adb (Find_Type_Of_Subtype_Indic): If subtype indication
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-strbou.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --                  A D A . S T R I N G S . B O U N D E D                   --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.12 $
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.Maps;
41
42 package Ada.Strings.Bounded is
43 pragma Preelaborate (Bounded);
44
45    generic
46       Max : Positive;
47       --  Maximum length of a Bounded_String
48
49    package Generic_Bounded_Length is
50
51       Max_Length : constant Positive := Max;
52
53       type Bounded_String is private;
54
55       Null_Bounded_String : constant Bounded_String;
56
57       subtype Length_Range is Natural range 0 .. Max_Length;
58
59       function Length (Source : in Bounded_String) return Length_Range;
60
61       --------------------------------------------------------
62       -- Conversion, Concatenation, and Selection Functions --
63       --------------------------------------------------------
64
65       function To_Bounded_String
66         (Source : in String;
67          Drop   : in Truncation := Error)
68          return   Bounded_String;
69
70       function To_String (Source : in Bounded_String) return String;
71
72       function Append
73         (Left, Right : in Bounded_String;
74          Drop        : in Truncation  := Error)
75          return        Bounded_String;
76
77       function Append
78         (Left  : in Bounded_String;
79          Right : in String;
80          Drop  : in Truncation := Error)
81          return  Bounded_String;
82
83       function Append
84         (Left  : in String;
85          Right : in Bounded_String;
86          Drop  : in Truncation := Error)
87          return  Bounded_String;
88
89       function Append
90         (Left  : in Bounded_String;
91          Right : in Character;
92          Drop  : in Truncation := Error)
93          return  Bounded_String;
94
95       function Append
96         (Left  : in Character;
97          Right : in Bounded_String;
98          Drop  : in Truncation := Error)
99          return  Bounded_String;
100
101       procedure Append
102         (Source   : in out Bounded_String;
103          New_Item : in Bounded_String;
104          Drop     : in Truncation  := Error);
105
106       procedure Append
107         (Source   : in out Bounded_String;
108          New_Item : in String;
109          Drop     : in Truncation  := Error);
110
111       procedure Append
112         (Source   : in out Bounded_String;
113          New_Item : in Character;
114          Drop     : in Truncation  := Error);
115
116       function "&"
117         (Left, Right : in Bounded_String)
118          return        Bounded_String;
119
120       function "&"
121         (Left  : in Bounded_String;
122          Right : in String)
123          return  Bounded_String;
124
125       function "&"
126         (Left  : in String;
127          Right : in Bounded_String)
128          return  Bounded_String;
129
130       function "&"
131         (Left  : in Bounded_String;
132          Right : in Character)
133          return  Bounded_String;
134
135       function "&"
136         (Left  : in Character;
137          Right : in Bounded_String)
138          return  Bounded_String;
139
140       function Element
141         (Source : in Bounded_String;
142          Index  : in Positive)
143          return   Character;
144
145       procedure Replace_Element
146         (Source : in out Bounded_String;
147          Index  : in Positive;
148          By     : in Character);
149
150       function Slice
151         (Source : in Bounded_String;
152          Low    : in Positive;
153          High   : in Natural)
154          return   String;
155
156       function "="  (Left, Right : in Bounded_String) return Boolean;
157
158       function "="
159         (Left  : in Bounded_String;
160          Right : in String)
161          return  Boolean;
162
163       function "="
164         (Left  : in String;
165          Right : in Bounded_String)
166          return  Boolean;
167
168       function "<"  (Left, Right : in Bounded_String) return Boolean;
169
170       function "<"
171         (Left  : in Bounded_String;
172          Right : in String)
173          return  Boolean;
174
175       function "<"
176         (Left  : in String;
177          Right : in Bounded_String)
178          return  Boolean;
179
180       function "<=" (Left, Right : in Bounded_String) return Boolean;
181
182       function "<="
183         (Left  : in Bounded_String;
184          Right : in String)
185          return  Boolean;
186
187       function "<="
188         (Left  : in String;
189          Right : in Bounded_String)
190          return  Boolean;
191
192       function ">"  (Left, Right : in Bounded_String) return Boolean;
193
194       function ">"
195         (Left  : in Bounded_String;
196          Right : in String)
197          return  Boolean;
198
199       function ">"
200         (Left  : in String;
201          Right : in Bounded_String)
202          return  Boolean;
203
204       function ">=" (Left, Right : in Bounded_String) return Boolean;
205
206       function ">="
207         (Left  : in Bounded_String;
208          Right : in String)
209          return  Boolean;
210
211       function ">="
212         (Left  : in String;
213          Right : in Bounded_String)
214          return  Boolean;
215
216       ----------------------
217       -- Search Functions --
218       ----------------------
219
220       function Index
221         (Source  : in Bounded_String;
222          Pattern : in String;
223          Going   : in Direction := Forward;
224          Mapping : in Maps.Character_Mapping := Maps.Identity)
225          return    Natural;
226
227       function Index
228         (Source  : in Bounded_String;
229          Pattern : in String;
230          Going   : in Direction := Forward;
231          Mapping : in Maps.Character_Mapping_Function)
232          return    Natural;
233
234       function Index
235         (Source : in Bounded_String;
236          Set    : in Maps.Character_Set;
237          Test   : in Membership := Inside;
238          Going  : in Direction  := Forward)
239          return   Natural;
240
241       function Index_Non_Blank
242         (Source : in Bounded_String;
243          Going  : in Direction := Forward)
244          return   Natural;
245
246       function Count
247         (Source  : in Bounded_String;
248          Pattern : in String;
249          Mapping : in Maps.Character_Mapping := Maps.Identity)
250          return    Natural;
251
252       function Count
253         (Source  : in Bounded_String;
254          Pattern : in String;
255          Mapping : in Maps.Character_Mapping_Function)
256          return    Natural;
257
258       function Count
259         (Source : in Bounded_String;
260          Set    : in Maps.Character_Set)
261          return   Natural;
262
263       procedure Find_Token
264         (Source : in Bounded_String;
265          Set    : in Maps.Character_Set;
266          Test   : in Membership;
267          First  : out Positive;
268          Last   : out Natural);
269
270       ------------------------------------
271       -- String Translation Subprograms --
272       ------------------------------------
273
274       function Translate
275         (Source   : in Bounded_String;
276          Mapping  : in Maps.Character_Mapping)
277          return     Bounded_String;
278
279       procedure Translate
280         (Source   : in out Bounded_String;
281          Mapping  : in Maps.Character_Mapping);
282
283       function Translate
284         (Source  : in Bounded_String;
285          Mapping : in Maps.Character_Mapping_Function)
286          return    Bounded_String;
287
288       procedure Translate
289         (Source  : in out Bounded_String;
290          Mapping : in Maps.Character_Mapping_Function);
291
292       ---------------------------------------
293       -- String Transformation Subprograms --
294       ---------------------------------------
295
296       function Replace_Slice
297         (Source   : in Bounded_String;
298          Low      : in Positive;
299          High     : in Natural;
300          By       : in String;
301          Drop     : in Truncation := Error)
302          return     Bounded_String;
303
304       procedure Replace_Slice
305         (Source   : in out Bounded_String;
306          Low      : in Positive;
307          High     : in Natural;
308          By       : in String;
309          Drop     : in Truncation := Error);
310
311       function Insert
312         (Source   : in Bounded_String;
313          Before   : in Positive;
314          New_Item : in String;
315          Drop     : in Truncation := Error)
316          return     Bounded_String;
317
318       procedure Insert
319         (Source   : in out Bounded_String;
320          Before   : in Positive;
321          New_Item : in String;
322          Drop     : in Truncation := Error);
323
324       function Overwrite
325         (Source    : in Bounded_String;
326          Position  : in Positive;
327          New_Item  : in String;
328          Drop      : in Truncation := Error)
329          return      Bounded_String;
330
331       procedure Overwrite
332         (Source    : in out Bounded_String;
333          Position  : in Positive;
334          New_Item  : in String;
335          Drop      : in Truncation := Error);
336
337       function Delete
338         (Source  : in Bounded_String;
339          From    : in Positive;
340          Through : in Natural)
341          return    Bounded_String;
342
343       procedure Delete
344         (Source  : in out Bounded_String;
345          From    : in Positive;
346          Through : in Natural);
347
348       ---------------------------------
349       -- String Selector Subprograms --
350       ---------------------------------
351
352       function Trim
353         (Source : in Bounded_String;
354          Side   : in Trim_End)
355          return   Bounded_String;
356
357       procedure Trim
358         (Source : in out Bounded_String;
359          Side   : in Trim_End);
360
361       function Trim
362         (Source  : in Bounded_String;
363           Left   : in Maps.Character_Set;
364           Right  : in Maps.Character_Set)
365           return   Bounded_String;
366
367       procedure Trim
368         (Source : in out Bounded_String;
369          Left   : in Maps.Character_Set;
370          Right  : in Maps.Character_Set);
371
372       function Head
373         (Source : in Bounded_String;
374          Count  : in Natural;
375          Pad    : in Character := Space;
376          Drop   : in Truncation := Error)
377          return   Bounded_String;
378
379       procedure Head
380         (Source : in out Bounded_String;
381          Count  : in Natural;
382          Pad    : in Character  := Space;
383          Drop   : in Truncation := Error);
384
385       function Tail
386         (Source : in Bounded_String;
387          Count  : in Natural;
388          Pad    : in Character  := Space;
389          Drop   : in Truncation := Error)
390          return Bounded_String;
391
392       procedure Tail
393         (Source : in out Bounded_String;
394          Count  : in Natural;
395          Pad    : in Character  := Space;
396          Drop   : in Truncation := Error);
397
398       ------------------------------------
399       -- String Constructor Subprograms --
400       ------------------------------------
401
402       function "*"
403         (Left  : in Natural;
404          Right : in Character)
405          return  Bounded_String;
406
407       function "*"
408         (Left  : in Natural;
409          Right : in String)
410          return  Bounded_String;
411
412       function "*"
413         (Left  : in Natural;
414          Right : in Bounded_String)
415          return  Bounded_String;
416
417       function Replicate
418         (Count : in Natural;
419          Item  : in Character;
420          Drop  : in Truncation := Error)
421          return  Bounded_String;
422
423       function Replicate
424         (Count : in Natural;
425          Item  : in String;
426          Drop  : in Truncation := Error)
427          return  Bounded_String;
428
429       function Replicate
430         (Count : in Natural;
431          Item  : in Bounded_String;
432          Drop  : in Truncation := Error)
433          return  Bounded_String;
434
435    private
436
437       type Bounded_String is record
438          Length : Length_Range := 0;
439          Data   : String (1 .. Max_Length) := (1 .. Max_Length => ASCII.NUL);
440       end record;
441
442       Null_Bounded_String : constant Bounded_String :=
443                (Length => 0, Data => (1 .. Max_Length => ASCII.NUL));
444
445
446       --  Pragma Inline declarations (GNAT specific additions)
447
448       pragma Inline ("=");
449       pragma Inline ("<");
450       pragma Inline ("<=");
451       pragma Inline (">");
452       pragma Inline (">=");
453       pragma Inline ("&");
454       pragma Inline (Count);
455       pragma Inline (Element);
456       pragma Inline (Find_Token);
457       pragma Inline (Index);
458       pragma Inline (Index_Non_Blank);
459       pragma Inline (Length);
460       pragma Inline (Replace_Element);
461       pragma Inline (Slice);
462       pragma Inline (To_Bounded_String);
463       pragma Inline (To_String);
464
465    end Generic_Bounded_Length;
466
467 end Ada.Strings.Bounded;