1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . W I D E _ W I D E _ U N B O U N D E D --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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 3, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Ada
.Strings
.Wide_Wide_Fixed
;
33 with Ada
.Strings
.Wide_Wide_Search
;
34 with Ada
.Unchecked_Deallocation
;
36 package body Ada
.Strings
.Wide_Wide_Unbounded
is
45 (Left
: Unbounded_Wide_Wide_String
;
46 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
48 L_Length
: constant Natural := Left
.Last
;
49 R_Length
: constant Natural := Right
.Last
;
50 Result
: Unbounded_Wide_Wide_String
;
53 Result
.Last
:= L_Length
+ R_Length
;
55 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
57 Result
.Reference
(1 .. L_Length
) :=
58 Left
.Reference
(1 .. Left
.Last
);
59 Result
.Reference
(L_Length
+ 1 .. Result
.Last
) :=
60 Right
.Reference
(1 .. Right
.Last
);
66 (Left
: Unbounded_Wide_Wide_String
;
67 Right
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
69 L_Length
: constant Natural := Left
.Last
;
70 Result
: Unbounded_Wide_Wide_String
;
73 Result
.Last
:= L_Length
+ Right
'Length;
75 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
77 Result
.Reference
(1 .. L_Length
) := Left
.Reference
(1 .. Left
.Last
);
78 Result
.Reference
(L_Length
+ 1 .. Result
.Last
) := Right
;
84 (Left
: Wide_Wide_String
;
85 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
87 R_Length
: constant Natural := Right
.Last
;
88 Result
: Unbounded_Wide_Wide_String
;
91 Result
.Last
:= Left
'Length + R_Length
;
93 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
95 Result
.Reference
(1 .. Left
'Length) := Left
;
96 Result
.Reference
(Left
'Length + 1 .. Result
.Last
) :=
97 Right
.Reference
(1 .. Right
.Last
);
103 (Left
: Unbounded_Wide_Wide_String
;
104 Right
: Wide_Wide_Character
) return Unbounded_Wide_Wide_String
106 Result
: Unbounded_Wide_Wide_String
;
109 Result
.Last
:= Left
.Last
+ 1;
111 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
113 Result
.Reference
(1 .. Result
.Last
- 1) :=
114 Left
.Reference
(1 .. Left
.Last
);
115 Result
.Reference
(Result
.Last
) := Right
;
121 (Left
: Wide_Wide_Character
;
122 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
124 Result
: Unbounded_Wide_Wide_String
;
127 Result
.Last
:= Right
.Last
+ 1;
129 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
130 Result
.Reference
(1) := Left
;
131 Result
.Reference
(2 .. Result
.Last
) :=
132 Right
.Reference
(1 .. Right
.Last
);
142 Right
: Wide_Wide_Character
) return Unbounded_Wide_Wide_String
144 Result
: Unbounded_Wide_Wide_String
;
149 Result
.Reference
:= new Wide_Wide_String
(1 .. Left
);
150 for J
in Result
.Reference
'Range loop
151 Result
.Reference
(J
) := Right
;
159 Right
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
161 Len
: constant Natural := Right
'Length;
163 Result
: Unbounded_Wide_Wide_String
;
166 Result
.Last
:= Left
* Len
;
168 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
171 for J
in 1 .. Left
loop
172 Result
.Reference
(K
.. K
+ Len
- 1) := Right
;
181 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
183 Len
: constant Natural := Right
.Last
;
185 Result
: Unbounded_Wide_Wide_String
;
188 Result
.Last
:= Left
* Len
;
190 Result
.Reference
:= new Wide_Wide_String
(1 .. Result
.Last
);
193 for J
in 1 .. Left
loop
194 Result
.Reference
(K
.. K
+ Len
- 1) :=
195 Right
.Reference
(1 .. Right
.Last
);
207 (Left
: Unbounded_Wide_Wide_String
;
208 Right
: Unbounded_Wide_Wide_String
) return Boolean
212 Left
.Reference
(1 .. Left
.Last
) < Right
.Reference
(1 .. Right
.Last
);
216 (Left
: Unbounded_Wide_Wide_String
;
217 Right
: Wide_Wide_String
) return Boolean
220 return Left
.Reference
(1 .. Left
.Last
) < Right
;
224 (Left
: Wide_Wide_String
;
225 Right
: Unbounded_Wide_Wide_String
) return Boolean
228 return Left
< Right
.Reference
(1 .. Right
.Last
);
236 (Left
: Unbounded_Wide_Wide_String
;
237 Right
: Unbounded_Wide_Wide_String
) return Boolean
241 Left
.Reference
(1 .. Left
.Last
) <= Right
.Reference
(1 .. Right
.Last
);
245 (Left
: Unbounded_Wide_Wide_String
;
246 Right
: Wide_Wide_String
) return Boolean
249 return Left
.Reference
(1 .. Left
.Last
) <= Right
;
253 (Left
: Wide_Wide_String
;
254 Right
: Unbounded_Wide_Wide_String
) return Boolean
257 return Left
<= Right
.Reference
(1 .. Right
.Last
);
265 (Left
: Unbounded_Wide_Wide_String
;
266 Right
: Unbounded_Wide_Wide_String
) return Boolean
270 Left
.Reference
(1 .. Left
.Last
) = Right
.Reference
(1 .. Right
.Last
);
274 (Left
: Unbounded_Wide_Wide_String
;
275 Right
: Wide_Wide_String
) return Boolean
278 return Left
.Reference
(1 .. Left
.Last
) = Right
;
282 (Left
: Wide_Wide_String
;
283 Right
: Unbounded_Wide_Wide_String
) return Boolean
286 return Left
= Right
.Reference
(1 .. Right
.Last
);
294 (Left
: Unbounded_Wide_Wide_String
;
295 Right
: Unbounded_Wide_Wide_String
) return Boolean
299 Left
.Reference
(1 .. Left
.Last
) > Right
.Reference
(1 .. Right
.Last
);
303 (Left
: Unbounded_Wide_Wide_String
;
304 Right
: Wide_Wide_String
) return Boolean
307 return Left
.Reference
(1 .. Left
.Last
) > Right
;
311 (Left
: Wide_Wide_String
;
312 Right
: Unbounded_Wide_Wide_String
) return Boolean
315 return Left
> Right
.Reference
(1 .. Right
.Last
);
323 (Left
: Unbounded_Wide_Wide_String
;
324 Right
: Unbounded_Wide_Wide_String
) return Boolean
328 Left
.Reference
(1 .. Left
.Last
) >= Right
.Reference
(1 .. Right
.Last
);
332 (Left
: Unbounded_Wide_Wide_String
;
333 Right
: Wide_Wide_String
) return Boolean
336 return Left
.Reference
(1 .. Left
.Last
) >= Right
;
340 (Left
: Wide_Wide_String
;
341 Right
: Unbounded_Wide_Wide_String
) return Boolean
344 return Left
>= Right
.Reference
(1 .. Right
.Last
);
351 procedure Adjust
(Object
: in out Unbounded_Wide_Wide_String
) is
353 -- Copy string, except we do not copy the statically allocated null
354 -- string, since it can never be deallocated. Note that we do not copy
355 -- extra string room here to avoid dragging unused allocated memory.
357 if Object
.Reference
/= Null_Wide_Wide_String
'Access then
359 new Wide_Wide_String
'(Object.Reference (1 .. Object.Last));
368 (Source : in out Unbounded_Wide_Wide_String;
369 New_Item : Unbounded_Wide_Wide_String)
372 Realloc_For_Chunk (Source, New_Item.Last);
373 Source.Reference (Source.Last + 1 .. Source.Last + New_Item.Last) :=
374 New_Item.Reference (1 .. New_Item.Last);
375 Source.Last := Source.Last + New_Item.Last;
379 (Source : in out Unbounded_Wide_Wide_String;
380 New_Item : Wide_Wide_String)
383 Realloc_For_Chunk (Source, New_Item'Length);
384 Source.Reference (Source.Last + 1 .. Source.Last + New_Item'Length) :=
386 Source.Last := Source.Last + New_Item'Length;
390 (Source : in out Unbounded_Wide_Wide_String;
391 New_Item : Wide_Wide_Character)
394 Realloc_For_Chunk (Source, 1);
395 Source.Reference (Source.Last + 1) := New_Item;
396 Source.Last := Source.Last + 1;
404 (Source : Unbounded_Wide_Wide_String;
405 Pattern : Wide_Wide_String;
406 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
407 Wide_Wide_Maps.Identity)
412 Wide_Wide_Search.Count
413 (Source.Reference (1 .. Source.Last), Pattern, Mapping);
417 (Source : Unbounded_Wide_Wide_String;
418 Pattern : Wide_Wide_String;
419 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
424 Wide_Wide_Search.Count
425 (Source.Reference (1 .. Source.Last), Pattern, Mapping);
429 (Source : Unbounded_Wide_Wide_String;
430 Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural
434 Wide_Wide_Search.Count
435 (Source.Reference (1 .. Source.Last), Set);
443 (Source : Unbounded_Wide_Wide_String;
445 Through : Natural) return Unbounded_Wide_Wide_String
449 To_Unbounded_Wide_Wide_String
450 (Wide_Wide_Fixed.Delete
451 (Source.Reference (1 .. Source.Last), From, Through));
455 (Source : in out Unbounded_Wide_Wide_String;
460 if From > Through then
463 elsif From < Source.Reference'First or else Through > Source.Last then
468 Len : constant Natural := Through - From + 1;
471 Source.Reference (From .. Source.Last - Len) :=
472 Source.Reference (Through + 1 .. Source.Last);
473 Source.Last := Source.Last - Len;
483 (Source : Unbounded_Wide_Wide_String;
484 Index : Positive) return Wide_Wide_Character
487 if Index <= Source.Last then
488 return Source.Reference (Index);
490 raise Strings.Index_Error;
498 procedure Finalize (Object : in out Unbounded_Wide_Wide_String) is
499 procedure Deallocate is
500 new Ada.Unchecked_Deallocation
501 (Wide_Wide_String, Wide_Wide_String_Access);
504 -- Note: Don't try to free statically allocated null string
506 if Object.Reference /= Null_Wide_Wide_String'Access then
507 Deallocate (Object.Reference);
508 Object.Reference := Null_Unbounded_Wide_Wide_String.Reference;
518 (Source : Unbounded_Wide_Wide_String;
519 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
520 Test : Strings.Membership;
521 First : out Positive;
525 Wide_Wide_Search.Find_Token
526 (Source.Reference (1 .. Source.Last), Set, Test, First, Last);
533 procedure Free (X : in out Wide_Wide_String_Access) is
534 procedure Deallocate is
535 new Ada.Unchecked_Deallocation
536 (Wide_Wide_String, Wide_Wide_String_Access);
539 -- Note: Do not try to free statically allocated null string
541 if X /= Null_Unbounded_Wide_Wide_String.Reference then
551 (Source : Unbounded_Wide_Wide_String;
553 Pad : Wide_Wide_Character := Wide_Wide_Space)
554 return Unbounded_Wide_Wide_String
557 return To_Unbounded_Wide_Wide_String
558 (Wide_Wide_Fixed.Head
559 (Source.Reference (1 .. Source.Last), Count, Pad));
563 (Source : in out Unbounded_Wide_Wide_String;
565 Pad : Wide_Wide_Character := Wide_Wide_Space)
567 Old : Wide_Wide_String_Access := Source.Reference;
570 new Wide_Wide_String'
571 (Wide_Wide_Fixed
.Head
572 (Source
.Reference
(1 .. Source
.Last
), Count
, Pad
));
573 Source
.Last
:= Source
.Reference
'Length;
582 (Source
: Unbounded_Wide_Wide_String
;
583 Pattern
: Wide_Wide_String
;
584 Going
: Strings
.Direction
:= Strings
.Forward
;
585 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
586 Wide_Wide_Maps
.Identity
)
591 Wide_Wide_Search
.Index
592 (Source
.Reference
(1 .. Source
.Last
), Pattern
, Going
, Mapping
);
596 (Source
: Unbounded_Wide_Wide_String
;
597 Pattern
: Wide_Wide_String
;
598 Going
: Direction
:= Forward
;
599 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
604 Wide_Wide_Search
.Index
605 (Source
.Reference
(1 .. Source
.Last
), Pattern
, Going
, Mapping
);
609 (Source
: Unbounded_Wide_Wide_String
;
610 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
611 Test
: Strings
.Membership
:= Strings
.Inside
;
612 Going
: Strings
.Direction
:= Strings
.Forward
) return Natural
615 return Wide_Wide_Search
.Index
616 (Source
.Reference
(1 .. Source
.Last
), Set
, Test
, Going
);
620 (Source
: Unbounded_Wide_Wide_String
;
621 Pattern
: Wide_Wide_String
;
623 Going
: Direction
:= Forward
;
624 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
625 Wide_Wide_Maps
.Identity
)
630 Wide_Wide_Search
.Index
631 (Source
.Reference
(1 .. Source
.Last
), Pattern
, From
, Going
, Mapping
);
635 (Source
: Unbounded_Wide_Wide_String
;
636 Pattern
: Wide_Wide_String
;
638 Going
: Direction
:= Forward
;
639 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
644 Wide_Wide_Search
.Index
645 (Source
.Reference
(1 .. Source
.Last
), Pattern
, From
, Going
, Mapping
);
649 (Source
: Unbounded_Wide_Wide_String
;
650 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
652 Test
: Membership
:= Inside
;
653 Going
: Direction
:= Forward
) return Natural
657 Wide_Wide_Search
.Index
658 (Source
.Reference
(1 .. Source
.Last
), Set
, From
, Test
, Going
);
661 function Index_Non_Blank
662 (Source
: Unbounded_Wide_Wide_String
;
663 Going
: Strings
.Direction
:= Strings
.Forward
) return Natural
667 Wide_Wide_Search
.Index_Non_Blank
668 (Source
.Reference
(1 .. Source
.Last
), Going
);
671 function Index_Non_Blank
672 (Source
: Unbounded_Wide_Wide_String
;
674 Going
: Direction
:= Forward
) return Natural
678 Wide_Wide_Search
.Index_Non_Blank
679 (Source
.Reference
(1 .. Source
.Last
), From
, Going
);
686 procedure Initialize
(Object
: in out Unbounded_Wide_Wide_String
) is
688 Object
.Reference
:= Null_Unbounded_Wide_Wide_String
.Reference
;
697 (Source
: Unbounded_Wide_Wide_String
;
699 New_Item
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
703 To_Unbounded_Wide_Wide_String
704 (Wide_Wide_Fixed
.Insert
705 (Source
.Reference
(1 .. Source
.Last
), Before
, New_Item
));
709 (Source
: in out Unbounded_Wide_Wide_String
;
711 New_Item
: Wide_Wide_String
)
714 if Before
not in Source
.Reference
'First .. Source
.Last
+ 1 then
718 Realloc_For_Chunk
(Source
, New_Item
'Length);
721 (Before
+ New_Item
'Length .. Source
.Last
+ New_Item
'Length) :=
722 Source
.Reference
(Before
.. Source
.Last
);
724 Source
.Reference
(Before
.. Before
+ New_Item
'Length - 1) := New_Item
;
725 Source
.Last
:= Source
.Last
+ New_Item
'Length;
732 function Length
(Source
: Unbounded_Wide_Wide_String
) return Natural is
742 (Source
: Unbounded_Wide_Wide_String
;
744 New_Item
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
748 To_Unbounded_Wide_Wide_String
749 (Wide_Wide_Fixed
.Overwrite
750 (Source
.Reference
(1 .. Source
.Last
), Position
, New_Item
));
754 (Source
: in out Unbounded_Wide_Wide_String
;
756 New_Item
: Wide_Wide_String
)
758 NL
: constant Natural := New_Item
'Length;
760 if Position
<= Source
.Last
- NL
+ 1 then
761 Source
.Reference
(Position
.. Position
+ NL
- 1) := New_Item
;
764 Old
: Wide_Wide_String_Access
:= Source
.Reference
;
766 Source
.Reference
:= new Wide_Wide_String
'
767 (Wide_Wide_Fixed.Overwrite
768 (Source.Reference (1 .. Source.Last), Position, New_Item));
769 Source.Last := Source.Reference'Length;
775 -----------------------
776 -- Realloc_For_Chunk --
777 -----------------------
779 procedure Realloc_For_Chunk
780 (Source : in out Unbounded_Wide_Wide_String;
781 Chunk_Size : Natural)
783 Growth_Factor : constant := 32;
784 -- The growth factor controls how much extra space is allocated when
785 -- we have to increase the size of an allocated unbounded string. By
786 -- allocating extra space, we avoid the need to reallocate on every
787 -- append, particularly important when a string is built up by repeated
788 -- append operations of small pieces. This is expressed as a factor so
789 -- 32 means add 1/32 of the length of the string as growth space.
791 Min_Mul_Alloc : constant := Standard'Maximum_Alignment;
792 -- Allocation will be done by a multiple of Min_Mul_Alloc This causes
793 -- no memory loss as most (all?) malloc implementations are obliged to
794 -- align the returned memory on the maximum alignment as malloc does not
795 -- know the target alignment.
797 S_Length : constant Natural := Source.Reference'Length;
800 if Chunk_Size > S_Length - Source.Last then
802 New_Size : constant Positive :=
803 S_Length + Chunk_Size + (S_Length / Growth_Factor);
805 New_Rounded_Up_Size : constant Positive :=
806 ((New_Size - 1) / Min_Mul_Alloc + 1) *
809 Tmp : constant Wide_Wide_String_Access :=
810 new Wide_Wide_String (1 .. New_Rounded_Up_Size);
813 Tmp (1 .. Source.Last) := Source.Reference (1 .. Source.Last);
814 Free (Source.Reference);
815 Source.Reference := Tmp;
818 end Realloc_For_Chunk;
820 ---------------------
821 -- Replace_Element --
822 ---------------------
824 procedure Replace_Element
825 (Source : in out Unbounded_Wide_Wide_String;
827 By : Wide_Wide_Character)
830 if Index <= Source.Last then
831 Source.Reference (Index) := By;
833 raise Strings.Index_Error;
841 function Replace_Slice
842 (Source : Unbounded_Wide_Wide_String;
845 By : Wide_Wide_String) return Unbounded_Wide_Wide_String
848 return To_Unbounded_Wide_Wide_String
849 (Wide_Wide_Fixed.Replace_Slice
850 (Source.Reference (1 .. Source.Last), Low, High, By));
853 procedure Replace_Slice
854 (Source : in out Unbounded_Wide_Wide_String;
857 By : Wide_Wide_String)
859 Old : Wide_Wide_String_Access := Source.Reference;
861 Source.Reference := new Wide_Wide_String'
862 (Wide_Wide_Fixed
.Replace_Slice
863 (Source
.Reference
(1 .. Source
.Last
), Low
, High
, By
));
864 Source
.Last
:= Source
.Reference
'Length;
868 ------------------------------------
869 -- Set_Unbounded_Wide_Wide_String --
870 ------------------------------------
872 procedure Set_Unbounded_Wide_Wide_String
873 (Target
: out Unbounded_Wide_Wide_String
;
874 Source
: Wide_Wide_String
)
877 Target
.Last
:= Source
'Length;
878 Target
.Reference
:= new Wide_Wide_String
(1 .. Source
'Length);
879 Target
.Reference
.all := Source
;
880 end Set_Unbounded_Wide_Wide_String
;
887 (Source
: Unbounded_Wide_Wide_String
;
889 High
: Natural) return Wide_Wide_String
892 -- Note: test of High > Length is in accordance with AI95-00128
894 if Low
> Source
.Last
+ 1 or else High
> Source
.Last
then
897 return Source
.Reference
(Low
.. High
);
906 (Source
: Unbounded_Wide_Wide_String
;
908 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
)
909 return Unbounded_Wide_Wide_String
is
911 return To_Unbounded_Wide_Wide_String
912 (Wide_Wide_Fixed
.Tail
913 (Source
.Reference
(1 .. Source
.Last
), Count
, Pad
));
917 (Source
: in out Unbounded_Wide_Wide_String
;
919 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
)
921 Old
: Wide_Wide_String_Access
:= Source
.Reference
;
923 Source
.Reference
:= new Wide_Wide_String
'
924 (Wide_Wide_Fixed.Tail
925 (Source.Reference (1 .. Source.Last), Count, Pad));
926 Source.Last := Source.Reference'Length;
930 -----------------------------------
931 -- To_Unbounded_Wide_Wide_String --
932 -----------------------------------
934 function To_Unbounded_Wide_Wide_String
935 (Source : Wide_Wide_String) return Unbounded_Wide_Wide_String
937 Result : Unbounded_Wide_Wide_String;
939 Result.Last := Source'Length;
940 Result.Reference := new Wide_Wide_String (1 .. Source'Length);
941 Result.Reference.all := Source;
943 end To_Unbounded_Wide_Wide_String;
945 function To_Unbounded_Wide_Wide_String
946 (Length : Natural) return Unbounded_Wide_Wide_String
948 Result : Unbounded_Wide_Wide_String;
950 Result.Last := Length;
951 Result.Reference := new Wide_Wide_String (1 .. Length);
953 end To_Unbounded_Wide_Wide_String;
955 -------------------------
956 -- To_Wide_Wide_String --
957 -------------------------
959 function To_Wide_Wide_String
960 (Source : Unbounded_Wide_Wide_String) return Wide_Wide_String
963 return Source.Reference (1 .. Source.Last);
964 end To_Wide_Wide_String;
971 (Source : Unbounded_Wide_Wide_String;
972 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
973 return Unbounded_Wide_Wide_String
977 To_Unbounded_Wide_Wide_String
978 (Wide_Wide_Fixed.Translate
979 (Source.Reference (1 .. Source.Last), Mapping));
983 (Source : in out Unbounded_Wide_Wide_String;
984 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
987 Wide_Wide_Fixed.Translate (Source.Reference (1 .. Source.Last), Mapping);
991 (Source : Unbounded_Wide_Wide_String;
992 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
993 return Unbounded_Wide_Wide_String
997 To_Unbounded_Wide_Wide_String
998 (Wide_Wide_Fixed.Translate
999 (Source.Reference (1 .. Source.Last), Mapping));
1003 (Source : in out Unbounded_Wide_Wide_String;
1004 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
1007 Wide_Wide_Fixed.Translate (Source.Reference (1 .. Source.Last), Mapping);
1015 (Source : Unbounded_Wide_Wide_String;
1016 Side : Trim_End) return Unbounded_Wide_Wide_String
1020 To_Unbounded_Wide_Wide_String
1021 (Wide_Wide_Fixed.Trim (Source.Reference (1 .. Source.Last), Side));
1025 (Source : in out Unbounded_Wide_Wide_String;
1028 Old : Wide_Wide_String_Access := Source.Reference;
1031 new Wide_Wide_String'
1032 (Wide_Wide_Fixed
.Trim
(Source
.Reference
(1 .. Source
.Last
), Side
));
1033 Source
.Last
:= Source
.Reference
'Length;
1038 (Source
: Unbounded_Wide_Wide_String
;
1039 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
1040 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
)
1041 return Unbounded_Wide_Wide_String
1045 To_Unbounded_Wide_Wide_String
1046 (Wide_Wide_Fixed
.Trim
1047 (Source
.Reference
(1 .. Source
.Last
), Left
, Right
));
1051 (Source
: in out Unbounded_Wide_Wide_String
;
1052 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
1053 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
)
1055 Old
: Wide_Wide_String_Access
:= Source
.Reference
;
1058 new Wide_Wide_String
'
1059 (Wide_Wide_Fixed.Trim
1060 (Source.Reference (1 .. Source.Last), Left, Right));
1061 Source.Last := Source.Reference'Length;
1065 ---------------------
1066 -- Unbounded_Slice --
1067 ---------------------
1069 function Unbounded_Slice
1070 (Source : Unbounded_Wide_Wide_String;
1072 High : Natural) return Unbounded_Wide_Wide_String
1075 if Low > Source.Last + 1 or else High > Source.Last then
1079 To_Unbounded_Wide_Wide_String (Source.Reference.all (Low .. High));
1081 end Unbounded_Slice;
1083 procedure Unbounded_Slice
1084 (Source : Unbounded_Wide_Wide_String;
1085 Target : out Unbounded_Wide_Wide_String;
1090 if Low > Source.Last + 1 or else High > Source.Last then
1094 To_Unbounded_Wide_Wide_String (Source.Reference.all (Low .. High));
1096 end Unbounded_Slice;
1098 end Ada.Strings.Wide_Wide_Unbounded;