1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . U N B O U N D E D --
9 -- $Revision: 1.20 $ --
11 -- Copyright (C) 1992-1998 Free Software Foundation, Inc. --
13 -- This specification is derived from the Ada Reference Manual for use with --
14 -- GNAT. The copyright notice above, and the license provisions that follow --
15 -- apply solely to the contents of the part following the private keyword. --
17 -- GNAT is free software; you can redistribute it and/or modify it under --
18 -- terms of the GNU General Public License as published by the Free Soft- --
19 -- ware Foundation; either version 2, or (at your option) any later ver- --
20 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
21 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
22 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
23 -- for more details. You should have received a copy of the GNU General --
24 -- Public License distributed with GNAT; see file COPYING. If not, write --
25 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
26 -- MA 02111-1307, USA. --
28 -- As a special exception, if other files instantiate generics from this --
29 -- unit, or you link this unit with other files to produce an executable, --
30 -- this unit does not by itself cause the resulting executable to be --
31 -- covered by the GNU General Public License. This exception does not --
32 -- however invalidate any other reasons why the executable file might be --
33 -- covered by the GNU Public License. --
35 -- GNAT was originally developed by the GNAT team at New York University. --
36 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
38 ------------------------------------------------------------------------------
40 with Ada
.Strings
.Maps
;
41 with Ada
.Finalization
;
43 package Ada
.Strings
.Unbounded
is
44 pragma Preelaborate
(Unbounded
);
46 type Unbounded_String
is private;
48 Null_Unbounded_String
: constant Unbounded_String
;
50 function Length
(Source
: Unbounded_String
) return Natural;
52 type String_Access
is access all String;
54 procedure Free
(X
: in out String_Access
);
56 --------------------------------------------------------
57 -- Conversion, Concatenation, and Selection Functions --
58 --------------------------------------------------------
60 function To_Unbounded_String
(Source
: String) return Unbounded_String
;
61 function To_Unbounded_String
(Length
: in Natural) return Unbounded_String
;
63 function To_String
(Source
: Unbounded_String
) return String;
66 (Source
: in out Unbounded_String
;
67 New_Item
: in Unbounded_String
);
70 (Source
: in out Unbounded_String
;
71 New_Item
: in String);
74 (Source
: in out Unbounded_String
;
75 New_Item
: in Character);
77 function "&" (Left
, Right
: Unbounded_String
) return Unbounded_String
;
80 (Left
: in Unbounded_String
;
82 return Unbounded_String
;
86 Right
: in Unbounded_String
)
87 return Unbounded_String
;
90 (Left
: in Unbounded_String
;
92 return Unbounded_String
;
96 Right
: in Unbounded_String
)
97 return Unbounded_String
;
100 (Source
: in Unbounded_String
;
104 procedure Replace_Element
105 (Source
: in out Unbounded_String
;
110 (Source
: in Unbounded_String
;
115 function "=" (Left
, Right
: in Unbounded_String
) return Boolean;
118 (Left
: in Unbounded_String
;
124 Right
: in Unbounded_String
)
127 function "<" (Left
, Right
: in Unbounded_String
) return Boolean;
130 (Left
: in Unbounded_String
;
136 Right
: in Unbounded_String
)
139 function "<=" (Left
, Right
: in Unbounded_String
) return Boolean;
142 (Left
: in Unbounded_String
;
148 Right
: in Unbounded_String
)
151 function ">" (Left
, Right
: in Unbounded_String
) return Boolean;
154 (Left
: in Unbounded_String
;
160 Right
: in Unbounded_String
)
163 function ">=" (Left
, Right
: in Unbounded_String
) return Boolean;
166 (Left
: in Unbounded_String
;
172 Right
: in Unbounded_String
)
175 ------------------------
176 -- Search Subprograms --
177 ------------------------
180 (Source
: in Unbounded_String
;
182 Going
: in Direction
:= Forward
;
183 Mapping
: in Maps
.Character_Mapping
:= Maps
.Identity
)
187 (Source
: in Unbounded_String
;
189 Going
: in Direction
:= Forward
;
190 Mapping
: in Maps
.Character_Mapping_Function
)
194 (Source
: in Unbounded_String
;
195 Set
: in Maps
.Character_Set
;
196 Test
: in Membership
:= Inside
;
197 Going
: in Direction
:= Forward
)
200 function Index_Non_Blank
201 (Source
: in Unbounded_String
;
202 Going
: in Direction
:= Forward
)
206 (Source
: in Unbounded_String
;
208 Mapping
: in Maps
.Character_Mapping
:= Maps
.Identity
)
212 (Source
: in Unbounded_String
;
214 Mapping
: in Maps
.Character_Mapping_Function
)
218 (Source
: in Unbounded_String
;
219 Set
: in Maps
.Character_Set
)
223 (Source
: in Unbounded_String
;
224 Set
: in Maps
.Character_Set
;
225 Test
: in Membership
;
226 First
: out Positive;
229 ------------------------------------
230 -- String Translation Subprograms --
231 ------------------------------------
234 (Source
: in Unbounded_String
;
235 Mapping
: in Maps
.Character_Mapping
)
236 return Unbounded_String
;
239 (Source
: in out Unbounded_String
;
240 Mapping
: Maps
.Character_Mapping
);
243 (Source
: in Unbounded_String
;
244 Mapping
: in Maps
.Character_Mapping_Function
)
245 return Unbounded_String
;
248 (Source
: in out Unbounded_String
;
249 Mapping
: in Maps
.Character_Mapping_Function
);
251 ---------------------------------------
252 -- String Transformation Subprograms --
253 ---------------------------------------
255 function Replace_Slice
256 (Source
: in Unbounded_String
;
260 return Unbounded_String
;
262 procedure Replace_Slice
263 (Source
: in out Unbounded_String
;
269 (Source
: in Unbounded_String
;
270 Before
: in Positive;
271 New_Item
: in String)
272 return Unbounded_String
;
275 (Source
: in out Unbounded_String
;
276 Before
: in Positive;
277 New_Item
: in String);
280 (Source
: in Unbounded_String
;
281 Position
: in Positive;
282 New_Item
: in String)
283 return Unbounded_String
;
286 (Source
: in out Unbounded_String
;
287 Position
: in Positive;
288 New_Item
: in String);
291 (Source
: in Unbounded_String
;
293 Through
: in Natural)
294 return Unbounded_String
;
297 (Source
: in out Unbounded_String
;
299 Through
: in Natural);
302 (Source
: in Unbounded_String
;
304 return Unbounded_String
;
307 (Source
: in out Unbounded_String
;
311 (Source
: in Unbounded_String
;
312 Left
: in Maps
.Character_Set
;
313 Right
: in Maps
.Character_Set
)
314 return Unbounded_String
;
317 (Source
: in out Unbounded_String
;
318 Left
: in Maps
.Character_Set
;
319 Right
: in Maps
.Character_Set
);
322 (Source
: in Unbounded_String
;
324 Pad
: in Character := Space
)
325 return Unbounded_String
;
328 (Source
: in out Unbounded_String
;
330 Pad
: in Character := Space
);
333 (Source
: in Unbounded_String
;
335 Pad
: in Character := Space
)
336 return Unbounded_String
;
339 (Source
: in out Unbounded_String
;
341 Pad
: in Character := Space
);
345 Right
: in Character)
346 return Unbounded_String
;
351 return Unbounded_String
;
355 Right
: in Unbounded_String
)
356 return Unbounded_String
;
359 pragma Inline
(Length
);
361 package AF
renames Ada
.Finalization
;
363 Null_String
: aliased String := "";
365 function To_Unbounded
(S
: String) return Unbounded_String
366 renames To_Unbounded_String
;
368 type Unbounded_String
is new AF
.Controlled
with record
369 Reference
: String_Access
:= Null_String
'Access;
372 pragma Stream_Convert
(Unbounded_String
, To_Unbounded
, To_String
);
374 pragma Finalize_Storage_Only
(Unbounded_String
);
376 procedure Initialize
(Object
: in out Unbounded_String
);
377 procedure Adjust
(Object
: in out Unbounded_String
);
378 procedure Finalize
(Object
: in out Unbounded_String
);
380 Null_Unbounded_String
: constant Unbounded_String
:=
381 (AF
.Controlled
with Reference
=> Null_String
'Access);
383 end Ada
.Strings
.Unbounded
;