PR ada/18819
[official-gcc.git] / gcc / ada / a-stzsup.ads
blobab84ad46f8b42a1a55223dc3d9b33a744e42b6fc
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . W I D E _ 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-2005, 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This non generic package contains most of the implementation of the
35 -- generic package Ada.Strings.Wide_Wide_Bounded.Generic_Bounded_Length.
37 -- It defines type Super_String as a discriminated record with the maximum
38 -- length as the discriminant. Individual instantiations of the package
39 -- Strings.Wide_Wide_Bounded.Generic_Bounded_Length use this type with
40 -- an appropriate discriminant value set.
42 with Ada.Strings.Wide_Wide_Maps;
44 package Ada.Strings.Wide_Wide_Superbounded is
45 pragma Preelaborate;
47 Wide_Wide_NUL : constant Wide_Wide_Character :=
48 Wide_Wide_Character'Val (0);
50 type Super_String (Max_Length : Positive) is record
51 Current_Length : Natural := 0;
52 Data : Wide_Wide_String (1 .. Max_Length) :=
53 (others => Wide_Wide_NUL);
54 end record;
55 -- Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is
56 -- derived from this type, with the constraint of the maximum length.
58 -- The subprograms defined for Super_String are similar to those defined
59 -- for Bounded_Wide_Wide_String, except that they have different names, so
60 -- that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length.
62 function Super_Length (Source : Super_String) return Natural;
64 --------------------------------------------------------
65 -- Conversion, Concatenation, and Selection Functions --
66 --------------------------------------------------------
68 function To_Super_String
69 (Source : Wide_Wide_String;
70 Max_Length : Natural;
71 Drop : Truncation := Error) return Super_String;
72 -- Note the additional parameter Max_Length, which specifies the maximum
73 -- length setting of the resulting Super_String value.
75 -- The following procedures have declarations (and semantics) that are
76 -- exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded.
78 function Super_To_String (Source : Super_String) return Wide_Wide_String;
80 procedure Set_Super_String
81 (Target : out Super_String;
82 Source : Wide_Wide_String;
83 Drop : Truncation := Error);
85 function Super_Append
86 (Left : Super_String;
87 Right : Super_String;
88 Drop : Truncation := Error) return Super_String;
90 function Super_Append
91 (Left : Super_String;
92 Right : Wide_Wide_String;
93 Drop : Truncation := Error) return Super_String;
95 function Super_Append
96 (Left : Wide_Wide_String;
97 Right : Super_String;
98 Drop : Truncation := Error) return Super_String;
100 function Super_Append
101 (Left : Super_String;
102 Right : Wide_Wide_Character;
103 Drop : Truncation := Error) return Super_String;
105 function Super_Append
106 (Left : Wide_Wide_Character;
107 Right : Super_String;
108 Drop : Truncation := Error) return Super_String;
110 procedure Super_Append
111 (Source : in out Super_String;
112 New_Item : Super_String;
113 Drop : Truncation := Error);
115 procedure Super_Append
116 (Source : in out Super_String;
117 New_Item : Wide_Wide_String;
118 Drop : Truncation := Error);
120 procedure Super_Append
121 (Source : in out Super_String;
122 New_Item : Wide_Wide_Character;
123 Drop : Truncation := Error);
125 function Concat
126 (Left : Super_String;
127 Right : Super_String) return Super_String;
129 function Concat
130 (Left : Super_String;
131 Right : Wide_Wide_String) return Super_String;
133 function Concat
134 (Left : Wide_Wide_String;
135 Right : Super_String) return Super_String;
137 function Concat
138 (Left : Super_String;
139 Right : Wide_Wide_Character) return Super_String;
141 function Concat
142 (Left : Wide_Wide_Character;
143 Right : Super_String) return Super_String;
145 function Super_Element
146 (Source : Super_String;
147 Index : Positive) return Wide_Wide_Character;
149 procedure Super_Replace_Element
150 (Source : in out Super_String;
151 Index : Positive;
152 By : Wide_Wide_Character);
154 function Super_Slice
155 (Source : Super_String;
156 Low : Positive;
157 High : Natural) return Wide_Wide_String;
159 function Super_Slice
160 (Source : Super_String;
161 Low : Positive;
162 High : Natural) return Super_String;
164 procedure Super_Slice
165 (Source : Super_String;
166 Target : out Super_String;
167 Low : Positive;
168 High : Natural);
170 function "="
171 (Left : Super_String;
172 Right : Super_String) return Boolean;
174 function Equal
175 (Left : Super_String;
176 Right : Super_String) return Boolean renames "=";
178 function Equal
179 (Left : Super_String;
180 Right : Wide_Wide_String) return Boolean;
182 function Equal
183 (Left : Wide_Wide_String;
184 Right : Super_String) return Boolean;
186 function Less
187 (Left : Super_String;
188 Right : Super_String) return Boolean;
190 function Less
191 (Left : Super_String;
192 Right : Wide_Wide_String) return Boolean;
194 function Less
195 (Left : Wide_Wide_String;
196 Right : Super_String) return Boolean;
198 function Less_Or_Equal
199 (Left : Super_String;
200 Right : Super_String) return Boolean;
202 function Less_Or_Equal
203 (Left : Super_String;
204 Right : Wide_Wide_String) return Boolean;
206 function Less_Or_Equal
207 (Left : Wide_Wide_String;
208 Right : Super_String) return Boolean;
210 function Greater
211 (Left : Super_String;
212 Right : Super_String) return Boolean;
214 function Greater
215 (Left : Super_String;
216 Right : Wide_Wide_String) return Boolean;
218 function Greater
219 (Left : Wide_Wide_String;
220 Right : Super_String) return Boolean;
222 function Greater_Or_Equal
223 (Left : Super_String;
224 Right : Super_String) return Boolean;
226 function Greater_Or_Equal
227 (Left : Super_String;
228 Right : Wide_Wide_String) return Boolean;
230 function Greater_Or_Equal
231 (Left : Wide_Wide_String;
232 Right : Super_String) return Boolean;
234 ----------------------
235 -- Search Functions --
236 ----------------------
238 function Super_Index
239 (Source : Super_String;
240 Pattern : Wide_Wide_String;
241 Going : Direction := Forward;
242 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
243 Wide_Wide_Maps.Identity)
244 return Natural;
246 function Super_Index
247 (Source : Super_String;
248 Pattern : Wide_Wide_String;
249 Going : Direction := Forward;
250 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
251 return Natural;
253 function Super_Index
254 (Source : Super_String;
255 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
256 Test : Membership := Inside;
257 Going : Direction := Forward) return Natural;
259 function Super_Index
260 (Source : Super_String;
261 Pattern : Wide_Wide_String;
262 From : Positive;
263 Going : Direction := Forward;
264 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
265 Wide_Wide_Maps.Identity)
266 return Natural;
268 function Super_Index
269 (Source : Super_String;
270 Pattern : Wide_Wide_String;
271 From : Positive;
272 Going : Direction := Forward;
273 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
274 return Natural;
276 function Super_Index
277 (Source : Super_String;
278 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
279 From : Positive;
280 Test : Membership := Inside;
281 Going : Direction := Forward) return Natural;
283 function Super_Index_Non_Blank
284 (Source : Super_String;
285 Going : Direction := Forward) return Natural;
287 function Super_Index_Non_Blank
288 (Source : Super_String;
289 From : Positive;
290 Going : Direction := Forward) return Natural;
292 function Super_Count
293 (Source : Super_String;
294 Pattern : Wide_Wide_String;
295 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
296 Wide_Wide_Maps.Identity)
297 return Natural;
299 function Super_Count
300 (Source : Super_String;
301 Pattern : Wide_Wide_String;
302 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
303 return Natural;
305 function Super_Count
306 (Source : Super_String;
307 Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;
309 procedure Super_Find_Token
310 (Source : Super_String;
311 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
312 Test : Membership;
313 First : out Positive;
314 Last : out Natural);
316 ------------------------------------
317 -- String Translation Subprograms --
318 ------------------------------------
320 function Super_Translate
321 (Source : Super_String;
322 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
323 return Super_String;
325 procedure Super_Translate
326 (Source : in out Super_String;
327 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping);
329 function Super_Translate
330 (Source : Super_String;
331 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
332 return Super_String;
334 procedure Super_Translate
335 (Source : in out Super_String;
336 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);
338 ---------------------------------------
339 -- String Transformation Subprograms --
340 ---------------------------------------
342 function Super_Replace_Slice
343 (Source : Super_String;
344 Low : Positive;
345 High : Natural;
346 By : Wide_Wide_String;
347 Drop : Truncation := Error) return Super_String;
349 procedure Super_Replace_Slice
350 (Source : in out Super_String;
351 Low : Positive;
352 High : Natural;
353 By : Wide_Wide_String;
354 Drop : Truncation := Error);
356 function Super_Insert
357 (Source : Super_String;
358 Before : Positive;
359 New_Item : Wide_Wide_String;
360 Drop : Truncation := Error) return Super_String;
362 procedure Super_Insert
363 (Source : in out Super_String;
364 Before : Positive;
365 New_Item : Wide_Wide_String;
366 Drop : Truncation := Error);
368 function Super_Overwrite
369 (Source : Super_String;
370 Position : Positive;
371 New_Item : Wide_Wide_String;
372 Drop : Truncation := Error) return Super_String;
374 procedure Super_Overwrite
375 (Source : in out Super_String;
376 Position : Positive;
377 New_Item : Wide_Wide_String;
378 Drop : Truncation := Error);
380 function Super_Delete
381 (Source : Super_String;
382 From : Positive;
383 Through : Natural) return Super_String;
385 procedure Super_Delete
386 (Source : in out Super_String;
387 From : Positive;
388 Through : Natural);
390 ---------------------------------
391 -- String Selector Subprograms --
392 ---------------------------------
394 function Super_Trim
395 (Source : Super_String;
396 Side : Trim_End) return Super_String;
398 procedure Super_Trim
399 (Source : in out Super_String;
400 Side : Trim_End);
402 function Super_Trim
403 (Source : Super_String;
404 Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
405 Right : Wide_Wide_Maps.Wide_Wide_Character_Set) return Super_String;
407 procedure Super_Trim
408 (Source : in out Super_String;
409 Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
410 Right : Wide_Wide_Maps.Wide_Wide_Character_Set);
412 function Super_Head
413 (Source : Super_String;
414 Count : Natural;
415 Pad : Wide_Wide_Character := Wide_Wide_Space;
416 Drop : Truncation := Error) return Super_String;
418 procedure Super_Head
419 (Source : in out Super_String;
420 Count : Natural;
421 Pad : Wide_Wide_Character := Wide_Wide_Space;
422 Drop : Truncation := Error);
424 function Super_Tail
425 (Source : Super_String;
426 Count : Natural;
427 Pad : Wide_Wide_Character := Wide_Wide_Space;
428 Drop : Truncation := Error) return Super_String;
430 procedure Super_Tail
431 (Source : in out Super_String;
432 Count : Natural;
433 Pad : Wide_Wide_Character := Wide_Wide_Space;
434 Drop : Truncation := Error);
436 ------------------------------------
437 -- String Constructor Subprograms --
438 ------------------------------------
440 -- Note: in some of the following routines, there is an extra parameter
441 -- Max_Length which specifies the value of the maximum length for the
442 -- resulting Super_String value.
444 function Times
445 (Left : Natural;
446 Right : Wide_Wide_Character;
447 Max_Length : Positive) return Super_String;
448 -- Note the additional parameter Max_Length
450 function Times
451 (Left : Natural;
452 Right : Wide_Wide_String;
453 Max_Length : Positive) return Super_String;
454 -- Note the additional parameter Max_Length
456 function Times
457 (Left : Natural;
458 Right : Super_String) return Super_String;
460 function Super_Replicate
461 (Count : Natural;
462 Item : Wide_Wide_Character;
463 Drop : Truncation := Error;
464 Max_Length : Positive) return Super_String;
465 -- Note the additional parameter Max_Length
467 function Super_Replicate
468 (Count : Natural;
469 Item : Wide_Wide_String;
470 Drop : Truncation := Error;
471 Max_Length : Positive) return Super_String;
472 -- Note the additional parameter Max_Length
474 function Super_Replicate
475 (Count : Natural;
476 Item : Super_String;
477 Drop : Truncation := Error) return Super_String;
479 private
480 -- Pragma Inline declarations
482 pragma Inline ("=");
483 pragma Inline (Less);
484 pragma Inline (Less_Or_Equal);
485 pragma Inline (Greater);
486 pragma Inline (Greater_Or_Equal);
487 pragma Inline (Concat);
488 pragma Inline (Super_Count);
489 pragma Inline (Super_Element);
490 pragma Inline (Super_Find_Token);
491 pragma Inline (Super_Index);
492 pragma Inline (Super_Index_Non_Blank);
493 pragma Inline (Super_Length);
494 pragma Inline (Super_Replace_Element);
495 pragma Inline (Super_Slice);
496 pragma Inline (Super_To_String);
498 end Ada.Strings.Wide_Wide_Superbounded;