]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/a-strbou.ads
3psoccon.ads, [...]: Files added.
[thirdparty/gcc.git] / gcc / ada / a-strbou.ads
CommitLineData
d23b8f57
RK
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-- --
fbf5a39b 9-- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
d23b8f57
RK
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, 59 Temple Place - Suite 330, Boston, --
24-- MA 02111-1307, 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. --
71ff80dc 34-- Extensive contributions were provided by Ada Core Technologies Inc. --
d23b8f57
RK
35-- --
36------------------------------------------------------------------------------
37
38with Ada.Strings.Maps;
fbf5a39b 39with Ada.Strings.Superbounded;
d23b8f57
RK
40
41package Ada.Strings.Bounded is
42pragma Preelaborate (Bounded);
43
44 generic
45 Max : Positive;
46 -- Maximum length of a Bounded_String
47
48 package Generic_Bounded_Length is
49
50 Max_Length : constant Positive := Max;
51
52 type Bounded_String is private;
53
54 Null_Bounded_String : constant Bounded_String;
55
56 subtype Length_Range is Natural range 0 .. Max_Length;
57
58 function Length (Source : in Bounded_String) return Length_Range;
59
60 --------------------------------------------------------
61 -- Conversion, Concatenation, and Selection Functions --
62 --------------------------------------------------------
63
64 function To_Bounded_String
65 (Source : in String;
66 Drop : in Truncation := Error)
67 return Bounded_String;
68
69 function To_String (Source : in Bounded_String) return String;
70
71 function Append
72 (Left, Right : in Bounded_String;
73 Drop : in Truncation := Error)
74 return Bounded_String;
75
76 function Append
77 (Left : in Bounded_String;
78 Right : in String;
79 Drop : in Truncation := Error)
80 return Bounded_String;
81
82 function Append
83 (Left : in String;
84 Right : in Bounded_String;
85 Drop : in Truncation := Error)
86 return Bounded_String;
87
88 function Append
89 (Left : in Bounded_String;
90 Right : in Character;
91 Drop : in Truncation := Error)
92 return Bounded_String;
93
94 function Append
95 (Left : in Character;
96 Right : in Bounded_String;
97 Drop : in Truncation := Error)
98 return Bounded_String;
99
100 procedure Append
101 (Source : in out Bounded_String;
102 New_Item : in Bounded_String;
103 Drop : in Truncation := Error);
104
105 procedure Append
106 (Source : in out Bounded_String;
107 New_Item : in String;
108 Drop : in Truncation := Error);
109
110 procedure Append
111 (Source : in out Bounded_String;
112 New_Item : in Character;
113 Drop : in Truncation := Error);
114
115 function "&"
116 (Left, Right : in Bounded_String)
117 return Bounded_String;
118
119 function "&"
120 (Left : in Bounded_String;
121 Right : in String)
122 return Bounded_String;
123
124 function "&"
125 (Left : in String;
126 Right : in Bounded_String)
127 return Bounded_String;
128
129 function "&"
130 (Left : in Bounded_String;
131 Right : in Character)
132 return Bounded_String;
133
134 function "&"
135 (Left : in Character;
136 Right : in Bounded_String)
137 return Bounded_String;
138
139 function Element
140 (Source : in Bounded_String;
141 Index : in Positive)
142 return Character;
143
144 procedure Replace_Element
145 (Source : in out Bounded_String;
146 Index : in Positive;
147 By : in Character);
148
149 function Slice
150 (Source : in Bounded_String;
151 Low : in Positive;
152 High : in Natural)
153 return String;
154
155 function "=" (Left, Right : in Bounded_String) return Boolean;
156
157 function "="
158 (Left : in Bounded_String;
159 Right : in String)
160 return Boolean;
161
162 function "="
163 (Left : in String;
164 Right : in Bounded_String)
165 return Boolean;
166
167 function "<" (Left, Right : in Bounded_String) return Boolean;
168
169 function "<"
170 (Left : in Bounded_String;
171 Right : in String)
172 return Boolean;
173
174 function "<"
175 (Left : in String;
176 Right : in Bounded_String)
177 return Boolean;
178
179 function "<=" (Left, Right : in Bounded_String) return Boolean;
180
181 function "<="
182 (Left : in Bounded_String;
183 Right : in String)
184 return Boolean;
185
186 function "<="
187 (Left : in String;
188 Right : in Bounded_String)
189 return Boolean;
190
191 function ">" (Left, Right : in Bounded_String) return Boolean;
192
193 function ">"
194 (Left : in Bounded_String;
195 Right : in String)
196 return Boolean;
197
198 function ">"
199 (Left : in String;
200 Right : in Bounded_String)
201 return Boolean;
202
203 function ">=" (Left, Right : in Bounded_String) return Boolean;
204
205 function ">="
206 (Left : in Bounded_String;
207 Right : in String)
208 return Boolean;
209
210 function ">="
211 (Left : in String;
212 Right : in Bounded_String)
213 return Boolean;
214
215 ----------------------
216 -- Search Functions --
217 ----------------------
218
219 function Index
220 (Source : in Bounded_String;
221 Pattern : in String;
222 Going : in Direction := Forward;
223 Mapping : in Maps.Character_Mapping := Maps.Identity)
224 return Natural;
225
226 function Index
227 (Source : in Bounded_String;
228 Pattern : in String;
229 Going : in Direction := Forward;
230 Mapping : in Maps.Character_Mapping_Function)
231 return Natural;
232
233 function Index
234 (Source : in Bounded_String;
235 Set : in Maps.Character_Set;
236 Test : in Membership := Inside;
237 Going : in Direction := Forward)
238 return Natural;
239
240 function Index_Non_Blank
241 (Source : in Bounded_String;
242 Going : in Direction := Forward)
243 return Natural;
244
245 function Count
246 (Source : in Bounded_String;
247 Pattern : in String;
248 Mapping : in Maps.Character_Mapping := Maps.Identity)
249 return Natural;
250
251 function Count
252 (Source : in Bounded_String;
253 Pattern : in String;
254 Mapping : in Maps.Character_Mapping_Function)
255 return Natural;
256
257 function Count
258 (Source : in Bounded_String;
259 Set : in Maps.Character_Set)
260 return Natural;
261
262 procedure Find_Token
263 (Source : in Bounded_String;
264 Set : in Maps.Character_Set;
265 Test : in Membership;
266 First : out Positive;
267 Last : out Natural);
268
269 ------------------------------------
270 -- String Translation Subprograms --
271 ------------------------------------
272
273 function Translate
274 (Source : in Bounded_String;
275 Mapping : in Maps.Character_Mapping)
276 return Bounded_String;
277
278 procedure Translate
279 (Source : in out Bounded_String;
280 Mapping : in Maps.Character_Mapping);
281
282 function Translate
283 (Source : in Bounded_String;
284 Mapping : in Maps.Character_Mapping_Function)
285 return Bounded_String;
286
287 procedure Translate
288 (Source : in out Bounded_String;
289 Mapping : in Maps.Character_Mapping_Function);
290
291 ---------------------------------------
292 -- String Transformation Subprograms --
293 ---------------------------------------
294
295 function Replace_Slice
296 (Source : in Bounded_String;
297 Low : in Positive;
298 High : in Natural;
299 By : in String;
300 Drop : in Truncation := Error)
301 return Bounded_String;
302
303 procedure Replace_Slice
304 (Source : in out Bounded_String;
305 Low : in Positive;
306 High : in Natural;
307 By : in String;
308 Drop : in Truncation := Error);
309
310 function Insert
311 (Source : in Bounded_String;
312 Before : in Positive;
313 New_Item : in String;
314 Drop : in Truncation := Error)
315 return Bounded_String;
316
317 procedure Insert
318 (Source : in out Bounded_String;
319 Before : in Positive;
320 New_Item : in String;
321 Drop : in Truncation := Error);
322
323 function Overwrite
324 (Source : in Bounded_String;
325 Position : in Positive;
326 New_Item : in String;
327 Drop : in Truncation := Error)
328 return Bounded_String;
329
330 procedure Overwrite
331 (Source : in out Bounded_String;
332 Position : in Positive;
333 New_Item : in String;
334 Drop : in Truncation := Error);
335
336 function Delete
337 (Source : in Bounded_String;
338 From : in Positive;
339 Through : in Natural)
340 return Bounded_String;
341
342 procedure Delete
343 (Source : in out Bounded_String;
344 From : in Positive;
345 Through : in Natural);
346
347 ---------------------------------
348 -- String Selector Subprograms --
349 ---------------------------------
350
351 function Trim
352 (Source : in Bounded_String;
353 Side : in Trim_End)
354 return Bounded_String;
355
356 procedure Trim
357 (Source : in out Bounded_String;
358 Side : in Trim_End);
359
360 function Trim
361 (Source : in Bounded_String;
362 Left : in Maps.Character_Set;
363 Right : in Maps.Character_Set)
364 return Bounded_String;
365
366 procedure Trim
367 (Source : in out Bounded_String;
368 Left : in Maps.Character_Set;
369 Right : in Maps.Character_Set);
370
371 function Head
372 (Source : in Bounded_String;
373 Count : in Natural;
374 Pad : in Character := Space;
375 Drop : in Truncation := Error)
376 return Bounded_String;
377
378 procedure Head
379 (Source : in out Bounded_String;
380 Count : in Natural;
381 Pad : in Character := Space;
382 Drop : in Truncation := Error);
383
384 function Tail
385 (Source : in Bounded_String;
386 Count : in Natural;
387 Pad : in Character := Space;
388 Drop : in Truncation := Error)
389 return Bounded_String;
390
391 procedure Tail
392 (Source : in out Bounded_String;
393 Count : in Natural;
394 Pad : in Character := Space;
395 Drop : in Truncation := Error);
396
397 ------------------------------------
398 -- String Constructor Subprograms --
399 ------------------------------------
400
401 function "*"
402 (Left : in Natural;
403 Right : in Character)
404 return Bounded_String;
405
406 function "*"
407 (Left : in Natural;
408 Right : in String)
409 return Bounded_String;
410
411 function "*"
412 (Left : in Natural;
413 Right : in Bounded_String)
414 return Bounded_String;
415
416 function Replicate
417 (Count : in Natural;
418 Item : in Character;
419 Drop : in Truncation := Error)
420 return Bounded_String;
421
422 function Replicate
423 (Count : in Natural;
424 Item : in String;
425 Drop : in Truncation := Error)
426 return Bounded_String;
427
428 function Replicate
429 (Count : in Natural;
430 Item : in Bounded_String;
431 Drop : in Truncation := Error)
432 return Bounded_String;
433
434 private
435
fbf5a39b
AC
436 -- Most of the implementation is in the non generic package
437 -- Ada.Strings.Superbounded. Type Bounded_String is derived from type
438 -- Superbounded.Super_String with the maximum length constraint.
439 -- Except for five, all subprograms are renames of subprograms that
440 -- are inherited from Superbounded.Super_String.
441
442 type Bounded_String is new Superbounded.Super_String (Max_Length);
d23b8f57
RK
443
444 Null_Bounded_String : constant Bounded_String :=
fbf5a39b
AC
445 (Max_Length => Max_Length,
446 Current_Length => 0,
447 Data => (1 .. Max_Length => ASCII.NUL));
448
d23b8f57 449 pragma Inline (To_Bounded_String);
fbf5a39b
AC
450
451 function Length (Source : in Bounded_String) return Length_Range
452 renames Super_Length;
453
454 function To_String (Source : in Bounded_String) return String
455 renames Super_To_String;
456
457 function Append
458 (Left, Right : in Bounded_String;
459 Drop : in Truncation := Error)
460 return Bounded_String
461 renames Super_Append;
462
463 function Append
464 (Left : in Bounded_String;
465 Right : in String;
466 Drop : in Truncation := Error)
467 return Bounded_String
468 renames Super_Append;
469
470 function Append
471 (Left : in String;
472 Right : in Bounded_String;
473 Drop : in Truncation := Error)
474 return Bounded_String
475 renames Super_Append;
476
477 function Append
478 (Left : in Bounded_String;
479 Right : in Character;
480 Drop : in Truncation := Error)
481 return Bounded_String
482 renames Super_Append;
483
484 function Append
485 (Left : in Character;
486 Right : in Bounded_String;
487 Drop : in Truncation := Error)
488 return Bounded_String
489 renames Super_Append;
490
491 procedure Append
492 (Source : in out Bounded_String;
493 New_Item : in Bounded_String;
494 Drop : in Truncation := Error)
495 renames Super_Append;
496
497 procedure Append
498 (Source : in out Bounded_String;
499 New_Item : in String;
500 Drop : in Truncation := Error)
501 renames Super_Append;
502
503 procedure Append
504 (Source : in out Bounded_String;
505 New_Item : in Character;
506 Drop : in Truncation := Error)
507 renames Super_Append;
508
509 function "&"
510 (Left, Right : in Bounded_String)
511 return Bounded_String
512 renames Concat;
513
514 function "&"
515 (Left : in Bounded_String;
516 Right : in String)
517 return Bounded_String
518 renames Concat;
519
520 function "&"
521 (Left : in String;
522 Right : in Bounded_String)
523 return Bounded_String
524 renames Concat;
525
526 function "&"
527 (Left : in Bounded_String;
528 Right : in Character)
529 return Bounded_String
530 renames Concat;
531
532 function "&"
533 (Left : in Character;
534 Right : in Bounded_String)
535 return Bounded_String
536 renames Concat;
537
538 function Element
539 (Source : in Bounded_String;
540 Index : in Positive)
541 return Character
542 renames Super_Element;
543
544 procedure Replace_Element
545 (Source : in out Bounded_String;
546 Index : in Positive;
547 By : in Character)
548 renames Super_Replace_Element;
549
550 function Slice
551 (Source : in Bounded_String;
552 Low : in Positive;
553 High : in Natural)
554 return String
555 renames Super_Slice;
556
557 function "=" (Left, Right : in Bounded_String) return Boolean
558 renames Equal;
559
560 function "="
561 (Left : in Bounded_String;
562 Right : in String)
563 return Boolean
564 renames Equal;
565
566 function "="
567 (Left : in String;
568 Right : in Bounded_String)
569 return Boolean
570 renames Equal;
571
572 function "<" (Left, Right : in Bounded_String) return Boolean
573 renames Less;
574
575 function "<"
576 (Left : in Bounded_String;
577 Right : in String)
578 return Boolean
579 renames Less;
580
581 function "<"
582 (Left : in String;
583 Right : in Bounded_String)
584 return Boolean
585 renames Less;
586
587 function "<=" (Left, Right : in Bounded_String) return Boolean
588 renames Less_Or_Equal;
589
590 function "<="
591 (Left : in Bounded_String;
592 Right : in String)
593 return Boolean
594 renames Less_Or_Equal;
595
596 function "<="
597 (Left : in String;
598 Right : in Bounded_String)
599 return Boolean
600 renames Less_Or_Equal;
601
602 function ">" (Left, Right : in Bounded_String) return Boolean
603 renames Greater;
604
605 function ">"
606 (Left : in Bounded_String;
607 Right : in String)
608 return Boolean
609 renames Greater;
610
611 function ">"
612 (Left : in String;
613 Right : in Bounded_String)
614 return Boolean
615 renames Greater;
616
617 function ">=" (Left, Right : in Bounded_String) return Boolean
618 renames Greater_Or_Equal;
619
620 function ">="
621 (Left : in Bounded_String;
622 Right : in String)
623 return Boolean
624 renames Greater_Or_Equal;
625
626 function ">="
627 (Left : in String;
628 Right : in Bounded_String)
629 return Boolean
630 renames Greater_Or_Equal;
631
632 function Index
633 (Source : in Bounded_String;
634 Pattern : in String;
635 Going : in Direction := Forward;
636 Mapping : in Maps.Character_Mapping := Maps.Identity)
637 return Natural
638 renames Super_Index;
639
640 function Index
641 (Source : in Bounded_String;
642 Pattern : in String;
643 Going : in Direction := Forward;
644 Mapping : in Maps.Character_Mapping_Function)
645 return Natural
646 renames Super_Index;
647
648 function Index
649 (Source : in Bounded_String;
650 Set : in Maps.Character_Set;
651 Test : in Membership := Inside;
652 Going : in Direction := Forward)
653 return Natural
654 renames Super_Index;
655
656 function Index_Non_Blank
657 (Source : in Bounded_String;
658 Going : in Direction := Forward)
659 return Natural
660 renames Super_Index_Non_Blank;
661
662 function Count
663 (Source : in Bounded_String;
664 Pattern : in String;
665 Mapping : in Maps.Character_Mapping := Maps.Identity)
666 return Natural
667 renames Super_Count;
668
669 function Count
670 (Source : in Bounded_String;
671 Pattern : in String;
672 Mapping : in Maps.Character_Mapping_Function)
673 return Natural
674 renames Super_Count;
675
676 function Count
677 (Source : in Bounded_String;
678 Set : in Maps.Character_Set)
679 return Natural
680 renames Super_Count;
681
682 procedure Find_Token
683 (Source : in Bounded_String;
684 Set : in Maps.Character_Set;
685 Test : in Membership;
686 First : out Positive;
687 Last : out Natural)
688 renames Super_Find_Token;
689
690 function Translate
691 (Source : in Bounded_String;
692 Mapping : in Maps.Character_Mapping)
693 return Bounded_String
694 renames Super_Translate;
695
696 procedure Translate
697 (Source : in out Bounded_String;
698 Mapping : in Maps.Character_Mapping)
699 renames Super_Translate;
700
701 function Translate
702 (Source : in Bounded_String;
703 Mapping : in Maps.Character_Mapping_Function)
704 return Bounded_String
705 renames Super_Translate;
706
707 procedure Translate
708 (Source : in out Bounded_String;
709 Mapping : in Maps.Character_Mapping_Function)
710 renames Super_Translate;
711
712 function Replace_Slice
713 (Source : in Bounded_String;
714 Low : in Positive;
715 High : in Natural;
716 By : in String;
717 Drop : in Truncation := Error)
718 return Bounded_String
719 renames Super_Replace_Slice;
720
721 procedure Replace_Slice
722 (Source : in out Bounded_String;
723 Low : in Positive;
724 High : in Natural;
725 By : in String;
726 Drop : in Truncation := Error)
727 renames Super_Replace_Slice;
728
729 function Insert
730 (Source : in Bounded_String;
731 Before : in Positive;
732 New_Item : in String;
733 Drop : in Truncation := Error)
734 return Bounded_String
735 renames Super_Insert;
736
737 procedure Insert
738 (Source : in out Bounded_String;
739 Before : in Positive;
740 New_Item : in String;
741 Drop : in Truncation := Error)
742 renames Super_Insert;
743
744 function Overwrite
745 (Source : in Bounded_String;
746 Position : in Positive;
747 New_Item : in String;
748 Drop : in Truncation := Error)
749 return Bounded_String
750 renames Super_Overwrite;
751
752 procedure Overwrite
753 (Source : in out Bounded_String;
754 Position : in Positive;
755 New_Item : in String;
756 Drop : in Truncation := Error)
757 renames Super_Overwrite;
758
759 function Delete
760 (Source : in Bounded_String;
761 From : in Positive;
762 Through : in Natural)
763 return Bounded_String
764 renames Super_Delete;
765
766 procedure Delete
767 (Source : in out Bounded_String;
768 From : in Positive;
769 Through : in Natural)
770 renames Super_Delete;
771
772 function Trim
773 (Source : in Bounded_String;
774 Side : in Trim_End)
775 return Bounded_String
776 renames Super_Trim;
777
778 procedure Trim
779 (Source : in out Bounded_String;
780 Side : in Trim_End)
781 renames Super_Trim;
782
783 function Trim
784 (Source : in Bounded_String;
785 Left : in Maps.Character_Set;
786 Right : in Maps.Character_Set)
787 return Bounded_String
788 renames Super_Trim;
789
790 procedure Trim
791 (Source : in out Bounded_String;
792 Left : in Maps.Character_Set;
793 Right : in Maps.Character_Set)
794 renames Super_Trim;
795
796 function Head
797 (Source : in Bounded_String;
798 Count : in Natural;
799 Pad : in Character := Space;
800 Drop : in Truncation := Error)
801 return Bounded_String
802 renames Super_Head;
803
804 procedure Head
805 (Source : in out Bounded_String;
806 Count : in Natural;
807 Pad : in Character := Space;
808 Drop : in Truncation := Error)
809 renames Super_Head;
810
811 function Tail
812 (Source : in Bounded_String;
813 Count : in Natural;
814 Pad : in Character := Space;
815 Drop : in Truncation := Error)
816 return Bounded_String
817 renames Super_Tail;
818
819 procedure Tail
820 (Source : in out Bounded_String;
821 Count : in Natural;
822 Pad : in Character := Space;
823 Drop : in Truncation := Error)
824 renames Super_Tail;
825
826 function "*"
827 (Left : in Natural;
828 Right : in Bounded_String)
829 return Bounded_String
830 renames Times;
831
832 function Replicate
833 (Count : in Natural;
834 Item : in Bounded_String;
835 Drop : in Truncation := Error)
836 return Bounded_String
837 renames Super_Replicate;
d23b8f57
RK
838
839 end Generic_Bounded_Length;
840
841end Ada.Strings.Bounded;