1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
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 --
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_Wide_Maps
;
39 with Ada
.Finalization
;
41 package Ada
.Strings
.Wide_Wide_Unbounded
is
44 type Unbounded_Wide_Wide_String
is private;
45 pragma Preelaborable_Initialization
(Unbounded_Wide_Wide_String
);
47 Null_Unbounded_Wide_Wide_String
: constant Unbounded_Wide_Wide_String
;
49 function Length
(Source
: Unbounded_Wide_Wide_String
) return Natural;
51 type Wide_Wide_String_Access
is access all Wide_Wide_String
;
53 procedure Free
(X
: in out Wide_Wide_String_Access
);
55 --------------------------------------------------------
56 -- Conversion, Concatenation, and Selection Functions --
57 --------------------------------------------------------
59 function To_Unbounded_Wide_Wide_String
60 (Source
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
62 function To_Unbounded_Wide_Wide_String
63 (Length
: Natural) return Unbounded_Wide_Wide_String
;
65 function To_Wide_Wide_String
66 (Source
: Unbounded_Wide_Wide_String
) return Wide_Wide_String
;
68 procedure Set_Unbounded_Wide_Wide_String
69 (Target
: out Unbounded_Wide_Wide_String
;
70 Source
: Wide_Wide_String
);
71 pragma Ada_05
(Set_Unbounded_Wide_Wide_String
);
74 (Source
: in out Unbounded_Wide_Wide_String
;
75 New_Item
: Unbounded_Wide_Wide_String
);
78 (Source
: in out Unbounded_Wide_Wide_String
;
79 New_Item
: Wide_Wide_String
);
82 (Source
: in out Unbounded_Wide_Wide_String
;
83 New_Item
: Wide_Wide_Character
);
86 (Left
: Unbounded_Wide_Wide_String
;
87 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
90 (Left
: Unbounded_Wide_Wide_String
;
91 Right
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
94 (Left
: Wide_Wide_String
;
95 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
98 (Left
: Unbounded_Wide_Wide_String
;
99 Right
: Wide_Wide_Character
) return Unbounded_Wide_Wide_String
;
102 (Left
: Wide_Wide_Character
;
103 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
106 (Source
: Unbounded_Wide_Wide_String
;
107 Index
: Positive) return Wide_Wide_Character
;
109 procedure Replace_Element
110 (Source
: in out Unbounded_Wide_Wide_String
;
112 By
: Wide_Wide_Character
);
115 (Source
: Unbounded_Wide_Wide_String
;
117 High
: Natural) return Wide_Wide_String
;
119 function Unbounded_Slice
120 (Source
: Unbounded_Wide_Wide_String
;
122 High
: Natural) return Unbounded_Wide_Wide_String
;
123 pragma Ada_05
(Unbounded_Slice
);
125 procedure Unbounded_Slice
126 (Source
: Unbounded_Wide_Wide_String
;
127 Target
: out Unbounded_Wide_Wide_String
;
130 pragma Ada_05
(Unbounded_Slice
);
133 (Left
: Unbounded_Wide_Wide_String
;
134 Right
: Unbounded_Wide_Wide_String
) return Boolean;
137 (Left
: Unbounded_Wide_Wide_String
;
138 Right
: Wide_Wide_String
) return Boolean;
141 (Left
: Wide_Wide_String
;
142 Right
: Unbounded_Wide_Wide_String
) return Boolean;
145 (Left
: Unbounded_Wide_Wide_String
;
146 Right
: Unbounded_Wide_Wide_String
) return Boolean;
149 (Left
: Unbounded_Wide_Wide_String
;
150 Right
: Wide_Wide_String
) return Boolean;
153 (Left
: Wide_Wide_String
;
154 Right
: Unbounded_Wide_Wide_String
) return Boolean;
157 (Left
: Unbounded_Wide_Wide_String
;
158 Right
: Unbounded_Wide_Wide_String
) return Boolean;
161 (Left
: Unbounded_Wide_Wide_String
;
162 Right
: Wide_Wide_String
) return Boolean;
165 (Left
: Wide_Wide_String
;
166 Right
: Unbounded_Wide_Wide_String
) return Boolean;
169 (Left
: Unbounded_Wide_Wide_String
;
170 Right
: Unbounded_Wide_Wide_String
) return Boolean;
173 (Left
: Unbounded_Wide_Wide_String
;
174 Right
: Wide_Wide_String
) return Boolean;
177 (Left
: Wide_Wide_String
;
178 Right
: Unbounded_Wide_Wide_String
) return Boolean;
181 (Left
: Unbounded_Wide_Wide_String
;
182 Right
: Unbounded_Wide_Wide_String
) return Boolean;
185 (Left
: Unbounded_Wide_Wide_String
;
186 Right
: Wide_Wide_String
) return Boolean;
189 (Left
: Wide_Wide_String
;
190 Right
: Unbounded_Wide_Wide_String
) return Boolean;
192 ------------------------
193 -- Search Subprograms --
194 ------------------------
197 (Source
: Unbounded_Wide_Wide_String
;
198 Pattern
: Wide_Wide_String
;
199 Going
: Direction
:= Forward
;
200 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
201 Wide_Wide_Maps
.Identity
)
205 (Source
: Unbounded_Wide_Wide_String
;
206 Pattern
: Wide_Wide_String
;
207 Going
: Direction
:= Forward
;
208 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
212 (Source
: Unbounded_Wide_Wide_String
;
213 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
214 Test
: Membership
:= Inside
;
215 Going
: Direction
:= Forward
) return Natural;
218 (Source
: Unbounded_Wide_Wide_String
;
219 Pattern
: Wide_Wide_String
;
221 Going
: Direction
:= Forward
;
222 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
223 Wide_Wide_Maps
.Identity
)
225 pragma Ada_05
(Index
);
228 (Source
: Unbounded_Wide_Wide_String
;
229 Pattern
: Wide_Wide_String
;
231 Going
: Direction
:= Forward
;
232 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
234 pragma Ada_05
(Index
);
237 (Source
: Unbounded_Wide_Wide_String
;
238 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
240 Test
: Membership
:= Inside
;
241 Going
: Direction
:= Forward
) return Natural;
242 pragma Ada_05
(Index
);
244 function Index_Non_Blank
245 (Source
: Unbounded_Wide_Wide_String
;
246 Going
: Direction
:= Forward
) return Natural;
248 function Index_Non_Blank
249 (Source
: Unbounded_Wide_Wide_String
;
251 Going
: Direction
:= Forward
) return Natural;
252 pragma Ada_05
(Index_Non_Blank
);
255 (Source
: Unbounded_Wide_Wide_String
;
256 Pattern
: Wide_Wide_String
;
257 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
258 Wide_Wide_Maps
.Identity
)
262 (Source
: Unbounded_Wide_Wide_String
;
263 Pattern
: Wide_Wide_String
;
264 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
268 (Source
: Unbounded_Wide_Wide_String
;
269 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Natural;
272 (Source
: Unbounded_Wide_Wide_String
;
273 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
275 First
: out Positive;
278 ------------------------------------
279 -- String Translation Subprograms --
280 ------------------------------------
283 (Source
: Unbounded_Wide_Wide_String
;
284 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
)
285 return Unbounded_Wide_Wide_String
;
288 (Source
: in out Unbounded_Wide_Wide_String
;
289 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
);
292 (Source
: Unbounded_Wide_Wide_String
;
293 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
294 return Unbounded_Wide_Wide_String
;
297 (Source
: in out Unbounded_Wide_Wide_String
;
298 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
);
300 ---------------------------------------
301 -- String Transformation Subprograms --
302 ---------------------------------------
304 function Replace_Slice
305 (Source
: Unbounded_Wide_Wide_String
;
308 By
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
310 procedure Replace_Slice
311 (Source
: in out Unbounded_Wide_Wide_String
;
314 By
: Wide_Wide_String
);
317 (Source
: Unbounded_Wide_Wide_String
;
319 New_Item
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
322 (Source
: in out Unbounded_Wide_Wide_String
;
324 New_Item
: Wide_Wide_String
);
327 (Source
: Unbounded_Wide_Wide_String
;
329 New_Item
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
332 (Source
: in out Unbounded_Wide_Wide_String
;
334 New_Item
: Wide_Wide_String
);
337 (Source
: Unbounded_Wide_Wide_String
;
339 Through
: Natural) return Unbounded_Wide_Wide_String
;
342 (Source
: in out Unbounded_Wide_Wide_String
;
347 (Source
: Unbounded_Wide_Wide_String
;
348 Side
: Trim_End
) return Unbounded_Wide_Wide_String
;
351 (Source
: in out Unbounded_Wide_Wide_String
;
355 (Source
: Unbounded_Wide_Wide_String
;
356 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
357 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
)
358 return Unbounded_Wide_Wide_String
;
361 (Source
: in out Unbounded_Wide_Wide_String
;
362 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
363 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
);
366 (Source
: Unbounded_Wide_Wide_String
;
368 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
)
369 return Unbounded_Wide_Wide_String
;
372 (Source
: in out Unbounded_Wide_Wide_String
;
374 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
);
377 (Source
: Unbounded_Wide_Wide_String
;
379 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
)
380 return Unbounded_Wide_Wide_String
;
383 (Source
: in out Unbounded_Wide_Wide_String
;
385 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
);
389 Right
: Wide_Wide_Character
) return Unbounded_Wide_Wide_String
;
393 Right
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
397 Right
: Unbounded_Wide_Wide_String
) return Unbounded_Wide_Wide_String
;
400 pragma Inline
(Length
);
402 package AF
renames Ada
.Finalization
;
404 Null_Wide_Wide_String
: aliased Wide_Wide_String
:= "";
406 function To_Unbounded_Wide
407 (S
: Wide_Wide_String
) return Unbounded_Wide_Wide_String
408 renames To_Unbounded_Wide_Wide_String
;
410 type Unbounded_Wide_Wide_String
is new AF
.Controlled
with record
411 Reference
: Wide_Wide_String_Access
:= Null_Wide_Wide_String
'Access;
415 -- The Unbounded_Wide_Wide_String is using a buffered implementation to
416 -- increase speed of the Append/Delete/Insert procedures. The Reference
417 -- string pointer above contains the current string value and extra room
418 -- at the end to be used by the next Append routine. Last is the index of
419 -- the string ending character. So the current string value is really
420 -- Reference (1 .. Last).
422 pragma Stream_Convert
423 (Unbounded_Wide_Wide_String
, To_Unbounded_Wide
, To_Wide_Wide_String
);
425 pragma Finalize_Storage_Only
(Unbounded_Wide_Wide_String
);
426 -- Finalization is required only for freeing storage
428 procedure Initialize
(Object
: in out Unbounded_Wide_Wide_String
);
429 procedure Adjust
(Object
: in out Unbounded_Wide_Wide_String
);
430 procedure Finalize
(Object
: in out Unbounded_Wide_Wide_String
);
431 procedure Realloc_For_Chunk
432 (Source
: in out Unbounded_Wide_Wide_String
;
433 Chunk_Size
: Natural);
434 -- Adjust the size allocated for the string. Add at least Chunk_Size so it
435 -- is safe to add a string of this size at the end of the current content.
436 -- The real size allocated for the string is Chunk_Size + x of the current
437 -- string size. This buffered handling makes the Append unbounded string
438 -- routines very fast.
440 Null_Unbounded_Wide_Wide_String
: constant Unbounded_Wide_Wide_String
:=
443 Null_Wide_Wide_String
'Access,
445 end Ada
.Strings
.Wide_Wide_Unbounded
;