OSDN Git Service

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