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