OSDN Git Service

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