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-2005 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, 59 Temple Place - Suite 330, Boston, --
24 -- MA 02111-1307, 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
42 pragma Preelaborate
(Wide_Unbounded
);
44 type Unbounded_Wide_String
is private;
46 Null_Unbounded_Wide_String
: constant Unbounded_Wide_String
;
48 function Length
(Source
: Unbounded_Wide_String
) return Natural;
50 type Wide_String_Access
is access all Wide_String;
52 procedure Free
(X
: in out Wide_String_Access
);
54 --------------------------------------------------------
55 -- Conversion, Concatenation, and Selection Functions --
56 --------------------------------------------------------
58 function To_Unbounded_Wide_String
59 (Source
: Wide_String) return Unbounded_Wide_String
;
61 function To_Unbounded_Wide_String
62 (Length
: Natural) return Unbounded_Wide_String
;
64 function To_Wide_String
65 (Source
: Unbounded_Wide_String
) return Wide_String;
68 (Source
: in out Unbounded_Wide_String
;
69 New_Item
: Unbounded_Wide_String
);
72 (Source
: in out Unbounded_Wide_String
;
73 New_Item
: Wide_String);
76 (Source
: in out Unbounded_Wide_String
;
77 New_Item
: Wide_Character);
80 (Left
, Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
83 (Left
: Unbounded_Wide_String
;
84 Right
: Wide_String) return Unbounded_Wide_String
;
88 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
91 (Left
: Unbounded_Wide_String
;
92 Right
: Wide_Character) return Unbounded_Wide_String
;
95 (Left
: Wide_Character;
96 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
99 (Source
: Unbounded_Wide_String
;
100 Index
: Positive) return Wide_Character;
102 procedure Replace_Element
103 (Source
: in out Unbounded_Wide_String
;
105 By
: Wide_Character);
108 (Source
: Unbounded_Wide_String
;
110 High
: Natural) return Wide_String;
113 (Left
: Unbounded_Wide_String
;
114 Right
: Unbounded_Wide_String
) return Boolean;
117 (Left
: Unbounded_Wide_String
;
118 Right
: Wide_String) return Boolean;
122 Right
: Unbounded_Wide_String
) return Boolean;
125 (Left
: Unbounded_Wide_String
;
126 Right
: Unbounded_Wide_String
) return Boolean;
129 (Left
: Unbounded_Wide_String
;
130 Right
: Wide_String) return Boolean;
134 Right
: Unbounded_Wide_String
) return Boolean;
137 (Left
: Unbounded_Wide_String
;
138 Right
: Unbounded_Wide_String
) return Boolean;
141 (Left
: Unbounded_Wide_String
;
142 Right
: Wide_String) return Boolean;
146 Right
: Unbounded_Wide_String
) return Boolean;
149 (Left
: Unbounded_Wide_String
;
150 Right
: Unbounded_Wide_String
) return Boolean;
153 (Left
: Unbounded_Wide_String
;
154 Right
: Wide_String) return Boolean;
158 Right
: Unbounded_Wide_String
) return Boolean;
161 (Left
: Unbounded_Wide_String
;
162 Right
: Unbounded_Wide_String
) return Boolean;
165 (Left
: Unbounded_Wide_String
;
166 Right
: Wide_String) return Boolean;
170 Right
: Unbounded_Wide_String
) return Boolean;
172 ------------------------
173 -- Search Subprograms --
174 ------------------------
177 (Source
: Unbounded_Wide_String
;
178 Pattern
: Wide_String;
179 Going
: Direction
:= Forward
;
180 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
184 (Source
: Unbounded_Wide_String
;
185 Pattern
: Wide_String;
186 Going
: Direction
:= Forward
;
187 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
190 (Source
: Unbounded_Wide_String
;
191 Set
: Wide_Maps
.Wide_Character_Set
;
192 Test
: Membership
:= Inside
;
193 Going
: Direction
:= Forward
) return Natural;
195 function Index_Non_Blank
196 (Source
: Unbounded_Wide_String
;
197 Going
: Direction
:= Forward
) return Natural;
200 (Source
: Unbounded_Wide_String
;
201 Pattern
: Wide_String;
202 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
206 (Source
: Unbounded_Wide_String
;
207 Pattern
: Wide_String;
208 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
) return Natural;
211 (Source
: Unbounded_Wide_String
;
212 Set
: Wide_Maps
.Wide_Character_Set
) return Natural;
215 (Source
: Unbounded_Wide_String
;
216 Set
: Wide_Maps
.Wide_Character_Set
;
218 First
: out Positive;
221 ------------------------------------
222 -- Wide_String Translation Subprograms --
223 ------------------------------------
226 (Source
: Unbounded_Wide_String
;
227 Mapping
: Wide_Maps
.Wide_Character_Mapping
) return Unbounded_Wide_String
;
230 (Source
: in out Unbounded_Wide_String
;
231 Mapping
: Wide_Maps
.Wide_Character_Mapping
);
234 (Source
: Unbounded_Wide_String
;
235 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
)
236 return Unbounded_Wide_String
;
239 (Source
: in out Unbounded_Wide_String
;
240 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
);
242 ---------------------------------------
243 -- Wide_String Transformation Subprograms --
244 ---------------------------------------
246 function Replace_Slice
247 (Source
: Unbounded_Wide_String
;
250 By
: Wide_String) return Unbounded_Wide_String
;
252 procedure Replace_Slice
253 (Source
: in out Unbounded_Wide_String
;
259 (Source
: Unbounded_Wide_String
;
261 New_Item
: Wide_String) return Unbounded_Wide_String
;
264 (Source
: in out Unbounded_Wide_String
;
266 New_Item
: Wide_String);
269 (Source
: Unbounded_Wide_String
;
271 New_Item
: Wide_String) return Unbounded_Wide_String
;
274 (Source
: in out Unbounded_Wide_String
;
276 New_Item
: Wide_String);
279 (Source
: Unbounded_Wide_String
;
281 Through
: Natural) return Unbounded_Wide_String
;
284 (Source
: in out Unbounded_Wide_String
;
289 (Source
: Unbounded_Wide_String
;
290 Side
: Trim_End
) return Unbounded_Wide_String
;
293 (Source
: in out Unbounded_Wide_String
;
297 (Source
: Unbounded_Wide_String
;
298 Left
: Wide_Maps
.Wide_Character_Set
;
299 Right
: Wide_Maps
.Wide_Character_Set
) return Unbounded_Wide_String
;
302 (Source
: in out Unbounded_Wide_String
;
303 Left
: Wide_Maps
.Wide_Character_Set
;
304 Right
: Wide_Maps
.Wide_Character_Set
);
307 (Source
: Unbounded_Wide_String
;
309 Pad
: Wide_Character := Wide_Space
) return Unbounded_Wide_String
;
312 (Source
: in out Unbounded_Wide_String
;
314 Pad
: Wide_Character := Wide_Space
);
317 (Source
: Unbounded_Wide_String
;
319 Pad
: Wide_Character := Wide_Space
) return Unbounded_Wide_String
;
322 (Source
: in out Unbounded_Wide_String
;
324 Pad
: Wide_Character := Wide_Space
);
328 Right
: Wide_Character) return Unbounded_Wide_String
;
332 Right
: Wide_String) return Unbounded_Wide_String
;
336 Right
: Unbounded_Wide_String
) return Unbounded_Wide_String
;
339 pragma Inline
(Length
);
341 package AF
renames Ada
.Finalization
;
343 Null_Wide_String
: aliased Wide_String := "";
345 function To_Unbounded_Wide
(S
: Wide_String) return Unbounded_Wide_String
346 renames To_Unbounded_Wide_String
;
348 type Unbounded_Wide_String
is new AF
.Controlled
with record
349 Reference
: Wide_String_Access
:= Null_Wide_String
'Access;
353 -- The Unbounded_Wide_String is using a buffered implementation to increase
354 -- speed of the Append/Delete/Insert procedures. The Reference string
355 -- pointer above contains the current string value and extra room at the
356 -- end to be used by the next Append routine. Last is the index of the
357 -- string ending character. So the current string value is really
358 -- Reference (1 .. Last).
360 pragma Stream_Convert
361 (Unbounded_Wide_String
, To_Unbounded_Wide
, To_Wide_String
);
363 pragma Finalize_Storage_Only
(Unbounded_Wide_String
);
365 procedure Initialize
(Object
: in out Unbounded_Wide_String
);
366 procedure Adjust
(Object
: in out Unbounded_Wide_String
);
367 procedure Finalize
(Object
: in out Unbounded_Wide_String
);
369 Null_Unbounded_Wide_String
: constant Unbounded_Wide_String
:=
370 (AF
.Controlled
with Reference
=> Null_Wide_String
'Access, Last
=> 0);
372 end Ada
.Strings
.Wide_Unbounded
;