OSDN Git Service

* 1aexcept.adb, 1aexcept.ads, 1ic.ads, 1ssecsta.adb,
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-stwiun.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUNTIME COMPONENTS                          --
4 --                                                                          --
5 --           A D A . S T R I N G S . W I D E _ U N B O U N D E D            --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2001 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 ------------------------------------------------------------------------------
33
34 with Ada.Strings.Wide_Fixed;
35 with Ada.Strings.Wide_Search;
36 with Ada.Unchecked_Deallocation;
37
38 package body Ada.Strings.Wide_Unbounded is
39
40    use Ada.Finalization;
41
42    ---------
43    -- "&" --
44    ---------
45
46    function "&"
47      (Left  : Unbounded_Wide_String;
48       Right : Unbounded_Wide_String)
49       return  Unbounded_Wide_String
50    is
51       L_Length : constant Integer := Left.Reference.all'Length;
52       R_Length : constant Integer := Right.Reference.all'Length;
53       Length   : constant Integer := L_Length + R_Length;
54       Result   : Unbounded_Wide_String;
55
56    begin
57       Result.Reference := new Wide_String (1 .. Length);
58       Result.Reference.all (1 .. L_Length)          := Left.Reference.all;
59       Result.Reference.all (L_Length + 1 .. Length) := Right.Reference.all;
60       return Result;
61    end "&";
62
63    function "&"
64      (Left  : Unbounded_Wide_String;
65       Right : Wide_String)
66       return  Unbounded_Wide_String
67    is
68       L_Length : constant Integer := Left.Reference.all'Length;
69       Length   : constant Integer := L_Length +  Right'Length;
70       Result   : Unbounded_Wide_String;
71
72    begin
73       Result.Reference := new Wide_String (1 .. Length);
74       Result.Reference.all (1 .. L_Length)          := Left.Reference.all;
75       Result.Reference.all (L_Length + 1 .. Length) := Right;
76       return Result;
77    end "&";
78
79    function "&"
80      (Left  : Wide_String;
81       Right : Unbounded_Wide_String)
82       return  Unbounded_Wide_String
83    is
84       R_Length : constant Integer := Right.Reference.all'Length;
85       Length   : constant Integer := Left'Length + R_Length;
86       Result   : Unbounded_Wide_String;
87
88    begin
89       Result.Reference := new Wide_String (1 .. Length);
90       Result.Reference.all (1 .. Left'Length)          := Left;
91       Result.Reference.all (Left'Length + 1 .. Length) := Right.Reference.all;
92       return Result;
93    end "&";
94
95    function "&"
96      (Left  : Unbounded_Wide_String;
97       Right : Wide_Character)
98       return  Unbounded_Wide_String
99    is
100       Length : constant Integer := Left.Reference.all'Length + 1;
101       Result : Unbounded_Wide_String;
102
103    begin
104       Result.Reference := new Wide_String (1 .. Length);
105       Result.Reference.all (1 .. Length - 1) := Left.Reference.all;
106       Result.Reference.all (Length)          := Right;
107       return Result;
108    end "&";
109
110    function "&"
111      (Left  : Wide_Character;
112       Right : Unbounded_Wide_String)
113       return  Unbounded_Wide_String
114    is
115       Length : constant Integer      := Right.Reference.all'Length + 1;
116       Result : Unbounded_Wide_String;
117
118    begin
119       Result.Reference := new Wide_String (1 .. Length);
120       Result.Reference.all (1)           := Left;
121       Result.Reference.all (2 .. Length) := Right.Reference.all;
122       return Result;
123    end "&";
124
125    ---------
126    -- "*" --
127    ---------
128
129    function "*"
130      (Left  : Natural;
131       Right : Wide_Character)
132       return  Unbounded_Wide_String
133    is
134       Result : Unbounded_Wide_String;
135
136    begin
137       Result.Reference := new Wide_String (1 .. Left);
138       for J in Result.Reference'Range loop
139          Result.Reference (J) := Right;
140       end loop;
141
142       return Result;
143    end "*";
144
145    function "*"
146      (Left   : Natural;
147       Right  : Wide_String)
148       return   Unbounded_Wide_String
149    is
150       Result : Unbounded_Wide_String;
151
152    begin
153       Result.Reference := new Wide_String (1 .. Left * Right'Length);
154
155       for J in 1 .. Left loop
156          Result.Reference.all
157            (Right'Length * J - Right'Length + 1 .. Right'Length * J) := Right;
158       end loop;
159
160       return Result;
161    end "*";
162
163    function "*"
164      (Left  : Natural;
165       Right : Unbounded_Wide_String)
166       return  Unbounded_Wide_String
167    is
168       R_Length : constant Integer := Right.Reference.all'Length;
169       Result   : Unbounded_Wide_String;
170
171    begin
172       Result.Reference := new Wide_String (1 .. Left * R_Length);
173
174       for I in 1 .. Left loop
175          Result.Reference.all (R_Length * I - R_Length + 1 .. R_Length * I) :=
176            Right.Reference.all;
177       end loop;
178
179       return Result;
180    end "*";
181
182    ---------
183    -- "<" --
184    ---------
185
186    function "<"
187      (Left  : in Unbounded_Wide_String;
188       Right : in Unbounded_Wide_String)
189       return  Boolean
190    is
191    begin
192       return Left.Reference.all < Right.Reference.all;
193    end "<";
194
195    function "<"
196      (Left  : in Unbounded_Wide_String;
197       Right : in Wide_String)
198       return  Boolean
199    is
200    begin
201       return Left.Reference.all < Right;
202    end "<";
203
204    function "<"
205      (Left  : in Wide_String;
206       Right : in Unbounded_Wide_String)
207       return  Boolean
208    is
209    begin
210       return Left < Right.Reference.all;
211    end "<";
212
213    ----------
214    -- "<=" --
215    ----------
216
217    function "<="
218      (Left  : in Unbounded_Wide_String;
219       Right : in Unbounded_Wide_String)
220       return  Boolean
221    is
222    begin
223       return Left.Reference.all <= Right.Reference.all;
224    end "<=";
225
226    function "<="
227      (Left  : in Unbounded_Wide_String;
228       Right : in Wide_String)
229       return  Boolean
230    is
231    begin
232       return Left.Reference.all <= Right;
233    end "<=";
234
235    function "<="
236      (Left  : in Wide_String;
237       Right : in Unbounded_Wide_String)
238       return  Boolean
239    is
240    begin
241       return Left <= Right.Reference.all;
242    end "<=";
243
244    ---------
245    -- "=" --
246    ---------
247
248    function "="
249      (Left  : in Unbounded_Wide_String;
250       Right : in Unbounded_Wide_String)
251       return  Boolean
252    is
253    begin
254       return Left.Reference.all = Right.Reference.all;
255    end "=";
256
257    function "="
258      (Left  : in Unbounded_Wide_String;
259       Right : in Wide_String)
260       return  Boolean
261    is
262    begin
263       return Left.Reference.all = Right;
264    end "=";
265
266    function "="
267      (Left  : in Wide_String;
268       Right : in Unbounded_Wide_String)
269       return  Boolean
270    is
271    begin
272       return Left = Right.Reference.all;
273    end "=";
274
275    ---------
276    -- ">" --
277    ---------
278
279    function ">"
280      (Left  : in Unbounded_Wide_String;
281       Right : in Unbounded_Wide_String)
282       return  Boolean
283    is
284    begin
285       return Left.Reference.all > Right.Reference.all;
286    end ">";
287
288    function ">"
289      (Left  : in Unbounded_Wide_String;
290       Right : in Wide_String)
291       return  Boolean
292    is
293    begin
294       return Left.Reference.all > Right;
295    end ">";
296
297    function ">"
298      (Left  : in Wide_String;
299       Right : in Unbounded_Wide_String)
300       return  Boolean
301    is
302    begin
303       return Left > Right.Reference.all;
304    end ">";
305
306    ----------
307    -- ">=" --
308    ----------
309
310    function ">="
311      (Left  : in Unbounded_Wide_String;
312       Right : in Unbounded_Wide_String)
313       return  Boolean
314    is
315    begin
316       return Left.Reference.all >= Right.Reference.all;
317    end ">=";
318
319    function ">="
320      (Left  : in Unbounded_Wide_String;
321       Right : in Wide_String)
322       return  Boolean
323    is
324    begin
325       return Left.Reference.all >= Right;
326    end ">=";
327
328    function ">="
329      (Left  : in Wide_String;
330       Right : in Unbounded_Wide_String)
331       return  Boolean
332    is
333    begin
334       return Left >= Right.Reference.all;
335    end ">=";
336
337    ------------
338    -- Adjust --
339    ------------
340
341    procedure Adjust (Object : in out Unbounded_Wide_String) is
342    begin
343       --  Copy string, except we do not copy the statically allocated
344       --  null string, since it can never be deallocated.
345
346       if Object.Reference /= Null_Wide_String'Access then
347          Object.Reference := new Wide_String'(Object.Reference.all);
348       end if;
349    end Adjust;
350
351    ------------
352    -- Append --
353    ------------
354
355    procedure Append
356      (Source   : in out Unbounded_Wide_String;
357       New_Item : in Unbounded_Wide_String)
358    is
359       S_Length : constant Integer := Source.Reference.all'Length;
360       Length   : constant Integer := S_Length + New_Item.Reference.all'Length;
361       Temp     : Wide_String_Access := Source.Reference;
362
363    begin
364       if Source.Reference = Null_Wide_String'Access then
365          Source := To_Unbounded_Wide_String (New_Item.Reference.all);
366          return;
367       end if;
368
369       Source.Reference := new Wide_String (1 .. Length);
370
371       Source.Reference.all (1 .. S_Length) := Temp.all;
372       Source.Reference.all (S_Length + 1 .. Length) := New_Item.Reference.all;
373       Free (Temp);
374    end Append;
375
376    procedure Append
377      (Source   : in out Unbounded_Wide_String;
378       New_Item : in Wide_String)
379    is
380       S_Length : constant Integer := Source.Reference.all'Length;
381       Length   : constant Integer := S_Length + New_Item'Length;
382       Temp     : Wide_String_Access := Source.Reference;
383
384    begin
385       if Source.Reference = Null_Wide_String'Access then
386          Source := To_Unbounded_Wide_String (New_Item);
387          return;
388       end if;
389
390       Source.Reference := new Wide_String (1 .. Length);
391       Source.Reference.all (1 .. S_Length) := Temp.all;
392       Source.Reference.all (S_Length + 1 .. Length) := New_Item;
393       Free (Temp);
394    end Append;
395
396    procedure Append
397      (Source   : in out Unbounded_Wide_String;
398       New_Item : in Wide_Character)
399    is
400       S_Length : constant Integer := Source.Reference.all'Length;
401       Length   : constant Integer := S_Length + 1;
402       Temp     : Wide_String_Access := Source.Reference;
403
404    begin
405       if Source.Reference = Null_Wide_String'Access then
406          Source := To_Unbounded_Wide_String ("" & New_Item);
407          return;
408       end if;
409
410       Source.Reference := new Wide_String (1 .. Length);
411       Source.Reference.all (1 .. S_Length) := Temp.all;
412       Source.Reference.all (S_Length + 1) := New_Item;
413       Free (Temp);
414    end Append;
415
416    -----------
417    -- Count --
418    -----------
419
420    function Count
421      (Source   : Unbounded_Wide_String;
422       Pattern  : Wide_String;
423       Mapping  : Wide_Maps.Wide_Character_Mapping :=
424                         Wide_Maps.Identity)
425       return     Natural
426    is
427    begin
428       return Wide_Search.Count (Source.Reference.all, Pattern, Mapping);
429    end Count;
430
431    function Count
432      (Source   : in Unbounded_Wide_String;
433       Pattern  : in Wide_String;
434       Mapping  : in Wide_Maps.Wide_Character_Mapping_Function)
435       return     Natural
436    is
437    begin
438       return Wide_Search.Count (Source.Reference.all, Pattern, Mapping);
439    end Count;
440
441    function Count
442      (Source   : Unbounded_Wide_String;
443       Set      : Wide_Maps.Wide_Character_Set)
444       return     Natural
445    is
446    begin
447       return Wide_Search.Count (Source.Reference.all, Set);
448    end Count;
449
450    ------------
451    -- Delete --
452    ------------
453
454    function Delete
455      (Source  : Unbounded_Wide_String;
456       From    : Positive;
457       Through : Natural)
458       return    Unbounded_Wide_String
459    is
460    begin
461       return
462         To_Unbounded_Wide_String
463           (Wide_Fixed.Delete (Source.Reference.all, From, Through));
464    end Delete;
465
466    procedure Delete
467      (Source  : in out Unbounded_Wide_String;
468       From    : in Positive;
469       Through : in Natural)
470    is
471       Temp : Wide_String_Access := Source.Reference;
472    begin
473       Source := To_Unbounded_Wide_String
474         (Wide_Fixed.Delete (Temp.all, From, Through));
475    end Delete;
476
477    -------------
478    -- Element --
479    -------------
480
481    function Element
482      (Source : Unbounded_Wide_String;
483       Index  : Positive)
484       return   Wide_Character
485    is
486    begin
487       if Index <= Source.Reference.all'Last then
488          return Source.Reference.all (Index);
489       else
490          raise Strings.Index_Error;
491       end if;
492    end Element;
493
494    --------------
495    -- Finalize --
496    --------------
497
498    procedure Finalize (Object : in out Unbounded_Wide_String) is
499       procedure Deallocate is
500         new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access);
501
502    begin
503       --  Note: Don't try to free statically allocated null string
504
505       if Object.Reference /= Null_Wide_String'Access then
506          Deallocate (Object.Reference);
507          Object.Reference := Null_Unbounded_Wide_String.Reference;
508       end if;
509    end Finalize;
510
511    ----------------
512    -- Find_Token --
513    ----------------
514
515    procedure Find_Token
516      (Source : Unbounded_Wide_String;
517       Set    : Wide_Maps.Wide_Character_Set;
518       Test   : Strings.Membership;
519       First  : out Positive;
520       Last   : out Natural)
521    is
522    begin
523       Wide_Search.Find_Token (Source.Reference.all, Set, Test, First, Last);
524    end Find_Token;
525
526    ----------
527    -- Free --
528    ----------
529
530    procedure Free (X : in out Wide_String_Access) is
531       procedure Deallocate is
532          new Ada.Unchecked_Deallocation (Wide_String, Wide_String_Access);
533    begin
534       Deallocate (X);
535    end Free;
536
537    ----------
538    -- Head --
539    ----------
540
541    function Head
542      (Source : Unbounded_Wide_String;
543       Count  : Natural;
544       Pad    : Wide_Character := Wide_Space)
545       return   Unbounded_Wide_String
546    is
547    begin
548       return
549         To_Unbounded_Wide_String
550           (Wide_Fixed.Head (Source.Reference.all, Count, Pad));
551    end Head;
552
553    procedure Head
554      (Source : in out Unbounded_Wide_String;
555       Count  : in Natural;
556       Pad    : in Wide_Character := Wide_Space)
557    is
558    begin
559       Source := To_Unbounded_Wide_String
560         (Wide_Fixed.Head (Source.Reference.all, Count, Pad));
561    end Head;
562
563    -----------
564    -- Index --
565    -----------
566
567    function Index
568      (Source   : Unbounded_Wide_String;
569       Pattern  : Wide_String;
570       Going    : Strings.Direction := Strings.Forward;
571       Mapping  : Wide_Maps.Wide_Character_Mapping :=
572                         Wide_Maps.Identity)
573       return     Natural
574    is
575    begin
576       return
577         Wide_Search.Index (Source.Reference.all, Pattern, Going, Mapping);
578    end Index;
579
580    function Index
581      (Source   : in Unbounded_Wide_String;
582       Pattern  : in Wide_String;
583       Going    : in Direction := Forward;
584       Mapping  : in Wide_Maps.Wide_Character_Mapping_Function)
585       return Natural
586    is
587    begin
588       return
589         Wide_Search.Index (Source.Reference.all, Pattern, Going, Mapping);
590    end Index;
591
592    function Index
593      (Source : Unbounded_Wide_String;
594       Set    : Wide_Maps.Wide_Character_Set;
595       Test   : Strings.Membership := Strings.Inside;
596       Going  : Strings.Direction  := Strings.Forward)
597       return   Natural
598    is
599    begin
600       return Wide_Search.Index (Source.Reference.all, Set, Test, Going);
601    end Index;
602
603    function Index_Non_Blank
604      (Source : Unbounded_Wide_String;
605       Going  : Strings.Direction := Strings.Forward)
606       return   Natural
607    is
608    begin
609       return Wide_Search.Index_Non_Blank (Source.Reference.all, Going);
610    end Index_Non_Blank;
611
612    ----------------
613    -- Initialize --
614    ----------------
615
616    procedure Initialize (Object : in out Unbounded_Wide_String) is
617    begin
618       Object.Reference := Null_Unbounded_Wide_String.Reference;
619    end Initialize;
620
621    ------------
622    -- Insert --
623    ------------
624
625    function Insert
626      (Source   : Unbounded_Wide_String;
627       Before   : Positive;
628       New_Item : Wide_String)
629       return     Unbounded_Wide_String
630    is
631    begin
632       return
633         To_Unbounded_Wide_String
634           (Wide_Fixed.Insert (Source.Reference.all, Before, New_Item));
635    end Insert;
636
637    procedure Insert
638      (Source   : in out Unbounded_Wide_String;
639       Before   : in Positive;
640       New_Item : in Wide_String)
641    is
642    begin
643       Source := To_Unbounded_Wide_String
644         (Wide_Fixed.Insert (Source.Reference.all, Before, New_Item));
645    end Insert;
646
647    ------------
648    -- Length --
649    ------------
650
651    function Length (Source : Unbounded_Wide_String) return Natural is
652    begin
653       return Source.Reference.all'Length;
654    end Length;
655
656    ---------------
657    -- Overwrite --
658    ---------------
659
660    function Overwrite
661      (Source    : Unbounded_Wide_String;
662       Position  : Positive;
663       New_Item  : Wide_String)
664       return      Unbounded_Wide_String is
665
666    begin
667       return To_Unbounded_Wide_String
668         (Wide_Fixed.Overwrite (Source.Reference.all, Position, New_Item));
669    end Overwrite;
670
671    procedure Overwrite
672      (Source    : in out Unbounded_Wide_String;
673       Position  : in Positive;
674       New_Item  : in Wide_String)
675    is
676       Temp : Wide_String_Access := Source.Reference;
677    begin
678       Source := To_Unbounded_Wide_String
679         (Wide_Fixed.Overwrite (Temp.all, Position, New_Item));
680    end Overwrite;
681
682    ---------------------
683    -- Replace_Element --
684    ---------------------
685
686    procedure Replace_Element
687      (Source : in out Unbounded_Wide_String;
688       Index  : Positive;
689       By     : Wide_Character)
690    is
691    begin
692       if Index <= Source.Reference.all'Last then
693          Source.Reference.all (Index) := By;
694       else
695          raise Strings.Index_Error;
696       end if;
697    end Replace_Element;
698
699    -------------------
700    -- Replace_Slice --
701    -------------------
702
703    function Replace_Slice
704      (Source   : Unbounded_Wide_String;
705       Low      : Positive;
706       High     : Natural;
707       By       : Wide_String)
708       return     Unbounded_Wide_String
709    is
710    begin
711       return
712         To_Unbounded_Wide_String
713           (Wide_Fixed.Replace_Slice (Source.Reference.all, Low, High, By));
714    end Replace_Slice;
715
716    procedure Replace_Slice
717      (Source   : in out Unbounded_Wide_String;
718       Low      : in Positive;
719       High     : in Natural;
720       By       : in Wide_String)
721    is
722       Temp : Wide_String_Access := Source.Reference;
723    begin
724       Source := To_Unbounded_Wide_String
725         (Wide_Fixed.Replace_Slice (Temp.all, Low, High, By));
726    end Replace_Slice;
727
728    -----------
729    -- Slice --
730    -----------
731
732    function Slice
733      (Source : Unbounded_Wide_String;
734       Low    : Positive;
735       High   : Natural)
736       return   Wide_String
737    is
738       Length : constant Natural := Source.Reference'Length;
739
740    begin
741       --  Note: test of High > Length is in accordance with AI95-00128
742
743       if Low > Length + 1 or else High > Length then
744          raise Index_Error;
745
746       else
747          declare
748             Result : Wide_String (1 .. High - Low + 1);
749
750          begin
751             Result := Source.Reference.all (Low .. High);
752             return Result;
753          end;
754       end if;
755    end Slice;
756
757    ----------
758    -- Tail --
759    ----------
760
761    function Tail
762      (Source : Unbounded_Wide_String;
763       Count  : Natural;
764       Pad    : Wide_Character := Wide_Space)
765       return   Unbounded_Wide_String is
766
767    begin
768       return
769         To_Unbounded_Wide_String
770           (Wide_Fixed.Tail (Source.Reference.all, Count, Pad));
771    end Tail;
772
773    procedure Tail
774      (Source : in out Unbounded_Wide_String;
775       Count  : in Natural;
776       Pad    : in Wide_Character := Wide_Space)
777    is
778       Temp : Wide_String_Access := Source.Reference;
779
780    begin
781       Source := To_Unbounded_Wide_String
782         (Wide_Fixed.Tail (Temp.all, Count, Pad));
783    end Tail;
784
785    ------------------------------
786    -- To_Unbounded_Wide_String --
787    ------------------------------
788
789    function To_Unbounded_Wide_String
790      (Source : Wide_String)
791       return   Unbounded_Wide_String
792    is
793       Result : Unbounded_Wide_String;
794
795    begin
796       Result.Reference := new Wide_String (1 .. Source'Length);
797       Result.Reference.all := Source;
798       return Result;
799    end To_Unbounded_Wide_String;
800
801    function To_Unbounded_Wide_String (Length : in Natural)
802       return Unbounded_Wide_String
803    is
804       Result : Unbounded_Wide_String;
805
806    begin
807       Result.Reference := new Wide_String (1 .. Length);
808       return Result;
809    end To_Unbounded_Wide_String;
810
811    --------------------
812    -- To_Wide_String --
813    --------------------
814
815    function To_Wide_String
816      (Source : Unbounded_Wide_String)
817       return   Wide_String
818    is
819    begin
820       return Source.Reference.all;
821    end To_Wide_String;
822
823    ---------------
824    -- Translate --
825    ---------------
826
827    function Translate
828      (Source  : Unbounded_Wide_String;
829       Mapping : Wide_Maps.Wide_Character_Mapping)
830       return    Unbounded_Wide_String
831    is
832    begin
833       return
834         To_Unbounded_Wide_String
835           (Wide_Fixed.Translate (Source.Reference.all, Mapping));
836    end Translate;
837
838    procedure Translate
839      (Source  : in out Unbounded_Wide_String;
840       Mapping : Wide_Maps.Wide_Character_Mapping)
841    is
842    begin
843       Wide_Fixed.Translate (Source.Reference.all, Mapping);
844    end Translate;
845
846    function Translate
847      (Source  : in Unbounded_Wide_String;
848       Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
849       return    Unbounded_Wide_String
850    is
851    begin
852       return
853         To_Unbounded_Wide_String
854           (Wide_Fixed.Translate (Source.Reference.all, Mapping));
855    end Translate;
856
857    procedure Translate
858      (Source  : in out Unbounded_Wide_String;
859       Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
860    is
861    begin
862       Wide_Fixed.Translate (Source.Reference.all, Mapping);
863    end Translate;
864
865    ----------
866    -- Trim --
867    ----------
868
869    function Trim
870      (Source : in Unbounded_Wide_String;
871       Side   : in Trim_End)
872       return   Unbounded_Wide_String
873    is
874    begin
875       return
876         To_Unbounded_Wide_String
877           (Wide_Fixed.Trim (Source.Reference.all, Side));
878    end Trim;
879
880    procedure Trim
881      (Source : in out Unbounded_Wide_String;
882       Side   : in Trim_End)
883    is
884       Old : Wide_String_Access := Source.Reference;
885    begin
886       Source.Reference := new Wide_String'(Wide_Fixed.Trim (Old.all, Side));
887       Free (Old);
888    end Trim;
889
890    function Trim
891      (Source : in Unbounded_Wide_String;
892       Left   : in Wide_Maps.Wide_Character_Set;
893       Right  : in Wide_Maps.Wide_Character_Set)
894       return   Unbounded_Wide_String
895    is
896    begin
897       return
898         To_Unbounded_Wide_String
899           (Wide_Fixed.Trim (Source.Reference.all, Left, Right));
900    end Trim;
901
902    procedure Trim
903      (Source : in out Unbounded_Wide_String;
904       Left   : in Wide_Maps.Wide_Character_Set;
905       Right  : in Wide_Maps.Wide_Character_Set)
906    is
907       Old : Wide_String_Access := Source.Reference;
908
909    begin
910       Source.Reference :=
911         new Wide_String'(Wide_Fixed.Trim (Old.all, Left, Right));
912       Free (Old);
913    end Trim;
914
915 end Ada.Strings.Wide_Unbounded;