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-2006, 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 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. --
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. --
33 -- GNAT was originally developed by the GNAT team at New York University. --
34 -- Extensive contributions were provided by Ada Core Technologies Inc. --
36 ------------------------------------------------------------------------------
38 with Ada
.Strings
.Wide_Maps
;
39 with Ada
.Finalization
;
41 package Ada
.Strings
.Wide_Unbounded
is
44 type Unbounded_Wide_String
is private;
45 pragma Preelaborable_Initialization
(Unbounded_Wide_String
);
47 Null_Unbounded_Wide_String
: constant Unbounded_Wide_String
;
49 function Length
(Source
: Unbounded_Wide_String
) return Natural;
51 type Wide_String_Access
is access all Wide_String;
53 procedure Free
(X
: in out Wide_String_Access
);
55 --------------------------------------------------------
56 -- Conversion, Concatenation, and Selection Functions --
57 --------------------------------------------------------
59 function To_Unbounded_Wide_String
60 (Source
: Wide_String) return Unbounded_Wide_String
;
62 function To_Unbounded_Wide_String
63 (Length
: Natural) return Unbounded_Wide_String
;
65 function To_Wide_String
66 (Source
: Unbounded_Wide_String
)
69 procedure Set_Unbounded_Wide_String
70 (Target
: out Unbounded_Wide_String
;
71 Source
: Wide_String);
72 pragma Ada_05
(Set_Unbounded_Wide_String
);
75 (Source
: in out Unbounded_Wide_String
;
76 New_Item
: Unbounded_Wide_String
);
79 (Source
: in out Unbounded_Wide_String
;
80 New_Item
: Wide_String);
83 (Source
: in out Unbounded_Wide_String
;
84 New_Item
: Wide_Character);
87 (Left
: Unbounded_Wide_String
;
88 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
91 (Left
: Unbounded_Wide_String
;
92 Right
: Wide_String) return Unbounded_Wide_String
;
96 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
99 (Left
: Unbounded_Wide_String
;
100 Right
: Wide_Character) return Unbounded_Wide_String
;
103 (Left
: Wide_Character;
104 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
107 (Source
: Unbounded_Wide_String
;
108 Index
: Positive) return Wide_Character;
110 procedure Replace_Element
111 (Source
: in out Unbounded_Wide_String
;
113 By
: Wide_Character);
116 (Source
: Unbounded_Wide_String
;
118 High
: Natural) return Wide_String;
120 function Unbounded_Slice
121 (Source
: Unbounded_Wide_String
;
123 High
: Natural) return Unbounded_Wide_String
;
124 pragma Ada_05
(Unbounded_Slice
);
126 procedure Unbounded_Slice
127 (Source
: Unbounded_Wide_String
;
128 Target
: out Unbounded_Wide_String
;
131 pragma Ada_05
(Unbounded_Slice
);
134 (Left
: Unbounded_Wide_String
;
135 Right
: Unbounded_Wide_String
) return Boolean;
138 (Left
: Unbounded_Wide_String
;
139 Right
: Wide_String) return Boolean;
143 Right
: Unbounded_Wide_String
) return Boolean;
146 (Left
: Unbounded_Wide_String
;
147 Right
: Unbounded_Wide_String
) return Boolean;
150 (Left
: Unbounded_Wide_String
;
151 Right
: Wide_String) return Boolean;
155 Right
: Unbounded_Wide_String
) return Boolean;
158 (Left
: Unbounded_Wide_String
;
159 Right
: Unbounded_Wide_String
) return Boolean;
162 (Left
: Unbounded_Wide_String
;
163 Right
: Wide_String) return Boolean;
167 Right
: Unbounded_Wide_String
) return Boolean;
170 (Left
: Unbounded_Wide_String
;
171 Right
: Unbounded_Wide_String
) return Boolean;
174 (Left
: Unbounded_Wide_String
;
175 Right
: Wide_String) return Boolean;
179 Right
: Unbounded_Wide_String
) return Boolean;
182 (Left
: Unbounded_Wide_String
;
183 Right
: Unbounded_Wide_String
) return Boolean;
186 (Left
: Unbounded_Wide_String
;
187 Right
: Wide_String) return Boolean;
191 Right
: Unbounded_Wide_String
) return Boolean;
193 ------------------------
194 -- Search Subprograms --
195 ------------------------
198 (Source
: Unbounded_Wide_String
;
199 Pattern
: Wide_String;
200 Going
: Direction
:= Forward
;
201 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
205 (Source
: Unbounded_Wide_String
;
206 Pattern
: Wide_String;
207 Going
: Direction
:= Forward
;
208 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
211 (Source
: Unbounded_Wide_String
;
212 Set
: Wide_Maps
.Wide_Character_Set
;
213 Test
: Membership
:= Inside
;
214 Going
: Direction
:= Forward
) return Natural;
217 (Source
: Unbounded_Wide_String
;
218 Pattern
: Wide_String;
220 Going
: Direction
:= Forward
;
221 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
223 pragma Ada_05
(Index
);
226 (Source
: Unbounded_Wide_String
;
227 Pattern
: Wide_String;
229 Going
: Direction
:= Forward
;
230 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
231 pragma Ada_05
(Index
);
234 (Source
: Unbounded_Wide_String
;
235 Set
: Wide_Maps
.Wide_Character_Set
;
237 Test
: Membership
:= Inside
;
238 Going
: Direction
:= Forward
) return Natural;
239 pragma Ada_05
(Index
);
241 function Index_Non_Blank
242 (Source
: Unbounded_Wide_String
;
243 Going
: Direction
:= Forward
) return Natural;
245 function Index_Non_Blank
246 (Source
: Unbounded_Wide_String
;
248 Going
: Direction
:= Forward
) return Natural;
249 pragma Ada_05
(Index_Non_Blank
);
252 (Source
: Unbounded_Wide_String
;
253 Pattern
: Wide_String;
254 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
258 (Source
: Unbounded_Wide_String
;
259 Pattern
: Wide_String;
260 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
263 (Source
: Unbounded_Wide_String
;
264 Set
: Wide_Maps
.Wide_Character_Set
) return Natural;
267 (Source
: Unbounded_Wide_String
;
268 Set
: Wide_Maps
.Wide_Character_Set
;
270 First
: out Positive;
273 ------------------------------------
274 -- String Translation Subprograms --
275 ------------------------------------
278 (Source
: Unbounded_Wide_String
;
279 Mapping
: Wide_Maps
.Wide_Character_Mapping
)
280 return Unbounded_Wide_String
;
283 (Source
: in out Unbounded_Wide_String
;
284 Mapping
: Wide_Maps
.Wide_Character_Mapping
);
287 (Source
: Unbounded_Wide_String
;
288 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
)
289 return Unbounded_Wide_String
;
292 (Source
: in out Unbounded_Wide_String
;
293 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
);
295 ---------------------------------------
296 -- String Transformation Subprograms --
297 ---------------------------------------
299 function Replace_Slice
300 (Source
: Unbounded_Wide_String
;
303 By
: Wide_String) return Unbounded_Wide_String
;
305 procedure Replace_Slice
306 (Source
: in out Unbounded_Wide_String
;
312 (Source
: Unbounded_Wide_String
;
314 New_Item
: Wide_String) return Unbounded_Wide_String
;
317 (Source
: in out Unbounded_Wide_String
;
319 New_Item
: Wide_String);
322 (Source
: Unbounded_Wide_String
;
324 New_Item
: Wide_String) return Unbounded_Wide_String
;
327 (Source
: in out Unbounded_Wide_String
;
329 New_Item
: Wide_String);
332 (Source
: Unbounded_Wide_String
;
334 Through
: Natural) return Unbounded_Wide_String
;
337 (Source
: in out Unbounded_Wide_String
;
342 (Source
: Unbounded_Wide_String
;
343 Side
: Trim_End
) return Unbounded_Wide_String
;
346 (Source
: in out Unbounded_Wide_String
;
350 (Source
: Unbounded_Wide_String
;
351 Left
: Wide_Maps
.Wide_Character_Set
;
352 Right
: Wide_Maps
.Wide_Character_Set
) return Unbounded_Wide_String
;
355 (Source
: in out Unbounded_Wide_String
;
356 Left
: Wide_Maps
.Wide_Character_Set
;
357 Right
: Wide_Maps
.Wide_Character_Set
);
360 (Source
: Unbounded_Wide_String
;
362 Pad
: Wide_Character := Wide_Space
) return Unbounded_Wide_String
;
365 (Source
: in out Unbounded_Wide_String
;
367 Pad
: Wide_Character := Wide_Space
);
370 (Source
: Unbounded_Wide_String
;
372 Pad
: Wide_Character := Wide_Space
) return Unbounded_Wide_String
;
375 (Source
: in out Unbounded_Wide_String
;
377 Pad
: Wide_Character := Wide_Space
);
381 Right
: Wide_Character) return Unbounded_Wide_String
;
385 Right
: Wide_String) return Unbounded_Wide_String
;
389 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
392 pragma Inline
(Length
);
394 package AF
renames Ada
.Finalization
;
396 Null_Wide_String
: aliased Wide_String := "";
398 function To_Unbounded_Wide
(S
: Wide_String) return Unbounded_Wide_String
399 renames To_Unbounded_Wide_String
;
401 type Unbounded_Wide_String
is new AF
.Controlled
with record
402 Reference
: Wide_String_Access
:= Null_Wide_String
'Access;
406 -- The Unbounded_Wide_String is using a buffered implementation to increase
407 -- speed of the Append/Delete/Insert procedures. The Reference string
408 -- pointer above contains the current string value and extra room at the
409 -- end to be used by the next Append routine. Last is the index of the
410 -- string ending character. So the current string value is really
411 -- Reference (1 .. Last).
413 pragma Stream_Convert
414 (Unbounded_Wide_String
, To_Unbounded_Wide
, To_Wide_String
);
416 pragma Finalize_Storage_Only
(Unbounded_Wide_String
);
417 -- Finalization is required only for freeing storage
419 procedure Initialize
(Object
: in out Unbounded_Wide_String
);
420 procedure Adjust
(Object
: in out Unbounded_Wide_String
);
421 procedure Finalize
(Object
: in out Unbounded_Wide_String
);
423 procedure Realloc_For_Chunk
424 (Source
: in out Unbounded_Wide_String
;
425 Chunk_Size
: Natural);
426 -- Adjust the size allocated for the string. Add at least Chunk_Size so it
427 -- is safe to add a string of this size at the end of the current content.
428 -- The real size allocated for the string is Chunk_Size + x of the current
429 -- string size. This buffered handling makes the Append unbounded string
430 -- routines very fast.
432 Null_Unbounded_Wide_String
: constant Unbounded_Wide_String
:=
434 Reference
=> Null_Wide_String
'Access,
436 end Ada
.Strings
.Wide_Unbounded
;