File : a-strmap.ads


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