* MAINTAINERS: (Write After Approval): Add myself.
[official-gcc.git] / gcc / ada / a-stwima.ads
blob392932668f690bafd2f05f692dadbd9a0aef7e73
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . W I D E _ M A P S --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1992-1998 Free Software Foundation, Inc. --
11 -- --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the contents of the part following the private keyword. --
15 -- --
16 -- GNAT is free software; you can redistribute it and/or modify it under --
17 -- terms of the GNU General Public License as published by the Free Soft- --
18 -- ware Foundation; either version 2, or (at your option) any later ver- --
19 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
22 -- for more details. You should have received a copy of the GNU General --
23 -- Public License distributed with GNAT; see file COPYING. If not, write --
24 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
25 -- MA 02111-1307, USA. --
26 -- --
27 -- As a special exception, if other files instantiate generics from this --
28 -- unit, or you link this unit with other files to produce an executable, --
29 -- this unit does not by itself cause the resulting executable to be --
30 -- covered by the GNU General Public License. This exception does not --
31 -- however invalidate any other reasons why the executable file might be --
32 -- covered by the GNU Public License. --
33 -- --
34 -- GNAT was originally developed by the GNAT team at New York University. --
35 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
36 -- --
37 ------------------------------------------------------------------------------
39 with Ada.Finalization;
41 package Ada.Strings.Wide_Maps is
42 pragma Preelaborate (Wide_Maps);
44 -------------------------------------
45 -- Wide Character Set Declarations --
46 -------------------------------------
48 type Wide_Character_Set is private;
49 -- Representation for a set of Wide_Character values:
51 Null_Set : constant Wide_Character_Set;
53 ------------------------------------------
54 -- Constructors for Wide Character Sets --
55 ------------------------------------------
57 type Wide_Character_Range is record
58 Low : Wide_Character;
59 High : Wide_Character;
60 end record;
61 -- Represents Wide_Character range Low .. High
63 type Wide_Character_Ranges is
64 array (Positive range <>) of Wide_Character_Range;
66 function To_Set
67 (Ranges : in Wide_Character_Ranges)
68 return Wide_Character_Set;
70 function To_Set
71 (Span : in Wide_Character_Range)
72 return Wide_Character_Set;
74 function To_Ranges
75 (Set : in Wide_Character_Set)
76 return Wide_Character_Ranges;
78 ---------------------------------------
79 -- Operations on Wide Character Sets --
80 ---------------------------------------
82 function "=" (Left, Right : in Wide_Character_Set) return Boolean;
84 function "not"
85 (Right : in Wide_Character_Set)
86 return Wide_Character_Set;
88 function "and"
89 (Left, Right : in Wide_Character_Set)
90 return Wide_Character_Set;
92 function "or"
93 (Left, Right : in Wide_Character_Set)
94 return Wide_Character_Set;
96 function "xor"
97 (Left, Right : in Wide_Character_Set)
98 return Wide_Character_Set;
100 function "-"
101 (Left, Right : in Wide_Character_Set)
102 return Wide_Character_Set;
104 function Is_In
105 (Element : in Wide_Character;
106 Set : in Wide_Character_Set)
107 return Boolean;
109 function Is_Subset
110 (Elements : in Wide_Character_Set;
111 Set : in Wide_Character_Set)
112 return Boolean;
114 function "<="
115 (Left : in Wide_Character_Set;
116 Right : in Wide_Character_Set)
117 return Boolean
118 renames Is_Subset;
120 subtype Wide_Character_Sequence is Wide_String;
121 -- Alternative representation for a set of character values
123 function To_Set
124 (Sequence : in Wide_Character_Sequence)
125 return Wide_Character_Set;
127 function To_Set
128 (Singleton : in Wide_Character)
129 return Wide_Character_Set;
131 function To_Sequence
132 (Set : in Wide_Character_Set)
133 return Wide_Character_Sequence;
135 -----------------------------------------
136 -- Wide Character Mapping Declarations --
137 -----------------------------------------
139 type Wide_Character_Mapping is private;
140 -- Representation for a wide character to wide character mapping:
142 function Value
143 (Map : in Wide_Character_Mapping;
144 Element : in Wide_Character)
145 return Wide_Character;
147 Identity : constant Wide_Character_Mapping;
149 ---------------------------------
150 -- Operations on Wide Mappings --
151 ---------------------------------
153 function To_Mapping
154 (From, To : in Wide_Character_Sequence)
155 return Wide_Character_Mapping;
157 function To_Domain
158 (Map : in Wide_Character_Mapping)
159 return Wide_Character_Sequence;
161 function To_Range
162 (Map : in Wide_Character_Mapping)
163 return Wide_Character_Sequence;
165 type Wide_Character_Mapping_Function is
166 access function (From : in Wide_Character) return Wide_Character;
168 private
169 package AF renames Ada.Finalization;
171 ------------------------------------------
172 -- Representation of Wide_Character_Set --
173 ------------------------------------------
175 -- A wide character set is represented as a sequence of wide character
176 -- ranges (i.e. an object of type Wide_Character_Ranges) in which the
177 -- following hold:
179 -- The lower bound is 1
180 -- The ranges are in order by increasing Low values
181 -- The ranges are non-overlapping and discontigous
183 -- A character value is in the set if it is contained in one of the
184 -- ranges. The actual Wide_Character_Set value is a controlled pointer
185 -- to this Wide_Character_Ranges value. The use of a controlled type
186 -- is necessary to prevent storage leaks.
188 type Wide_Character_Ranges_Access is access all Wide_Character_Ranges;
190 type Wide_Character_Set is new AF.Controlled with record
191 Set : Wide_Character_Ranges_Access;
192 end record;
194 pragma Finalize_Storage_Only (Wide_Character_Set);
195 -- This avoids useless finalizations, and, more importantly avoids
196 -- incorrect attempts to finalize constants that are statically
197 -- declared here and in Ada.Strings.Wide_Maps, which is incorrect.
199 procedure Initialize (Object : in out Wide_Character_Set);
200 procedure Adjust (Object : in out Wide_Character_Set);
201 procedure Finalize (Object : in out Wide_Character_Set);
203 Null_Range : aliased constant Wide_Character_Ranges :=
204 (1 .. 0 => (Low => ' ', High => ' '));
206 Null_Set : constant Wide_Character_Set :=
207 (AF.Controlled with
208 Set => Null_Range'Unrestricted_Access);
210 ----------------------------------------------
211 -- Representation of Wide_Character_Mapping --
212 ----------------------------------------------
214 -- A wide character mapping is represented as two strings of equal
215 -- length, where any character appearing in Domain is mapped to the
216 -- corresponding character in Rangev. A character not appearing in
217 -- Domain is mapped to itself. The characters in Domain are sorted
218 -- in ascending order.
220 -- The actual Wide_Character_Mapping value is a controlled record
221 -- that contains a pointer to a discriminated record containing the
222 -- range and domain values.
224 -- Note: this representation is canonical, and the values stored in
225 -- Domain and Rangev are exactly the values that are returned by the
226 -- functions To_Domain and To_Range. The use of a controlled type is
227 -- necessary to prevent storage leaks.
229 type Wide_Character_Mapping_Values (Length : Natural) is record
230 Domain : Wide_Character_Sequence (1 .. Length);
231 Rangev : Wide_Character_Sequence (1 .. Length);
232 end record;
234 type Wide_Character_Mapping_Values_Access is
235 access all Wide_Character_Mapping_Values;
237 type Wide_Character_Mapping is new AF.Controlled with record
238 Map : Wide_Character_Mapping_Values_Access;
239 end record;
241 pragma Finalize_Storage_Only (Wide_Character_Mapping);
242 -- This avoids useless finalizations, and, more importantly avoids
243 -- incorrect attempts to finalize constants that are statically
244 -- declared here and in Ada.Strings.Wide_Maps, which is incorrect.
246 procedure Initialize (Object : in out Wide_Character_Mapping);
247 procedure Adjust (Object : in out Wide_Character_Mapping);
248 procedure Finalize (Object : in out Wide_Character_Mapping);
250 Null_Map : aliased constant Wide_Character_Mapping_Values :=
251 (Length => 0,
252 Domain => "",
253 Rangev => "");
255 Identity : constant Wide_Character_Mapping :=
256 (AF.Controlled with
257 Map => Null_Map'Unrestricted_Access);
259 end Ada.Strings.Wide_Maps;