OSDN Git Service

PR c++/27714
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-stzunb.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 _ U N B O U N D E D       --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2005, 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.Strings.Wide_Wide_Maps;
39 with Ada.Finalization;
40
41 package Ada.Strings.Wide_Wide_Unbounded is
42    pragma Preelaborate;
43
44    type Unbounded_Wide_Wide_String is private;
45
46    Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String;
47
48    function Length (Source : Unbounded_Wide_Wide_String) return Natural;
49
50    type Wide_Wide_String_Access is access all Wide_Wide_String;
51
52    procedure Free (X : in out Wide_Wide_String_Access);
53
54    --------------------------------------------------------
55    -- Conversion, Concatenation, and Selection Functions --
56    --------------------------------------------------------
57
58    function To_Unbounded_Wide_Wide_String
59      (Source : Wide_Wide_String) return Unbounded_Wide_Wide_String;
60
61    function To_Unbounded_Wide_Wide_String
62      (Length : Natural) return Unbounded_Wide_Wide_String;
63
64    function To_Wide_Wide_String
65      (Source : Unbounded_Wide_Wide_String) return Wide_Wide_String;
66
67    procedure Set_Unbounded_Wide_Wide_String
68      (Target : out Unbounded_Wide_Wide_String;
69       Source : Wide_Wide_String);
70    pragma Ada_05 (Set_Unbounded_Wide_Wide_String);
71
72    procedure Append
73      (Source   : in out Unbounded_Wide_Wide_String;
74       New_Item : Unbounded_Wide_Wide_String);
75
76    procedure Append
77      (Source   : in out Unbounded_Wide_Wide_String;
78       New_Item : Wide_Wide_String);
79
80    procedure Append
81      (Source   : in out Unbounded_Wide_Wide_String;
82       New_Item : Wide_Wide_Character);
83
84    function "&"
85      (Left  : Unbounded_Wide_Wide_String;
86       Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
87
88    function "&"
89      (Left  : Unbounded_Wide_Wide_String;
90       Right : Wide_Wide_String) return Unbounded_Wide_Wide_String;
91
92    function "&"
93      (Left  : Wide_Wide_String;
94       Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
95
96    function "&"
97      (Left  : Unbounded_Wide_Wide_String;
98       Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String;
99
100    function "&"
101      (Left  : Wide_Wide_Character;
102       Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
103
104    function Element
105      (Source : Unbounded_Wide_Wide_String;
106       Index  : Positive) return Wide_Wide_Character;
107
108    procedure Replace_Element
109      (Source : in out Unbounded_Wide_Wide_String;
110       Index  : Positive;
111       By     : Wide_Wide_Character);
112
113    function Slice
114      (Source : Unbounded_Wide_Wide_String;
115       Low    : Positive;
116       High   : Natural) return Wide_Wide_String;
117
118    function Unbounded_Slice
119      (Source : Unbounded_Wide_Wide_String;
120       Low    : Positive;
121       High   : Natural) return Unbounded_Wide_Wide_String;
122       pragma Ada_05 (Unbounded_Slice);
123
124    procedure Unbounded_Slice
125      (Source : Unbounded_Wide_Wide_String;
126       Target : out Unbounded_Wide_Wide_String;
127       Low    : Positive;
128       High   : Natural);
129       pragma Ada_05 (Unbounded_Slice);
130
131    function "="
132      (Left  : Unbounded_Wide_Wide_String;
133       Right : Unbounded_Wide_Wide_String) return Boolean;
134
135    function "="
136      (Left  : Unbounded_Wide_Wide_String;
137       Right : Wide_Wide_String) return Boolean;
138
139    function "="
140      (Left  : Wide_Wide_String;
141       Right : Unbounded_Wide_Wide_String) return Boolean;
142
143    function "<"
144      (Left  : Unbounded_Wide_Wide_String;
145       Right : Unbounded_Wide_Wide_String) return Boolean;
146
147    function "<"
148      (Left  : Unbounded_Wide_Wide_String;
149       Right : Wide_Wide_String) return Boolean;
150
151    function "<"
152      (Left  : Wide_Wide_String;
153       Right : Unbounded_Wide_Wide_String) return Boolean;
154
155    function "<="
156      (Left  : Unbounded_Wide_Wide_String;
157       Right : Unbounded_Wide_Wide_String) return Boolean;
158
159    function "<="
160      (Left  : Unbounded_Wide_Wide_String;
161       Right : Wide_Wide_String) return Boolean;
162
163    function "<="
164      (Left  : Wide_Wide_String;
165       Right : Unbounded_Wide_Wide_String) return Boolean;
166
167    function ">"
168      (Left  : Unbounded_Wide_Wide_String;
169       Right : Unbounded_Wide_Wide_String) return Boolean;
170
171    function ">"
172      (Left  : Unbounded_Wide_Wide_String;
173       Right : Wide_Wide_String) return Boolean;
174
175    function ">"
176      (Left  : Wide_Wide_String;
177       Right : Unbounded_Wide_Wide_String) return Boolean;
178
179    function ">="
180      (Left  : Unbounded_Wide_Wide_String;
181       Right : Unbounded_Wide_Wide_String) return Boolean;
182
183    function ">="
184      (Left  : Unbounded_Wide_Wide_String;
185       Right : Wide_Wide_String) return Boolean;
186
187    function ">="
188      (Left  : Wide_Wide_String;
189       Right : Unbounded_Wide_Wide_String) return Boolean;
190
191    ------------------------
192    -- Search Subprograms --
193    ------------------------
194
195    function Index
196      (Source  : Unbounded_Wide_Wide_String;
197       Pattern : Wide_Wide_String;
198       Going   : Direction := Forward;
199       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
200                   Wide_Wide_Maps.Identity)
201       return Natural;
202
203    function Index
204      (Source  : Unbounded_Wide_Wide_String;
205       Pattern : Wide_Wide_String;
206       Going   : Direction := Forward;
207       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
208       return Natural;
209
210    function Index
211      (Source : Unbounded_Wide_Wide_String;
212       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
213       Test   : Membership := Inside;
214       Going  : Direction  := Forward) return Natural;
215
216    function Index
217      (Source  : Unbounded_Wide_Wide_String;
218       Pattern : Wide_Wide_String;
219       From    : Positive;
220       Going   : Direction := Forward;
221       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
222                   Wide_Wide_Maps.Identity)
223       return Natural;
224    pragma Ada_05 (Index);
225
226    function Index
227      (Source  : Unbounded_Wide_Wide_String;
228       Pattern : Wide_Wide_String;
229       From    : Positive;
230       Going   : Direction := Forward;
231       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
232       return Natural;
233    pragma Ada_05 (Index);
234
235    function Index
236      (Source : Unbounded_Wide_Wide_String;
237       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
238       From   : Positive;
239       Test   : Membership := Inside;
240       Going  : Direction := Forward) return Natural;
241    pragma Ada_05 (Index);
242
243    function Index_Non_Blank
244      (Source : Unbounded_Wide_Wide_String;
245       Going  : Direction := Forward) return Natural;
246
247    function Index_Non_Blank
248      (Source : Unbounded_Wide_Wide_String;
249       From   : Positive;
250       Going  : Direction := Forward) return Natural;
251    pragma Ada_05 (Index_Non_Blank);
252
253    function Count
254      (Source  : Unbounded_Wide_Wide_String;
255       Pattern : Wide_Wide_String;
256       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
257                   Wide_Wide_Maps.Identity)
258       return Natural;
259
260    function Count
261      (Source  : Unbounded_Wide_Wide_String;
262       Pattern : Wide_Wide_String;
263       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
264       return Natural;
265
266    function Count
267      (Source : Unbounded_Wide_Wide_String;
268       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;
269
270    procedure Find_Token
271      (Source : Unbounded_Wide_Wide_String;
272       Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
273       Test   : Membership;
274       First  : out Positive;
275       Last   : out Natural);
276
277    ------------------------------------
278    -- String Translation Subprograms --
279    ------------------------------------
280
281    function Translate
282      (Source  : Unbounded_Wide_Wide_String;
283       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
284       return Unbounded_Wide_Wide_String;
285
286    procedure Translate
287      (Source  : in out Unbounded_Wide_Wide_String;
288       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping);
289
290    function Translate
291      (Source  : Unbounded_Wide_Wide_String;
292       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
293       return Unbounded_Wide_Wide_String;
294
295    procedure Translate
296      (Source  : in out Unbounded_Wide_Wide_String;
297       Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);
298
299    ---------------------------------------
300    -- String Transformation Subprograms --
301    ---------------------------------------
302
303    function Replace_Slice
304      (Source : Unbounded_Wide_Wide_String;
305       Low    : Positive;
306       High   : Natural;
307       By     : Wide_Wide_String) return Unbounded_Wide_Wide_String;
308
309    procedure Replace_Slice
310      (Source : in out Unbounded_Wide_Wide_String;
311       Low    : Positive;
312       High   : Natural;
313       By     : Wide_Wide_String);
314
315    function Insert
316      (Source   : Unbounded_Wide_Wide_String;
317       Before   : Positive;
318       New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String;
319
320    procedure Insert
321      (Source   : in out Unbounded_Wide_Wide_String;
322       Before   : Positive;
323       New_Item : Wide_Wide_String);
324
325    function Overwrite
326      (Source   : Unbounded_Wide_Wide_String;
327       Position : Positive;
328       New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String;
329
330    procedure Overwrite
331      (Source   : in out Unbounded_Wide_Wide_String;
332       Position : Positive;
333       New_Item : Wide_Wide_String);
334
335    function Delete
336      (Source  : Unbounded_Wide_Wide_String;
337       From    : Positive;
338       Through : Natural) return Unbounded_Wide_Wide_String;
339
340    procedure Delete
341      (Source  : in out Unbounded_Wide_Wide_String;
342       From    : Positive;
343       Through : Natural);
344
345    function Trim
346      (Source : Unbounded_Wide_Wide_String;
347       Side   : Trim_End) return Unbounded_Wide_Wide_String;
348
349    procedure Trim
350      (Source : in out Unbounded_Wide_Wide_String;
351       Side   : Trim_End);
352
353    function Trim
354      (Source : Unbounded_Wide_Wide_String;
355       Left   : Wide_Wide_Maps.Wide_Wide_Character_Set;
356       Right  : Wide_Wide_Maps.Wide_Wide_Character_Set)
357       return Unbounded_Wide_Wide_String;
358
359    procedure Trim
360      (Source : in out Unbounded_Wide_Wide_String;
361       Left   : Wide_Wide_Maps.Wide_Wide_Character_Set;
362       Right  : Wide_Wide_Maps.Wide_Wide_Character_Set);
363
364    function Head
365      (Source : Unbounded_Wide_Wide_String;
366       Count  : Natural;
367       Pad    : Wide_Wide_Character := Wide_Wide_Space)
368       return Unbounded_Wide_Wide_String;
369
370    procedure Head
371      (Source : in out Unbounded_Wide_Wide_String;
372       Count  : Natural;
373       Pad    : Wide_Wide_Character := Wide_Wide_Space);
374
375    function Tail
376      (Source : Unbounded_Wide_Wide_String;
377       Count  : Natural;
378       Pad    : Wide_Wide_Character := Wide_Wide_Space)
379       return Unbounded_Wide_Wide_String;
380
381    procedure Tail
382      (Source : in out Unbounded_Wide_Wide_String;
383       Count  : Natural;
384       Pad    : Wide_Wide_Character := Wide_Wide_Space);
385
386    function "*"
387      (Left  : Natural;
388       Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String;
389
390    function "*"
391      (Left  : Natural;
392       Right : Wide_Wide_String) return Unbounded_Wide_Wide_String;
393
394    function "*"
395      (Left  : Natural;
396       Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
397
398 private
399    pragma Inline (Length);
400
401    package AF renames Ada.Finalization;
402
403    Null_Wide_Wide_String : aliased Wide_Wide_String := "";
404
405    function To_Unbounded_Wide
406      (S : Wide_Wide_String) return Unbounded_Wide_Wide_String
407      renames To_Unbounded_Wide_Wide_String;
408
409    type Unbounded_Wide_Wide_String is new AF.Controlled with record
410       Reference : Wide_Wide_String_Access := Null_Wide_Wide_String'Access;
411       Last      : Natural            := 0;
412    end record;
413
414    --  The Unbounded_Wide_Wide_String is using a buffered implementation to
415    --  increase speed of the Append/Delete/Insert procedures. The Reference
416    --  string pointer above contains the current string value and extra room
417    --  at the end to be used by the next Append routine. Last is the index of
418    --  the string ending character. So the current string value is really
419    --  Reference (1 .. Last).
420
421    pragma Stream_Convert
422      (Unbounded_Wide_Wide_String, To_Unbounded_Wide, To_Wide_Wide_String);
423
424    pragma Finalize_Storage_Only (Unbounded_Wide_Wide_String);
425    --  Finalization is required only for freeing storage
426
427    procedure Initialize (Object : in out Unbounded_Wide_Wide_String);
428    procedure Adjust     (Object : in out Unbounded_Wide_Wide_String);
429    procedure Finalize   (Object : in out Unbounded_Wide_Wide_String);
430    procedure Realloc_For_Chunk
431      (Source     : in out Unbounded_Wide_Wide_String;
432       Chunk_Size : Natural);
433    --  Adjust the size allocated for the string. Add at least Chunk_Size so it
434    --  is safe to add a string of this size at the end of the current content.
435    --  The real size allocated for the string is Chunk_Size + x of the current
436    --  string size. This buffered handling makes the Append unbounded string
437    --  routines very fast.
438
439    Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String :=
440                                        (AF.Controlled with
441                                           Reference =>
442                                             Null_Wide_Wide_String'Access,
443                                           Last => 0);
444    --  Note: this declaration is illegal since library level controlled
445    --  objects are not allowed in preelaborated units. See AI-161 for a
446    --  discussion of this issue and an attempt to address it. Meanwhile,
447    --  what happens in GNAT is that this check is omitted for internal
448    --  implementation units (see check in sem_cat.adb).
449
450 end Ada.Strings.Wide_Wide_Unbounded;