Debian Codegraph @

gcc/ada/libgnat/a-stwisu.ads

raw
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-2025, 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 ------------------------------------------------------------------------------
31
32 -- This non generic package contains most of the implementation of the
33 -- generic package Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
34
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.
39
40 with Ada.Strings.Text_Buffers;
41 with Ada.Strings.Wide_Maps;
42
43 package Ada.Strings.Wide_Superbounded is
44 pragma Preelaborate;
45
46 Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
47
48 -- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
49 -- derived from Super_String, with the constraint of the maximum length.
50
51 type Super_String (Max_Length : Positive) is record
52 Current_Length : Natural := 0;
53 Data : Wide_String (1 .. Max_Length);
54 -- A previous version had a default initial value for Data, which is
55 -- no longer necessary, because we now special-case this type in the
56 -- compiler, so "=" composes properly for descendants of this type.
57 -- Leaving it out is more efficient.
58 end record
59 with Put_Image => Put_Image;
60
61 -- The subprograms defined for Super_String are similar to those defined
62 -- for Bounded_Wide_String, except that they have different names, so that
63 -- they can be renamed in Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
64
65 function Super_Length (Source : Super_String) return Natural;
66
67 --------------------------------------------------------
68 -- Conversion, Concatenation, and Selection Functions --
69 --------------------------------------------------------
70
71 function To_Super_String
72 (Source : Wide_String;
73 Max_Length : Natural;
74 Drop : Truncation := Error) return Super_String;
75 -- Note the additional parameter Max_Length, which specifies the maximum
76 -- length setting of the resulting Super_String value.
77
78 -- The following procedures have declarations (and semantics) that are
79 -- exactly analogous to those declared in Ada.Strings.Wide_Bounded.
80
81 function Super_To_String (Source : Super_String) return Wide_String;
82
83 procedure Set_Super_String
84 (Target : out Super_String;
85 Source : Wide_String;
86 Drop : Truncation := Error);
87
88 function Super_Append
89 (Left : Super_String;
90 Right : Super_String;
91 Drop : Truncation := Error) return Super_String;
92
93 function Super_Append
94 (Left : Super_String;
95 Right : Wide_String;
96 Drop : Truncation := Error) return Super_String;
97
98 function Super_Append
99 (Left : Wide_String;
100 Right : Super_String;
101 Drop : Truncation := Error) return Super_String;
102
103 function Super_Append
104 (Left : Super_String;
105 Right : Wide_Character;
106 Drop : Truncation := Error) return Super_String;
107
108 function Super_Append
109 (Left : Wide_Character;
110 Right : Super_String;
111 Drop : Truncation := Error) return Super_String;
112
113 procedure Super_Append
114 (Source : in out Super_String;
115 New_Item : Super_String;
116 Drop : Truncation := Error);
117
118 procedure Super_Append
119 (Source : in out Super_String;
120 New_Item : Wide_String;
121 Drop : Truncation := Error);
122
123 procedure Super_Append
124 (Source : in out Super_String;
125 New_Item : Wide_Character;
126 Drop : Truncation := Error);
127
128 function Concat
129 (Left : Super_String;
130 Right : Super_String) return Super_String;
131
132 function Concat
133 (Left : Super_String;
134 Right : Wide_String) return Super_String;
135
136 function Concat
137 (Left : Wide_String;
138 Right : Super_String) return Super_String;
139
140 function Concat
141 (Left : Super_String;
142 Right : Wide_Character) return Super_String;
143
144 function Concat
145 (Left : Wide_Character;
146 Right : Super_String) return Super_String;
147
148 function Super_Element
149 (Source : Super_String;
150 Index : Positive) return Wide_Character;
151
152 procedure Super_Replace_Element
153 (Source : in out Super_String;
154 Index : Positive;
155 By : Wide_Character);
156
157 function Super_Slice
158 (Source : Super_String;
159 Low : Positive;
160 High : Natural) return Wide_String;
161
162 function Super_Slice
163 (Source : Super_String;
164 Low : Positive;
165 High : Natural) return Super_String;
166
167 procedure Super_Slice
168 (Source : Super_String;
169 Target : out Super_String;
170 Low : Positive;
171 High : Natural);
172
173 function "="
174 (Left : Super_String;
175 Right : Super_String) return Boolean;
176
177 function Equal
178 (Left : Super_String;
179 Right : Super_String) return Boolean renames "=";
180
181 function Equal
182 (Left : Super_String;
183 Right : Wide_String) return Boolean;
184
185 function Equal
186 (Left : Wide_String;
187 Right : Super_String) return Boolean;
188
189 function Less
190 (Left : Super_String;
191 Right : Super_String) return Boolean;
192
193 function Less
194 (Left : Super_String;
195 Right : Wide_String) return Boolean;
196
197 function Less
198 (Left : Wide_String;
199 Right : Super_String) return Boolean;
200
201 function Less_Or_Equal
202 (Left : Super_String;
203 Right : Super_String) return Boolean;
204
205 function Less_Or_Equal
206 (Left : Super_String;
207 Right : Wide_String) return Boolean;
208
209 function Less_Or_Equal
210 (Left : Wide_String;
211 Right : Super_String) return Boolean;
212
213 function Greater
214 (Left : Super_String;
215 Right : Super_String) return Boolean;
216
217 function Greater
218 (Left : Super_String;
219 Right : Wide_String) return Boolean;
220
221 function Greater
222 (Left : Wide_String;
223 Right : Super_String) return Boolean;
224
225 function Greater_Or_Equal
226 (Left : Super_String;
227 Right : Super_String) return Boolean;
228
229 function Greater_Or_Equal
230 (Left : Super_String;
231 Right : Wide_String) return Boolean;
232
233 function Greater_Or_Equal
234 (Left : Wide_String;
235 Right : Super_String) return Boolean;
236
237 ----------------------
238 -- Search Functions --
239 ----------------------
240
241 function Super_Index
242 (Source : Super_String;
243 Pattern : Wide_String;
244 Going : Direction := Forward;
245 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
246 return Natural;
247
248 function Super_Index
249 (Source : Super_String;
250 Pattern : Wide_String;
251 Going : Direction := Forward;
252 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
253
254 function Super_Index
255 (Source : Super_String;
256 Set : Wide_Maps.Wide_Character_Set;
257 Test : Membership := Inside;
258 Going : Direction := Forward) return Natural;
259
260 function Super_Index
261 (Source : Super_String;
262 Pattern : Wide_String;
263 From : Positive;
264 Going : Direction := Forward;
265 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
266 return Natural;
267
268 function Super_Index
269 (Source : Super_String;
270 Pattern : Wide_String;
271 From : Positive;
272 Going : Direction := Forward;
273 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
274
275 function Super_Index
276 (Source : Super_String;
277 Set : Wide_Maps.Wide_Character_Set;
278 From : Positive;
279 Test : Membership := Inside;
280 Going : Direction := Forward) return Natural;
281
282 function Super_Index_Non_Blank
283 (Source : Super_String;
284 Going : Direction := Forward) return Natural;
285
286 function Super_Index_Non_Blank
287 (Source : Super_String;
288 From : Positive;
289 Going : Direction := Forward) return Natural;
290
291 function Super_Count
292 (Source : Super_String;
293 Pattern : Wide_String;
294 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
295 return Natural;
296
297 function Super_Count
298 (Source : Super_String;
299 Pattern : Wide_String;
300 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
301
302 function Super_Count
303 (Source : Super_String;
304 Set : Wide_Maps.Wide_Character_Set) return Natural;
305
306 procedure Super_Find_Token
307 (Source : Super_String;
308 Set : Wide_Maps.Wide_Character_Set;
309 From : Positive;
310 Test : Membership;
311 First : out Positive;
312 Last : out Natural);
313
314 procedure Super_Find_Token
315 (Source : Super_String;
316 Set : Wide_Maps.Wide_Character_Set;
317 Test : Membership;
318 First : out Positive;
319 Last : out Natural);
320
321 ------------------------------------
322 -- String Translation Subprograms --
323 ------------------------------------
324
325 function Super_Translate
326 (Source : Super_String;
327 Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
328
329 procedure Super_Translate
330 (Source : in out Super_String;
331 Mapping : Wide_Maps.Wide_Character_Mapping);
332
333 function Super_Translate
334 (Source : Super_String;
335 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
336
337 procedure Super_Translate
338 (Source : in out Super_String;
339 Mapping : Wide_Maps.Wide_Character_Mapping_Function);
340
341 ---------------------------------------
342 -- String Transformation Subprograms --
343 ---------------------------------------
344
345 function Super_Replace_Slice
346 (Source : Super_String;
347 Low : Positive;
348 High : Natural;
349 By : Wide_String;
350 Drop : Truncation := Error) return Super_String;
351
352 procedure Super_Replace_Slice
353 (Source : in out Super_String;
354 Low : Positive;
355 High : Natural;
356 By : Wide_String;
357 Drop : Truncation := Error);
358
359 function Super_Insert
360 (Source : Super_String;
361 Before : Positive;
362 New_Item : Wide_String;
363 Drop : Truncation := Error) return Super_String;
364
365 procedure Super_Insert
366 (Source : in out Super_String;
367 Before : Positive;
368 New_Item : Wide_String;
369 Drop : Truncation := Error);
370
371 function Super_Overwrite
372 (Source : Super_String;
373 Position : Positive;
374 New_Item : Wide_String;
375 Drop : Truncation := Error) return Super_String;
376
377 procedure Super_Overwrite
378 (Source : in out Super_String;
379 Position : Positive;
380 New_Item : Wide_String;
381 Drop : Truncation := Error);
382
383 function Super_Delete
384 (Source : Super_String;
385 From : Positive;
386 Through : Natural) return Super_String;
387
388 procedure Super_Delete
389 (Source : in out Super_String;
390 From : Positive;
391 Through : Natural);
392
393 ---------------------------------
394 -- String Selector Subprograms --
395 ---------------------------------
396
397 function Super_Trim
398 (Source : Super_String;
399 Side : Trim_End) return Super_String;
400
401 procedure Super_Trim
402 (Source : in out Super_String;
403 Side : Trim_End);
404
405 function Super_Trim
406 (Source : Super_String;
407 Left : Wide_Maps.Wide_Character_Set;
408 Right : Wide_Maps.Wide_Character_Set) return Super_String;
409
410 procedure Super_Trim
411 (Source : in out Super_String;
412 Left : Wide_Maps.Wide_Character_Set;
413 Right : Wide_Maps.Wide_Character_Set);
414
415 function Super_Head
416 (Source : Super_String;
417 Count : Natural;
418 Pad : Wide_Character := Wide_Space;
419 Drop : Truncation := Error) return Super_String;
420
421 procedure Super_Head
422 (Source : in out Super_String;
423 Count : Natural;
424 Pad : Wide_Character := Wide_Space;
425 Drop : Truncation := Error);
426
427 function Super_Tail
428 (Source : Super_String;
429 Count : Natural;
430 Pad : Wide_Character := Wide_Space;
431 Drop : Truncation := Error) return Super_String;
432
433 procedure Super_Tail
434 (Source : in out Super_String;
435 Count : Natural;
436 Pad : Wide_Character := Wide_Space;
437 Drop : Truncation := Error);
438
439 ------------------------------------
440 -- String Constructor Subprograms --
441 ------------------------------------
442
443 -- Note: in some of the following routines, there is an extra parameter
444 -- Max_Length which specifies the value of the maximum length for the
445 -- resulting Super_String value.
446
447 function Times
448 (Left : Natural;
449 Right : Wide_Character;
450 Max_Length : Positive) return Super_String;
451 -- Note the additional parameter Max_Length
452
453 function Times
454 (Left : Natural;
455 Right : Wide_String;
456 Max_Length : Positive) return Super_String;
457 -- Note the additional parameter Max_Length
458
459 function Times
460 (Left : Natural;
461 Right : Super_String) return Super_String;
462
463 function Super_Replicate
464 (Count : Natural;
465 Item : Wide_Character;
466 Drop : Truncation := Error;
467 Max_Length : Positive) return Super_String;
468 -- Note the additional parameter Max_Length
469
470 function Super_Replicate
471 (Count : Natural;
472 Item : Wide_String;
473 Drop : Truncation := Error;
474 Max_Length : Positive) return Super_String;
475 -- Note the additional parameter Max_Length
476
477 function Super_Replicate
478 (Count : Natural;
479 Item : Super_String;
480 Drop : Truncation := Error) return Super_String;
481
482 procedure Put_Image
483 (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class;
484 Source : Super_String);
485
486 private
487 -- Pragma Inline declarations
488
489 pragma Inline ("=");
490 pragma Inline (Less);
491 pragma Inline (Less_Or_Equal);
492 pragma Inline (Greater);
493 pragma Inline (Greater_Or_Equal);
494 pragma Inline (Concat);
495 pragma Inline (Super_Count);
496 pragma Inline (Super_Element);
497 pragma Inline (Super_Find_Token);
498 pragma Inline (Super_Index);
499 pragma Inline (Super_Index_Non_Blank);
500 pragma Inline (Super_Length);
501 pragma Inline (Super_Replace_Element);
502 pragma Inline (Super_Slice);
503 pragma Inline (Super_To_String);
504
505 end Ada.Strings.Wide_Superbounded;