home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada / a-strmap.ads < prev    next >
Text File  |  1996-09-28  |  24KB  |  403 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                     A D A . S T R I N G S . M A P S                      --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.18 $                             --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18. with Ada.Characters.Latin_1;
  19.  
  20. package Ada.Strings.Maps is
  21. pragma Preelaborate (Maps);
  22.  
  23.    use Ada.Characters.Latin_1;
  24.  
  25.    --------------------------------
  26.    -- Character Set Declarations --
  27.    --------------------------------
  28.  
  29.    type Character_Set is private;
  30.    --  Representation for a set of character values:
  31.  
  32.    Null_Set : constant Character_Set;
  33.  
  34.    ---------------------------
  35.    -- Constructors for Sets --
  36.    ---------------------------
  37.  
  38.    type Character_Range is record
  39.       Low  : Character;
  40.       High : Character;
  41.    end record;
  42.    --  Represents Character range Low .. High
  43.  
  44.    type Character_Ranges is array (Positive range <>) of Character_Range;
  45.  
  46.    function To_Set    (Ranges : in Character_Ranges) return Character_Set;
  47.  
  48.    function To_Set    (Span   : in Character_Range)  return Character_Set;
  49.  
  50.    function To_Ranges (Set    : in Character_Set)    return Character_Ranges;
  51.  
  52.    ----------------------------------
  53.    -- Operations on Character Sets --
  54.    ----------------------------------
  55.  
  56.    function "="   (Left, Right : in Character_Set) return Boolean;
  57.  
  58.    function "not" (Right       : in Character_Set) return Character_Set;
  59.    function "and" (Left, Right : in Character_Set) return Character_Set;
  60.    function "or"  (Left, Right : in Character_Set) return Character_Set;
  61.    function "xor" (Left, Right : in Character_Set) return Character_Set;
  62.    function "-"   (Left, Right : in Character_Set) return Character_Set;
  63.  
  64.    function Is_In
  65.      (Element : in Character;
  66.       Set     : in Character_Set)
  67.       return    Boolean;
  68.  
  69.    function Is_Subset
  70.      (Elements : in Character_Set;
  71.       Set      : in Character_Set)
  72.       return     Boolean;
  73.  
  74.    function "<="
  75.      (Left  : in Character_Set;
  76.       Right : in Character_Set)
  77.       return  Boolean
  78.    renames Is_Subset;
  79.  
  80.    subtype Character_Sequence is String;
  81.    --  Alternative representation for a set of character values
  82.  
  83.    function To_Set (Sequence  : in Character_Sequence) return Character_Set;
  84.  
  85.    function To_Set (Singleton : in Character)          return Character_Set;
  86.  
  87.    function To_Sequence (Set : in Character_Set) return Character_Sequence;
  88.  
  89.    ------------------------------------
  90.    -- Character Mapping Declarations --
  91.    ------------------------------------
  92.  
  93.    type Character_Mapping is private;
  94.    --  Representation for a character to character mapping:
  95.  
  96.    function Value
  97.      (Map     : in Character_Mapping;
  98.       Element : in Character)
  99.       return    Character;
  100.  
  101.    Identity : constant Character_Mapping;
  102.  
  103.    ----------------------------
  104.    -- Operations on Mappings --
  105.    ----------------------------
  106.  
  107.    function To_Mapping
  108.      (From, To : in Character_Sequence)
  109.       return     Character_Mapping;
  110.  
  111.    function To_Domain
  112.      (Map  : in Character_Mapping)
  113.       return Character_Sequence;
  114.  
  115.    function To_Range
  116.      (Map  : in Character_Mapping)
  117.       return Character_Sequence;
  118.  
  119.    type Character_Mapping_Function is
  120.       access function (From : in Character) return Character;
  121.  
  122.    ------------------
  123.    -- Private Part --
  124.    ------------------
  125.  
  126. private
  127.    pragma Inline (Is_In);
  128.    pragma Inline (Value);
  129.  
  130.    type Character_Set_Internal is array (Character) of Boolean;
  131.    pragma Pack (Character_Set_Internal);
  132.  
  133.    type Character_Set is new Character_Set_Internal;
  134.    --  Note: the reason for this level of derivation is to make sure
  135.    --  that the predefined logical operations on this type remain
  136.    --  accessible. The operations on Character_Set are overridden by
  137.    --  the defined operations in the spec, but the operations defined
  138.    --  on Character_Set_Internal remain visible.
  139.  
  140.    Null_Set : constant Character_Set := (others => False);
  141.  
  142.    type Character_Mapping is array (Character) of Character;
  143.  
  144.    Identity : constant Character_Mapping :=
  145.      (NUL                         &  -- NUL                             0
  146.       SOH                         &  -- SOH                             1
  147.       STX                         &  -- STX                             2
  148.       ETX                         &  -- ETX                             3
  149.       EOT                         &  -- EOT                             4
  150.       ENQ                         &  -- ENQ                             5
  151.       ACK                         &  -- ACK                             6
  152.       BEL                         &  -- BEL                             7
  153.       BS                          &  -- BS                              8
  154.       HT                          &  -- HT                              9
  155.       LF                          &  -- LF                             10
  156.       VT                          &  -- VT                             11
  157.       FF                          &  -- FF                             12
  158.       CR                          &  -- CR                             13
  159.       SO                          &  -- SO                             14
  160.       SI                          &  -- SI                             15
  161.       DLE                         &  -- DLE                            16
  162.       DC1                         &  -- DC1                            17
  163.       DC2                         &  -- DC2                            18
  164.       DC3                         &  -- DC3                            19
  165.       DC4                         &  -- DC4                            20
  166.       NAK                         &  -- NAK                            21
  167.       SYN                         &  -- SYN                            22
  168.       ETB                         &  -- ETB                            23
  169.       CAN                         &  -- CAN                            24
  170.       EM                          &  -- EM                             25
  171.       SUB                         &  -- SUB                            26
  172.       ESC                         &  -- ESC                            27
  173.       FS                          &  -- FS                             28
  174.       GS                          &  -- GS                             29
  175.       RS                          &  -- RS                             30
  176.       US                          &  -- US                             31
  177.       ' '                         &  -- ' '                            32
  178.       '!'                         &  -- '!'                            33
  179.       '"'                         &  -- '"'                            34
  180.       '#'                         &  -- '#'                            35
  181.       '$'                         &  -- '$'                            36
  182.       '%'                         &  -- '%'                            37
  183.       '&'                         &  -- '&'                            38
  184.       '''                         &  -- '''                            39
  185.       '('                         &  -- '('                            40
  186.       ')'                         &  -- ')'                            41
  187.       '*'                         &  -- '*'                            42
  188.       '+'                         &  -- '+'                            43
  189.       ','                         &  -- ','                            44
  190.       '-'                         &  -- '-'                            45
  191.       '.'                         &  -- '.'                            46
  192.       '/'                         &  -- '/'                            47
  193.       '0'                         &  -- '0'                            48
  194.       '1'                         &  -- '1'                            49
  195.       '2'                         &  -- '2'                            50
  196.       '3'                         &  -- '3'                            51
  197.       '4'                         &  -- '4'                            52
  198.       '5'                         &  -- '5'                            53
  199.       '6'                         &  -- '6'                            54
  200.       '7'                         &  -- '7'                            55
  201.       '8'                         &  -- '8'                            56
  202.       '9'                         &  -- '9'                            57
  203.       ':'                         &  -- ':'                            58
  204.       ';'                         &  -- ';'                            59
  205.       '<'                         &  -- '<'                            60
  206.       '='                         &  -- '='                            61
  207.       '>'                         &  -- '>'                            62
  208.       '?'                         &  -- '?'                            63
  209.       '@'                         &  -- '@'                            64
  210.       'A'                         &  -- 'A'                            65
  211.       'B'                         &  -- 'B'                            66
  212.       'C'                         &  -- 'C'                            67
  213.       'D'                         &  -- 'D'                            68
  214.       'E'                         &  -- 'E'                            69
  215.       'F'                         &  -- 'F'                            70
  216.       'G'                         &  -- 'G'                            71
  217.       'H'                         &  -- 'H'                            72
  218.       'I'                         &  -- 'I'                            73
  219.       'J'                         &  -- 'J'                            74
  220.       'K'                         &  -- 'K'                            75
  221.       'L'                         &  -- 'L'                            76
  222.       'M'                         &  -- 'M'                            77
  223.       'N'                         &  -- 'N'                            78
  224.       'O'                         &  -- 'O'                            79
  225.       'P'                         &  -- 'P'                            80
  226.       'Q'                         &  -- 'Q'                            81
  227.       'R'                         &  -- 'R'                            82
  228.       'S'                         &  -- 'S'                            83
  229.       'T'                         &  -- 'T'                            84
  230.       'U'                         &  -- 'U'                            85
  231.       'V'                         &  -- 'V'                            86
  232.       'W'                         &  -- 'W'                            87
  233.       'X'                         &  -- 'X'                            88
  234.       'Y'                         &  -- 'Y'                            89
  235.       'Z'                         &  -- 'Z'                            90
  236.       '['                         &  -- '['                            91
  237.       '\'                         &  -- '\'                            92
  238.       ']'                         &  -- ']'                            93
  239.       '^'                         &  -- '^'                            94
  240.       '_'                         &  -- '_'                            95
  241.       '`'                         &  -- '`'                            96
  242.       'a'                         &  -- 'a'                            97
  243.       'b'                         &  -- 'b'                            98
  244.       'c'                         &  -- 'c'                            99
  245.       'd'                         &  -- 'd'                           100
  246.       'e'                         &  -- 'e'                           101
  247.       'f'                         &  -- 'f'                           102
  248.       'g'                         &  -- 'g'                           103
  249.       'h'                         &  -- 'h'                           104
  250.       'i'                         &  -- 'i'                           105
  251.       'j'                         &  -- 'j'                           106
  252.       'k'                         &  -- 'k'                           107
  253.       'l'                         &  -- 'l'                           108
  254.       'm'                         &  -- 'm'                           109
  255.       'n'                         &  -- 'n'                           110
  256.       'o'                         &  -- 'o'                           111
  257.       'p'                         &  -- 'p'                           112
  258.       'q'                         &  -- 'q'                           113
  259.       'r'                         &  -- 'r'                           114
  260.       's'                         &  -- 's'                           115
  261.       't'                         &  -- 't'                           116
  262.       'u'                         &  -- 'u'                           117
  263.       'v'                         &  -- 'v'                           118
  264.       'w'                         &  -- 'w'                           119
  265.       'x'                         &  -- 'x'                           120
  266.       'y'                         &  -- 'y'                           121
  267.       'z'                         &  -- 'z'                           122
  268.       '{'                         &  -- '{'                           123
  269.       '|'                         &  -- '|'                           124
  270.       '}'                         &  -- '}'                           125
  271.       '~'                         &  -- '~'                           126
  272.       DEL                         &  -- DEL                           127
  273.       Reserved_128                &  -- Reserved_128                  128
  274.       Reserved_129                &  -- Reserved_129                  129
  275.       BPH                         &  -- BPH                           130
  276.       NBH                         &  -- NBH                           131
  277.       Reserved_132                &  -- Reserved_132                  132
  278.       NEL                         &  -- NEL                           133
  279.       SSA                         &  -- SSA                           134
  280.       ESA                         &  -- ESA                           135
  281.       HTS                         &  -- HTS                           136
  282.       HTJ                         &  -- HTJ                           137
  283.       VTS                         &  -- VTS                           138
  284.       PLD                         &  -- PLD                           139
  285.       PLU                         &  -- PLU                           140
  286.       RI                          &  -- RI                            141
  287.       SS2                         &  -- SS2                           142
  288.       SS3                         &  -- SS3                           143
  289.       DCS                         &  -- DCS                           144
  290.       PU1                         &  -- PU1                           145
  291.       PU2                         &  -- PU2                           146
  292.       STS                         &  -- STS                           147
  293.       CCH                         &  -- CCH                           148
  294.       MW                          &  -- MW                            149
  295.       SPA                         &  -- SPA                           150
  296.       EPA                         &  -- EPA                           151
  297.       SOS                         &  -- SOS                           152
  298.       Reserved_153                &  -- Reserved_153                  153
  299.       SCI                         &  -- SCI                           154
  300.       CSI                         &  -- CSI                           155
  301.       ST                          &  -- ST                            156
  302.       OSC                         &  -- OSC                           157
  303.       PM                          &  -- PM                            158
  304.       APC                         &  -- APC                           159
  305.       No_Break_Space              &  -- No_Break_Space                160
  306.       Inverted_Exclamation        &  -- Inverted_Exclamation          161
  307.       Cent_Sign                   &  -- Cent_Sign                     162
  308.       Pound_Sign                  &  -- Pound_Sign                    163
  309.       Currency_Sign               &  -- Currency_Sign                 164
  310.       Yen_Sign                    &  -- Yen_Sign                      165
  311.       Broken_Bar                  &  -- Broken_Bar                    166
  312.       Section_Sign                &  -- Section_Sign                  167
  313.       Diaeresis                   &  -- Diaeresis                     168
  314.       Copyright_Sign              &  -- Copyright_Sign                169
  315.       Feminine_Ordinal_Indicator  &  -- Feminine_Ordinal_Indicator    170
  316.       Left_Angle_Quotation        &  -- Left_Angle_Quotation          171
  317.       Not_Sign                    &  -- Not_Sign                      172
  318.       Soft_Hyphen                 &  -- Soft_Hyphen                   173
  319.       Registered_Trade_Mark_Sign  &  -- Registered_Trade_Mark_Sign    174
  320.       Macron                      &  -- Macron                        175
  321.       Degree_Sign                 &  -- Degree_Sign                   176
  322.       Plus_Minus_Sign             &  -- Plus_Minus_Sign               177
  323.       Superscript_Two             &  -- Superscript_Two               178
  324.       Superscript_Three           &  -- Superscript_Three             179
  325.       Acute                       &  -- Acute                         180
  326.       Micro_Sign                  &  -- Micro_Sign                    181
  327.       Pilcrow_Sign                &  -- Pilcrow_Sign                  182
  328.       Middle_Dot                  &  -- Middle_Dot                    183
  329.       Cedilla                     &  -- Cedilla                       184
  330.       Superscript_One             &  -- Superscript_One               185
  331.       Masculine_Ordinal_Indicator &  -- Masculine_Ordinal_Indicator   186
  332.       Right_Angle_Quotation       &  -- Right_Angle_Quotation         187
  333.       Fraction_One_Quarter        &  -- Fraction_One_Quarter          188
  334.       Fraction_One_Half           &  -- Fraction_One_Half             189
  335.       Fraction_Three_Quarters     &  -- Fraction_Three_Quarters       190
  336.       Inverted_Question           &  -- Inverted_Question             191
  337.       UC_A_Grave                  &  -- UC_A_Grave                    192
  338.       UC_A_Acute                  &  -- UC_A_Acute                    193
  339.       UC_A_Circumflex             &  -- UC_A_Circumflex               194
  340.       UC_A_Tilde                  &  -- UC_A_Tilde                    195
  341.       UC_A_Diaeresis              &  -- UC_A_Diaeresis                196
  342.       UC_A_Ring                   &  -- UC_A_Ring                     197
  343.       UC_AE_Diphthong             &  -- UC_AE_Diphthong               198
  344.       UC_C_Cedilla                &  -- UC_C_Cedilla                  199
  345.       UC_E_Grave                  &  -- UC_E_Grave                    200
  346.       UC_E_Acute                  &  -- UC_E_Acute                    201
  347.       UC_E_Circumflex             &  -- UC_E_Circumflex               202
  348.       UC_E_Diaeresis              &  -- UC_E_Diaeresis                203
  349.       UC_I_Grave                  &  -- UC_I_Grave                    204
  350.       UC_I_Acute                  &  -- UC_I_Acute                    205
  351.       UC_I_Circumflex             &  -- UC_I_Circumflex               206
  352.       UC_I_Diaeresis              &  -- UC_I_Diaeresis                207
  353.       UC_Icelandic_Eth            &  -- UC_Icelandic_Eth              208
  354.       UC_N_Tilde                  &  -- UC_N_Tilde                    209
  355.       UC_O_Grave                  &  -- UC_O_Grave                    210
  356.       UC_O_Acute                  &  -- UC_O_Acute                    211
  357.       UC_O_Circumflex             &  -- UC_O_Circumflex               212
  358.       UC_O_Tilde                  &  -- UC_O_Tilde                    213
  359.       UC_O_Diaeresis              &  -- UC_O_Diaeresis                214
  360.       Multiplication_Sign         &  -- Multiplication_Sign           215
  361.       UC_O_Oblique_Stroke         &  -- UC_O_Oblique_Stroke           216
  362.       UC_U_Grave                  &  -- UC_U_Grave                    217
  363.       UC_U_Acute                  &  -- UC_U_Acute                    218
  364.       UC_U_Circumflex             &  -- UC_U_Circumflex               219
  365.       UC_U_Diaeresis              &  -- UC_U_Diaeresis                220
  366.       UC_Y_Acute                  &  -- UC_Y_Acute                    221
  367.       UC_Icelandic_Thorn          &  -- UC_Icelandic_Thorn            222
  368.       LC_German_Sharp_S           &  -- LC_German_Sharp_S             223
  369.       LC_A_Grave                  &  -- LC_A_Grave                    224
  370.       LC_A_Acute                  &  -- LC_A_Acute                    225
  371.       LC_A_Circumflex             &  -- LC_A_Circumflex               226
  372.       LC_A_Tilde                  &  -- LC_A_Tilde                    227
  373.       LC_A_Diaeresis              &  -- LC_A_Diaeresis                228
  374.       LC_A_Ring                   &  -- LC_A_Ring                     229
  375.       LC_AE_Diphthong             &  -- LC_AE_Diphthong               230
  376.       LC_C_Cedilla                &  -- LC_C_Cedilla                  231
  377.       LC_E_Grave                  &  -- LC_E_Grave                    232
  378.       LC_E_Acute                  &  -- LC_E_Acute                    233
  379.       LC_E_Circumflex             &  -- LC_E_Circumflex               234
  380.       LC_E_Diaeresis              &  -- LC_E_Diaeresis                235
  381.       LC_I_Grave                  &  -- LC_I_Grave                    236
  382.       LC_I_Acute                  &  -- LC_I_Acute                    237
  383.       LC_I_Circumflex             &  -- LC_I_Circumflex               238
  384.       LC_I_Diaeresis              &  -- LC_I_Diaeresis                239
  385.       LC_Icelandic_Eth            &  -- LC_Icelandic_Eth              240
  386.       LC_N_Tilde                  &  -- LC_N_Tilde                    241
  387.       LC_O_Grave                  &  -- LC_O_Grave                    242
  388.       LC_O_Acute                  &  -- LC_O_Acute                    243
  389.       LC_O_Circumflex             &  -- LC_O_Circumflex               244
  390.       LC_O_Tilde                  &  -- LC_O_Tilde                    245
  391.       LC_O_Diaeresis              &  -- LC_O_Diaeresis                246
  392.       Division_Sign               &  -- Division_Sign                 247
  393.       LC_O_Oblique_Stroke         &  -- LC_O_Oblique_Stroke           248
  394.       LC_U_Grave                  &  -- LC_U_Grave                    249
  395.       LC_U_Acute                  &  -- LC_U_Acute                    250
  396.       LC_U_Circumflex             &  -- LC_U_Circumflex               251
  397.       LC_U_Diaeresis              &  -- LC_U_Diaeresis                252
  398.       LC_Y_Acute                  &  -- LC_Y_Acute                    253
  399.       LC_Icelandic_Thorn          &  -- LC_Icelandic_Thorn            254
  400.       LC_Y_Diaeresis);               -- LC_Y_Diaeresis                255
  401.  
  402. end Ada.Strings.Maps;
  403.