OSDN Git Service

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