1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . M A P S --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
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. --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception, --
24 -- version 3.1, as published by the Free Software Foundation. --
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/>. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
34 ------------------------------------------------------------------------------
36 with Ada
.Characters
.Latin_1
;
38 package Ada
.Strings
.Maps
is
41 -- In accordance with Ada 2005 AI-362
43 --------------------------------
44 -- Character Set Declarations --
45 --------------------------------
47 type Character_Set
is private;
48 pragma Preelaborable_Initialization
(Character_Set
);
49 -- Representation for a set of character values:
51 Null_Set
: constant Character_Set
;
53 ---------------------------
54 -- Constructors for Sets --
55 ---------------------------
57 type Character_Range
is record
61 -- Represents Character range Low .. High
63 type Character_Ranges
is array (Positive range <>) of Character_Range
;
65 function To_Set
(Ranges
: Character_Ranges
) return Character_Set
;
67 function To_Set
(Span
: Character_Range
) return Character_Set
;
69 function To_Ranges
(Set
: Character_Set
) return Character_Ranges
;
71 ----------------------------------
72 -- Operations on Character Sets --
73 ----------------------------------
75 function "=" (Left
, Right
: Character_Set
) return Boolean;
77 function "not" (Right
: Character_Set
) return Character_Set
;
78 function "and" (Left
, Right
: Character_Set
) return Character_Set
;
79 function "or" (Left
, Right
: Character_Set
) return Character_Set
;
80 function "xor" (Left
, Right
: Character_Set
) return Character_Set
;
81 function "-" (Left
, Right
: Character_Set
) return Character_Set
;
85 Set
: Character_Set
) return Boolean;
88 (Elements
: Character_Set
;
89 Set
: Character_Set
) return Boolean;
92 (Left
: Character_Set
;
93 Right
: Character_Set
) return Boolean
96 subtype Character_Sequence
is String;
97 -- Alternative representation for a set of character values
99 function To_Set
(Sequence
: Character_Sequence
) return Character_Set
;
100 function To_Set
(Singleton
: Character) return Character_Set
;
102 function To_Sequence
(Set
: Character_Set
) return Character_Sequence
;
104 ------------------------------------
105 -- Character Mapping Declarations --
106 ------------------------------------
108 type Character_Mapping
is private;
109 pragma Preelaborable_Initialization
(Character_Mapping
);
110 -- Representation for a character to character mapping:
113 (Map
: Character_Mapping
;
114 Element
: Character) return Character;
116 Identity
: constant Character_Mapping
;
118 ----------------------------
119 -- Operations on Mappings --
120 ----------------------------
123 (From
, To
: Character_Sequence
) return Character_Mapping
;
126 (Map
: Character_Mapping
) return Character_Sequence
;
129 (Map
: Character_Mapping
) return Character_Sequence
;
131 type Character_Mapping_Function
is
132 access function (From
: Character) return Character;
135 pragma Inline
(Is_In
);
136 pragma Inline
(Value
);
138 type Character_Set_Internal
is array (Character) of Boolean;
139 pragma Pack
(Character_Set_Internal
);
141 type Character_Set
is new Character_Set_Internal
;
142 -- Note: the reason for this level of derivation is to make sure
143 -- that the predefined logical operations on this type remain
144 -- accessible. The operations on Character_Set are overridden by
145 -- the defined operations in the spec, but the operations defined
146 -- on Character_Set_Internal remain visible.
148 Null_Set
: constant Character_Set
:= (others => False);
150 type Character_Mapping
is array (Character) of Character;
152 package L
renames Ada
.Characters
.Latin_1
;
154 Identity
: constant Character_Mapping
:=
188 L
.Exclamation
& -- '!' 33
189 L
.Quotation
& -- '"' 34
190 L
.Number_Sign
& -- '#' 35
191 L
.Dollar_Sign
& -- '$' 36
192 L
.Percent_Sign
& -- '%' 37
193 L
.Ampersand
& -- '&' 38
194 L
.Apostrophe
& -- ''' 39
195 L
.Left_Parenthesis
& -- '(' 40
196 L
.Right_Parenthesis
& -- ')' 41
197 L
.Asterisk
& -- '*' 42
198 L
.Plus_Sign
& -- '+' 43
201 L
.Full_Stop
& -- '.' 46
202 L
.Solidus
& -- '/' 47
214 L
.Semicolon
& -- ';' 59
215 L
.Less_Than_Sign
& -- '<' 60
216 L
.Equals_Sign
& -- '=' 61
217 L
.Greater_Than_Sign
& -- '>' 62
218 L
.Question
& -- '?' 63
219 L
.Commercial_At
& -- '@' 64
246 L
.Left_Square_Bracket
& -- '[' 91
247 L
.Reverse_Solidus
& -- '\' 92
248 L
.Right_Square_Bracket
& -- ']' 93
249 L
.Circumflex
& -- '^' 94
250 L
.Low_Line
& -- '_' 95
278 L
.Left_Curly_Bracket
& -- '{' 123
279 L
.Vertical_Line
& -- '|' 124
280 L
.Right_Curly_Bracket
& -- '}' 125
283 L
.Reserved_128
& -- Reserved_128 128
284 L
.Reserved_129
& -- Reserved_129 129
287 L
.Reserved_132
& -- Reserved_132 132
308 L
.Reserved_153
& -- Reserved_153 153
315 L
.No_Break_Space
& -- No_Break_Space 160
316 L
.Inverted_Exclamation
& -- Inverted_Exclamation 161
317 L
.Cent_Sign
& -- Cent_Sign 162
318 L
.Pound_Sign
& -- Pound_Sign 163
319 L
.Currency_Sign
& -- Currency_Sign 164
320 L
.Yen_Sign
& -- Yen_Sign 165
321 L
.Broken_Bar
& -- Broken_Bar 166
322 L
.Section_Sign
& -- Section_Sign 167
323 L
.Diaeresis
& -- Diaeresis 168
324 L
.Copyright_Sign
& -- Copyright_Sign 169
325 L
.Feminine_Ordinal_Indicator
& -- Feminine_Ordinal_Indicator 170
326 L
.Left_Angle_Quotation
& -- Left_Angle_Quotation 171
327 L
.Not_Sign
& -- Not_Sign 172
328 L
.Soft_Hyphen
& -- Soft_Hyphen 173
329 L
.Registered_Trade_Mark_Sign
& -- Registered_Trade_Mark_Sign 174
330 L
.Macron
& -- Macron 175
331 L
.Degree_Sign
& -- Degree_Sign 176
332 L
.Plus_Minus_Sign
& -- Plus_Minus_Sign 177
333 L
.Superscript_Two
& -- Superscript_Two 178
334 L
.Superscript_Three
& -- Superscript_Three 179
335 L
.Acute
& -- Acute 180
336 L
.Micro_Sign
& -- Micro_Sign 181
337 L
.Pilcrow_Sign
& -- Pilcrow_Sign 182
338 L
.Middle_Dot
& -- Middle_Dot 183
339 L
.Cedilla
& -- Cedilla 184
340 L
.Superscript_One
& -- Superscript_One 185
341 L
.Masculine_Ordinal_Indicator
& -- Masculine_Ordinal_Indicator 186
342 L
.Right_Angle_Quotation
& -- Right_Angle_Quotation 187
343 L
.Fraction_One_Quarter
& -- Fraction_One_Quarter 188
344 L
.Fraction_One_Half
& -- Fraction_One_Half 189
345 L
.Fraction_Three_Quarters
& -- Fraction_Three_Quarters 190
346 L
.Inverted_Question
& -- Inverted_Question 191
347 L
.UC_A_Grave
& -- UC_A_Grave 192
348 L
.UC_A_Acute
& -- UC_A_Acute 193
349 L
.UC_A_Circumflex
& -- UC_A_Circumflex 194
350 L
.UC_A_Tilde
& -- UC_A_Tilde 195
351 L
.UC_A_Diaeresis
& -- UC_A_Diaeresis 196
352 L
.UC_A_Ring
& -- UC_A_Ring 197
353 L
.UC_AE_Diphthong
& -- UC_AE_Diphthong 198
354 L
.UC_C_Cedilla
& -- UC_C_Cedilla 199
355 L
.UC_E_Grave
& -- UC_E_Grave 200
356 L
.UC_E_Acute
& -- UC_E_Acute 201
357 L
.UC_E_Circumflex
& -- UC_E_Circumflex 202
358 L
.UC_E_Diaeresis
& -- UC_E_Diaeresis 203
359 L
.UC_I_Grave
& -- UC_I_Grave 204
360 L
.UC_I_Acute
& -- UC_I_Acute 205
361 L
.UC_I_Circumflex
& -- UC_I_Circumflex 206
362 L
.UC_I_Diaeresis
& -- UC_I_Diaeresis 207
363 L
.UC_Icelandic_Eth
& -- UC_Icelandic_Eth 208
364 L
.UC_N_Tilde
& -- UC_N_Tilde 209
365 L
.UC_O_Grave
& -- UC_O_Grave 210
366 L
.UC_O_Acute
& -- UC_O_Acute 211
367 L
.UC_O_Circumflex
& -- UC_O_Circumflex 212
368 L
.UC_O_Tilde
& -- UC_O_Tilde 213
369 L
.UC_O_Diaeresis
& -- UC_O_Diaeresis 214
370 L
.Multiplication_Sign
& -- Multiplication_Sign 215
371 L
.UC_O_Oblique_Stroke
& -- UC_O_Oblique_Stroke 216
372 L
.UC_U_Grave
& -- UC_U_Grave 217
373 L
.UC_U_Acute
& -- UC_U_Acute 218
374 L
.UC_U_Circumflex
& -- UC_U_Circumflex 219
375 L
.UC_U_Diaeresis
& -- UC_U_Diaeresis 220
376 L
.UC_Y_Acute
& -- UC_Y_Acute 221
377 L
.UC_Icelandic_Thorn
& -- UC_Icelandic_Thorn 222
378 L
.LC_German_Sharp_S
& -- LC_German_Sharp_S 223
379 L
.LC_A_Grave
& -- LC_A_Grave 224
380 L
.LC_A_Acute
& -- LC_A_Acute 225
381 L
.LC_A_Circumflex
& -- LC_A_Circumflex 226
382 L
.LC_A_Tilde
& -- LC_A_Tilde 227
383 L
.LC_A_Diaeresis
& -- LC_A_Diaeresis 228
384 L
.LC_A_Ring
& -- LC_A_Ring 229
385 L
.LC_AE_Diphthong
& -- LC_AE_Diphthong 230
386 L
.LC_C_Cedilla
& -- LC_C_Cedilla 231
387 L
.LC_E_Grave
& -- LC_E_Grave 232
388 L
.LC_E_Acute
& -- LC_E_Acute 233
389 L
.LC_E_Circumflex
& -- LC_E_Circumflex 234
390 L
.LC_E_Diaeresis
& -- LC_E_Diaeresis 235
391 L
.LC_I_Grave
& -- LC_I_Grave 236
392 L
.LC_I_Acute
& -- LC_I_Acute 237
393 L
.LC_I_Circumflex
& -- LC_I_Circumflex 238
394 L
.LC_I_Diaeresis
& -- LC_I_Diaeresis 239
395 L
.LC_Icelandic_Eth
& -- LC_Icelandic_Eth 240
396 L
.LC_N_Tilde
& -- LC_N_Tilde 241
397 L
.LC_O_Grave
& -- LC_O_Grave 242
398 L
.LC_O_Acute
& -- LC_O_Acute 243
399 L
.LC_O_Circumflex
& -- LC_O_Circumflex 244
400 L
.LC_O_Tilde
& -- LC_O_Tilde 245
401 L
.LC_O_Diaeresis
& -- LC_O_Diaeresis 246
402 L
.Division_Sign
& -- Division_Sign 247
403 L
.LC_O_Oblique_Stroke
& -- LC_O_Oblique_Stroke 248
404 L
.LC_U_Grave
& -- LC_U_Grave 249
405 L
.LC_U_Acute
& -- LC_U_Acute 250
406 L
.LC_U_Circumflex
& -- LC_U_Circumflex 251
407 L
.LC_U_Diaeresis
& -- LC_U_Diaeresis 252
408 L
.LC_Y_Acute
& -- LC_Y_Acute 253
409 L
.LC_Icelandic_Thorn
& -- LC_Icelandic_Thorn 254
410 L
.LC_Y_Diaeresis
); -- LC_Y_Diaeresis 255
412 end Ada
.Strings
.Maps
;