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 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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)
68 -- Note the additional parameter Max_Length, which specifies the maximum
69 -- length setting of the resulting Super_String value.
71 -- The following procedures have declarations (and semantics) that are
72 -- exactly analogous to those declared in Ada.Strings.Bounded.
74 function Super_To_String (Source : Super_String) return String;
77 (Left, Right : Super_String;
78 Drop : Truncation := Error)
84 Drop : Truncation := Error)
90 Drop : Truncation := Error)
96 Drop : Truncation := Error)
101 Right : Super_String;
102 Drop : Truncation := Error)
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, Right : Super_String)
125 (Left : Super_String;
131 Right : Super_String)
135 (Left : Super_String;
141 Right : Super_String)
144 function Super_Element
145 (Source : Super_String;
149 procedure Super_Replace_Element
150 (Source : in out Super_String;
155 (Source : Super_String;
160 function "=" (Left, Right : Super_String) return Boolean;
162 function Equal (Left, Right : Super_String) return Boolean renames "=";
165 (Left : Super_String;
171 Right : Super_String)
174 function Less (Left, Right : Super_String) return Boolean;
177 (Left : Super_String;
183 Right : Super_String)
186 function Less_Or_Equal (Left, Right : Super_String) return Boolean;
188 function Less_Or_Equal
189 (Left : Super_String;
193 function Less_Or_Equal
195 Right : Super_String)
198 function Greater (Left, Right : Super_String) return Boolean;
201 (Left : Super_String;
207 Right : Super_String)
210 function Greater_Or_Equal (Left, Right : Super_String) return Boolean;
212 function Greater_Or_Equal
213 (Left : Super_String;
217 function Greater_Or_Equal
219 Right : Super_String)
222 ----------------------
223 -- Search Functions --
224 ----------------------
227 (Source : Super_String;
229 Going : Direction := Forward;
230 Mapping : Maps.Character_Mapping := Maps.Identity)
234 (Source : Super_String;
236 Going : Direction := Forward;
237 Mapping : Maps.Character_Mapping_Function)
241 (Source : Super_String;
242 Set : Maps.Character_Set;
243 Test : Membership := Inside;
244 Going : Direction := Forward)
247 function Super_Index_Non_Blank
248 (Source : Super_String;
249 Going : Direction := Forward)
253 (Source : Super_String;
255 Mapping : Maps.Character_Mapping := Maps.Identity)
259 (Source : Super_String;
261 Mapping : Maps.Character_Mapping_Function)
265 (Source : Super_String;
266 Set : Maps.Character_Set)
269 procedure Super_Find_Token
270 (Source : Super_String;
271 Set : Maps.Character_Set;
273 First : out Positive;
276 ------------------------------------
277 -- String Translation Subprograms --
278 ------------------------------------
280 function Super_Translate
281 (Source : Super_String;
282 Mapping : Maps.Character_Mapping)
285 procedure Super_Translate
286 (Source : in out Super_String;
287 Mapping : Maps.Character_Mapping);
289 function Super_Translate
290 (Source : Super_String;
291 Mapping : Maps.Character_Mapping_Function)
294 procedure Super_Translate
295 (Source : in out Super_String;
296 Mapping : Maps.Character_Mapping_Function);
298 ---------------------------------------
299 -- String Transformation Subprograms --
300 ---------------------------------------
302 function Super_Replace_Slice
303 (Source : Super_String;
307 Drop : Truncation := Error)
310 procedure Super_Replace_Slice
311 (Source : in out Super_String;
315 Drop : Truncation := Error);
317 function Super_Insert
318 (Source : Super_String;
321 Drop : Truncation := Error)
324 procedure Super_Insert
325 (Source : in out Super_String;
328 Drop : Truncation := Error);
330 function Super_Overwrite
331 (Source : Super_String;
334 Drop : Truncation := Error)
337 procedure Super_Overwrite
338 (Source : in out Super_String;
341 Drop : Truncation := Error);
343 function Super_Delete
344 (Source : Super_String;
349 procedure Super_Delete
350 (Source : in out Super_String;
354 ---------------------------------
355 -- String Selector Subprograms --
356 ---------------------------------
359 (Source : Super_String;
364 (Source : in out Super_String;
368 (Source : Super_String;
369 Left : Maps.Character_Set;
370 Right : Maps.Character_Set)
374 (Source : in out Super_String;
375 Left : Maps.Character_Set;
376 Right : Maps.Character_Set);
379 (Source : Super_String;
381 Pad : Character := Space;
382 Drop : Truncation := Error)
386 (Source : in out Super_String;
388 Pad : Character := Space;
389 Drop : Truncation := Error);
392 (Source : Super_String;
394 Pad : Character := Space;
395 Drop : Truncation := Error)
399 (Source : in out Super_String;
401 Pad : Character := Space;
402 Drop : Truncation := Error);
404 ------------------------------------
405 -- String Constructor Subprograms --
406 ------------------------------------
408 -- Note: in some of the following routines, there is an extra parameter
409 -- Max_Length which specifies the value of the maximum length for the
410 -- resulting Super_String value.
415 Max_Length : Positive)
417 -- Note the additional parameter Max_Length
422 Max_Length : Positive)
424 -- Note the additional parameter Max_Length
428 Right : Super_String)
431 function Super_Replicate
434 Drop : Truncation := Error;
435 Max_Length : Positive)
437 -- Note the additional parameter Max_Length
439 function Super_Replicate
442 Drop : Truncation := Error;
443 Max_Length : Positive)
445 -- Note the additional parameter Max_Length
447 function Super_Replicate
450 Drop : Truncation := Error)
455 -- Pragma Inline declarations
458 pragma Inline (Less);
459 pragma Inline (Less_Or_Equal);
460 pragma Inline (Greater);
461 pragma Inline (Greater_Or_Equal);
462 pragma Inline (Concat);
463 pragma Inline (Super_Count);
464 pragma Inline (Super_Element);
465 pragma Inline (Super_Find_Token);
466 pragma Inline (Super_Index);
467 pragma Inline (Super_Index_Non_Blank);
468 pragma Inline (Super_Length);
469 pragma Inline (Super_Replace_Element);
470 pragma Inline (Super_Slice);
471 pragma Inline (Super_To_String);
473 end Ada.Strings.Superbounded;