1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . B O U N D E D --
9 -- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
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. --
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. --
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. --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
36 ------------------------------------------------------------------------------
38 with Ada.Strings.Maps;
39 with Ada.Strings.Superbounded;
41 package Ada.Strings.Bounded is
42 pragma Preelaborate (Bounded);
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;
54 Null_Bounded_String : constant Bounded_String;
56 subtype Length_Range is Natural range 0 .. Max_Length;
58 function Length (Source : in Bounded_String) return Length_Range;
60 --------------------------------------------------------
61 -- Conversion, Concatenation, and Selection Functions --
62 --------------------------------------------------------
64 function To_Bounded_String
66 Drop : in Truncation := Error)
67 return Bounded_String;
69 function To_String (Source : in Bounded_String) return String;
72 (Left, Right : in Bounded_String;
73 Drop : in Truncation := Error)
74 return Bounded_String;
77 (Left : in Bounded_String;
79 Drop : in Truncation := Error)
80 return Bounded_String;
84 Right : in Bounded_String;
85 Drop : in Truncation := Error)
86 return Bounded_String;
89 (Left : in Bounded_String;
91 Drop : in Truncation := Error)
92 return Bounded_String;
96 Right : in Bounded_String;
97 Drop : in Truncation := Error)
98 return Bounded_String;
101 (Source : in out Bounded_String;
102 New_Item : in Bounded_String;
103 Drop : in Truncation := Error);
106 (Source : in out Bounded_String;
107 New_Item : in String;
108 Drop : in Truncation := Error);
111 (Source : in out Bounded_String;
112 New_Item : in Character;
113 Drop : in Truncation := Error);
116 (Left, Right : in Bounded_String)
117 return Bounded_String;
120 (Left : in Bounded_String;
122 return Bounded_String;
126 Right : in Bounded_String)
127 return Bounded_String;
130 (Left : in Bounded_String;
131 Right : in Character)
132 return Bounded_String;
135 (Left : in Character;
136 Right : in Bounded_String)
137 return Bounded_String;
140 (Source : in Bounded_String;
144 procedure Replace_Element
145 (Source : in out Bounded_String;
150 (Source : in Bounded_String;
155 function "=" (Left, Right : in Bounded_String) return Boolean;
158 (Left : in Bounded_String;
164 Right : in Bounded_String)
167 function "<" (Left, Right : in Bounded_String) return Boolean;
170 (Left : in Bounded_String;
176 Right : in Bounded_String)
179 function "<=" (Left, Right : in Bounded_String) return Boolean;
182 (Left : in Bounded_String;
188 Right : in Bounded_String)
191 function ">" (Left, Right : in Bounded_String) return Boolean;
194 (Left : in Bounded_String;
200 Right : in Bounded_String)
203 function ">=" (Left, Right : in Bounded_String) return Boolean;
206 (Left : in Bounded_String;
212 Right : in Bounded_String)
215 ----------------------
216 -- Search Functions --
217 ----------------------
220 (Source : in Bounded_String;
222 Going : in Direction := Forward;
223 Mapping : in Maps.Character_Mapping := Maps.Identity)
227 (Source : in Bounded_String;
229 Going : in Direction := Forward;
230 Mapping : in Maps.Character_Mapping_Function)
234 (Source : in Bounded_String;
235 Set : in Maps.Character_Set;
236 Test : in Membership := Inside;
237 Going : in Direction := Forward)
240 function Index_Non_Blank
241 (Source : in Bounded_String;
242 Going : in Direction := Forward)
246 (Source : in Bounded_String;
248 Mapping : in Maps.Character_Mapping := Maps.Identity)
252 (Source : in Bounded_String;
254 Mapping : in Maps.Character_Mapping_Function)
258 (Source : in Bounded_String;
259 Set : in Maps.Character_Set)
263 (Source : in Bounded_String;
264 Set : in Maps.Character_Set;
265 Test : in Membership;
266 First : out Positive;
269 ------------------------------------
270 -- String Translation Subprograms --
271 ------------------------------------
274 (Source : in Bounded_String;
275 Mapping : in Maps.Character_Mapping)
276 return Bounded_String;
279 (Source : in out Bounded_String;
280 Mapping : in Maps.Character_Mapping);
283 (Source : in Bounded_String;
284 Mapping : in Maps.Character_Mapping_Function)
285 return Bounded_String;
288 (Source : in out Bounded_String;
289 Mapping : in Maps.Character_Mapping_Function);
291 ---------------------------------------
292 -- String Transformation Subprograms --
293 ---------------------------------------
295 function Replace_Slice
296 (Source : in Bounded_String;
300 Drop : in Truncation := Error)
301 return Bounded_String;
303 procedure Replace_Slice
304 (Source : in out Bounded_String;
308 Drop : in Truncation := Error);
311 (Source : in Bounded_String;
312 Before : in Positive;
313 New_Item : in String;
314 Drop : in Truncation := Error)
315 return Bounded_String;
318 (Source : in out Bounded_String;
319 Before : in Positive;
320 New_Item : in String;
321 Drop : in Truncation := Error);
324 (Source : in Bounded_String;
325 Position : in Positive;
326 New_Item : in String;
327 Drop : in Truncation := Error)
328 return Bounded_String;
331 (Source : in out Bounded_String;
332 Position : in Positive;
333 New_Item : in String;
334 Drop : in Truncation := Error);
337 (Source : in Bounded_String;
339 Through : in Natural)
340 return Bounded_String;
343 (Source : in out Bounded_String;
345 Through : in Natural);
347 ---------------------------------
348 -- String Selector Subprograms --
349 ---------------------------------
352 (Source : in Bounded_String;
354 return Bounded_String;
357 (Source : in out Bounded_String;
361 (Source : in Bounded_String;
362 Left : in Maps.Character_Set;
363 Right : in Maps.Character_Set)
364 return Bounded_String;
367 (Source : in out Bounded_String;
368 Left : in Maps.Character_Set;
369 Right : in Maps.Character_Set);
372 (Source : in Bounded_String;
374 Pad : in Character := Space;
375 Drop : in Truncation := Error)
376 return Bounded_String;
379 (Source : in out Bounded_String;
381 Pad : in Character := Space;
382 Drop : in Truncation := Error);
385 (Source : in Bounded_String;
387 Pad : in Character := Space;
388 Drop : in Truncation := Error)
389 return Bounded_String;
392 (Source : in out Bounded_String;
394 Pad : in Character := Space;
395 Drop : in Truncation := Error);
397 ------------------------------------
398 -- String Constructor Subprograms --
399 ------------------------------------
403 Right : in Character)
404 return Bounded_String;
409 return Bounded_String;
413 Right : in Bounded_String)
414 return Bounded_String;
419 Drop : in Truncation := Error)
420 return Bounded_String;
425 Drop : in Truncation := Error)
426 return Bounded_String;
430 Item : in Bounded_String;
431 Drop : in Truncation := Error)
432 return Bounded_String;
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.
442 type Bounded_String is new Superbounded.Super_String (Max_Length);
444 Null_Bounded_String : constant Bounded_String :=
445 (Max_Length => Max_Length,
447 Data => (1 .. Max_Length => ASCII.NUL));
449 pragma Inline (To_Bounded_String);
451 function Length (Source : in Bounded_String) return Length_Range
452 renames Super_Length;
454 function To_String (Source : in Bounded_String) return String
455 renames Super_To_String;
458 (Left, Right : in Bounded_String;
459 Drop : in Truncation := Error)
460 return Bounded_String
461 renames Super_Append;
464 (Left : in Bounded_String;
466 Drop : in Truncation := Error)
467 return Bounded_String
468 renames Super_Append;
472 Right : in Bounded_String;
473 Drop : in Truncation := Error)
474 return Bounded_String
475 renames Super_Append;
478 (Left : in Bounded_String;
479 Right : in Character;
480 Drop : in Truncation := Error)
481 return Bounded_String
482 renames Super_Append;
485 (Left : in Character;
486 Right : in Bounded_String;
487 Drop : in Truncation := Error)
488 return Bounded_String
489 renames Super_Append;
492 (Source : in out Bounded_String;
493 New_Item : in Bounded_String;
494 Drop : in Truncation := Error)
495 renames Super_Append;
498 (Source : in out Bounded_String;
499 New_Item : in String;
500 Drop : in Truncation := Error)
501 renames Super_Append;
504 (Source : in out Bounded_String;
505 New_Item : in Character;
506 Drop : in Truncation := Error)
507 renames Super_Append;
510 (Left, Right : in Bounded_String)
511 return Bounded_String
515 (Left : in Bounded_String;
517 return Bounded_String
522 Right : in Bounded_String)
523 return Bounded_String
527 (Left : in Bounded_String;
528 Right : in Character)
529 return Bounded_String
533 (Left : in Character;
534 Right : in Bounded_String)
535 return Bounded_String
539 (Source : in Bounded_String;
542 renames Super_Element;
544 procedure Replace_Element
545 (Source : in out Bounded_String;
548 renames Super_Replace_Element;
551 (Source : in Bounded_String;
557 function "=" (Left, Right : in Bounded_String) return Boolean
561 (Left : in Bounded_String;
568 Right : in Bounded_String)
572 function "<" (Left, Right : in Bounded_String) return Boolean
576 (Left : in Bounded_String;
583 Right : in Bounded_String)
587 function "<=" (Left, Right : in Bounded_String) return Boolean
588 renames Less_Or_Equal;
591 (Left : in Bounded_String;
594 renames Less_Or_Equal;
598 Right : in Bounded_String)
600 renames Less_Or_Equal;
602 function ">" (Left, Right : in Bounded_String) return Boolean
606 (Left : in Bounded_String;
613 Right : in Bounded_String)
617 function ">=" (Left, Right : in Bounded_String) return Boolean
618 renames Greater_Or_Equal;
621 (Left : in Bounded_String;
624 renames Greater_Or_Equal;
628 Right : in Bounded_String)
630 renames Greater_Or_Equal;
633 (Source : in Bounded_String;
635 Going : in Direction := Forward;
636 Mapping : in Maps.Character_Mapping := Maps.Identity)
641 (Source : in Bounded_String;
643 Going : in Direction := Forward;
644 Mapping : in Maps.Character_Mapping_Function)
649 (Source : in Bounded_String;
650 Set : in Maps.Character_Set;
651 Test : in Membership := Inside;
652 Going : in Direction := Forward)
656 function Index_Non_Blank
657 (Source : in Bounded_String;
658 Going : in Direction := Forward)
660 renames Super_Index_Non_Blank;
663 (Source : in Bounded_String;
665 Mapping : in Maps.Character_Mapping := Maps.Identity)
670 (Source : in Bounded_String;
672 Mapping : in Maps.Character_Mapping_Function)
677 (Source : in Bounded_String;
678 Set : in Maps.Character_Set)
683 (Source : in Bounded_String;
684 Set : in Maps.Character_Set;
685 Test : in Membership;
686 First : out Positive;
688 renames Super_Find_Token;
691 (Source : in Bounded_String;
692 Mapping : in Maps.Character_Mapping)
693 return Bounded_String
694 renames Super_Translate;
697 (Source : in out Bounded_String;
698 Mapping : in Maps.Character_Mapping)
699 renames Super_Translate;
702 (Source : in Bounded_String;
703 Mapping : in Maps.Character_Mapping_Function)
704 return Bounded_String
705 renames Super_Translate;
708 (Source : in out Bounded_String;
709 Mapping : in Maps.Character_Mapping_Function)
710 renames Super_Translate;
712 function Replace_Slice
713 (Source : in Bounded_String;
717 Drop : in Truncation := Error)
718 return Bounded_String
719 renames Super_Replace_Slice;
721 procedure Replace_Slice
722 (Source : in out Bounded_String;
726 Drop : in Truncation := Error)
727 renames Super_Replace_Slice;
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;
738 (Source : in out Bounded_String;
739 Before : in Positive;
740 New_Item : in String;
741 Drop : in Truncation := Error)
742 renames Super_Insert;
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;
753 (Source : in out Bounded_String;
754 Position : in Positive;
755 New_Item : in String;
756 Drop : in Truncation := Error)
757 renames Super_Overwrite;
760 (Source : in Bounded_String;
762 Through : in Natural)
763 return Bounded_String
764 renames Super_Delete;
767 (Source : in out Bounded_String;
769 Through : in Natural)
770 renames Super_Delete;
773 (Source : in Bounded_String;
775 return Bounded_String
779 (Source : in out Bounded_String;
784 (Source : in Bounded_String;
785 Left : in Maps.Character_Set;
786 Right : in Maps.Character_Set)
787 return Bounded_String
791 (Source : in out Bounded_String;
792 Left : in Maps.Character_Set;
793 Right : in Maps.Character_Set)
797 (Source : in Bounded_String;
799 Pad : in Character := Space;
800 Drop : in Truncation := Error)
801 return Bounded_String
805 (Source : in out Bounded_String;
807 Pad : in Character := Space;
808 Drop : in Truncation := Error)
812 (Source : in Bounded_String;
814 Pad : in Character := Space;
815 Drop : in Truncation := Error)
816 return Bounded_String
820 (Source : in out Bounded_String;
822 Pad : in Character := Space;
823 Drop : in Truncation := Error)
828 Right : in Bounded_String)
829 return Bounded_String
834 Item : in Bounded_String;
835 Drop : in Truncation := Error)
836 return Bounded_String
837 renames Super_Replicate;
839 end Generic_Bounded_Length;
841 end Ada.Strings.Bounded;