home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / a-stwiun.adb < prev    next >
Text File  |  2000-07-19  |  23KB  |  859 lines

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