2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / ada / a-stzunb.ads
blobc753051a5f1deeab49bccbb4aa3168162a73adb9
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-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 ------------------------------------------------------------------------------
36 with Ada.Strings.Wide_Wide_Maps;
37 with Ada.Finalization;
39 package Ada.Strings.Wide_Wide_Unbounded is
40 pragma Preelaborate;
42 type Unbounded_Wide_Wide_String is private;
43 pragma Preelaborable_Initialization (Unbounded_Wide_Wide_String);
45 Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String;
47 function Length (Source : Unbounded_Wide_Wide_String) return Natural;
49 type Wide_Wide_String_Access is access all Wide_Wide_String;
51 procedure Free (X : in out Wide_Wide_String_Access);
53 --------------------------------------------------------
54 -- Conversion, Concatenation, and Selection Functions --
55 --------------------------------------------------------
57 function To_Unbounded_Wide_Wide_String
58 (Source : Wide_Wide_String) return Unbounded_Wide_Wide_String;
60 function To_Unbounded_Wide_Wide_String
61 (Length : Natural) return Unbounded_Wide_Wide_String;
63 function To_Wide_Wide_String
64 (Source : Unbounded_Wide_Wide_String) return Wide_Wide_String;
66 procedure Set_Unbounded_Wide_Wide_String
67 (Target : out Unbounded_Wide_Wide_String;
68 Source : Wide_Wide_String);
69 pragma Ada_05 (Set_Unbounded_Wide_Wide_String);
71 procedure Append
72 (Source : in out Unbounded_Wide_Wide_String;
73 New_Item : Unbounded_Wide_Wide_String);
75 procedure Append
76 (Source : in out Unbounded_Wide_Wide_String;
77 New_Item : Wide_Wide_String);
79 procedure Append
80 (Source : in out Unbounded_Wide_Wide_String;
81 New_Item : Wide_Wide_Character);
83 function "&"
84 (Left : Unbounded_Wide_Wide_String;
85 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
87 function "&"
88 (Left : Unbounded_Wide_Wide_String;
89 Right : Wide_Wide_String) return Unbounded_Wide_Wide_String;
91 function "&"
92 (Left : Wide_Wide_String;
93 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
95 function "&"
96 (Left : Unbounded_Wide_Wide_String;
97 Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String;
99 function "&"
100 (Left : Wide_Wide_Character;
101 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
103 function Element
104 (Source : Unbounded_Wide_Wide_String;
105 Index : Positive) return Wide_Wide_Character;
107 procedure Replace_Element
108 (Source : in out Unbounded_Wide_Wide_String;
109 Index : Positive;
110 By : Wide_Wide_Character);
112 function Slice
113 (Source : Unbounded_Wide_Wide_String;
114 Low : Positive;
115 High : Natural) return Wide_Wide_String;
117 function Unbounded_Slice
118 (Source : Unbounded_Wide_Wide_String;
119 Low : Positive;
120 High : Natural) return Unbounded_Wide_Wide_String;
121 pragma Ada_05 (Unbounded_Slice);
123 procedure Unbounded_Slice
124 (Source : Unbounded_Wide_Wide_String;
125 Target : out Unbounded_Wide_Wide_String;
126 Low : Positive;
127 High : Natural);
128 pragma Ada_05 (Unbounded_Slice);
130 function "="
131 (Left : Unbounded_Wide_Wide_String;
132 Right : Unbounded_Wide_Wide_String) return Boolean;
134 function "="
135 (Left : Unbounded_Wide_Wide_String;
136 Right : Wide_Wide_String) return Boolean;
138 function "="
139 (Left : Wide_Wide_String;
140 Right : Unbounded_Wide_Wide_String) return Boolean;
142 function "<"
143 (Left : Unbounded_Wide_Wide_String;
144 Right : Unbounded_Wide_Wide_String) return Boolean;
146 function "<"
147 (Left : Unbounded_Wide_Wide_String;
148 Right : Wide_Wide_String) return Boolean;
150 function "<"
151 (Left : Wide_Wide_String;
152 Right : Unbounded_Wide_Wide_String) return Boolean;
154 function "<="
155 (Left : Unbounded_Wide_Wide_String;
156 Right : Unbounded_Wide_Wide_String) return Boolean;
158 function "<="
159 (Left : Unbounded_Wide_Wide_String;
160 Right : Wide_Wide_String) return Boolean;
162 function "<="
163 (Left : Wide_Wide_String;
164 Right : Unbounded_Wide_Wide_String) return Boolean;
166 function ">"
167 (Left : Unbounded_Wide_Wide_String;
168 Right : Unbounded_Wide_Wide_String) return Boolean;
170 function ">"
171 (Left : Unbounded_Wide_Wide_String;
172 Right : Wide_Wide_String) return Boolean;
174 function ">"
175 (Left : Wide_Wide_String;
176 Right : Unbounded_Wide_Wide_String) return Boolean;
178 function ">="
179 (Left : Unbounded_Wide_Wide_String;
180 Right : Unbounded_Wide_Wide_String) return Boolean;
182 function ">="
183 (Left : Unbounded_Wide_Wide_String;
184 Right : Wide_Wide_String) return Boolean;
186 function ">="
187 (Left : Wide_Wide_String;
188 Right : Unbounded_Wide_Wide_String) return Boolean;
190 ------------------------
191 -- Search Subprograms --
192 ------------------------
194 function Index
195 (Source : Unbounded_Wide_Wide_String;
196 Pattern : Wide_Wide_String;
197 Going : Direction := Forward;
198 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
199 Wide_Wide_Maps.Identity)
200 return Natural;
202 function Index
203 (Source : Unbounded_Wide_Wide_String;
204 Pattern : Wide_Wide_String;
205 Going : Direction := Forward;
206 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
207 return Natural;
209 function Index
210 (Source : Unbounded_Wide_Wide_String;
211 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
212 Test : Membership := Inside;
213 Going : Direction := Forward) return Natural;
215 function Index
216 (Source : Unbounded_Wide_Wide_String;
217 Pattern : Wide_Wide_String;
218 From : Positive;
219 Going : Direction := Forward;
220 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
221 Wide_Wide_Maps.Identity)
222 return Natural;
223 pragma Ada_05 (Index);
225 function Index
226 (Source : Unbounded_Wide_Wide_String;
227 Pattern : Wide_Wide_String;
228 From : Positive;
229 Going : Direction := Forward;
230 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
231 return Natural;
232 pragma Ada_05 (Index);
234 function Index
235 (Source : Unbounded_Wide_Wide_String;
236 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
237 From : Positive;
238 Test : Membership := Inside;
239 Going : Direction := Forward) return Natural;
240 pragma Ada_05 (Index);
242 function Index_Non_Blank
243 (Source : Unbounded_Wide_Wide_String;
244 Going : Direction := Forward) return Natural;
246 function Index_Non_Blank
247 (Source : Unbounded_Wide_Wide_String;
248 From : Positive;
249 Going : Direction := Forward) return Natural;
250 pragma Ada_05 (Index_Non_Blank);
252 function Count
253 (Source : Unbounded_Wide_Wide_String;
254 Pattern : Wide_Wide_String;
255 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
256 Wide_Wide_Maps.Identity)
257 return Natural;
259 function Count
260 (Source : Unbounded_Wide_Wide_String;
261 Pattern : Wide_Wide_String;
262 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
263 return Natural;
265 function Count
266 (Source : Unbounded_Wide_Wide_String;
267 Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;
269 procedure Find_Token
270 (Source : Unbounded_Wide_Wide_String;
271 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
272 Test : Membership;
273 First : out Positive;
274 Last : out Natural);
276 ------------------------------------
277 -- String Translation Subprograms --
278 ------------------------------------
280 function Translate
281 (Source : Unbounded_Wide_Wide_String;
282 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
283 return Unbounded_Wide_Wide_String;
285 procedure Translate
286 (Source : in out Unbounded_Wide_Wide_String;
287 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping);
289 function Translate
290 (Source : Unbounded_Wide_Wide_String;
291 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
292 return Unbounded_Wide_Wide_String;
294 procedure Translate
295 (Source : in out Unbounded_Wide_Wide_String;
296 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);
298 ---------------------------------------
299 -- String Transformation Subprograms --
300 ---------------------------------------
302 function Replace_Slice
303 (Source : Unbounded_Wide_Wide_String;
304 Low : Positive;
305 High : Natural;
306 By : Wide_Wide_String) return Unbounded_Wide_Wide_String;
308 procedure Replace_Slice
309 (Source : in out Unbounded_Wide_Wide_String;
310 Low : Positive;
311 High : Natural;
312 By : Wide_Wide_String);
314 function Insert
315 (Source : Unbounded_Wide_Wide_String;
316 Before : Positive;
317 New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String;
319 procedure Insert
320 (Source : in out Unbounded_Wide_Wide_String;
321 Before : Positive;
322 New_Item : Wide_Wide_String);
324 function Overwrite
325 (Source : Unbounded_Wide_Wide_String;
326 Position : Positive;
327 New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String;
329 procedure Overwrite
330 (Source : in out Unbounded_Wide_Wide_String;
331 Position : Positive;
332 New_Item : Wide_Wide_String);
334 function Delete
335 (Source : Unbounded_Wide_Wide_String;
336 From : Positive;
337 Through : Natural) return Unbounded_Wide_Wide_String;
339 procedure Delete
340 (Source : in out Unbounded_Wide_Wide_String;
341 From : Positive;
342 Through : Natural);
344 function Trim
345 (Source : Unbounded_Wide_Wide_String;
346 Side : Trim_End) return Unbounded_Wide_Wide_String;
348 procedure Trim
349 (Source : in out Unbounded_Wide_Wide_String;
350 Side : Trim_End);
352 function Trim
353 (Source : Unbounded_Wide_Wide_String;
354 Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
355 Right : Wide_Wide_Maps.Wide_Wide_Character_Set)
356 return Unbounded_Wide_Wide_String;
358 procedure Trim
359 (Source : in out Unbounded_Wide_Wide_String;
360 Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
361 Right : Wide_Wide_Maps.Wide_Wide_Character_Set);
363 function Head
364 (Source : Unbounded_Wide_Wide_String;
365 Count : Natural;
366 Pad : Wide_Wide_Character := Wide_Wide_Space)
367 return Unbounded_Wide_Wide_String;
369 procedure Head
370 (Source : in out Unbounded_Wide_Wide_String;
371 Count : Natural;
372 Pad : Wide_Wide_Character := Wide_Wide_Space);
374 function Tail
375 (Source : Unbounded_Wide_Wide_String;
376 Count : Natural;
377 Pad : Wide_Wide_Character := Wide_Wide_Space)
378 return Unbounded_Wide_Wide_String;
380 procedure Tail
381 (Source : in out Unbounded_Wide_Wide_String;
382 Count : Natural;
383 Pad : Wide_Wide_Character := Wide_Wide_Space);
385 function "*"
386 (Left : Natural;
387 Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String;
389 function "*"
390 (Left : Natural;
391 Right : Wide_Wide_String) return Unbounded_Wide_Wide_String;
393 function "*"
394 (Left : Natural;
395 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
397 private
398 pragma Inline (Length);
400 package AF renames Ada.Finalization;
402 Null_Wide_Wide_String : aliased Wide_Wide_String := "";
404 function To_Unbounded_Wide
405 (S : Wide_Wide_String) return Unbounded_Wide_Wide_String
406 renames To_Unbounded_Wide_Wide_String;
408 type Unbounded_Wide_Wide_String is new AF.Controlled with record
409 Reference : Wide_Wide_String_Access := Null_Wide_Wide_String'Access;
410 Last : Natural := 0;
411 end record;
413 -- The Unbounded_Wide_Wide_String is using a buffered implementation to
414 -- increase speed of the Append/Delete/Insert procedures. The Reference
415 -- string pointer above contains the current string value and extra room
416 -- at the end to be used by the next Append routine. Last is the index of
417 -- the string ending character. So the current string value is really
418 -- Reference (1 .. Last).
420 pragma Stream_Convert
421 (Unbounded_Wide_Wide_String, To_Unbounded_Wide, To_Wide_Wide_String);
423 pragma Finalize_Storage_Only (Unbounded_Wide_Wide_String);
424 -- Finalization is required only for freeing storage
426 procedure Initialize (Object : in out Unbounded_Wide_Wide_String);
427 procedure Adjust (Object : in out Unbounded_Wide_Wide_String);
428 procedure Finalize (Object : in out Unbounded_Wide_Wide_String);
429 procedure Realloc_For_Chunk
430 (Source : in out Unbounded_Wide_Wide_String;
431 Chunk_Size : Natural);
432 -- Adjust the size allocated for the string. Add at least Chunk_Size so it
433 -- is safe to add a string of this size at the end of the current content.
434 -- The real size allocated for the string is Chunk_Size + x of the current
435 -- string size. This buffered handling makes the Append unbounded string
436 -- routines very fast.
438 Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String :=
439 (AF.Controlled with
440 Reference =>
441 Null_Wide_Wide_String'Access,
442 Last => 0);
443 end Ada.Strings.Wide_Wide_Unbounded;