Merge from the pain train
[official-gcc.git] / gcc / ada / a-stwisu.ads
bloba9df6fa2547ae206ae045b9df2a4e36fef3b75ed
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-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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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_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_Bounded.Generic_Bounded_Length use this type with
40 -- an appropriate discriminant value set.
42 with Ada.Strings.Wide_Maps;
44 package Ada.Strings.Wide_Superbounded is
45 pragma Preelaborate (Wide_Superbounded);
47 Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
49 type Super_String (Max_Length : Positive) is record
50 Current_Length : Natural := 0;
51 Data : Wide_String (1 .. Max_Length) := (others => Wide_NUL);
52 end record;
53 -- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
54 -- derived from this type, with the constraint of the maximum length.
56 -- The subprograms defined for Super_String are similar to those defined
57 -- for Bounded_Wide_String, except that they have different names, so that
58 -- they can be renamed in Ada.Strings.Wide_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 : Wide_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.Wide_Bounded.
76 function Super_To_String (Source : Super_String) return Wide_String;
78 procedure Set_Super_String
79 (Target : out Super_String;
80 Source : Wide_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 : Wide_String;
91 Drop : Truncation := Error) return Super_String;
93 function Super_Append
94 (Left : Wide_String;
95 Right : Super_String;
96 Drop : Truncation := Error) return Super_String;
98 function Super_Append
99 (Left : Super_String;
100 Right : Wide_Character;
101 Drop : Truncation := Error) return Super_String;
103 function Super_Append
104 (Left : Wide_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 : Wide_String;
116 Drop : Truncation := Error);
118 procedure Super_Append
119 (Source : in out Super_String;
120 New_Item : Wide_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 : Wide_String) return Super_String;
131 function Concat
132 (Left : Wide_String;
133 Right : Super_String) return Super_String;
135 function Concat
136 (Left : Super_String;
137 Right : Wide_Character) return Super_String;
139 function Concat
140 (Left : Wide_Character;
141 Right : Super_String) return Super_String;
143 function Super_Element
144 (Source : Super_String;
145 Index : Positive) return Wide_Character;
147 procedure Super_Replace_Element
148 (Source : in out Super_String;
149 Index : Positive;
150 By : Wide_Character);
152 function Super_Slice
153 (Source : Super_String;
154 Low : Positive;
155 High : Natural) return Wide_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 : Wide_String) return Boolean;
180 function Equal
181 (Left : Wide_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 : Wide_String) return Boolean;
192 function Less
193 (Left : Wide_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 : Wide_String) return Boolean;
204 function Less_Or_Equal
205 (Left : Wide_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 : Wide_String) return Boolean;
216 function Greater
217 (Left : Wide_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 : Wide_String) return Boolean;
228 function Greater_Or_Equal
229 (Left : Wide_String;
230 Right : Super_String) return Boolean;
232 ----------------------
233 -- Search Functions --
234 ----------------------
236 function Super_Index
237 (Source : Super_String;
238 Pattern : Wide_String;
239 Going : Direction := Forward;
240 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
241 return Natural;
243 function Super_Index
244 (Source : Super_String;
245 Pattern : Wide_String;
246 Going : Direction := Forward;
247 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
249 function Super_Index
250 (Source : Super_String;
251 Set : Wide_Maps.Wide_Character_Set;
252 Test : Membership := Inside;
253 Going : Direction := Forward) return Natural;
255 function Super_Index
256 (Source : Super_String;
257 Pattern : Wide_String;
258 From : Positive;
259 Going : Direction := Forward;
260 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
261 return Natural;
263 function Super_Index
264 (Source : Super_String;
265 Pattern : Wide_String;
266 From : Positive;
267 Going : Direction := Forward;
268 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
270 function Super_Index
271 (Source : Super_String;
272 Set : Wide_Maps.Wide_Character_Set;
273 From : Positive;
274 Test : Membership := Inside;
275 Going : Direction := Forward) return Natural;
277 function Super_Index_Non_Blank
278 (Source : Super_String;
279 Going : Direction := Forward) return Natural;
281 function Super_Index_Non_Blank
282 (Source : Super_String;
283 From : Positive;
284 Going : Direction := Forward) return Natural;
286 function Super_Count
287 (Source : Super_String;
288 Pattern : Wide_String;
289 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
290 return Natural;
292 function Super_Count
293 (Source : Super_String;
294 Pattern : Wide_String;
295 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
297 function Super_Count
298 (Source : Super_String;
299 Set : Wide_Maps.Wide_Character_Set) return Natural;
301 procedure Super_Find_Token
302 (Source : Super_String;
303 Set : Wide_Maps.Wide_Character_Set;
304 Test : Membership;
305 First : out Positive;
306 Last : out Natural);
308 ------------------------------------
309 -- String Translation Subprograms --
310 ------------------------------------
312 function Super_Translate
313 (Source : Super_String;
314 Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
316 procedure Super_Translate
317 (Source : in out Super_String;
318 Mapping : Wide_Maps.Wide_Character_Mapping);
320 function Super_Translate
321 (Source : Super_String;
322 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
324 procedure Super_Translate
325 (Source : in out Super_String;
326 Mapping : Wide_Maps.Wide_Character_Mapping_Function);
328 ---------------------------------------
329 -- String Transformation Subprograms --
330 ---------------------------------------
332 function Super_Replace_Slice
333 (Source : Super_String;
334 Low : Positive;
335 High : Natural;
336 By : Wide_String;
337 Drop : Truncation := Error) return Super_String;
339 procedure Super_Replace_Slice
340 (Source : in out Super_String;
341 Low : Positive;
342 High : Natural;
343 By : Wide_String;
344 Drop : Truncation := Error);
346 function Super_Insert
347 (Source : Super_String;
348 Before : Positive;
349 New_Item : Wide_String;
350 Drop : Truncation := Error) return Super_String;
352 procedure Super_Insert
353 (Source : in out Super_String;
354 Before : Positive;
355 New_Item : Wide_String;
356 Drop : Truncation := Error);
358 function Super_Overwrite
359 (Source : Super_String;
360 Position : Positive;
361 New_Item : Wide_String;
362 Drop : Truncation := Error) return Super_String;
364 procedure Super_Overwrite
365 (Source : in out Super_String;
366 Position : Positive;
367 New_Item : Wide_String;
368 Drop : Truncation := Error);
370 function Super_Delete
371 (Source : Super_String;
372 From : Positive;
373 Through : Natural) return Super_String;
375 procedure Super_Delete
376 (Source : in out Super_String;
377 From : Positive;
378 Through : Natural);
380 ---------------------------------
381 -- String Selector Subprograms --
382 ---------------------------------
384 function Super_Trim
385 (Source : Super_String;
386 Side : Trim_End) return Super_String;
388 procedure Super_Trim
389 (Source : in out Super_String;
390 Side : Trim_End);
392 function Super_Trim
393 (Source : Super_String;
394 Left : Wide_Maps.Wide_Character_Set;
395 Right : Wide_Maps.Wide_Character_Set) return Super_String;
397 procedure Super_Trim
398 (Source : in out Super_String;
399 Left : Wide_Maps.Wide_Character_Set;
400 Right : Wide_Maps.Wide_Character_Set);
402 function Super_Head
403 (Source : Super_String;
404 Count : Natural;
405 Pad : Wide_Character := Wide_Space;
406 Drop : Truncation := Error) return Super_String;
408 procedure Super_Head
409 (Source : in out Super_String;
410 Count : Natural;
411 Pad : Wide_Character := Wide_Space;
412 Drop : Truncation := Error);
414 function Super_Tail
415 (Source : Super_String;
416 Count : Natural;
417 Pad : Wide_Character := Wide_Space;
418 Drop : Truncation := Error) return Super_String;
420 procedure Super_Tail
421 (Source : in out Super_String;
422 Count : Natural;
423 Pad : Wide_Character := Wide_Space;
424 Drop : Truncation := Error);
426 ------------------------------------
427 -- String Constructor Subprograms --
428 ------------------------------------
430 -- Note: in some of the following routines, there is an extra parameter
431 -- Max_Length which specifies the value of the maximum length for the
432 -- resulting Super_String value.
434 function Times
435 (Left : Natural;
436 Right : Wide_Character;
437 Max_Length : Positive) return Super_String;
438 -- Note the additional parameter Max_Length
440 function Times
441 (Left : Natural;
442 Right : Wide_String;
443 Max_Length : Positive) return Super_String;
444 -- Note the additional parameter Max_Length
446 function Times
447 (Left : Natural;
448 Right : Super_String) return Super_String;
450 function Super_Replicate
451 (Count : Natural;
452 Item : Wide_Character;
453 Drop : Truncation := Error;
454 Max_Length : Positive) return Super_String;
455 -- Note the additional parameter Max_Length
457 function Super_Replicate
458 (Count : Natural;
459 Item : Wide_String;
460 Drop : Truncation := Error;
461 Max_Length : Positive) return Super_String;
462 -- Note the additional parameter Max_Length
464 function Super_Replicate
465 (Count : Natural;
466 Item : Super_String;
467 Drop : Truncation := Error) return Super_String;
469 private
470 -- Pragma Inline declarations
472 pragma Inline ("=");
473 pragma Inline (Less);
474 pragma Inline (Less_Or_Equal);
475 pragma Inline (Greater);
476 pragma Inline (Greater_Or_Equal);
477 pragma Inline (Concat);
478 pragma Inline (Super_Count);
479 pragma Inline (Super_Element);
480 pragma Inline (Super_Find_Token);
481 pragma Inline (Super_Index);
482 pragma Inline (Super_Index_Non_Blank);
483 pragma Inline (Super_Length);
484 pragma Inline (Super_Replace_Element);
485 pragma Inline (Super_Slice);
486 pragma Inline (Super_To_String);
488 end Ada.Strings.Wide_Superbounded;