fixing pr42337
[official-gcc.git] / gcc / ada / a-stwiun.ads
blobfc75be4278de36e1a46092a279b5a5dc06879f5a
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . 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_Maps;
37 with Ada.Finalization;
39 package Ada.Strings.Wide_Unbounded is
40 pragma Preelaborate;
42 type Unbounded_Wide_String is private;
43 pragma Preelaborable_Initialization (Unbounded_Wide_String);
45 Null_Unbounded_Wide_String : constant Unbounded_Wide_String;
47 function Length (Source : Unbounded_Wide_String) return Natural;
49 type Wide_String_Access is access all Wide_String;
51 procedure Free (X : in out Wide_String_Access);
53 --------------------------------------------------------
54 -- Conversion, Concatenation, and Selection Functions --
55 --------------------------------------------------------
57 function To_Unbounded_Wide_String
58 (Source : Wide_String) return Unbounded_Wide_String;
60 function To_Unbounded_Wide_String
61 (Length : Natural) return Unbounded_Wide_String;
63 function To_Wide_String
64 (Source : Unbounded_Wide_String)
65 return Wide_String;
67 procedure Set_Unbounded_Wide_String
68 (Target : out Unbounded_Wide_String;
69 Source : Wide_String);
70 pragma Ada_05 (Set_Unbounded_Wide_String);
72 procedure Append
73 (Source : in out Unbounded_Wide_String;
74 New_Item : Unbounded_Wide_String);
76 procedure Append
77 (Source : in out Unbounded_Wide_String;
78 New_Item : Wide_String);
80 procedure Append
81 (Source : in out Unbounded_Wide_String;
82 New_Item : Wide_Character);
84 function "&"
85 (Left : Unbounded_Wide_String;
86 Right : Unbounded_Wide_String) return Unbounded_Wide_String;
88 function "&"
89 (Left : Unbounded_Wide_String;
90 Right : Wide_String) return Unbounded_Wide_String;
92 function "&"
93 (Left : Wide_String;
94 Right : Unbounded_Wide_String) return Unbounded_Wide_String;
96 function "&"
97 (Left : Unbounded_Wide_String;
98 Right : Wide_Character) return Unbounded_Wide_String;
100 function "&"
101 (Left : Wide_Character;
102 Right : Unbounded_Wide_String) return Unbounded_Wide_String;
104 function Element
105 (Source : Unbounded_Wide_String;
106 Index : Positive) return Wide_Character;
108 procedure Replace_Element
109 (Source : in out Unbounded_Wide_String;
110 Index : Positive;
111 By : Wide_Character);
113 function Slice
114 (Source : Unbounded_Wide_String;
115 Low : Positive;
116 High : Natural) return Wide_String;
118 function Unbounded_Slice
119 (Source : Unbounded_Wide_String;
120 Low : Positive;
121 High : Natural) return Unbounded_Wide_String;
122 pragma Ada_05 (Unbounded_Slice);
124 procedure Unbounded_Slice
125 (Source : Unbounded_Wide_String;
126 Target : out Unbounded_Wide_String;
127 Low : Positive;
128 High : Natural);
129 pragma Ada_05 (Unbounded_Slice);
131 function "="
132 (Left : Unbounded_Wide_String;
133 Right : Unbounded_Wide_String) return Boolean;
135 function "="
136 (Left : Unbounded_Wide_String;
137 Right : Wide_String) return Boolean;
139 function "="
140 (Left : Wide_String;
141 Right : Unbounded_Wide_String) return Boolean;
143 function "<"
144 (Left : Unbounded_Wide_String;
145 Right : Unbounded_Wide_String) return Boolean;
147 function "<"
148 (Left : Unbounded_Wide_String;
149 Right : Wide_String) return Boolean;
151 function "<"
152 (Left : Wide_String;
153 Right : Unbounded_Wide_String) return Boolean;
155 function "<="
156 (Left : Unbounded_Wide_String;
157 Right : Unbounded_Wide_String) return Boolean;
159 function "<="
160 (Left : Unbounded_Wide_String;
161 Right : Wide_String) return Boolean;
163 function "<="
164 (Left : Wide_String;
165 Right : Unbounded_Wide_String) return Boolean;
167 function ">"
168 (Left : Unbounded_Wide_String;
169 Right : Unbounded_Wide_String) return Boolean;
171 function ">"
172 (Left : Unbounded_Wide_String;
173 Right : Wide_String) return Boolean;
175 function ">"
176 (Left : Wide_String;
177 Right : Unbounded_Wide_String) return Boolean;
179 function ">="
180 (Left : Unbounded_Wide_String;
181 Right : Unbounded_Wide_String) return Boolean;
183 function ">="
184 (Left : Unbounded_Wide_String;
185 Right : Wide_String) return Boolean;
187 function ">="
188 (Left : Wide_String;
189 Right : Unbounded_Wide_String) return Boolean;
191 ------------------------
192 -- Search Subprograms --
193 ------------------------
195 function Index
196 (Source : Unbounded_Wide_String;
197 Pattern : Wide_String;
198 Going : Direction := Forward;
199 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
200 return Natural;
202 function Index
203 (Source : Unbounded_Wide_String;
204 Pattern : Wide_String;
205 Going : Direction := Forward;
206 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
208 function Index
209 (Source : Unbounded_Wide_String;
210 Set : Wide_Maps.Wide_Character_Set;
211 Test : Membership := Inside;
212 Going : Direction := Forward) return Natural;
214 function Index
215 (Source : Unbounded_Wide_String;
216 Pattern : Wide_String;
217 From : Positive;
218 Going : Direction := Forward;
219 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
220 return Natural;
221 pragma Ada_05 (Index);
223 function Index
224 (Source : Unbounded_Wide_String;
225 Pattern : Wide_String;
226 From : Positive;
227 Going : Direction := Forward;
228 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
229 pragma Ada_05 (Index);
231 function Index
232 (Source : Unbounded_Wide_String;
233 Set : Wide_Maps.Wide_Character_Set;
234 From : Positive;
235 Test : Membership := Inside;
236 Going : Direction := Forward) return Natural;
237 pragma Ada_05 (Index);
239 function Index_Non_Blank
240 (Source : Unbounded_Wide_String;
241 Going : Direction := Forward) return Natural;
243 function Index_Non_Blank
244 (Source : Unbounded_Wide_String;
245 From : Positive;
246 Going : Direction := Forward) return Natural;
247 pragma Ada_05 (Index_Non_Blank);
249 function Count
250 (Source : Unbounded_Wide_String;
251 Pattern : Wide_String;
252 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
253 return Natural;
255 function Count
256 (Source : Unbounded_Wide_String;
257 Pattern : Wide_String;
258 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
260 function Count
261 (Source : Unbounded_Wide_String;
262 Set : Wide_Maps.Wide_Character_Set) return Natural;
264 procedure Find_Token
265 (Source : Unbounded_Wide_String;
266 Set : Wide_Maps.Wide_Character_Set;
267 Test : Membership;
268 First : out Positive;
269 Last : out Natural);
271 ------------------------------------
272 -- String Translation Subprograms --
273 ------------------------------------
275 function Translate
276 (Source : Unbounded_Wide_String;
277 Mapping : Wide_Maps.Wide_Character_Mapping)
278 return Unbounded_Wide_String;
280 procedure Translate
281 (Source : in out Unbounded_Wide_String;
282 Mapping : Wide_Maps.Wide_Character_Mapping);
284 function Translate
285 (Source : Unbounded_Wide_String;
286 Mapping : Wide_Maps.Wide_Character_Mapping_Function)
287 return Unbounded_Wide_String;
289 procedure Translate
290 (Source : in out Unbounded_Wide_String;
291 Mapping : Wide_Maps.Wide_Character_Mapping_Function);
293 ---------------------------------------
294 -- String Transformation Subprograms --
295 ---------------------------------------
297 function Replace_Slice
298 (Source : Unbounded_Wide_String;
299 Low : Positive;
300 High : Natural;
301 By : Wide_String) return Unbounded_Wide_String;
303 procedure Replace_Slice
304 (Source : in out Unbounded_Wide_String;
305 Low : Positive;
306 High : Natural;
307 By : Wide_String);
309 function Insert
310 (Source : Unbounded_Wide_String;
311 Before : Positive;
312 New_Item : Wide_String) return Unbounded_Wide_String;
314 procedure Insert
315 (Source : in out Unbounded_Wide_String;
316 Before : Positive;
317 New_Item : Wide_String);
319 function Overwrite
320 (Source : Unbounded_Wide_String;
321 Position : Positive;
322 New_Item : Wide_String) return Unbounded_Wide_String;
324 procedure Overwrite
325 (Source : in out Unbounded_Wide_String;
326 Position : Positive;
327 New_Item : Wide_String);
329 function Delete
330 (Source : Unbounded_Wide_String;
331 From : Positive;
332 Through : Natural) return Unbounded_Wide_String;
334 procedure Delete
335 (Source : in out Unbounded_Wide_String;
336 From : Positive;
337 Through : Natural);
339 function Trim
340 (Source : Unbounded_Wide_String;
341 Side : Trim_End) return Unbounded_Wide_String;
343 procedure Trim
344 (Source : in out Unbounded_Wide_String;
345 Side : Trim_End);
347 function Trim
348 (Source : Unbounded_Wide_String;
349 Left : Wide_Maps.Wide_Character_Set;
350 Right : Wide_Maps.Wide_Character_Set) return Unbounded_Wide_String;
352 procedure Trim
353 (Source : in out Unbounded_Wide_String;
354 Left : Wide_Maps.Wide_Character_Set;
355 Right : Wide_Maps.Wide_Character_Set);
357 function Head
358 (Source : Unbounded_Wide_String;
359 Count : Natural;
360 Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String;
362 procedure Head
363 (Source : in out Unbounded_Wide_String;
364 Count : Natural;
365 Pad : Wide_Character := Wide_Space);
367 function Tail
368 (Source : Unbounded_Wide_String;
369 Count : Natural;
370 Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String;
372 procedure Tail
373 (Source : in out Unbounded_Wide_String;
374 Count : Natural;
375 Pad : Wide_Character := Wide_Space);
377 function "*"
378 (Left : Natural;
379 Right : Wide_Character) return Unbounded_Wide_String;
381 function "*"
382 (Left : Natural;
383 Right : Wide_String) return Unbounded_Wide_String;
385 function "*"
386 (Left : Natural;
387 Right : Unbounded_Wide_String) return Unbounded_Wide_String;
389 private
390 pragma Inline (Length);
392 package AF renames Ada.Finalization;
394 Null_Wide_String : aliased Wide_String := "";
396 function To_Unbounded_Wide (S : Wide_String) return Unbounded_Wide_String
397 renames To_Unbounded_Wide_String;
399 type Unbounded_Wide_String is new AF.Controlled with record
400 Reference : Wide_String_Access := Null_Wide_String'Access;
401 Last : Natural := 0;
402 end record;
404 -- The Unbounded_Wide_String is using a buffered implementation to increase
405 -- speed of the Append/Delete/Insert procedures. The Reference string
406 -- pointer above contains the current string value and extra room at the
407 -- end to be used by the next Append routine. Last is the index of the
408 -- string ending character. So the current string value is really
409 -- Reference (1 .. Last).
411 pragma Stream_Convert
412 (Unbounded_Wide_String, To_Unbounded_Wide, To_Wide_String);
414 pragma Finalize_Storage_Only (Unbounded_Wide_String);
415 -- Finalization is required only for freeing storage
417 procedure Initialize (Object : in out Unbounded_Wide_String);
418 procedure Adjust (Object : in out Unbounded_Wide_String);
419 procedure Finalize (Object : in out Unbounded_Wide_String);
421 procedure Realloc_For_Chunk
422 (Source : in out Unbounded_Wide_String;
423 Chunk_Size : Natural);
424 -- Adjust the size allocated for the string. Add at least Chunk_Size so it
425 -- is safe to add a string of this size at the end of the current content.
426 -- The real size allocated for the string is Chunk_Size + x of the current
427 -- string size. This buffered handling makes the Append unbounded string
428 -- routines very fast.
430 Null_Unbounded_Wide_String : constant Unbounded_Wide_String :=
431 (AF.Controlled with
432 Reference => Null_Wide_String'Access,
433 Last => 0);
434 end Ada.Strings.Wide_Unbounded;