Daily bump.
[official-gcc.git] / gcc / ada / a-strbou.ads
blob179e38f98de7ca796ef48e4885441a71e95c5d15
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.1 $
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 -- Extensive contributions were provided by Ada Core Technologies Inc. --
37 -- --
38 ------------------------------------------------------------------------------
40 with Ada.Strings.Maps;
42 package Ada.Strings.Bounded is
43 pragma Preelaborate (Bounded);
45 generic
46 Max : Positive;
47 -- Maximum length of a Bounded_String
49 package Generic_Bounded_Length is
51 Max_Length : constant Positive := Max;
53 type Bounded_String is private;
55 Null_Bounded_String : constant Bounded_String;
57 subtype Length_Range is Natural range 0 .. Max_Length;
59 function Length (Source : in Bounded_String) return Length_Range;
61 --------------------------------------------------------
62 -- Conversion, Concatenation, and Selection Functions --
63 --------------------------------------------------------
65 function To_Bounded_String
66 (Source : in String;
67 Drop : in Truncation := Error)
68 return Bounded_String;
70 function To_String (Source : in Bounded_String) return String;
72 function Append
73 (Left, Right : in Bounded_String;
74 Drop : in Truncation := Error)
75 return Bounded_String;
77 function Append
78 (Left : in Bounded_String;
79 Right : in String;
80 Drop : in Truncation := Error)
81 return Bounded_String;
83 function Append
84 (Left : in String;
85 Right : in Bounded_String;
86 Drop : in Truncation := Error)
87 return Bounded_String;
89 function Append
90 (Left : in Bounded_String;
91 Right : in Character;
92 Drop : in Truncation := Error)
93 return Bounded_String;
95 function Append
96 (Left : in Character;
97 Right : in Bounded_String;
98 Drop : in Truncation := Error)
99 return Bounded_String;
101 procedure Append
102 (Source : in out Bounded_String;
103 New_Item : in Bounded_String;
104 Drop : in Truncation := Error);
106 procedure Append
107 (Source : in out Bounded_String;
108 New_Item : in String;
109 Drop : in Truncation := Error);
111 procedure Append
112 (Source : in out Bounded_String;
113 New_Item : in Character;
114 Drop : in Truncation := Error);
116 function "&"
117 (Left, Right : in Bounded_String)
118 return Bounded_String;
120 function "&"
121 (Left : in Bounded_String;
122 Right : in String)
123 return Bounded_String;
125 function "&"
126 (Left : in String;
127 Right : in Bounded_String)
128 return Bounded_String;
130 function "&"
131 (Left : in Bounded_String;
132 Right : in Character)
133 return Bounded_String;
135 function "&"
136 (Left : in Character;
137 Right : in Bounded_String)
138 return Bounded_String;
140 function Element
141 (Source : in Bounded_String;
142 Index : in Positive)
143 return Character;
145 procedure Replace_Element
146 (Source : in out Bounded_String;
147 Index : in Positive;
148 By : in Character);
150 function Slice
151 (Source : in Bounded_String;
152 Low : in Positive;
153 High : in Natural)
154 return String;
156 function "=" (Left, Right : in Bounded_String) return Boolean;
158 function "="
159 (Left : in Bounded_String;
160 Right : in String)
161 return Boolean;
163 function "="
164 (Left : in String;
165 Right : in Bounded_String)
166 return Boolean;
168 function "<" (Left, Right : in Bounded_String) return Boolean;
170 function "<"
171 (Left : in Bounded_String;
172 Right : in String)
173 return Boolean;
175 function "<"
176 (Left : in String;
177 Right : in Bounded_String)
178 return Boolean;
180 function "<=" (Left, Right : in Bounded_String) return Boolean;
182 function "<="
183 (Left : in Bounded_String;
184 Right : in String)
185 return Boolean;
187 function "<="
188 (Left : in String;
189 Right : in Bounded_String)
190 return Boolean;
192 function ">" (Left, Right : in Bounded_String) return Boolean;
194 function ">"
195 (Left : in Bounded_String;
196 Right : in String)
197 return Boolean;
199 function ">"
200 (Left : in String;
201 Right : in Bounded_String)
202 return Boolean;
204 function ">=" (Left, Right : in Bounded_String) return Boolean;
206 function ">="
207 (Left : in Bounded_String;
208 Right : in String)
209 return Boolean;
211 function ">="
212 (Left : in String;
213 Right : in Bounded_String)
214 return Boolean;
216 ----------------------
217 -- Search Functions --
218 ----------------------
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;
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;
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;
241 function Index_Non_Blank
242 (Source : in Bounded_String;
243 Going : in Direction := Forward)
244 return Natural;
246 function Count
247 (Source : in Bounded_String;
248 Pattern : in String;
249 Mapping : in Maps.Character_Mapping := Maps.Identity)
250 return Natural;
252 function Count
253 (Source : in Bounded_String;
254 Pattern : in String;
255 Mapping : in Maps.Character_Mapping_Function)
256 return Natural;
258 function Count
259 (Source : in Bounded_String;
260 Set : in Maps.Character_Set)
261 return Natural;
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);
270 ------------------------------------
271 -- String Translation Subprograms --
272 ------------------------------------
274 function Translate
275 (Source : in Bounded_String;
276 Mapping : in Maps.Character_Mapping)
277 return Bounded_String;
279 procedure Translate
280 (Source : in out Bounded_String;
281 Mapping : in Maps.Character_Mapping);
283 function Translate
284 (Source : in Bounded_String;
285 Mapping : in Maps.Character_Mapping_Function)
286 return Bounded_String;
288 procedure Translate
289 (Source : in out Bounded_String;
290 Mapping : in Maps.Character_Mapping_Function);
292 ---------------------------------------
293 -- String Transformation Subprograms --
294 ---------------------------------------
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;
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);
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;
318 procedure Insert
319 (Source : in out Bounded_String;
320 Before : in Positive;
321 New_Item : in String;
322 Drop : in Truncation := Error);
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;
331 procedure Overwrite
332 (Source : in out Bounded_String;
333 Position : in Positive;
334 New_Item : in String;
335 Drop : in Truncation := Error);
337 function Delete
338 (Source : in Bounded_String;
339 From : in Positive;
340 Through : in Natural)
341 return Bounded_String;
343 procedure Delete
344 (Source : in out Bounded_String;
345 From : in Positive;
346 Through : in Natural);
348 ---------------------------------
349 -- String Selector Subprograms --
350 ---------------------------------
352 function Trim
353 (Source : in Bounded_String;
354 Side : in Trim_End)
355 return Bounded_String;
357 procedure Trim
358 (Source : in out Bounded_String;
359 Side : in Trim_End);
361 function Trim
362 (Source : in Bounded_String;
363 Left : in Maps.Character_Set;
364 Right : in Maps.Character_Set)
365 return Bounded_String;
367 procedure Trim
368 (Source : in out Bounded_String;
369 Left : in Maps.Character_Set;
370 Right : in Maps.Character_Set);
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;
379 procedure Head
380 (Source : in out Bounded_String;
381 Count : in Natural;
382 Pad : in Character := Space;
383 Drop : in Truncation := Error);
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;
392 procedure Tail
393 (Source : in out Bounded_String;
394 Count : in Natural;
395 Pad : in Character := Space;
396 Drop : in Truncation := Error);
398 ------------------------------------
399 -- String Constructor Subprograms --
400 ------------------------------------
402 function "*"
403 (Left : in Natural;
404 Right : in Character)
405 return Bounded_String;
407 function "*"
408 (Left : in Natural;
409 Right : in String)
410 return Bounded_String;
412 function "*"
413 (Left : in Natural;
414 Right : in Bounded_String)
415 return Bounded_String;
417 function Replicate
418 (Count : in Natural;
419 Item : in Character;
420 Drop : in Truncation := Error)
421 return Bounded_String;
423 function Replicate
424 (Count : in Natural;
425 Item : in String;
426 Drop : in Truncation := Error)
427 return Bounded_String;
429 function Replicate
430 (Count : in Natural;
431 Item : in Bounded_String;
432 Drop : in Truncation := Error)
433 return Bounded_String;
435 private
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;
442 Null_Bounded_String : constant Bounded_String :=
443 (Length => 0, Data => (1 .. Max_Length => ASCII.NUL));
446 -- Pragma Inline declarations (GNAT specific additions)
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);
465 end Generic_Bounded_Length;
467 end Ada.Strings.Bounded;