PR testsuite/79036 - gcc.dg/tree-ssa/builtin-sprintf.c fails starting with r244037
[official-gcc.git] / gcc / ada / a-strsup.ads
blobd43a560a543acf0876ee92753a77d54fc9d64c20
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . S U P E R B O U N D E D --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2003-2012, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 -- This non generic package contains most of the implementation of the
33 -- generic package Ada.Strings.Bounded.Generic_Bounded_Length.
35 -- It defines type Super_String as a discriminated record with the maximum
36 -- length as the discriminant. Individual instantiations of Strings.Bounded
37 -- use this type with an appropriate discriminant value set.
39 with Ada.Strings.Maps;
41 package Ada.Strings.Superbounded is
42 pragma Preelaborate;
44 -- Type Bounded_String in Ada.Strings.Bounded.Generic_Bounded_Length is
45 -- derived from Super_String, with the constraint of the maximum length.
47 type Super_String (Max_Length : Positive) is record
48 Current_Length : Natural := 0;
49 Data : String (1 .. Max_Length);
50 -- A previous version had a default initial value for Data, which is
51 -- no longer necessary, because we now special-case this type in the
52 -- compiler, so "=" composes properly for descendants of this type.
53 -- Leaving it out is more efficient.
54 end record;
56 -- The subprograms defined for Super_String are similar to those
57 -- defined for Bounded_String, except that they have different names, so
58 -- that they can be renamed in Ada.Strings.Bounded.Generic_Bounded_Length.
60 function Super_Length (Source : Super_String) return Natural;
62 --------------------------------------------------------
63 -- Conversion, Concatenation, and Selection Functions --
64 --------------------------------------------------------
66 function To_Super_String
67 (Source : String;
68 Max_Length : Natural;
69 Drop : Truncation := Error) return Super_String;
70 -- Note the additional parameter Max_Length, which specifies the maximum
71 -- length setting of the resulting Super_String value.
73 -- The following procedures have declarations (and semantics) that are
74 -- exactly analogous to those declared in Ada.Strings.Bounded.
76 function Super_To_String (Source : Super_String) return String;
78 procedure Set_Super_String
79 (Target : out Super_String;
80 Source : String;
81 Drop : Truncation := Error);
83 function Super_Append
84 (Left : Super_String;
85 Right : Super_String;
86 Drop : Truncation := Error) return Super_String;
88 function Super_Append
89 (Left : Super_String;
90 Right : String;
91 Drop : Truncation := Error) return Super_String;
93 function Super_Append
94 (Left : String;
95 Right : Super_String;
96 Drop : Truncation := Error) return Super_String;
98 function Super_Append
99 (Left : Super_String;
100 Right : Character;
101 Drop : Truncation := Error) return Super_String;
103 function Super_Append
104 (Left : Character;
105 Right : Super_String;
106 Drop : Truncation := Error) return Super_String;
108 procedure Super_Append
109 (Source : in out Super_String;
110 New_Item : Super_String;
111 Drop : Truncation := Error);
113 procedure Super_Append
114 (Source : in out Super_String;
115 New_Item : String;
116 Drop : Truncation := Error);
118 procedure Super_Append
119 (Source : in out Super_String;
120 New_Item : Character;
121 Drop : Truncation := Error);
123 function Concat
124 (Left : Super_String;
125 Right : Super_String) return Super_String;
127 function Concat
128 (Left : Super_String;
129 Right : String) return Super_String;
131 function Concat
132 (Left : String;
133 Right : Super_String) return Super_String;
135 function Concat
136 (Left : Super_String;
137 Right : Character) return Super_String;
139 function Concat
140 (Left : Character;
141 Right : Super_String) return Super_String;
143 function Super_Element
144 (Source : Super_String;
145 Index : Positive) return Character;
147 procedure Super_Replace_Element
148 (Source : in out Super_String;
149 Index : Positive;
150 By : Character);
152 function Super_Slice
153 (Source : Super_String;
154 Low : Positive;
155 High : Natural) return String;
157 function Super_Slice
158 (Source : Super_String;
159 Low : Positive;
160 High : Natural) return Super_String;
162 procedure Super_Slice
163 (Source : Super_String;
164 Target : out Super_String;
165 Low : Positive;
166 High : Natural);
168 function "="
169 (Left : Super_String;
170 Right : Super_String) return Boolean;
172 function Equal
173 (Left : Super_String;
174 Right : Super_String) return Boolean renames "=";
176 function Equal
177 (Left : Super_String;
178 Right : String) return Boolean;
180 function Equal
181 (Left : String;
182 Right : Super_String) return Boolean;
184 function Less
185 (Left : Super_String;
186 Right : Super_String) return Boolean;
188 function Less
189 (Left : Super_String;
190 Right : String) return Boolean;
192 function Less
193 (Left : String;
194 Right : Super_String) return Boolean;
196 function Less_Or_Equal
197 (Left : Super_String;
198 Right : Super_String) return Boolean;
200 function Less_Or_Equal
201 (Left : Super_String;
202 Right : String) return Boolean;
204 function Less_Or_Equal
205 (Left : String;
206 Right : Super_String) return Boolean;
208 function Greater
209 (Left : Super_String;
210 Right : Super_String) return Boolean;
212 function Greater
213 (Left : Super_String;
214 Right : String) return Boolean;
216 function Greater
217 (Left : String;
218 Right : Super_String) return Boolean;
220 function Greater_Or_Equal
221 (Left : Super_String;
222 Right : Super_String) return Boolean;
224 function Greater_Or_Equal
225 (Left : Super_String;
226 Right : String) return Boolean;
228 function Greater_Or_Equal
229 (Left : String;
230 Right : Super_String) return Boolean;
232 ----------------------
233 -- Search Functions --
234 ----------------------
236 function Super_Index
237 (Source : Super_String;
238 Pattern : String;
239 Going : Direction := Forward;
240 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
242 function Super_Index
243 (Source : Super_String;
244 Pattern : String;
245 Going : Direction := Forward;
246 Mapping : Maps.Character_Mapping_Function) return Natural;
248 function Super_Index
249 (Source : Super_String;
250 Set : Maps.Character_Set;
251 Test : Membership := Inside;
252 Going : Direction := Forward) return Natural;
254 function Super_Index
255 (Source : Super_String;
256 Pattern : String;
257 From : Positive;
258 Going : Direction := Forward;
259 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
261 function Super_Index
262 (Source : Super_String;
263 Pattern : String;
264 From : Positive;
265 Going : Direction := Forward;
266 Mapping : Maps.Character_Mapping_Function) return Natural;
268 function Super_Index
269 (Source : Super_String;
270 Set : Maps.Character_Set;
271 From : Positive;
272 Test : Membership := Inside;
273 Going : Direction := Forward) return Natural;
275 function Super_Index_Non_Blank
276 (Source : Super_String;
277 Going : Direction := Forward) return Natural;
279 function Super_Index_Non_Blank
280 (Source : Super_String;
281 From : Positive;
282 Going : Direction := Forward) return Natural;
284 function Super_Count
285 (Source : Super_String;
286 Pattern : String;
287 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
289 function Super_Count
290 (Source : Super_String;
291 Pattern : String;
292 Mapping : Maps.Character_Mapping_Function) return Natural;
294 function Super_Count
295 (Source : Super_String;
296 Set : Maps.Character_Set) return Natural;
298 procedure Super_Find_Token
299 (Source : Super_String;
300 Set : Maps.Character_Set;
301 From : Positive;
302 Test : Membership;
303 First : out Positive;
304 Last : out Natural);
306 procedure Super_Find_Token
307 (Source : Super_String;
308 Set : Maps.Character_Set;
309 Test : Membership;
310 First : out Positive;
311 Last : out Natural);
313 ------------------------------------
314 -- String Translation Subprograms --
315 ------------------------------------
317 function Super_Translate
318 (Source : Super_String;
319 Mapping : Maps.Character_Mapping) return Super_String;
321 procedure Super_Translate
322 (Source : in out Super_String;
323 Mapping : Maps.Character_Mapping);
325 function Super_Translate
326 (Source : Super_String;
327 Mapping : Maps.Character_Mapping_Function) return Super_String;
329 procedure Super_Translate
330 (Source : in out Super_String;
331 Mapping : Maps.Character_Mapping_Function);
333 ---------------------------------------
334 -- String Transformation Subprograms --
335 ---------------------------------------
337 function Super_Replace_Slice
338 (Source : Super_String;
339 Low : Positive;
340 High : Natural;
341 By : String;
342 Drop : Truncation := Error) return Super_String;
344 procedure Super_Replace_Slice
345 (Source : in out Super_String;
346 Low : Positive;
347 High : Natural;
348 By : String;
349 Drop : Truncation := Error);
351 function Super_Insert
352 (Source : Super_String;
353 Before : Positive;
354 New_Item : String;
355 Drop : Truncation := Error) return Super_String;
357 procedure Super_Insert
358 (Source : in out Super_String;
359 Before : Positive;
360 New_Item : String;
361 Drop : Truncation := Error);
363 function Super_Overwrite
364 (Source : Super_String;
365 Position : Positive;
366 New_Item : String;
367 Drop : Truncation := Error) return Super_String;
369 procedure Super_Overwrite
370 (Source : in out Super_String;
371 Position : Positive;
372 New_Item : String;
373 Drop : Truncation := Error);
375 function Super_Delete
376 (Source : Super_String;
377 From : Positive;
378 Through : Natural) return Super_String;
380 procedure Super_Delete
381 (Source : in out Super_String;
382 From : Positive;
383 Through : Natural);
385 ---------------------------------
386 -- String Selector Subprograms --
387 ---------------------------------
389 function Super_Trim
390 (Source : Super_String;
391 Side : Trim_End) return Super_String;
393 procedure Super_Trim
394 (Source : in out Super_String;
395 Side : Trim_End);
397 function Super_Trim
398 (Source : Super_String;
399 Left : Maps.Character_Set;
400 Right : Maps.Character_Set) return Super_String;
402 procedure Super_Trim
403 (Source : in out Super_String;
404 Left : Maps.Character_Set;
405 Right : Maps.Character_Set);
407 function Super_Head
408 (Source : Super_String;
409 Count : Natural;
410 Pad : Character := Space;
411 Drop : Truncation := Error) return Super_String;
413 procedure Super_Head
414 (Source : in out Super_String;
415 Count : Natural;
416 Pad : Character := Space;
417 Drop : Truncation := Error);
419 function Super_Tail
420 (Source : Super_String;
421 Count : Natural;
422 Pad : Character := Space;
423 Drop : Truncation := Error) return Super_String;
425 procedure Super_Tail
426 (Source : in out Super_String;
427 Count : Natural;
428 Pad : Character := Space;
429 Drop : Truncation := Error);
431 ------------------------------------
432 -- String Constructor Subprograms --
433 ------------------------------------
435 -- Note: in some of the following routines, there is an extra parameter
436 -- Max_Length which specifies the value of the maximum length for the
437 -- resulting Super_String value.
439 function Times
440 (Left : Natural;
441 Right : Character;
442 Max_Length : Positive) return Super_String;
443 -- Note the additional parameter Max_Length
445 function Times
446 (Left : Natural;
447 Right : String;
448 Max_Length : Positive) return Super_String;
449 -- Note the additional parameter Max_Length
451 function Times
452 (Left : Natural;
453 Right : Super_String) return Super_String;
455 function Super_Replicate
456 (Count : Natural;
457 Item : Character;
458 Drop : Truncation := Error;
459 Max_Length : Positive) return Super_String;
460 -- Note the additional parameter Max_Length
462 function Super_Replicate
463 (Count : Natural;
464 Item : String;
465 Drop : Truncation := Error;
466 Max_Length : Positive) return Super_String;
467 -- Note the additional parameter Max_Length
469 function Super_Replicate
470 (Count : Natural;
471 Item : Super_String;
472 Drop : Truncation := Error) return Super_String;
474 private
475 -- Pragma Inline declarations
477 pragma Inline ("=");
478 pragma Inline (Less);
479 pragma Inline (Less_Or_Equal);
480 pragma Inline (Greater);
481 pragma Inline (Greater_Or_Equal);
482 pragma Inline (Concat);
483 pragma Inline (Super_Count);
484 pragma Inline (Super_Element);
485 pragma Inline (Super_Find_Token);
486 pragma Inline (Super_Index);
487 pragma Inline (Super_Index_Non_Blank);
488 pragma Inline (Super_Length);
489 pragma Inline (Super_Replace_Element);
490 pragma Inline (Super_Slice);
491 pragma Inline (Super_To_String);
493 end Ada.Strings.Superbounded;