1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . W I D E _ W I D E _ M A P S --
9 -- Copyright (C) 1992-2005 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 2, 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. See the GNU General Public License --
21 -- for more details. You should have received a copy of the GNU General --
22 -- Public License distributed with GNAT; see file COPYING. If not, write --
23 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24 -- Boston, MA 02110-1301, USA. --
26 -- As a special exception, if other files instantiate generics from this --
27 -- unit, or you link this unit with other files to produce an executable, --
28 -- this unit does not by itself cause the resulting executable to be --
29 -- covered by the GNU General Public License. This exception does not --
30 -- however invalidate any other reasons why the executable file might be --
31 -- covered by the GNU Public License. --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
36 ------------------------------------------------------------------------------
38 with Ada
.Finalization
;
40 package Ada
.Strings
.Wide_Wide_Maps
is
43 ------------------------------------------
44 -- Wide_Wide_Character Set Declarations --
45 ------------------------------------------
47 type Wide_Wide_Character_Set
is private;
48 -- Representation for a set of Wide_Wide_Character values:
50 Null_Set
: constant Wide_Wide_Character_Set
;
52 -----------------------------------------------
53 -- Constructors for Wide_Wide_Character Sets --
54 -----------------------------------------------
56 type Wide_Wide_Character_Range
is record
57 Low
: Wide_Wide_Character
;
58 High
: Wide_Wide_Character
;
60 -- Represents Wide_Wide_Character range Low .. High
62 type Wide_Wide_Character_Ranges
is
63 array (Positive range <>) of Wide_Wide_Character_Range
;
66 (Ranges
: Wide_Wide_Character_Ranges
) return Wide_Wide_Character_Set
;
69 (Span
: Wide_Wide_Character_Range
) return Wide_Wide_Character_Set
;
72 (Set
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Ranges
;
74 ---------------------------------------
75 -- Operations on Wide Character Sets --
76 ---------------------------------------
78 function "=" (Left
, Right
: in Wide_Wide_Character_Set
) return Boolean;
81 (Right
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Set
;
84 (Left
, Right
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Set
;
87 (Left
, Right
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Set
;
90 (Left
, Right
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Set
;
93 (Left
, Right
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Set
;
96 (Element
: Wide_Wide_Character
;
97 Set
: Wide_Wide_Character_Set
) return Boolean;
100 (Elements
: Wide_Wide_Character_Set
;
101 Set
: Wide_Wide_Character_Set
) return Boolean;
104 (Left
: Wide_Wide_Character_Set
;
105 Right
: Wide_Wide_Character_Set
) return Boolean
108 subtype Wide_Wide_Character_Sequence
is Wide_Wide_String
;
109 -- Alternative representation for a set of character values
112 (Sequence
: Wide_Wide_Character_Sequence
) return Wide_Wide_Character_Set
;
115 (Singleton
: Wide_Wide_Character
) return Wide_Wide_Character_Set
;
118 (Set
: Wide_Wide_Character_Set
) return Wide_Wide_Character_Sequence
;
120 ----------------------------------------------
121 -- Wide_Wide_Character Mapping Declarations --
122 ----------------------------------------------
124 type Wide_Wide_Character_Mapping
is private;
125 -- Representation for a wide character to wide character mapping:
128 (Map
: Wide_Wide_Character_Mapping
;
129 Element
: Wide_Wide_Character
) return Wide_Wide_Character
;
131 Identity
: constant Wide_Wide_Character_Mapping
;
133 --------------------------------------
134 -- Operations on Wide Wide Mappings --
135 ---------------------------------------
138 (From
, To
: Wide_Wide_Character_Sequence
)
139 return Wide_Wide_Character_Mapping
;
142 (Map
: Wide_Wide_Character_Mapping
) return Wide_Wide_Character_Sequence
;
145 (Map
: Wide_Wide_Character_Mapping
) return Wide_Wide_Character_Sequence
;
147 type Wide_Wide_Character_Mapping_Function
is
148 access function (From
: Wide_Wide_Character
) return Wide_Wide_Character
;
151 package AF
renames Ada
.Finalization
;
153 -----------------------------------------------
154 -- Representation of Wide_Wide_Character_Set --
155 -----------------------------------------------
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
161 -- The lower bound is 1
162 -- The ranges are in order by increasing Low values
163 -- The ranges are non-overlapping and discontigous
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.
170 type Wide_Wide_Character_Ranges_Access
is
171 access all Wide_Wide_Character_Ranges
;
173 type Wide_Wide_Character_Set
is new AF
.Controlled
with record
174 Set
: Wide_Wide_Character_Ranges_Access
;
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.
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
);
186 Null_Range
: aliased constant Wide_Wide_Character_Ranges
:=
187 (1 .. 0 => (Low
=> ' ', High
=> ' '));
189 Null_Set
: constant Wide_Wide_Character_Set
:=
191 Set
=> Null_Range
'Unrestricted_Access);
193 ---------------------------------------------------
194 -- Representation of Wide_Wide_Character_Mapping --
195 ---------------------------------------------------
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.
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.
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.
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
);
217 type Wide_Wide_Character_Mapping_Values_Access
is
218 access all Wide_Wide_Character_Mapping_Values
;
220 type Wide_Wide_Character_Mapping
is new AF
.Controlled
with record
221 Map
: Wide_Wide_Character_Mapping_Values_Access
;
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.
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
);
233 Null_Map
: aliased constant Wide_Wide_Character_Mapping_Values
:=
238 Identity
: constant Wide_Wide_Character_Mapping
:=
240 Map
=> Null_Map
'Unrestricted_Access);
242 end Ada
.Strings
.Wide_Wide_Maps
;