1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . B O U N D E D --
11 -- Copyright (C) 1992-2000 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;
42 package Ada.Strings.Bounded is
43 pragma Preelaborate (Bounded);
47 -- Maximum length of a Bounded_String
49 package Generic_Bounded_Length is
51 Max_Length : constant Positive := Max;
53 type Bounded_String is private;
55 Null_Bounded_String : constant Bounded_String;
57 subtype Length_Range is Natural range 0 .. Max_Length;
59 function Length (Source : in Bounded_String) return Length_Range;
61 --------------------------------------------------------
62 -- Conversion, Concatenation, and Selection Functions --
63 --------------------------------------------------------
65 function To_Bounded_String
67 Drop : in Truncation := Error)
68 return Bounded_String;
70 function To_String (Source : in Bounded_String) return String;
73 (Left, Right : in Bounded_String;
74 Drop : in Truncation := Error)
75 return Bounded_String;
78 (Left : in Bounded_String;
80 Drop : in Truncation := Error)
81 return Bounded_String;
85 Right : in Bounded_String;
86 Drop : in Truncation := Error)
87 return Bounded_String;
90 (Left : in Bounded_String;
92 Drop : in Truncation := Error)
93 return Bounded_String;
97 Right : in Bounded_String;
98 Drop : in Truncation := Error)
99 return Bounded_String;
102 (Source : in out Bounded_String;
103 New_Item : in Bounded_String;
104 Drop : in Truncation := Error);
107 (Source : in out Bounded_String;
108 New_Item : in String;
109 Drop : in Truncation := Error);
112 (Source : in out Bounded_String;
113 New_Item : in Character;
114 Drop : in Truncation := Error);
117 (Left, Right : in Bounded_String)
118 return Bounded_String;
121 (Left : in Bounded_String;
123 return Bounded_String;
127 Right : in Bounded_String)
128 return Bounded_String;
131 (Left : in Bounded_String;
132 Right : in Character)
133 return Bounded_String;
136 (Left : in Character;
137 Right : in Bounded_String)
138 return Bounded_String;
141 (Source : in Bounded_String;
145 procedure Replace_Element
146 (Source : in out Bounded_String;
151 (Source : in Bounded_String;
156 function "=" (Left, Right : in Bounded_String) return Boolean;
159 (Left : in Bounded_String;
165 Right : in Bounded_String)
168 function "<" (Left, Right : in Bounded_String) return Boolean;
171 (Left : in Bounded_String;
177 Right : in Bounded_String)
180 function "<=" (Left, Right : in Bounded_String) return Boolean;
183 (Left : in Bounded_String;
189 Right : in Bounded_String)
192 function ">" (Left, Right : in Bounded_String) return Boolean;
195 (Left : in Bounded_String;
201 Right : in Bounded_String)
204 function ">=" (Left, Right : in Bounded_String) return Boolean;
207 (Left : in Bounded_String;
213 Right : in Bounded_String)
216 ----------------------
217 -- Search Functions --
218 ----------------------
221 (Source : in Bounded_String;
223 Going : in Direction := Forward;
224 Mapping : in Maps.Character_Mapping := Maps.Identity)
228 (Source : in Bounded_String;
230 Going : in Direction := Forward;
231 Mapping : in Maps.Character_Mapping_Function)
235 (Source : in Bounded_String;
236 Set : in Maps.Character_Set;
237 Test : in Membership := Inside;
238 Going : in Direction := Forward)
241 function Index_Non_Blank
242 (Source : in Bounded_String;
243 Going : in Direction := Forward)
247 (Source : in Bounded_String;
249 Mapping : in Maps.Character_Mapping := Maps.Identity)
253 (Source : in Bounded_String;
255 Mapping : in Maps.Character_Mapping_Function)
259 (Source : in Bounded_String;
260 Set : in Maps.Character_Set)
264 (Source : in Bounded_String;
265 Set : in Maps.Character_Set;
266 Test : in Membership;
267 First : out Positive;
270 ------------------------------------
271 -- String Translation Subprograms --
272 ------------------------------------
275 (Source : in Bounded_String;
276 Mapping : in Maps.Character_Mapping)
277 return Bounded_String;
280 (Source : in out Bounded_String;
281 Mapping : in Maps.Character_Mapping);
284 (Source : in Bounded_String;
285 Mapping : in Maps.Character_Mapping_Function)
286 return Bounded_String;
289 (Source : in out Bounded_String;
290 Mapping : in Maps.Character_Mapping_Function);
292 ---------------------------------------
293 -- String Transformation Subprograms --
294 ---------------------------------------
296 function Replace_Slice
297 (Source : in Bounded_String;
301 Drop : in Truncation := Error)
302 return Bounded_String;
304 procedure Replace_Slice
305 (Source : in out Bounded_String;
309 Drop : in Truncation := Error);
312 (Source : in Bounded_String;
313 Before : in Positive;
314 New_Item : in String;
315 Drop : in Truncation := Error)
316 return Bounded_String;
319 (Source : in out Bounded_String;
320 Before : in Positive;
321 New_Item : in String;
322 Drop : in Truncation := Error);
325 (Source : in Bounded_String;
326 Position : in Positive;
327 New_Item : in String;
328 Drop : in Truncation := Error)
329 return Bounded_String;
332 (Source : in out Bounded_String;
333 Position : in Positive;
334 New_Item : in String;
335 Drop : in Truncation := Error);
338 (Source : in Bounded_String;
340 Through : in Natural)
341 return Bounded_String;
344 (Source : in out Bounded_String;
346 Through : in Natural);
348 ---------------------------------
349 -- String Selector Subprograms --
350 ---------------------------------
353 (Source : in Bounded_String;
355 return Bounded_String;
358 (Source : in out Bounded_String;
362 (Source : in Bounded_String;
363 Left : in Maps.Character_Set;
364 Right : in Maps.Character_Set)
365 return Bounded_String;
368 (Source : in out Bounded_String;
369 Left : in Maps.Character_Set;
370 Right : in Maps.Character_Set);
373 (Source : in Bounded_String;
375 Pad : in Character := Space;
376 Drop : in Truncation := Error)
377 return Bounded_String;
380 (Source : in out Bounded_String;
382 Pad : in Character := Space;
383 Drop : in Truncation := Error);
386 (Source : in Bounded_String;
388 Pad : in Character := Space;
389 Drop : in Truncation := Error)
390 return Bounded_String;
393 (Source : in out Bounded_String;
395 Pad : in Character := Space;
396 Drop : in Truncation := Error);
398 ------------------------------------
399 -- String Constructor Subprograms --
400 ------------------------------------
404 Right : in Character)
405 return Bounded_String;
410 return Bounded_String;
414 Right : in Bounded_String)
415 return Bounded_String;
420 Drop : in Truncation := Error)
421 return Bounded_String;
426 Drop : in Truncation := Error)
427 return Bounded_String;
431 Item : in Bounded_String;
432 Drop : in Truncation := Error)
433 return Bounded_String;
437 type Bounded_String is record
438 Length : Length_Range := 0;
439 Data : String (1 .. Max_Length) := (1 .. Max_Length => ASCII.NUL);
442 Null_Bounded_String : constant Bounded_String :=
443 (Length => 0, Data => (1 .. Max_Length => ASCII.NUL));
446 -- Pragma Inline declarations (GNAT specific additions)
450 pragma Inline ("<=");
452 pragma Inline (">=");
454 pragma Inline (Count);
455 pragma Inline (Element);
456 pragma Inline (Find_Token);
457 pragma Inline (Index);
458 pragma Inline (Index_Non_Blank);
459 pragma Inline (Length);
460 pragma Inline (Replace_Element);
461 pragma Inline (Slice);
462 pragma Inline (To_Bounded_String);
463 pragma Inline (To_String);
465 end Generic_Bounded_Length;
467 end Ada.Strings.Bounded;