1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . B O U N D E D --
10 -- Copyright (C) 1992-2000 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 -- Extensive contributions were provided by Ada Core Technologies Inc. --
37 ------------------------------------------------------------------------------
39 with Ada
.Strings
.Maps
;
41 package Ada
.Strings
.Bounded
is
42 pragma Preelaborate
(Bounded
);
46 -- Maximum length of a Bounded_String
48 package Generic_Bounded_Length
is
50 Max_Length
: constant Positive := Max
;
52 type Bounded_String
is private;
54 Null_Bounded_String
: constant Bounded_String
;
56 subtype Length_Range
is Natural range 0 .. Max_Length
;
58 function Length
(Source
: in Bounded_String
) return Length_Range
;
60 --------------------------------------------------------
61 -- Conversion, Concatenation, and Selection Functions --
62 --------------------------------------------------------
64 function To_Bounded_String
66 Drop
: in Truncation
:= Error
)
67 return Bounded_String
;
69 function To_String
(Source
: in Bounded_String
) return String;
72 (Left
, Right
: in Bounded_String
;
73 Drop
: in Truncation
:= Error
)
74 return Bounded_String
;
77 (Left
: in Bounded_String
;
79 Drop
: in Truncation
:= Error
)
80 return Bounded_String
;
84 Right
: in Bounded_String
;
85 Drop
: in Truncation
:= Error
)
86 return Bounded_String
;
89 (Left
: in Bounded_String
;
91 Drop
: in Truncation
:= Error
)
92 return Bounded_String
;
96 Right
: in Bounded_String
;
97 Drop
: in Truncation
:= Error
)
98 return Bounded_String
;
101 (Source
: in out Bounded_String
;
102 New_Item
: in Bounded_String
;
103 Drop
: in Truncation
:= Error
);
106 (Source
: in out Bounded_String
;
107 New_Item
: in String;
108 Drop
: in Truncation
:= Error
);
111 (Source
: in out Bounded_String
;
112 New_Item
: in Character;
113 Drop
: in Truncation
:= Error
);
116 (Left
, Right
: in Bounded_String
)
117 return Bounded_String
;
120 (Left
: in Bounded_String
;
122 return Bounded_String
;
126 Right
: in Bounded_String
)
127 return Bounded_String
;
130 (Left
: in Bounded_String
;
131 Right
: in Character)
132 return Bounded_String
;
135 (Left
: in Character;
136 Right
: in Bounded_String
)
137 return Bounded_String
;
140 (Source
: in Bounded_String
;
144 procedure Replace_Element
145 (Source
: in out Bounded_String
;
150 (Source
: in Bounded_String
;
155 function "=" (Left
, Right
: in Bounded_String
) return Boolean;
158 (Left
: in Bounded_String
;
164 Right
: in Bounded_String
)
167 function "<" (Left
, Right
: in Bounded_String
) return Boolean;
170 (Left
: in Bounded_String
;
176 Right
: in Bounded_String
)
179 function "<=" (Left
, Right
: in Bounded_String
) return Boolean;
182 (Left
: in Bounded_String
;
188 Right
: in Bounded_String
)
191 function ">" (Left
, Right
: in Bounded_String
) return Boolean;
194 (Left
: in Bounded_String
;
200 Right
: in Bounded_String
)
203 function ">=" (Left
, Right
: in Bounded_String
) return Boolean;
206 (Left
: in Bounded_String
;
212 Right
: in Bounded_String
)
215 ----------------------
216 -- Search Functions --
217 ----------------------
220 (Source
: in Bounded_String
;
222 Going
: in Direction
:= Forward
;
223 Mapping
: in Maps
.Character_Mapping
:= Maps
.Identity
)
227 (Source
: in Bounded_String
;
229 Going
: in Direction
:= Forward
;
230 Mapping
: in Maps
.Character_Mapping_Function
)
234 (Source
: in Bounded_String
;
235 Set
: in Maps
.Character_Set
;
236 Test
: in Membership
:= Inside
;
237 Going
: in Direction
:= Forward
)
240 function Index_Non_Blank
241 (Source
: in Bounded_String
;
242 Going
: in Direction
:= Forward
)
246 (Source
: in Bounded_String
;
248 Mapping
: in Maps
.Character_Mapping
:= Maps
.Identity
)
252 (Source
: in Bounded_String
;
254 Mapping
: in Maps
.Character_Mapping_Function
)
258 (Source
: in Bounded_String
;
259 Set
: in Maps
.Character_Set
)
263 (Source
: in Bounded_String
;
264 Set
: in Maps
.Character_Set
;
265 Test
: in Membership
;
266 First
: out Positive;
269 ------------------------------------
270 -- String Translation Subprograms --
271 ------------------------------------
274 (Source
: in Bounded_String
;
275 Mapping
: in Maps
.Character_Mapping
)
276 return Bounded_String
;
279 (Source
: in out Bounded_String
;
280 Mapping
: in Maps
.Character_Mapping
);
283 (Source
: in Bounded_String
;
284 Mapping
: in Maps
.Character_Mapping_Function
)
285 return Bounded_String
;
288 (Source
: in out Bounded_String
;
289 Mapping
: in Maps
.Character_Mapping_Function
);
291 ---------------------------------------
292 -- String Transformation Subprograms --
293 ---------------------------------------
295 function Replace_Slice
296 (Source
: in Bounded_String
;
300 Drop
: in Truncation
:= Error
)
301 return Bounded_String
;
303 procedure Replace_Slice
304 (Source
: in out Bounded_String
;
308 Drop
: in Truncation
:= Error
);
311 (Source
: in Bounded_String
;
312 Before
: in Positive;
313 New_Item
: in String;
314 Drop
: in Truncation
:= Error
)
315 return Bounded_String
;
318 (Source
: in out Bounded_String
;
319 Before
: in Positive;
320 New_Item
: in String;
321 Drop
: in Truncation
:= Error
);
324 (Source
: in Bounded_String
;
325 Position
: in Positive;
326 New_Item
: in String;
327 Drop
: in Truncation
:= Error
)
328 return Bounded_String
;
331 (Source
: in out Bounded_String
;
332 Position
: in Positive;
333 New_Item
: in String;
334 Drop
: in Truncation
:= Error
);
337 (Source
: in Bounded_String
;
339 Through
: in Natural)
340 return Bounded_String
;
343 (Source
: in out Bounded_String
;
345 Through
: in Natural);
347 ---------------------------------
348 -- String Selector Subprograms --
349 ---------------------------------
352 (Source
: in Bounded_String
;
354 return Bounded_String
;
357 (Source
: in out Bounded_String
;
361 (Source
: in Bounded_String
;
362 Left
: in Maps
.Character_Set
;
363 Right
: in Maps
.Character_Set
)
364 return Bounded_String
;
367 (Source
: in out Bounded_String
;
368 Left
: in Maps
.Character_Set
;
369 Right
: in Maps
.Character_Set
);
372 (Source
: in Bounded_String
;
374 Pad
: in Character := Space
;
375 Drop
: in Truncation
:= Error
)
376 return Bounded_String
;
379 (Source
: in out Bounded_String
;
381 Pad
: in Character := Space
;
382 Drop
: in Truncation
:= Error
);
385 (Source
: in Bounded_String
;
387 Pad
: in Character := Space
;
388 Drop
: in Truncation
:= Error
)
389 return Bounded_String
;
392 (Source
: in out Bounded_String
;
394 Pad
: in Character := Space
;
395 Drop
: in Truncation
:= Error
);
397 ------------------------------------
398 -- String Constructor Subprograms --
399 ------------------------------------
403 Right
: in Character)
404 return Bounded_String
;
409 return Bounded_String
;
413 Right
: in Bounded_String
)
414 return Bounded_String
;
419 Drop
: in Truncation
:= Error
)
420 return Bounded_String
;
425 Drop
: in Truncation
:= Error
)
426 return Bounded_String
;
430 Item
: in Bounded_String
;
431 Drop
: in Truncation
:= Error
)
432 return Bounded_String
;
436 type Bounded_String
is record
437 Length
: Length_Range
:= 0;
438 Data
: String (1 .. Max_Length
) := (1 .. Max_Length
=> ASCII
.NUL
);
441 Null_Bounded_String
: constant Bounded_String
:=
442 (Length
=> 0, Data
=> (1 .. Max_Length
=> ASCII
.NUL
));
445 -- Pragma Inline declarations (GNAT specific additions)
449 pragma Inline
("<=");
451 pragma Inline
(">=");
453 pragma Inline
(Count
);
454 pragma Inline
(Element
);
455 pragma Inline
(Find_Token
);
456 pragma Inline
(Index
);
457 pragma Inline
(Index_Non_Blank
);
458 pragma Inline
(Length
);
459 pragma Inline
(Replace_Element
);
460 pragma Inline
(Slice
);
461 pragma Inline
(To_Bounded_String
);
462 pragma Inline
(To_String
);
464 end Generic_Bounded_Length
;
466 end Ada
.Strings
.Bounded
;