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 --
10 -- Copyright (C) 1992-1998 Free Software Foundation, Inc. --
12 -- This specification is derived from the Ada Reference Manual for use with --
13 -- GNAT. The copyright notice above, and the license provisions that follow --
14 -- apply solely to the contents of the part following the private keyword. --
16 -- GNAT is free software; you can redistribute it and/or modify it under --
17 -- terms of the GNU General Public License as published by the Free Soft- --
18 -- ware Foundation; either version 2, or (at your option) any later ver- --
19 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
20 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
21 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
22 -- for more details. You should have received a copy of the GNU General --
23 -- Public License distributed with GNAT; see file COPYING. If not, write --
24 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
25 -- MA 02111-1307, USA. --
27 -- As a special exception, if other files instantiate generics from this --
28 -- unit, or you link this unit with other files to produce an executable, --
29 -- this unit does not by itself cause the resulting executable to be --
30 -- covered by the GNU General Public License. This exception does not --
31 -- however invalidate any other reasons why the executable file might be --
32 -- covered by the GNU Public License. --
34 -- GNAT was originally developed by the GNAT team at New York University. --
35 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
37 ------------------------------------------------------------------------------
39 with Ada
.Strings
.Maps
;
40 with Ada
.Finalization
;
42 package Ada
.Strings
.Unbounded
is
43 pragma Preelaborate
(Unbounded
);
45 type Unbounded_String
is private;
47 Null_Unbounded_String
: constant Unbounded_String
;
49 function Length
(Source
: Unbounded_String
) return Natural;
51 type String_Access
is access all String;
53 procedure Free
(X
: in out String_Access
);
55 --------------------------------------------------------
56 -- Conversion, Concatenation, and Selection Functions --
57 --------------------------------------------------------
59 function To_Unbounded_String
(Source
: String) return Unbounded_String
;
60 function To_Unbounded_String
(Length
: in Natural) return Unbounded_String
;
62 function To_String
(Source
: Unbounded_String
) return String;
65 (Source
: in out Unbounded_String
;
66 New_Item
: in Unbounded_String
);
69 (Source
: in out Unbounded_String
;
70 New_Item
: in String);
73 (Source
: in out Unbounded_String
;
74 New_Item
: in Character);
76 function "&" (Left
, Right
: Unbounded_String
) return Unbounded_String
;
79 (Left
: in Unbounded_String
;
81 return Unbounded_String
;
85 Right
: in Unbounded_String
)
86 return Unbounded_String
;
89 (Left
: in Unbounded_String
;
91 return Unbounded_String
;
95 Right
: in Unbounded_String
)
96 return Unbounded_String
;
99 (Source
: in Unbounded_String
;
103 procedure Replace_Element
104 (Source
: in out Unbounded_String
;
109 (Source
: in Unbounded_String
;
114 function "=" (Left
, Right
: in Unbounded_String
) return Boolean;
117 (Left
: in Unbounded_String
;
123 Right
: in Unbounded_String
)
126 function "<" (Left
, Right
: in Unbounded_String
) return Boolean;
129 (Left
: in Unbounded_String
;
135 Right
: in Unbounded_String
)
138 function "<=" (Left
, Right
: in Unbounded_String
) return Boolean;
141 (Left
: in Unbounded_String
;
147 Right
: in Unbounded_String
)
150 function ">" (Left
, Right
: in Unbounded_String
) return Boolean;
153 (Left
: in Unbounded_String
;
159 Right
: in Unbounded_String
)
162 function ">=" (Left
, Right
: in Unbounded_String
) return Boolean;
165 (Left
: in Unbounded_String
;
171 Right
: in Unbounded_String
)
174 ------------------------
175 -- Search Subprograms --
176 ------------------------
179 (Source
: in Unbounded_String
;
181 Going
: in Direction
:= Forward
;
182 Mapping
: in Maps
.Character_Mapping
:= Maps
.Identity
)
186 (Source
: in Unbounded_String
;
188 Going
: in Direction
:= Forward
;
189 Mapping
: in Maps
.Character_Mapping_Function
)
193 (Source
: in Unbounded_String
;
194 Set
: in Maps
.Character_Set
;
195 Test
: in Membership
:= Inside
;
196 Going
: in Direction
:= Forward
)
199 function Index_Non_Blank
200 (Source
: in Unbounded_String
;
201 Going
: in Direction
:= Forward
)
205 (Source
: in Unbounded_String
;
207 Mapping
: in Maps
.Character_Mapping
:= Maps
.Identity
)
211 (Source
: in Unbounded_String
;
213 Mapping
: in Maps
.Character_Mapping_Function
)
217 (Source
: in Unbounded_String
;
218 Set
: in Maps
.Character_Set
)
222 (Source
: in Unbounded_String
;
223 Set
: in Maps
.Character_Set
;
224 Test
: in Membership
;
225 First
: out Positive;
228 ------------------------------------
229 -- String Translation Subprograms --
230 ------------------------------------
233 (Source
: in Unbounded_String
;
234 Mapping
: in Maps
.Character_Mapping
)
235 return Unbounded_String
;
238 (Source
: in out Unbounded_String
;
239 Mapping
: Maps
.Character_Mapping
);
242 (Source
: in Unbounded_String
;
243 Mapping
: in Maps
.Character_Mapping_Function
)
244 return Unbounded_String
;
247 (Source
: in out Unbounded_String
;
248 Mapping
: in Maps
.Character_Mapping_Function
);
250 ---------------------------------------
251 -- String Transformation Subprograms --
252 ---------------------------------------
254 function Replace_Slice
255 (Source
: in Unbounded_String
;
259 return Unbounded_String
;
261 procedure Replace_Slice
262 (Source
: in out Unbounded_String
;
268 (Source
: in Unbounded_String
;
269 Before
: in Positive;
270 New_Item
: in String)
271 return Unbounded_String
;
274 (Source
: in out Unbounded_String
;
275 Before
: in Positive;
276 New_Item
: in String);
279 (Source
: in Unbounded_String
;
280 Position
: in Positive;
281 New_Item
: in String)
282 return Unbounded_String
;
285 (Source
: in out Unbounded_String
;
286 Position
: in Positive;
287 New_Item
: in String);
290 (Source
: in Unbounded_String
;
292 Through
: in Natural)
293 return Unbounded_String
;
296 (Source
: in out Unbounded_String
;
298 Through
: in Natural);
301 (Source
: in Unbounded_String
;
303 return Unbounded_String
;
306 (Source
: in out Unbounded_String
;
310 (Source
: in Unbounded_String
;
311 Left
: in Maps
.Character_Set
;
312 Right
: in Maps
.Character_Set
)
313 return Unbounded_String
;
316 (Source
: in out Unbounded_String
;
317 Left
: in Maps
.Character_Set
;
318 Right
: in Maps
.Character_Set
);
321 (Source
: in Unbounded_String
;
323 Pad
: in Character := Space
)
324 return Unbounded_String
;
327 (Source
: in out Unbounded_String
;
329 Pad
: in Character := Space
);
332 (Source
: in Unbounded_String
;
334 Pad
: in Character := Space
)
335 return Unbounded_String
;
338 (Source
: in out Unbounded_String
;
340 Pad
: in Character := Space
);
344 Right
: in Character)
345 return Unbounded_String
;
350 return Unbounded_String
;
354 Right
: in Unbounded_String
)
355 return Unbounded_String
;
358 pragma Inline
(Length
);
360 package AF
renames Ada
.Finalization
;
362 Null_String
: aliased String := "";
364 function To_Unbounded
(S
: String) return Unbounded_String
365 renames To_Unbounded_String
;
367 type Unbounded_String
is new AF
.Controlled
with record
368 Reference
: String_Access
:= Null_String
'Access;
371 pragma Stream_Convert
(Unbounded_String
, To_Unbounded
, To_String
);
373 pragma Finalize_Storage_Only
(Unbounded_String
);
375 procedure Initialize
(Object
: in out Unbounded_String
);
376 procedure Adjust
(Object
: in out Unbounded_String
);
377 procedure Finalize
(Object
: in out Unbounded_String
);
379 Null_Unbounded_String
: constant Unbounded_String
:=
380 (AF
.Controlled
with Reference
=> Null_String
'Access);
382 end Ada
.Strings
.Unbounded
;