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-stwima.ads < prev    next >
Text File  |  2000-07-19  |  10KB  |  261 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUN-TIME COMPONENTS                         --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . W I D E _ M A P S                 --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.12 $                             --
  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.Finalization;
  41.  
  42. package Ada.Strings.Wide_Maps is
  43.    pragma Preelaborate (Wide_Maps);
  44.  
  45.    -------------------------------------
  46.    -- Wide Character Set Declarations --
  47.    -------------------------------------
  48.  
  49.    type Wide_Character_Set is private;
  50.    --  Representation for a set of Wide_Character values:
  51.  
  52.    Null_Set : constant Wide_Character_Set;
  53.  
  54.    ------------------------------------------
  55.    -- Constructors for Wide Character Sets --
  56.    ------------------------------------------
  57.  
  58.    type Wide_Character_Range is record
  59.       Low  : Wide_Character;
  60.       High : Wide_Character;
  61.    end record;
  62.    --  Represents Wide_Character range Low .. High
  63.  
  64.    type Wide_Character_Ranges is
  65.      array (Positive range <>) of Wide_Character_Range;
  66.  
  67.    function To_Set
  68.      (Ranges : in Wide_Character_Ranges)
  69.       return   Wide_Character_Set;
  70.  
  71.    function To_Set
  72.      (Span : in Wide_Character_Range)
  73.       return Wide_Character_Set;
  74.  
  75.    function To_Ranges
  76.      (Set :  in Wide_Character_Set)
  77.       return Wide_Character_Ranges;
  78.  
  79.    ---------------------------------------
  80.    -- Operations on Wide Character Sets --
  81.    ---------------------------------------
  82.  
  83.    function "=" (Left, Right : in Wide_Character_Set) return Boolean;
  84.  
  85.    function "not"
  86.      (Right  : in Wide_Character_Set)
  87.       return Wide_Character_Set;
  88.  
  89.    function "and"
  90.      (Left, Right : in Wide_Character_Set)
  91.       return        Wide_Character_Set;
  92.  
  93.    function "or"
  94.      (Left, Right : in Wide_Character_Set)
  95.       return        Wide_Character_Set;
  96.  
  97.    function "xor"
  98.      (Left, Right : in Wide_Character_Set)
  99.       return        Wide_Character_Set;
  100.  
  101.    function "-"
  102.      (Left, Right : in Wide_Character_Set)
  103.       return        Wide_Character_Set;
  104.  
  105.    function Is_In
  106.      (Element : in Wide_Character;
  107.       Set     : in Wide_Character_Set)
  108.       return    Boolean;
  109.  
  110.    function Is_Subset
  111.      (Elements : in Wide_Character_Set;
  112.       Set      : in Wide_Character_Set)
  113.       return     Boolean;
  114.  
  115.    function "<="
  116.      (Left  : in Wide_Character_Set;
  117.       Right : in Wide_Character_Set)
  118.       return  Boolean
  119.    renames Is_Subset;
  120.  
  121.    subtype Wide_Character_Sequence is Wide_String;
  122.    --  Alternative representation for a set of character values
  123.  
  124.    function To_Set
  125.      (Sequence  : in Wide_Character_Sequence)
  126.       return      Wide_Character_Set;
  127.  
  128.    function To_Set
  129.      (Singleton : in Wide_Character)
  130.       return      Wide_Character_Set;
  131.  
  132.    function To_Sequence
  133.      (Set  : in Wide_Character_Set)
  134.       return Wide_Character_Sequence;
  135.  
  136.    -----------------------------------------
  137.    -- Wide Character Mapping Declarations --
  138.    -----------------------------------------
  139.  
  140.    type Wide_Character_Mapping is private;
  141.    --  Representation for a wide character to wide character mapping:
  142.  
  143.    function Value
  144.      (Map     : in Wide_Character_Mapping;
  145.       Element : in Wide_Character)
  146.       return    Wide_Character;
  147.  
  148.    Identity : constant Wide_Character_Mapping;
  149.  
  150.    ---------------------------------
  151.    -- Operations on Wide Mappings --
  152.    ---------------------------------
  153.  
  154.    function To_Mapping
  155.      (From, To : in Wide_Character_Sequence)
  156.       return     Wide_Character_Mapping;
  157.  
  158.    function To_Domain
  159.      (Map  : in Wide_Character_Mapping)
  160.       return Wide_Character_Sequence;
  161.  
  162.    function To_Range
  163.      (Map  : in Wide_Character_Mapping)
  164.       return Wide_Character_Sequence;
  165.  
  166.    type Wide_Character_Mapping_Function is
  167.       access function (From : in Wide_Character) return Wide_Character;
  168.  
  169. private
  170.    package AF renames Ada.Finalization;
  171.  
  172.    ------------------------------------------
  173.    -- Representation of Wide_Character_Set --
  174.    ------------------------------------------
  175.  
  176.    --  A wide character set is represented as a sequence of wide character
  177.    --  ranges (i.e. an object of type Wide_Character_Ranges) in which the
  178.    --  following hold:
  179.  
  180.    --    The lower bound is 1
  181.    --    The ranges are in order by increasing Low values
  182.    --    The ranges are non-overlapping and discontigous
  183.  
  184.    --  A character value is in the set if it is contained in one of the
  185.    --  ranges. The actual Wide_Character_Set value is a controlled pointer
  186.    --  to this Wide_Character_Ranges value. The use of a controlled type
  187.    --  is necessary to prevent storage leaks.
  188.  
  189.    type Wide_Character_Ranges_Access is access all Wide_Character_Ranges;
  190.  
  191.    type Wide_Character_Set is new AF.Controlled with record
  192.       Set : Wide_Character_Ranges_Access;
  193.    end record;
  194.  
  195.    pragma Finalize_Storage_Only (Wide_Character_Set);
  196.    --  This avoids useless finalizations, and, more importantly avoids
  197.    --  incorrect attempts to finalize constants that are statically
  198.    --  declared here and in Ada.Strings.Wide_Maps, which is incorrect.
  199.  
  200.    procedure Initialize (Object : in out Wide_Character_Set);
  201.    procedure Adjust     (Object : in out Wide_Character_Set);
  202.    procedure Finalize   (Object : in out Wide_Character_Set);
  203.  
  204.    Null_Range : aliased constant Wide_Character_Ranges :=
  205.                   (1 .. 0 => (Low => ' ', High => ' '));
  206.  
  207.    Null_Set : constant Wide_Character_Set :=
  208.                 (AF.Controlled with
  209.                  Set => Null_Range'Unrestricted_Access);
  210.  
  211.    ----------------------------------------------
  212.    -- Representation of Wide_Character_Mapping --
  213.    ----------------------------------------------
  214.  
  215.    --  A wide character mapping is represented as two strings of equal
  216.    --  length, where any character appearing in Domain is mapped to the
  217.    --  corresponding character in Rangev. A character not appearing in
  218.    --  Domain is mapped to itself. The characters in Domain are sorted
  219.    --  in ascending order.
  220.  
  221.    --  The actual Wide_Character_Mapping value is a controlled record
  222.    --  that contains a pointer to a discriminated record containing the
  223.    --  range and domain values.
  224.  
  225.    --  Note: this representation is canonical, and the values stored in
  226.    --  Domain and Rangev are exactly the values that are returned by the
  227.    --  functions To_Domain and To_Range. The use of a controlled type is
  228.    --  necessary to prevent storage leaks.
  229.  
  230.    type Wide_Character_Mapping_Values (Length : Natural) is record
  231.       Domain : Wide_Character_Sequence (1 .. Length);
  232.       Rangev : Wide_Character_Sequence (1 .. Length);
  233.    end record;
  234.  
  235.    type Wide_Character_Mapping_Values_Access is
  236.      access all Wide_Character_Mapping_Values;
  237.  
  238.    type Wide_Character_Mapping is new AF.Controlled with record
  239.       Map : Wide_Character_Mapping_Values_Access;
  240.    end record;
  241.  
  242.    pragma Finalize_Storage_Only (Wide_Character_Mapping);
  243.    --  This avoids useless finalizations, and, more importantly avoids
  244.    --  incorrect attempts to finalize constants that are statically
  245.    --  declared here and in Ada.Strings.Wide_Maps, which is incorrect.
  246.  
  247.    procedure Initialize (Object : in out Wide_Character_Mapping);
  248.    procedure Adjust     (Object : in out Wide_Character_Mapping);
  249.    procedure Finalize   (Object : in out Wide_Character_Mapping);
  250.  
  251.    Null_Map : aliased constant Wide_Character_Mapping_Values :=
  252.                  (Length => 0,
  253.                   Domain => "",
  254.                   Rangev => "");
  255.  
  256.    Identity : constant Wide_Character_Mapping :=
  257.                 (AF.Controlled with
  258.                  Map => Null_Map'Unrestricted_Access);
  259.  
  260. end Ada.Strings.Wide_Maps;
  261.