* config/bfin/bfin.c (effective_address_32bit_p): Return true for
[official-gcc/alias-decl.git] / gcc / ada / a-strbou.ads
blob089bb28888fc60ef648de557222bce371902ca76
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . B O U N D E D --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
10 -- --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
14 -- --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 2, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
25 -- --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
32 -- --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
35 -- --
36 ------------------------------------------------------------------------------
38 with Ada.Strings.Maps;
39 with Ada.Strings.Superbounded;
41 package Ada.Strings.Bounded is
42 pragma Preelaborate;
44 generic
45 Max : Positive;
46 -- Maximum length of a Bounded_String
48 package Generic_Bounded_Length is
50 Max_Length : constant Positive := Max;
52 type Bounded_String is private;
53 pragma Preelaborable_Initialization (Bounded_String);
55 Null_Bounded_String : constant Bounded_String;
57 subtype Length_Range is Natural range 0 .. Max_Length;
59 function Length (Source : Bounded_String) return Length_Range;
61 --------------------------------------------------------
62 -- Conversion, Concatenation, and Selection Functions --
63 --------------------------------------------------------
65 function To_Bounded_String
66 (Source : String;
67 Drop : Truncation := Error) return Bounded_String;
69 function To_String (Source : Bounded_String) return String;
71 procedure Set_Bounded_String
72 (Target : out Bounded_String;
73 Source : String;
74 Drop : Truncation := Error);
75 pragma Ada_05 (Set_Bounded_String);
77 function Append
78 (Left : Bounded_String;
79 Right : Bounded_String;
80 Drop : Truncation := Error) return Bounded_String;
82 function Append
83 (Left : Bounded_String;
84 Right : String;
85 Drop : Truncation := Error) return Bounded_String;
87 function Append
88 (Left : String;
89 Right : Bounded_String;
90 Drop : Truncation := Error) return Bounded_String;
92 function Append
93 (Left : Bounded_String;
94 Right : Character;
95 Drop : Truncation := Error) return Bounded_String;
97 function Append
98 (Left : Character;
99 Right : Bounded_String;
100 Drop : Truncation := Error) return Bounded_String;
102 procedure Append
103 (Source : in out Bounded_String;
104 New_Item : Bounded_String;
105 Drop : Truncation := Error);
107 procedure Append
108 (Source : in out Bounded_String;
109 New_Item : String;
110 Drop : Truncation := Error);
112 procedure Append
113 (Source : in out Bounded_String;
114 New_Item : Character;
115 Drop : Truncation := Error);
117 function "&"
118 (Left : Bounded_String;
119 Right : Bounded_String) return Bounded_String;
121 function "&"
122 (Left : Bounded_String;
123 Right : String) return Bounded_String;
125 function "&"
126 (Left : String;
127 Right : Bounded_String) return Bounded_String;
129 function "&"
130 (Left : Bounded_String;
131 Right : Character) return Bounded_String;
133 function "&"
134 (Left : Character;
135 Right : Bounded_String) return Bounded_String;
137 function Element
138 (Source : Bounded_String;
139 Index : Positive) return Character;
141 procedure Replace_Element
142 (Source : in out Bounded_String;
143 Index : Positive;
144 By : Character);
146 function Slice
147 (Source : Bounded_String;
148 Low : Positive;
149 High : Natural) return String;
151 function Bounded_Slice
152 (Source : Bounded_String;
153 Low : Positive;
154 High : Natural) return Bounded_String;
155 pragma Ada_05 (Bounded_Slice);
157 procedure Bounded_Slice
158 (Source : Bounded_String;
159 Target : out Bounded_String;
160 Low : Positive;
161 High : Natural);
162 pragma Ada_05 (Bounded_Slice);
164 function "="
165 (Left : Bounded_String;
166 Right : Bounded_String) return Boolean;
168 function "="
169 (Left : Bounded_String;
170 Right : String) return Boolean;
172 function "="
173 (Left : String;
174 Right : Bounded_String) return Boolean;
176 function "<"
177 (Left : Bounded_String;
178 Right : Bounded_String) return Boolean;
180 function "<"
181 (Left : Bounded_String;
182 Right : String) return Boolean;
184 function "<"
185 (Left : String;
186 Right : Bounded_String) return Boolean;
188 function "<="
189 (Left : Bounded_String;
190 Right : Bounded_String) return Boolean;
192 function "<="
193 (Left : Bounded_String;
194 Right : String) return Boolean;
196 function "<="
197 (Left : String;
198 Right : Bounded_String) return Boolean;
200 function ">"
201 (Left : Bounded_String;
202 Right : Bounded_String) return Boolean;
204 function ">"
205 (Left : Bounded_String;
206 Right : String) return Boolean;
208 function ">"
209 (Left : String;
210 Right : Bounded_String) return Boolean;
212 function ">="
213 (Left : Bounded_String;
214 Right : Bounded_String) return Boolean;
216 function ">="
217 (Left : Bounded_String;
218 Right : String) return Boolean;
220 function ">="
221 (Left : String;
222 Right : Bounded_String) return Boolean;
224 ----------------------
225 -- Search Functions --
226 ----------------------
228 function Index
229 (Source : Bounded_String;
230 Pattern : String;
231 Going : Direction := Forward;
232 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
234 function Index
235 (Source : Bounded_String;
236 Pattern : String;
237 Going : Direction := Forward;
238 Mapping : Maps.Character_Mapping_Function) return Natural;
240 function Index
241 (Source : Bounded_String;
242 Set : Maps.Character_Set;
243 Test : Membership := Inside;
244 Going : Direction := Forward) return Natural;
246 function Index
247 (Source : Bounded_String;
248 Pattern : String;
249 From : Positive;
250 Going : Direction := Forward;
251 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
252 pragma Ada_05 (Index);
254 function Index
255 (Source : Bounded_String;
256 Pattern : String;
257 From : Positive;
258 Going : Direction := Forward;
259 Mapping : Maps.Character_Mapping_Function) return Natural;
260 pragma Ada_05 (Index);
262 function Index
263 (Source : Bounded_String;
264 Set : Maps.Character_Set;
265 From : Positive;
266 Test : Membership := Inside;
267 Going : Direction := Forward) return Natural;
268 pragma Ada_05 (Index);
270 function Index_Non_Blank
271 (Source : Bounded_String;
272 Going : Direction := Forward) return Natural;
274 function Index_Non_Blank
275 (Source : Bounded_String;
276 From : Positive;
277 Going : Direction := Forward) return Natural;
278 pragma Ada_05 (Index_Non_Blank);
280 function Count
281 (Source : Bounded_String;
282 Pattern : String;
283 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
285 function Count
286 (Source : Bounded_String;
287 Pattern : String;
288 Mapping : Maps.Character_Mapping_Function) return Natural;
290 function Count
291 (Source : Bounded_String;
292 Set : Maps.Character_Set) return Natural;
294 procedure Find_Token
295 (Source : Bounded_String;
296 Set : Maps.Character_Set;
297 Test : Membership;
298 First : out Positive;
299 Last : out Natural);
301 ------------------------------------
302 -- String Translation Subprograms --
303 ------------------------------------
305 function Translate
306 (Source : Bounded_String;
307 Mapping : Maps.Character_Mapping) return Bounded_String;
309 procedure Translate
310 (Source : in out Bounded_String;
311 Mapping : Maps.Character_Mapping);
313 function Translate
314 (Source : Bounded_String;
315 Mapping : Maps.Character_Mapping_Function) return Bounded_String;
317 procedure Translate
318 (Source : in out Bounded_String;
319 Mapping : Maps.Character_Mapping_Function);
321 ---------------------------------------
322 -- String Transformation Subprograms --
323 ---------------------------------------
325 function Replace_Slice
326 (Source : Bounded_String;
327 Low : Positive;
328 High : Natural;
329 By : String;
330 Drop : Truncation := Error) return Bounded_String;
332 procedure Replace_Slice
333 (Source : in out Bounded_String;
334 Low : Positive;
335 High : Natural;
336 By : String;
337 Drop : Truncation := Error);
339 function Insert
340 (Source : Bounded_String;
341 Before : Positive;
342 New_Item : String;
343 Drop : Truncation := Error) return Bounded_String;
345 procedure Insert
346 (Source : in out Bounded_String;
347 Before : Positive;
348 New_Item : String;
349 Drop : Truncation := Error);
351 function Overwrite
352 (Source : Bounded_String;
353 Position : Positive;
354 New_Item : String;
355 Drop : Truncation := Error) return Bounded_String;
357 procedure Overwrite
358 (Source : in out Bounded_String;
359 Position : Positive;
360 New_Item : String;
361 Drop : Truncation := Error);
363 function Delete
364 (Source : Bounded_String;
365 From : Positive;
366 Through : Natural) return Bounded_String;
368 procedure Delete
369 (Source : in out Bounded_String;
370 From : Positive;
371 Through : Natural);
373 ---------------------------------
374 -- String Selector Subprograms --
375 ---------------------------------
377 function Trim
378 (Source : Bounded_String;
379 Side : Trim_End) return Bounded_String;
381 procedure Trim
382 (Source : in out Bounded_String;
383 Side : Trim_End);
385 function Trim
386 (Source : Bounded_String;
387 Left : Maps.Character_Set;
388 Right : Maps.Character_Set) return Bounded_String;
390 procedure Trim
391 (Source : in out Bounded_String;
392 Left : Maps.Character_Set;
393 Right : Maps.Character_Set);
395 function Head
396 (Source : Bounded_String;
397 Count : Natural;
398 Pad : Character := Space;
399 Drop : Truncation := Error) return Bounded_String;
401 procedure Head
402 (Source : in out Bounded_String;
403 Count : Natural;
404 Pad : Character := Space;
405 Drop : Truncation := Error);
407 function Tail
408 (Source : Bounded_String;
409 Count : Natural;
410 Pad : Character := Space;
411 Drop : Truncation := Error) return Bounded_String;
413 procedure Tail
414 (Source : in out Bounded_String;
415 Count : Natural;
416 Pad : Character := Space;
417 Drop : Truncation := Error);
419 ------------------------------------
420 -- String Constructor Subprograms --
421 ------------------------------------
423 function "*"
424 (Left : Natural;
425 Right : Character) return Bounded_String;
427 function "*"
428 (Left : Natural;
429 Right : String) return Bounded_String;
431 function "*"
432 (Left : Natural;
433 Right : Bounded_String) return Bounded_String;
435 function Replicate
436 (Count : Natural;
437 Item : Character;
438 Drop : Truncation := Error) return Bounded_String;
440 function Replicate
441 (Count : Natural;
442 Item : String;
443 Drop : Truncation := Error) return Bounded_String;
445 function Replicate
446 (Count : Natural;
447 Item : Bounded_String;
448 Drop : Truncation := Error) return Bounded_String;
450 private
451 -- Most of the implementation is in the separate non generic package
452 -- Ada.Strings.Superbounded. Type Bounded_String is derived from type
453 -- Superbounded.Super_String with the maximum length constraint. In
454 -- almost all cases, the routines in Superbounded can be called with
455 -- no requirement to pass the maximum length explicitly, since there
456 -- is at least one Bounded_String argument from which the maximum
457 -- length can be obtained. For all such routines, the implementation
458 -- in this private part is simply a renaming of the corresponding
459 -- routine in the super bouded package.
461 -- The five exceptions are the * and Replicate routines operating on
462 -- character values. For these cases, we have a routine in the body
463 -- that calls the superbounded routine passing the maximum length
464 -- explicitly as an extra parameter.
466 type Bounded_String is new Superbounded.Super_String (Max_Length);
467 -- Deriving Bounded_String from Superbounded.Super_String is the
468 -- real trick, it ensures that the type Bounded_String declared in
469 -- the generic instantiation is compatible with the Super_String
470 -- type declared in the Superbounded package.
472 Null_Bounded_String : constant Bounded_String :=
473 (Max_Length => Max_Length,
474 Current_Length => 0,
475 Data =>
476 (1 .. Max_Length => ASCII.NUL));
478 pragma Inline (To_Bounded_String);
480 procedure Set_Bounded_String
481 (Target : out Bounded_String;
482 Source : String;
483 Drop : Truncation := Error)
484 renames Set_Super_String;
486 function Length
487 (Source : Bounded_String) return Length_Range
488 renames Super_Length;
490 function To_String
491 (Source : Bounded_String) return String
492 renames Super_To_String;
494 function Append
495 (Left : Bounded_String;
496 Right : Bounded_String;
497 Drop : Truncation := Error) return Bounded_String
498 renames Super_Append;
500 function Append
501 (Left : Bounded_String;
502 Right : String;
503 Drop : Truncation := Error) return Bounded_String
504 renames Super_Append;
506 function Append
507 (Left : String;
508 Right : Bounded_String;
509 Drop : Truncation := Error) return Bounded_String
510 renames Super_Append;
512 function Append
513 (Left : Bounded_String;
514 Right : Character;
515 Drop : Truncation := Error) return Bounded_String
516 renames Super_Append;
518 function Append
519 (Left : Character;
520 Right : Bounded_String;
521 Drop : Truncation := Error) return Bounded_String
522 renames Super_Append;
524 procedure Append
525 (Source : in out Bounded_String;
526 New_Item : Bounded_String;
527 Drop : Truncation := Error)
528 renames Super_Append;
530 procedure Append
531 (Source : in out Bounded_String;
532 New_Item : String;
533 Drop : Truncation := Error)
534 renames Super_Append;
536 procedure Append
537 (Source : in out Bounded_String;
538 New_Item : Character;
539 Drop : Truncation := Error)
540 renames Super_Append;
542 function "&"
543 (Left : Bounded_String;
544 Right : Bounded_String) return Bounded_String
545 renames Concat;
547 function "&"
548 (Left : Bounded_String;
549 Right : String) return Bounded_String
550 renames Concat;
552 function "&"
553 (Left : String;
554 Right : Bounded_String) return Bounded_String
555 renames Concat;
557 function "&"
558 (Left : Bounded_String;
559 Right : Character) return Bounded_String
560 renames Concat;
562 function "&"
563 (Left : Character;
564 Right : Bounded_String) return Bounded_String
565 renames Concat;
567 function Element
568 (Source : Bounded_String;
569 Index : Positive) return Character
570 renames Super_Element;
572 procedure Replace_Element
573 (Source : in out Bounded_String;
574 Index : Positive;
575 By : Character)
576 renames Super_Replace_Element;
578 function Slice
579 (Source : Bounded_String;
580 Low : Positive;
581 High : Natural) return String
582 renames Super_Slice;
584 function Bounded_Slice
585 (Source : Bounded_String;
586 Low : Positive;
587 High : Natural) return Bounded_String
588 renames Super_Slice;
590 procedure Bounded_Slice
591 (Source : Bounded_String;
592 Target : out Bounded_String;
593 Low : Positive;
594 High : Natural)
595 renames Super_Slice;
597 function "="
598 (Left : Bounded_String;
599 Right : Bounded_String) return Boolean
600 renames Equal;
602 function "="
603 (Left : Bounded_String;
604 Right : String) return Boolean
605 renames Equal;
607 function "="
608 (Left : String;
609 Right : Bounded_String) return Boolean
610 renames Equal;
612 function "<"
613 (Left : Bounded_String;
614 Right : Bounded_String) return Boolean
615 renames Less;
617 function "<"
618 (Left : Bounded_String;
619 Right : String) return Boolean
620 renames Less;
622 function "<"
623 (Left : String;
624 Right : Bounded_String) return Boolean
625 renames Less;
627 function "<="
628 (Left : Bounded_String;
629 Right : Bounded_String) return Boolean
630 renames Less_Or_Equal;
632 function "<="
633 (Left : Bounded_String;
634 Right : String) return Boolean
635 renames Less_Or_Equal;
637 function "<="
638 (Left : String;
639 Right : Bounded_String) return Boolean
640 renames Less_Or_Equal;
642 function ">"
643 (Left : Bounded_String;
644 Right : Bounded_String) return Boolean
645 renames Greater;
647 function ">"
648 (Left : Bounded_String;
649 Right : String) return Boolean
650 renames Greater;
652 function ">"
653 (Left : String;
654 Right : Bounded_String) return Boolean
655 renames Greater;
657 function ">="
658 (Left : Bounded_String;
659 Right : Bounded_String) return Boolean
660 renames Greater_Or_Equal;
662 function ">="
663 (Left : Bounded_String;
664 Right : String) return Boolean
665 renames Greater_Or_Equal;
667 function ">="
668 (Left : String;
669 Right : Bounded_String) return Boolean
670 renames Greater_Or_Equal;
672 function Index
673 (Source : Bounded_String;
674 Pattern : String;
675 Going : Direction := Forward;
676 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural
677 renames Super_Index;
679 function Index
680 (Source : Bounded_String;
681 Pattern : String;
682 Going : Direction := Forward;
683 Mapping : Maps.Character_Mapping_Function) return Natural
684 renames Super_Index;
686 function Index
687 (Source : Bounded_String;
688 Set : Maps.Character_Set;
689 Test : Membership := Inside;
690 Going : Direction := Forward) return Natural
691 renames Super_Index;
693 function Index
694 (Source : Bounded_String;
695 Pattern : String;
696 From : Positive;
697 Going : Direction := Forward;
698 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural
699 renames Super_Index;
701 function Index
702 (Source : Bounded_String;
703 Pattern : String;
704 From : Positive;
705 Going : Direction := Forward;
706 Mapping : Maps.Character_Mapping_Function) return Natural
707 renames Super_Index;
709 function Index
710 (Source : Bounded_String;
711 Set : Maps.Character_Set;
712 From : Positive;
713 Test : Membership := Inside;
714 Going : Direction := Forward) return Natural
715 renames Super_Index;
717 function Index_Non_Blank
718 (Source : Bounded_String;
719 Going : Direction := Forward) return Natural
720 renames Super_Index_Non_Blank;
722 function Index_Non_Blank
723 (Source : Bounded_String;
724 From : Positive;
725 Going : Direction := Forward) return Natural
726 renames Super_Index_Non_Blank;
728 function Count
729 (Source : Bounded_String;
730 Pattern : String;
731 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural
732 renames Super_Count;
734 function Count
735 (Source : Bounded_String;
736 Pattern : String;
737 Mapping : Maps.Character_Mapping_Function) return Natural
738 renames Super_Count;
740 function Count
741 (Source : Bounded_String;
742 Set : Maps.Character_Set) return Natural
743 renames Super_Count;
745 procedure Find_Token
746 (Source : Bounded_String;
747 Set : Maps.Character_Set;
748 Test : Membership;
749 First : out Positive;
750 Last : out Natural)
751 renames Super_Find_Token;
753 function Translate
754 (Source : Bounded_String;
755 Mapping : Maps.Character_Mapping) return Bounded_String
756 renames Super_Translate;
758 procedure Translate
759 (Source : in out Bounded_String;
760 Mapping : Maps.Character_Mapping)
761 renames Super_Translate;
763 function Translate
764 (Source : Bounded_String;
765 Mapping : Maps.Character_Mapping_Function) return Bounded_String
766 renames Super_Translate;
768 procedure Translate
769 (Source : in out Bounded_String;
770 Mapping : Maps.Character_Mapping_Function)
771 renames Super_Translate;
773 function Replace_Slice
774 (Source : Bounded_String;
775 Low : Positive;
776 High : Natural;
777 By : String;
778 Drop : Truncation := Error) return Bounded_String
779 renames Super_Replace_Slice;
781 procedure Replace_Slice
782 (Source : in out Bounded_String;
783 Low : Positive;
784 High : Natural;
785 By : String;
786 Drop : Truncation := Error)
787 renames Super_Replace_Slice;
789 function Insert
790 (Source : Bounded_String;
791 Before : Positive;
792 New_Item : String;
793 Drop : Truncation := Error) return Bounded_String
794 renames Super_Insert;
796 procedure Insert
797 (Source : in out Bounded_String;
798 Before : Positive;
799 New_Item : String;
800 Drop : Truncation := Error)
801 renames Super_Insert;
803 function Overwrite
804 (Source : Bounded_String;
805 Position : Positive;
806 New_Item : String;
807 Drop : Truncation := Error) return Bounded_String
808 renames Super_Overwrite;
810 procedure Overwrite
811 (Source : in out Bounded_String;
812 Position : Positive;
813 New_Item : String;
814 Drop : Truncation := Error)
815 renames Super_Overwrite;
817 function Delete
818 (Source : Bounded_String;
819 From : Positive;
820 Through : Natural) return Bounded_String
821 renames Super_Delete;
823 procedure Delete
824 (Source : in out Bounded_String;
825 From : Positive;
826 Through : Natural)
827 renames Super_Delete;
829 function Trim
830 (Source : Bounded_String;
831 Side : Trim_End) return Bounded_String
832 renames Super_Trim;
834 procedure Trim
835 (Source : in out Bounded_String;
836 Side : Trim_End)
837 renames Super_Trim;
839 function Trim
840 (Source : Bounded_String;
841 Left : Maps.Character_Set;
842 Right : Maps.Character_Set) return Bounded_String
843 renames Super_Trim;
845 procedure Trim
846 (Source : in out Bounded_String;
847 Left : Maps.Character_Set;
848 Right : Maps.Character_Set)
849 renames Super_Trim;
851 function Head
852 (Source : Bounded_String;
853 Count : Natural;
854 Pad : Character := Space;
855 Drop : Truncation := Error) return Bounded_String
856 renames Super_Head;
858 procedure Head
859 (Source : in out Bounded_String;
860 Count : Natural;
861 Pad : Character := Space;
862 Drop : Truncation := Error)
863 renames Super_Head;
865 function Tail
866 (Source : Bounded_String;
867 Count : Natural;
868 Pad : Character := Space;
869 Drop : Truncation := Error) return Bounded_String
870 renames Super_Tail;
872 procedure Tail
873 (Source : in out Bounded_String;
874 Count : Natural;
875 Pad : Character := Space;
876 Drop : Truncation := Error)
877 renames Super_Tail;
879 function "*"
880 (Left : Natural;
881 Right : Bounded_String) return Bounded_String
882 renames Times;
884 function Replicate
885 (Count : Natural;
886 Item : Bounded_String;
887 Drop : Truncation := Error) return Bounded_String
888 renames Super_Replicate;
890 end Generic_Bounded_Length;
892 end Ada.Strings.Bounded;