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-strunb.ads < prev    next >
Text File  |  2000-07-19  |  12KB  |  384 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUN-TIME COMPONENTS                         --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . U N B O U N D E D                 --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.20 $                              --
  10. --                                                                          --
  11. --          Copyright (C) 1992-1998 Free Software Foundation, Inc.          --
  12. --                                                                          --
  13. -- This specification is derived from the Ada Reference Manual for use with --
  14. -- GNAT. The copyright notice above, and the license provisions that follow --
  15. -- apply solely to the  contents of the part following the private keyword. --
  16. --                                                                          --
  17. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  18. -- terms of the  GNU General Public License as published  by the Free Soft- --
  19. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  20. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  21. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  22. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  23. -- for  more details.  You should have  received  a copy of the GNU General --
  24. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  25. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  26. -- MA 02111-1307, USA.                                                      --
  27. --                                                                          --
  28. -- As a special exception,  if other files  instantiate  generics from this --
  29. -- unit, or you link  this unit with other files  to produce an executable, --
  30. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  31. -- covered  by the  GNU  General  Public  License.  This exception does not --
  32. -- however invalidate  any other reasons why  the executable file  might be --
  33. -- covered by the  GNU Public License.                                      --
  34. --                                                                          --
  35. -- GNAT was originally developed  by the GNAT team at  New York University. --
  36. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  37. --                                                                          --
  38. ------------------------------------------------------------------------------
  39.  
  40. with Ada.Strings.Maps;
  41. with Ada.Finalization;
  42.  
  43. package Ada.Strings.Unbounded is
  44. pragma Preelaborate (Unbounded);
  45.  
  46.    type Unbounded_String is private;
  47.  
  48.    Null_Unbounded_String : constant Unbounded_String;
  49.  
  50.    function Length (Source : Unbounded_String) return Natural;
  51.  
  52.    type String_Access is access all String;
  53.  
  54.    procedure Free (X : in out String_Access);
  55.  
  56.    --------------------------------------------------------
  57.    -- Conversion, Concatenation, and Selection Functions --
  58.    --------------------------------------------------------
  59.  
  60.    function To_Unbounded_String (Source : String)     return Unbounded_String;
  61.    function To_Unbounded_String (Length : in Natural) return Unbounded_String;
  62.  
  63.    function To_String (Source : Unbounded_String) return String;
  64.  
  65.    procedure Append
  66.      (Source   : in out Unbounded_String;
  67.       New_Item : in Unbounded_String);
  68.  
  69.    procedure Append
  70.      (Source   : in out Unbounded_String;
  71.       New_Item : in String);
  72.  
  73.    procedure Append
  74.      (Source   : in out Unbounded_String;
  75.       New_Item : in Character);
  76.  
  77.    function "&" (Left, Right : Unbounded_String) return Unbounded_String;
  78.  
  79.    function "&"
  80.      (Left  : in Unbounded_String;
  81.       Right : in String)
  82.       return  Unbounded_String;
  83.  
  84.    function "&"
  85.      (Left  : in String;
  86.       Right : in Unbounded_String)
  87.       return  Unbounded_String;
  88.  
  89.    function "&"
  90.      (Left  : in Unbounded_String;
  91.       Right : in Character)
  92.       return  Unbounded_String;
  93.  
  94.    function "&"
  95.      (Left  : in Character;
  96.       Right : in Unbounded_String)
  97.       return  Unbounded_String;
  98.  
  99.    function Element
  100.      (Source : in Unbounded_String;
  101.       Index  : in Positive)
  102.       return   Character;
  103.  
  104.    procedure Replace_Element
  105.      (Source : in out Unbounded_String;
  106.       Index  : in Positive;
  107.       By     : Character);
  108.  
  109.    function Slice
  110.      (Source : in Unbounded_String;
  111.       Low    : in Positive;
  112.       High   : in Natural)
  113.       return   String;
  114.  
  115.    function "=" (Left, Right : in Unbounded_String) return Boolean;
  116.  
  117.    function "="
  118.      (Left  : in Unbounded_String;
  119.       Right : in String)
  120.       return  Boolean;
  121.  
  122.    function "="
  123.      (Left  : in String;
  124.       Right : in Unbounded_String)
  125.       return  Boolean;
  126.  
  127.    function "<" (Left, Right : in Unbounded_String) return Boolean;
  128.  
  129.    function "<"
  130.      (Left  : in Unbounded_String;
  131.       Right : in String)
  132.       return  Boolean;
  133.  
  134.    function "<"
  135.      (Left  : in String;
  136.       Right : in Unbounded_String)
  137.       return  Boolean;
  138.  
  139.    function "<=" (Left, Right : in Unbounded_String) return Boolean;
  140.  
  141.    function "<="
  142.      (Left  : in Unbounded_String;
  143.       Right : in String)
  144.       return  Boolean;
  145.  
  146.    function "<="
  147.      (Left  : in String;
  148.       Right : in Unbounded_String)
  149.       return  Boolean;
  150.  
  151.    function ">" (Left, Right : in Unbounded_String) return Boolean;
  152.  
  153.    function ">"
  154.      (Left  : in Unbounded_String;
  155.       Right : in String)
  156.       return  Boolean;
  157.  
  158.    function ">"
  159.      (Left  : in String;
  160.       Right : in Unbounded_String)
  161.       return  Boolean;
  162.  
  163.    function ">=" (Left, Right : in Unbounded_String) return Boolean;
  164.  
  165.    function ">="
  166.      (Left  : in Unbounded_String;
  167.       Right : in String)
  168.       return  Boolean;
  169.  
  170.    function ">="
  171.      (Left  : in String;
  172.       Right : in Unbounded_String)
  173.       return  Boolean;
  174.  
  175.    ------------------------
  176.    -- Search Subprograms --
  177.    ------------------------
  178.  
  179.    function Index
  180.      (Source   : in Unbounded_String;
  181.       Pattern  : in String;
  182.       Going    : in Direction := Forward;
  183.       Mapping  : in Maps.Character_Mapping := Maps.Identity)
  184.       return     Natural;
  185.  
  186.    function Index
  187.      (Source   : in Unbounded_String;
  188.       Pattern  : in String;
  189.       Going    : in Direction := Forward;
  190.       Mapping  : in Maps.Character_Mapping_Function)
  191.       return     Natural;
  192.  
  193.    function Index
  194.      (Source : in Unbounded_String;
  195.       Set    : in Maps.Character_Set;
  196.       Test   : in Membership := Inside;
  197.       Going  : in Direction  := Forward)
  198.       return   Natural;
  199.  
  200.    function Index_Non_Blank
  201.      (Source : in Unbounded_String;
  202.       Going  : in Direction := Forward)
  203.       return   Natural;
  204.  
  205.    function Count
  206.      (Source  : in Unbounded_String;
  207.       Pattern : in String;
  208.       Mapping : in Maps.Character_Mapping := Maps.Identity)
  209.       return    Natural;
  210.  
  211.    function Count
  212.      (Source   : in Unbounded_String;
  213.       Pattern  : in String;
  214.       Mapping  : in Maps.Character_Mapping_Function)
  215.       return     Natural;
  216.  
  217.    function Count
  218.      (Source : in Unbounded_String;
  219.       Set    : in Maps.Character_Set)
  220.       return   Natural;
  221.  
  222.    procedure Find_Token
  223.      (Source : in Unbounded_String;
  224.       Set    : in Maps.Character_Set;
  225.       Test   : in Membership;
  226.       First  : out Positive;
  227.       Last   : out Natural);
  228.  
  229.    ------------------------------------
  230.    -- String Translation Subprograms --
  231.    ------------------------------------
  232.  
  233.    function Translate
  234.      (Source  : in Unbounded_String;
  235.       Mapping : in Maps.Character_Mapping)
  236.       return    Unbounded_String;
  237.  
  238.    procedure Translate
  239.      (Source  : in out Unbounded_String;
  240.       Mapping : Maps.Character_Mapping);
  241.  
  242.    function Translate
  243.      (Source  : in Unbounded_String;
  244.       Mapping : in Maps.Character_Mapping_Function)
  245.       return    Unbounded_String;
  246.  
  247.    procedure Translate
  248.      (Source  : in out Unbounded_String;
  249.       Mapping : in Maps.Character_Mapping_Function);
  250.  
  251.    ---------------------------------------
  252.    -- String Transformation Subprograms --
  253.    ---------------------------------------
  254.  
  255.    function Replace_Slice
  256.      (Source : in Unbounded_String;
  257.       Low    : in Positive;
  258.       High   : in Natural;
  259.       By     : in String)
  260.       return   Unbounded_String;
  261.  
  262.    procedure Replace_Slice
  263.      (Source   : in out Unbounded_String;
  264.       Low      : in Positive;
  265.       High     : in Natural;
  266.       By       : in String);
  267.  
  268.    function Insert
  269.      (Source   : in Unbounded_String;
  270.       Before   : in Positive;
  271.       New_Item : in String)
  272.       return     Unbounded_String;
  273.  
  274.    procedure Insert
  275.      (Source   : in out Unbounded_String;
  276.       Before   : in Positive;
  277.       New_Item : in String);
  278.  
  279.    function Overwrite
  280.      (Source   : in Unbounded_String;
  281.       Position : in Positive;
  282.       New_Item : in String)
  283.       return     Unbounded_String;
  284.  
  285.    procedure Overwrite
  286.      (Source    : in out Unbounded_String;
  287.       Position  : in Positive;
  288.       New_Item  : in String);
  289.  
  290.    function Delete
  291.      (Source  : in Unbounded_String;
  292.       From    : in Positive;
  293.       Through : in Natural)
  294.       return    Unbounded_String;
  295.  
  296.    procedure Delete
  297.      (Source  : in out Unbounded_String;
  298.       From    : in Positive;
  299.       Through : in Natural);
  300.  
  301.    function Trim
  302.      (Source : in Unbounded_String;
  303.       Side   : in Trim_End)
  304.       return   Unbounded_String;
  305.  
  306.    procedure Trim
  307.      (Source : in out Unbounded_String;
  308.       Side   : in Trim_End);
  309.  
  310.    function Trim
  311.      (Source : in Unbounded_String;
  312.       Left   : in Maps.Character_Set;
  313.       Right  : in Maps.Character_Set)
  314.       return   Unbounded_String;
  315.  
  316.    procedure Trim
  317.      (Source : in out Unbounded_String;
  318.       Left   : in Maps.Character_Set;
  319.       Right  : in Maps.Character_Set);
  320.  
  321.    function Head
  322.      (Source : in Unbounded_String;
  323.       Count  : in Natural;
  324.       Pad    : in Character := Space)
  325.       return   Unbounded_String;
  326.  
  327.    procedure Head
  328.      (Source : in out Unbounded_String;
  329.       Count  : in Natural;
  330.       Pad    : in Character := Space);
  331.  
  332.    function Tail
  333.      (Source : in Unbounded_String;
  334.       Count  : in Natural;
  335.       Pad    : in Character := Space)
  336.       return   Unbounded_String;
  337.  
  338.    procedure Tail
  339.      (Source : in out Unbounded_String;
  340.       Count  : in Natural;
  341.       Pad    : in Character := Space);
  342.  
  343.    function "*"
  344.      (Left  : in Natural;
  345.       Right : in Character)
  346.       return  Unbounded_String;
  347.  
  348.    function "*"
  349.      (Left  : in Natural;
  350.       Right : in String)
  351.       return  Unbounded_String;
  352.  
  353.    function "*"
  354.      (Left  : in Natural;
  355.       Right : in Unbounded_String)
  356.       return  Unbounded_String;
  357.  
  358. private
  359.    pragma Inline (Length);
  360.  
  361.    package AF renames Ada.Finalization;
  362.  
  363.    Null_String : aliased String := "";
  364.  
  365.    function To_Unbounded (S : String) return Unbounded_String
  366.      renames To_Unbounded_String;
  367.  
  368.    type Unbounded_String is new AF.Controlled with record
  369.       Reference : String_Access := Null_String'Access;
  370.    end record;
  371.  
  372.    pragma Stream_Convert (Unbounded_String, To_Unbounded, To_String);
  373.  
  374.    pragma Finalize_Storage_Only (Unbounded_String);
  375.  
  376.    procedure Initialize (Object : in out Unbounded_String);
  377.    procedure Adjust     (Object : in out Unbounded_String);
  378.    procedure Finalize   (Object : in out Unbounded_String);
  379.  
  380.    Null_Unbounded_String : constant Unbounded_String :=
  381.      (AF.Controlled with Reference => Null_String'Access);
  382.  
  383. end Ada.Strings.Unbounded;
  384.