1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . S U P E R B O U N D E D --
9 -- Copyright (C) 2003-2005 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This non generic package contains most of the implementation of the
35 -- generic package Ada.Strings.Bounded.Generic_Bounded_Length.
37 -- It defines type Super_String as a discriminated record with the maximum
38 -- length as the discriminant. Individual instantiations of Strings.Bounded
39 -- use this type with an appropriate discriminant value set.
41 with Ada
.Strings
.Maps
;
43 package Ada
.Strings
.Superbounded
is
44 pragma Preelaborate
(Superbounded
);
46 type Super_String
(Max_Length
: Positive) is record
47 Current_Length
: Natural := 0;
48 Data
: String (1 .. Max_Length
) := (others => ASCII
.NUL
);
50 -- Type Bounded_String in Ada.Strings.Bounded.Generic_Bounded_Length is
51 -- derived from this type, with the constraint of the maximum length.
53 -- The subprograms defined for Super_String are similar to those
54 -- defined for Bounded_String, except that they have different names, so
55 -- that they can be renamed in Ada.Strings.Bounded.Generic_Bounded_Length.
57 function Super_Length
(Source
: Super_String
) return Natural;
59 --------------------------------------------------------
60 -- Conversion, Concatenation, and Selection Functions --
61 --------------------------------------------------------
63 function To_Super_String
66 Drop
: Truncation
:= Error
) return Super_String
;
67 -- Note the additional parameter Max_Length, which specifies the maximum
68 -- length setting of the resulting Super_String value.
70 -- The following procedures have declarations (and semantics) that are
71 -- exactly analogous to those declared in Ada.Strings.Bounded.
73 function Super_To_String
(Source
: Super_String
) return String;
75 procedure Set_Super_String
76 (Target
: out Super_String
;
78 Drop
: Truncation
:= Error
);
83 Drop
: Truncation
:= Error
) return Super_String
;
88 Drop
: Truncation
:= Error
) return Super_String
;
93 Drop
: Truncation
:= Error
) return Super_String
;
98 Drop
: Truncation
:= Error
) return Super_String
;
100 function Super_Append
102 Right
: Super_String
;
103 Drop
: Truncation
:= Error
) return Super_String
;
105 procedure Super_Append
106 (Source
: in out Super_String
;
107 New_Item
: Super_String
;
108 Drop
: Truncation
:= Error
);
110 procedure Super_Append
111 (Source
: in out Super_String
;
113 Drop
: Truncation
:= Error
);
115 procedure Super_Append
116 (Source
: in out Super_String
;
117 New_Item
: Character;
118 Drop
: Truncation
:= Error
);
121 (Left
: Super_String
;
122 Right
: Super_String
) return Super_String
;
125 (Left
: Super_String
;
126 Right
: String) return Super_String
;
130 Right
: Super_String
) return Super_String
;
133 (Left
: Super_String
;
134 Right
: Character) return Super_String
;
138 Right
: Super_String
) return Super_String
;
140 function Super_Element
141 (Source
: Super_String
;
142 Index
: Positive) return Character;
144 procedure Super_Replace_Element
145 (Source
: in out Super_String
;
150 (Source
: Super_String
;
152 High
: Natural) return String;
155 (Source
: Super_String
;
157 High
: Natural) return Super_String
;
159 procedure Super_Slice
160 (Source
: Super_String
;
161 Target
: out Super_String
;
166 (Left
: Super_String
;
167 Right
: Super_String
) return Boolean;
170 (Left
: Super_String
;
171 Right
: Super_String
) return Boolean renames "=";
174 (Left
: Super_String
;
175 Right
: String) return Boolean;
179 Right
: Super_String
) return Boolean;
182 (Left
: Super_String
;
183 Right
: Super_String
) return Boolean;
186 (Left
: Super_String
;
187 Right
: String) return Boolean;
191 Right
: Super_String
) return Boolean;
193 function Less_Or_Equal
194 (Left
: Super_String
;
195 Right
: Super_String
) return Boolean;
197 function Less_Or_Equal
198 (Left
: Super_String
;
199 Right
: String) return Boolean;
201 function Less_Or_Equal
203 Right
: Super_String
) return Boolean;
206 (Left
: Super_String
;
207 Right
: Super_String
) return Boolean;
210 (Left
: Super_String
;
211 Right
: String) return Boolean;
215 Right
: Super_String
) return Boolean;
217 function Greater_Or_Equal
218 (Left
: Super_String
;
219 Right
: Super_String
) return Boolean;
221 function Greater_Or_Equal
222 (Left
: Super_String
;
223 Right
: String) return Boolean;
225 function Greater_Or_Equal
227 Right
: Super_String
) return Boolean;
229 ----------------------
230 -- Search Functions --
231 ----------------------
234 (Source
: Super_String
;
236 Going
: Direction
:= Forward
;
237 Mapping
: Maps
.Character_Mapping
:= Maps
.Identity
) return Natural;
240 (Source
: Super_String
;
242 Going
: Direction
:= Forward
;
243 Mapping
: Maps
.Character_Mapping_Function
) return Natural;
246 (Source
: Super_String
;
247 Set
: Maps
.Character_Set
;
248 Test
: Membership
:= Inside
;
249 Going
: Direction
:= Forward
) return Natural;
252 (Source
: Super_String
;
255 Going
: Direction
:= Forward
;
256 Mapping
: Maps
.Character_Mapping
:= Maps
.Identity
) return Natural;
259 (Source
: Super_String
;
262 Going
: Direction
:= Forward
;
263 Mapping
: Maps
.Character_Mapping_Function
) return Natural;
266 (Source
: Super_String
;
267 Set
: Maps
.Character_Set
;
269 Test
: Membership
:= Inside
;
270 Going
: Direction
:= Forward
) return Natural;
272 function Super_Index_Non_Blank
273 (Source
: Super_String
;
274 Going
: Direction
:= Forward
) return Natural;
276 function Super_Index_Non_Blank
277 (Source
: Super_String
;
279 Going
: Direction
:= Forward
) return Natural;
282 (Source
: Super_String
;
284 Mapping
: Maps
.Character_Mapping
:= Maps
.Identity
) return Natural;
287 (Source
: Super_String
;
289 Mapping
: Maps
.Character_Mapping_Function
) return Natural;
292 (Source
: Super_String
;
293 Set
: Maps
.Character_Set
) return Natural;
295 procedure Super_Find_Token
296 (Source
: Super_String
;
297 Set
: Maps
.Character_Set
;
299 First
: out Positive;
302 ------------------------------------
303 -- String Translation Subprograms --
304 ------------------------------------
306 function Super_Translate
307 (Source
: Super_String
;
308 Mapping
: Maps
.Character_Mapping
) return Super_String
;
310 procedure Super_Translate
311 (Source
: in out Super_String
;
312 Mapping
: Maps
.Character_Mapping
);
314 function Super_Translate
315 (Source
: Super_String
;
316 Mapping
: Maps
.Character_Mapping_Function
) return Super_String
;
318 procedure Super_Translate
319 (Source
: in out Super_String
;
320 Mapping
: Maps
.Character_Mapping_Function
);
322 ---------------------------------------
323 -- String Transformation Subprograms --
324 ---------------------------------------
326 function Super_Replace_Slice
327 (Source
: Super_String
;
331 Drop
: Truncation
:= Error
) return Super_String
;
333 procedure Super_Replace_Slice
334 (Source
: in out Super_String
;
338 Drop
: Truncation
:= Error
);
340 function Super_Insert
341 (Source
: Super_String
;
344 Drop
: Truncation
:= Error
) return Super_String
;
346 procedure Super_Insert
347 (Source
: in out Super_String
;
350 Drop
: Truncation
:= Error
);
352 function Super_Overwrite
353 (Source
: Super_String
;
356 Drop
: Truncation
:= Error
) return Super_String
;
358 procedure Super_Overwrite
359 (Source
: in out Super_String
;
362 Drop
: Truncation
:= Error
);
364 function Super_Delete
365 (Source
: Super_String
;
367 Through
: Natural) return Super_String
;
369 procedure Super_Delete
370 (Source
: in out Super_String
;
374 ---------------------------------
375 -- String Selector Subprograms --
376 ---------------------------------
379 (Source
: Super_String
;
380 Side
: Trim_End
) return Super_String
;
383 (Source
: in out Super_String
;
387 (Source
: Super_String
;
388 Left
: Maps
.Character_Set
;
389 Right
: Maps
.Character_Set
) return Super_String
;
392 (Source
: in out Super_String
;
393 Left
: Maps
.Character_Set
;
394 Right
: Maps
.Character_Set
);
397 (Source
: Super_String
;
399 Pad
: Character := Space
;
400 Drop
: Truncation
:= Error
) return Super_String
;
403 (Source
: in out Super_String
;
405 Pad
: Character := Space
;
406 Drop
: Truncation
:= Error
);
409 (Source
: Super_String
;
411 Pad
: Character := Space
;
412 Drop
: Truncation
:= Error
) return Super_String
;
415 (Source
: in out Super_String
;
417 Pad
: Character := Space
;
418 Drop
: Truncation
:= Error
);
420 ------------------------------------
421 -- String Constructor Subprograms --
422 ------------------------------------
424 -- Note: in some of the following routines, there is an extra parameter
425 -- Max_Length which specifies the value of the maximum length for the
426 -- resulting Super_String value.
431 Max_Length
: Positive) return Super_String
;
432 -- Note the additional parameter Max_Length
437 Max_Length
: Positive) return Super_String
;
438 -- Note the additional parameter Max_Length
442 Right
: Super_String
) return Super_String
;
444 function Super_Replicate
447 Drop
: Truncation
:= Error
;
448 Max_Length
: Positive) return Super_String
;
449 -- Note the additional parameter Max_Length
451 function Super_Replicate
454 Drop
: Truncation
:= Error
;
455 Max_Length
: Positive) return Super_String
;
456 -- Note the additional parameter Max_Length
458 function Super_Replicate
461 Drop
: Truncation
:= Error
) return Super_String
;
464 -- Pragma Inline declarations
467 pragma Inline
(Less
);
468 pragma Inline
(Less_Or_Equal
);
469 pragma Inline
(Greater
);
470 pragma Inline
(Greater_Or_Equal
);
471 pragma Inline
(Concat
);
472 pragma Inline
(Super_Count
);
473 pragma Inline
(Super_Element
);
474 pragma Inline
(Super_Find_Token
);
475 pragma Inline
(Super_Index
);
476 pragma Inline
(Super_Index_Non_Blank
);
477 pragma Inline
(Super_Length
);
478 pragma Inline
(Super_Replace_Element
);
479 pragma Inline
(Super_Slice
);
480 pragma Inline
(Super_To_String
);
482 end Ada
.Strings
.Superbounded
;