1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . W I D E _ U N B O U N D E D --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
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. --
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. --
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/>. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
34 ------------------------------------------------------------------------------
36 with Ada
.Strings
.Wide_Maps
;
37 with Ada
.Finalization
;
39 package Ada
.Strings
.Wide_Unbounded
is
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
)
67 procedure Set_Unbounded_Wide_String
68 (Target
: out Unbounded_Wide_String
;
69 Source
: Wide_String);
70 pragma Ada_05
(Set_Unbounded_Wide_String
);
73 (Source
: in out Unbounded_Wide_String
;
74 New_Item
: Unbounded_Wide_String
);
77 (Source
: in out Unbounded_Wide_String
;
78 New_Item
: Wide_String);
81 (Source
: in out Unbounded_Wide_String
;
82 New_Item
: Wide_Character);
85 (Left
: Unbounded_Wide_String
;
86 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
89 (Left
: Unbounded_Wide_String
;
90 Right
: Wide_String) return Unbounded_Wide_String
;
94 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
97 (Left
: Unbounded_Wide_String
;
98 Right
: Wide_Character) return Unbounded_Wide_String
;
101 (Left
: Wide_Character;
102 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
105 (Source
: Unbounded_Wide_String
;
106 Index
: Positive) return Wide_Character;
108 procedure Replace_Element
109 (Source
: in out Unbounded_Wide_String
;
111 By
: Wide_Character);
114 (Source
: Unbounded_Wide_String
;
116 High
: Natural) return Wide_String;
118 function Unbounded_Slice
119 (Source
: Unbounded_Wide_String
;
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
;
129 pragma Ada_05
(Unbounded_Slice
);
132 (Left
: Unbounded_Wide_String
;
133 Right
: Unbounded_Wide_String
) return Boolean;
136 (Left
: Unbounded_Wide_String
;
137 Right
: Wide_String) return Boolean;
141 Right
: Unbounded_Wide_String
) return Boolean;
144 (Left
: Unbounded_Wide_String
;
145 Right
: Unbounded_Wide_String
) return Boolean;
148 (Left
: Unbounded_Wide_String
;
149 Right
: Wide_String) return Boolean;
153 Right
: Unbounded_Wide_String
) return Boolean;
156 (Left
: Unbounded_Wide_String
;
157 Right
: Unbounded_Wide_String
) return Boolean;
160 (Left
: Unbounded_Wide_String
;
161 Right
: Wide_String) return Boolean;
165 Right
: Unbounded_Wide_String
) return Boolean;
168 (Left
: Unbounded_Wide_String
;
169 Right
: Unbounded_Wide_String
) return Boolean;
172 (Left
: Unbounded_Wide_String
;
173 Right
: Wide_String) return Boolean;
177 Right
: Unbounded_Wide_String
) return Boolean;
180 (Left
: Unbounded_Wide_String
;
181 Right
: Unbounded_Wide_String
) return Boolean;
184 (Left
: Unbounded_Wide_String
;
185 Right
: Wide_String) return Boolean;
189 Right
: Unbounded_Wide_String
) return Boolean;
191 ------------------------
192 -- Search Subprograms --
193 ------------------------
196 (Source
: Unbounded_Wide_String
;
197 Pattern
: Wide_String;
198 Going
: Direction
:= Forward
;
199 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
203 (Source
: Unbounded_Wide_String
;
204 Pattern
: Wide_String;
205 Going
: Direction
:= Forward
;
206 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
209 (Source
: Unbounded_Wide_String
;
210 Set
: Wide_Maps
.Wide_Character_Set
;
211 Test
: Membership
:= Inside
;
212 Going
: Direction
:= Forward
) return Natural;
215 (Source
: Unbounded_Wide_String
;
216 Pattern
: Wide_String;
218 Going
: Direction
:= Forward
;
219 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
221 pragma Ada_05
(Index
);
224 (Source
: Unbounded_Wide_String
;
225 Pattern
: Wide_String;
227 Going
: Direction
:= Forward
;
228 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
229 pragma Ada_05
(Index
);
232 (Source
: Unbounded_Wide_String
;
233 Set
: Wide_Maps
.Wide_Character_Set
;
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
;
246 Going
: Direction
:= Forward
) return Natural;
247 pragma Ada_05
(Index_Non_Blank
);
250 (Source
: Unbounded_Wide_String
;
251 Pattern
: Wide_String;
252 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
256 (Source
: Unbounded_Wide_String
;
257 Pattern
: Wide_String;
258 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
261 (Source
: Unbounded_Wide_String
;
262 Set
: Wide_Maps
.Wide_Character_Set
) return Natural;
265 (Source
: Unbounded_Wide_String
;
266 Set
: Wide_Maps
.Wide_Character_Set
;
268 First
: out Positive;
271 ------------------------------------
272 -- String Translation Subprograms --
273 ------------------------------------
276 (Source
: Unbounded_Wide_String
;
277 Mapping
: Wide_Maps
.Wide_Character_Mapping
)
278 return Unbounded_Wide_String
;
281 (Source
: in out Unbounded_Wide_String
;
282 Mapping
: Wide_Maps
.Wide_Character_Mapping
);
285 (Source
: Unbounded_Wide_String
;
286 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
)
287 return Unbounded_Wide_String
;
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
;
301 By
: Wide_String) return Unbounded_Wide_String
;
303 procedure Replace_Slice
304 (Source
: in out Unbounded_Wide_String
;
310 (Source
: Unbounded_Wide_String
;
312 New_Item
: Wide_String) return Unbounded_Wide_String
;
315 (Source
: in out Unbounded_Wide_String
;
317 New_Item
: Wide_String);
320 (Source
: Unbounded_Wide_String
;
322 New_Item
: Wide_String) return Unbounded_Wide_String
;
325 (Source
: in out Unbounded_Wide_String
;
327 New_Item
: Wide_String);
330 (Source
: Unbounded_Wide_String
;
332 Through
: Natural) return Unbounded_Wide_String
;
335 (Source
: in out Unbounded_Wide_String
;
340 (Source
: Unbounded_Wide_String
;
341 Side
: Trim_End
) return Unbounded_Wide_String
;
344 (Source
: in out Unbounded_Wide_String
;
348 (Source
: Unbounded_Wide_String
;
349 Left
: Wide_Maps
.Wide_Character_Set
;
350 Right
: Wide_Maps
.Wide_Character_Set
) return Unbounded_Wide_String
;
353 (Source
: in out Unbounded_Wide_String
;
354 Left
: Wide_Maps
.Wide_Character_Set
;
355 Right
: Wide_Maps
.Wide_Character_Set
);
358 (Source
: Unbounded_Wide_String
;
360 Pad
: Wide_Character := Wide_Space
) return Unbounded_Wide_String
;
363 (Source
: in out Unbounded_Wide_String
;
365 Pad
: Wide_Character := Wide_Space
);
368 (Source
: Unbounded_Wide_String
;
370 Pad
: Wide_Character := Wide_Space
) return Unbounded_Wide_String
;
373 (Source
: in out Unbounded_Wide_String
;
375 Pad
: Wide_Character := Wide_Space
);
379 Right
: Wide_Character) return Unbounded_Wide_String
;
383 Right
: Wide_String) return Unbounded_Wide_String
;
387 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
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;
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
:=
432 Reference
=> Null_Wide_String
'Access,
434 end Ada
.Strings
.Wide_Unbounded
;