PR target/81369
[official-gcc.git] / gcc / ada / a-stwisu.ads
blobe2f3c570040e2f044180c89af633c518d851a3ba
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . W I D E _ 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.Wide_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 the package
37 -- Strings.Wide_Bounded.Generic_Bounded_Length use this type with
38 -- an appropriate discriminant value set.
40 with Ada.Strings.Wide_Maps;
42 package Ada.Strings.Wide_Superbounded is
43 pragma Preelaborate;
45 Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
47 -- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
48 -- derived from Super_String, with the constraint of the maximum length.
50 type Super_String (Max_Length : Positive) is record
51 Current_Length : Natural := 0;
52 Data : Wide_String (1 .. Max_Length);
53 -- A previous version had a default initial value for Data, which is
54 -- no longer necessary, because we now special-case this type in the
55 -- compiler, so "=" composes properly for descendants of this type.
56 -- Leaving it out is more efficient.
57 end record;
59 -- The subprograms defined for Super_String are similar to those defined
60 -- for Bounded_Wide_String, except that they have different names, so that
61 -- they can be renamed in Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
63 function Super_Length (Source : Super_String) return Natural;
65 --------------------------------------------------------
66 -- Conversion, Concatenation, and Selection Functions --
67 --------------------------------------------------------
69 function To_Super_String
70 (Source : Wide_String;
71 Max_Length : Natural;
72 Drop : Truncation := Error) return Super_String;
73 -- Note the additional parameter Max_Length, which specifies the maximum
74 -- length setting of the resulting Super_String value.
76 -- The following procedures have declarations (and semantics) that are
77 -- exactly analogous to those declared in Ada.Strings.Wide_Bounded.
79 function Super_To_String (Source : Super_String) return Wide_String;
81 procedure Set_Super_String
82 (Target : out Super_String;
83 Source : Wide_String;
84 Drop : Truncation := Error);
86 function Super_Append
87 (Left : Super_String;
88 Right : Super_String;
89 Drop : Truncation := Error) return Super_String;
91 function Super_Append
92 (Left : Super_String;
93 Right : Wide_String;
94 Drop : Truncation := Error) return Super_String;
96 function Super_Append
97 (Left : Wide_String;
98 Right : Super_String;
99 Drop : Truncation := Error) return Super_String;
101 function Super_Append
102 (Left : Super_String;
103 Right : Wide_Character;
104 Drop : Truncation := Error) return Super_String;
106 function Super_Append
107 (Left : Wide_Character;
108 Right : Super_String;
109 Drop : Truncation := Error) return Super_String;
111 procedure Super_Append
112 (Source : in out Super_String;
113 New_Item : Super_String;
114 Drop : Truncation := Error);
116 procedure Super_Append
117 (Source : in out Super_String;
118 New_Item : Wide_String;
119 Drop : Truncation := Error);
121 procedure Super_Append
122 (Source : in out Super_String;
123 New_Item : Wide_Character;
124 Drop : Truncation := Error);
126 function Concat
127 (Left : Super_String;
128 Right : Super_String) return Super_String;
130 function Concat
131 (Left : Super_String;
132 Right : Wide_String) return Super_String;
134 function Concat
135 (Left : Wide_String;
136 Right : Super_String) return Super_String;
138 function Concat
139 (Left : Super_String;
140 Right : Wide_Character) return Super_String;
142 function Concat
143 (Left : Wide_Character;
144 Right : Super_String) return Super_String;
146 function Super_Element
147 (Source : Super_String;
148 Index : Positive) return Wide_Character;
150 procedure Super_Replace_Element
151 (Source : in out Super_String;
152 Index : Positive;
153 By : Wide_Character);
155 function Super_Slice
156 (Source : Super_String;
157 Low : Positive;
158 High : Natural) return Wide_String;
160 function Super_Slice
161 (Source : Super_String;
162 Low : Positive;
163 High : Natural) return Super_String;
165 procedure Super_Slice
166 (Source : Super_String;
167 Target : out Super_String;
168 Low : Positive;
169 High : Natural);
171 function "="
172 (Left : Super_String;
173 Right : Super_String) return Boolean;
175 function Equal
176 (Left : Super_String;
177 Right : Super_String) return Boolean renames "=";
179 function Equal
180 (Left : Super_String;
181 Right : Wide_String) return Boolean;
183 function Equal
184 (Left : Wide_String;
185 Right : Super_String) return Boolean;
187 function Less
188 (Left : Super_String;
189 Right : Super_String) return Boolean;
191 function Less
192 (Left : Super_String;
193 Right : Wide_String) return Boolean;
195 function Less
196 (Left : Wide_String;
197 Right : Super_String) return Boolean;
199 function Less_Or_Equal
200 (Left : Super_String;
201 Right : Super_String) return Boolean;
203 function Less_Or_Equal
204 (Left : Super_String;
205 Right : Wide_String) return Boolean;
207 function Less_Or_Equal
208 (Left : Wide_String;
209 Right : Super_String) return Boolean;
211 function Greater
212 (Left : Super_String;
213 Right : Super_String) return Boolean;
215 function Greater
216 (Left : Super_String;
217 Right : Wide_String) return Boolean;
219 function Greater
220 (Left : Wide_String;
221 Right : Super_String) return Boolean;
223 function Greater_Or_Equal
224 (Left : Super_String;
225 Right : Super_String) return Boolean;
227 function Greater_Or_Equal
228 (Left : Super_String;
229 Right : Wide_String) return Boolean;
231 function Greater_Or_Equal
232 (Left : Wide_String;
233 Right : Super_String) return Boolean;
235 ----------------------
236 -- Search Functions --
237 ----------------------
239 function Super_Index
240 (Source : Super_String;
241 Pattern : Wide_String;
242 Going : Direction := Forward;
243 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
244 return Natural;
246 function Super_Index
247 (Source : Super_String;
248 Pattern : Wide_String;
249 Going : Direction := Forward;
250 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
252 function Super_Index
253 (Source : Super_String;
254 Set : Wide_Maps.Wide_Character_Set;
255 Test : Membership := Inside;
256 Going : Direction := Forward) return Natural;
258 function Super_Index
259 (Source : Super_String;
260 Pattern : Wide_String;
261 From : Positive;
262 Going : Direction := Forward;
263 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
264 return Natural;
266 function Super_Index
267 (Source : Super_String;
268 Pattern : Wide_String;
269 From : Positive;
270 Going : Direction := Forward;
271 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
273 function Super_Index
274 (Source : Super_String;
275 Set : Wide_Maps.Wide_Character_Set;
276 From : Positive;
277 Test : Membership := Inside;
278 Going : Direction := Forward) return Natural;
280 function Super_Index_Non_Blank
281 (Source : Super_String;
282 Going : Direction := Forward) return Natural;
284 function Super_Index_Non_Blank
285 (Source : Super_String;
286 From : Positive;
287 Going : Direction := Forward) return Natural;
289 function Super_Count
290 (Source : Super_String;
291 Pattern : Wide_String;
292 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
293 return Natural;
295 function Super_Count
296 (Source : Super_String;
297 Pattern : Wide_String;
298 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
300 function Super_Count
301 (Source : Super_String;
302 Set : Wide_Maps.Wide_Character_Set) return Natural;
304 procedure Super_Find_Token
305 (Source : Super_String;
306 Set : Wide_Maps.Wide_Character_Set;
307 From : Positive;
308 Test : Membership;
309 First : out Positive;
310 Last : out Natural);
312 procedure Super_Find_Token
313 (Source : Super_String;
314 Set : Wide_Maps.Wide_Character_Set;
315 Test : Membership;
316 First : out Positive;
317 Last : out Natural);
319 ------------------------------------
320 -- String Translation Subprograms --
321 ------------------------------------
323 function Super_Translate
324 (Source : Super_String;
325 Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
327 procedure Super_Translate
328 (Source : in out Super_String;
329 Mapping : Wide_Maps.Wide_Character_Mapping);
331 function Super_Translate
332 (Source : Super_String;
333 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
335 procedure Super_Translate
336 (Source : in out Super_String;
337 Mapping : Wide_Maps.Wide_Character_Mapping_Function);
339 ---------------------------------------
340 -- String Transformation Subprograms --
341 ---------------------------------------
343 function Super_Replace_Slice
344 (Source : Super_String;
345 Low : Positive;
346 High : Natural;
347 By : Wide_String;
348 Drop : Truncation := Error) return Super_String;
350 procedure Super_Replace_Slice
351 (Source : in out Super_String;
352 Low : Positive;
353 High : Natural;
354 By : Wide_String;
355 Drop : Truncation := Error);
357 function Super_Insert
358 (Source : Super_String;
359 Before : Positive;
360 New_Item : Wide_String;
361 Drop : Truncation := Error) return Super_String;
363 procedure Super_Insert
364 (Source : in out Super_String;
365 Before : Positive;
366 New_Item : Wide_String;
367 Drop : Truncation := Error);
369 function Super_Overwrite
370 (Source : Super_String;
371 Position : Positive;
372 New_Item : Wide_String;
373 Drop : Truncation := Error) return Super_String;
375 procedure Super_Overwrite
376 (Source : in out Super_String;
377 Position : Positive;
378 New_Item : Wide_String;
379 Drop : Truncation := Error);
381 function Super_Delete
382 (Source : Super_String;
383 From : Positive;
384 Through : Natural) return Super_String;
386 procedure Super_Delete
387 (Source : in out Super_String;
388 From : Positive;
389 Through : Natural);
391 ---------------------------------
392 -- String Selector Subprograms --
393 ---------------------------------
395 function Super_Trim
396 (Source : Super_String;
397 Side : Trim_End) return Super_String;
399 procedure Super_Trim
400 (Source : in out Super_String;
401 Side : Trim_End);
403 function Super_Trim
404 (Source : Super_String;
405 Left : Wide_Maps.Wide_Character_Set;
406 Right : Wide_Maps.Wide_Character_Set) return Super_String;
408 procedure Super_Trim
409 (Source : in out Super_String;
410 Left : Wide_Maps.Wide_Character_Set;
411 Right : Wide_Maps.Wide_Character_Set);
413 function Super_Head
414 (Source : Super_String;
415 Count : Natural;
416 Pad : Wide_Character := Wide_Space;
417 Drop : Truncation := Error) return Super_String;
419 procedure Super_Head
420 (Source : in out Super_String;
421 Count : Natural;
422 Pad : Wide_Character := Wide_Space;
423 Drop : Truncation := Error);
425 function Super_Tail
426 (Source : Super_String;
427 Count : Natural;
428 Pad : Wide_Character := Wide_Space;
429 Drop : Truncation := Error) return Super_String;
431 procedure Super_Tail
432 (Source : in out Super_String;
433 Count : Natural;
434 Pad : Wide_Character := Wide_Space;
435 Drop : Truncation := Error);
437 ------------------------------------
438 -- String Constructor Subprograms --
439 ------------------------------------
441 -- Note: in some of the following routines, there is an extra parameter
442 -- Max_Length which specifies the value of the maximum length for the
443 -- resulting Super_String value.
445 function Times
446 (Left : Natural;
447 Right : Wide_Character;
448 Max_Length : Positive) return Super_String;
449 -- Note the additional parameter Max_Length
451 function Times
452 (Left : Natural;
453 Right : Wide_String;
454 Max_Length : Positive) return Super_String;
455 -- Note the additional parameter Max_Length
457 function Times
458 (Left : Natural;
459 Right : Super_String) return Super_String;
461 function Super_Replicate
462 (Count : Natural;
463 Item : Wide_Character;
464 Drop : Truncation := Error;
465 Max_Length : Positive) return Super_String;
466 -- Note the additional parameter Max_Length
468 function Super_Replicate
469 (Count : Natural;
470 Item : Wide_String;
471 Drop : Truncation := Error;
472 Max_Length : Positive) return Super_String;
473 -- Note the additional parameter Max_Length
475 function Super_Replicate
476 (Count : Natural;
477 Item : Super_String;
478 Drop : Truncation := Error) return Super_String;
480 private
481 -- Pragma Inline declarations
483 pragma Inline ("=");
484 pragma Inline (Less);
485 pragma Inline (Less_Or_Equal);
486 pragma Inline (Greater);
487 pragma Inline (Greater_Or_Equal);
488 pragma Inline (Concat);
489 pragma Inline (Super_Count);
490 pragma Inline (Super_Element);
491 pragma Inline (Super_Find_Token);
492 pragma Inline (Super_Index);
493 pragma Inline (Super_Index_Non_Blank);
494 pragma Inline (Super_Length);
495 pragma Inline (Super_Replace_Element);
496 pragma Inline (Super_Slice);
497 pragma Inline (Super_To_String);
499 end Ada.Strings.Wide_Superbounded;