1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . W I D E _ S U P E R B O U N D E D --
9 -- Copyright (C) 2003-2010, 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 3, 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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This non generic package contains most of the implementation of the
33 -- generic package Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
35 -- It defines type Super_String as a discriminated record with the maximum
36 -- length as the discriminant. Individual instantiations of the package
37 -- Strings.Wide_Bounded.Generic_Bounded_Length use this type with
38 -- an appropriate discriminant value set.
40 with Ada.Strings.Wide_Maps;
42 package Ada.Strings.Wide_Superbounded is
45 Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
47 type Super_String (Max_Length : Positive) is record
48 Current_Length : Natural := 0;
49 Data : Wide_String (1 .. Max_Length) := (others => Wide_NUL);
51 -- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
52 -- derived from this type, with the constraint of the maximum length.
54 -- The subprograms defined for Super_String are similar to those defined
55 -- for Bounded_Wide_String, except that they have different names, so that
56 -- they can be renamed in Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
58 function Super_Length (Source : Super_String) return Natural;
60 --------------------------------------------------------
61 -- Conversion, Concatenation, and Selection Functions --
62 --------------------------------------------------------
64 function To_Super_String
65 (Source : Wide_String;
67 Drop : Truncation := Error) return Super_String;
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.Wide_Bounded.
74 function Super_To_String (Source : Super_String) return Wide_String;
76 procedure Set_Super_String
77 (Target : out Super_String;
79 Drop : Truncation := Error);
84 Drop : Truncation := Error) return Super_String;
89 Drop : Truncation := Error) return Super_String;
94 Drop : Truncation := Error) return Super_String;
98 Right : Wide_Character;
99 Drop : Truncation := Error) return Super_String;
101 function Super_Append
102 (Left : Wide_Character;
103 Right : Super_String;
104 Drop : Truncation := Error) return Super_String;
106 procedure Super_Append
107 (Source : in out Super_String;
108 New_Item : Super_String;
109 Drop : Truncation := Error);
111 procedure Super_Append
112 (Source : in out Super_String;
113 New_Item : Wide_String;
114 Drop : Truncation := Error);
116 procedure Super_Append
117 (Source : in out Super_String;
118 New_Item : Wide_Character;
119 Drop : Truncation := Error);
122 (Left : Super_String;
123 Right : Super_String) return Super_String;
126 (Left : Super_String;
127 Right : Wide_String) return Super_String;
131 Right : Super_String) return Super_String;
134 (Left : Super_String;
135 Right : Wide_Character) return Super_String;
138 (Left : Wide_Character;
139 Right : Super_String) return Super_String;
141 function Super_Element
142 (Source : Super_String;
143 Index : Positive) return Wide_Character;
145 procedure Super_Replace_Element
146 (Source : in out Super_String;
148 By : Wide_Character);
151 (Source : Super_String;
153 High : Natural) return Wide_String;
156 (Source : Super_String;
158 High : Natural) return Super_String;
160 procedure Super_Slice
161 (Source : Super_String;
162 Target : out Super_String;
167 (Left : Super_String;
168 Right : Super_String) return Boolean;
171 (Left : Super_String;
172 Right : Super_String) return Boolean renames "=";
175 (Left : Super_String;
176 Right : Wide_String) return Boolean;
180 Right : Super_String) return Boolean;
183 (Left : Super_String;
184 Right : Super_String) return Boolean;
187 (Left : Super_String;
188 Right : Wide_String) return Boolean;
192 Right : Super_String) return Boolean;
194 function Less_Or_Equal
195 (Left : Super_String;
196 Right : Super_String) return Boolean;
198 function Less_Or_Equal
199 (Left : Super_String;
200 Right : Wide_String) return Boolean;
202 function Less_Or_Equal
204 Right : Super_String) return Boolean;
207 (Left : Super_String;
208 Right : Super_String) return Boolean;
211 (Left : Super_String;
212 Right : Wide_String) return Boolean;
216 Right : Super_String) return Boolean;
218 function Greater_Or_Equal
219 (Left : Super_String;
220 Right : Super_String) return Boolean;
222 function Greater_Or_Equal
223 (Left : Super_String;
224 Right : Wide_String) return Boolean;
226 function Greater_Or_Equal
228 Right : Super_String) return Boolean;
230 ----------------------
231 -- Search Functions --
232 ----------------------
235 (Source : Super_String;
236 Pattern : Wide_String;
237 Going : Direction := Forward;
238 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
242 (Source : Super_String;
243 Pattern : Wide_String;
244 Going : Direction := Forward;
245 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
248 (Source : Super_String;
249 Set : Wide_Maps.Wide_Character_Set;
250 Test : Membership := Inside;
251 Going : Direction := Forward) return Natural;
254 (Source : Super_String;
255 Pattern : Wide_String;
257 Going : Direction := Forward;
258 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
262 (Source : Super_String;
263 Pattern : Wide_String;
265 Going : Direction := Forward;
266 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
269 (Source : Super_String;
270 Set : Wide_Maps.Wide_Character_Set;
272 Test : Membership := Inside;
273 Going : Direction := Forward) return Natural;
275 function Super_Index_Non_Blank
276 (Source : Super_String;
277 Going : Direction := Forward) return Natural;
279 function Super_Index_Non_Blank
280 (Source : Super_String;
282 Going : Direction := Forward) return Natural;
285 (Source : Super_String;
286 Pattern : Wide_String;
287 Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
291 (Source : Super_String;
292 Pattern : Wide_String;
293 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
296 (Source : Super_String;
297 Set : Wide_Maps.Wide_Character_Set) return Natural;
299 procedure Super_Find_Token
300 (Source : Super_String;
301 Set : Wide_Maps.Wide_Character_Set;
304 First : out Positive;
307 procedure Super_Find_Token
308 (Source : Super_String;
309 Set : Wide_Maps.Wide_Character_Set;
311 First : out Positive;
314 ------------------------------------
315 -- String Translation Subprograms --
316 ------------------------------------
318 function Super_Translate
319 (Source : Super_String;
320 Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
322 procedure Super_Translate
323 (Source : in out Super_String;
324 Mapping : Wide_Maps.Wide_Character_Mapping);
326 function Super_Translate
327 (Source : Super_String;
328 Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
330 procedure Super_Translate
331 (Source : in out Super_String;
332 Mapping : Wide_Maps.Wide_Character_Mapping_Function);
334 ---------------------------------------
335 -- String Transformation Subprograms --
336 ---------------------------------------
338 function Super_Replace_Slice
339 (Source : Super_String;
343 Drop : Truncation := Error) return Super_String;
345 procedure Super_Replace_Slice
346 (Source : in out Super_String;
350 Drop : Truncation := Error);
352 function Super_Insert
353 (Source : Super_String;
355 New_Item : Wide_String;
356 Drop : Truncation := Error) return Super_String;
358 procedure Super_Insert
359 (Source : in out Super_String;
361 New_Item : Wide_String;
362 Drop : Truncation := Error);
364 function Super_Overwrite
365 (Source : Super_String;
367 New_Item : Wide_String;
368 Drop : Truncation := Error) return Super_String;
370 procedure Super_Overwrite
371 (Source : in out Super_String;
373 New_Item : Wide_String;
374 Drop : Truncation := Error);
376 function Super_Delete
377 (Source : Super_String;
379 Through : Natural) return Super_String;
381 procedure Super_Delete
382 (Source : in out Super_String;
386 ---------------------------------
387 -- String Selector Subprograms --
388 ---------------------------------
391 (Source : Super_String;
392 Side : Trim_End) return Super_String;
395 (Source : in out Super_String;
399 (Source : Super_String;
400 Left : Wide_Maps.Wide_Character_Set;
401 Right : Wide_Maps.Wide_Character_Set) return Super_String;
404 (Source : in out Super_String;
405 Left : Wide_Maps.Wide_Character_Set;
406 Right : Wide_Maps.Wide_Character_Set);
409 (Source : Super_String;
411 Pad : Wide_Character := Wide_Space;
412 Drop : Truncation := Error) return Super_String;
415 (Source : in out Super_String;
417 Pad : Wide_Character := Wide_Space;
418 Drop : Truncation := Error);
421 (Source : Super_String;
423 Pad : Wide_Character := Wide_Space;
424 Drop : Truncation := Error) return Super_String;
427 (Source : in out Super_String;
429 Pad : Wide_Character := Wide_Space;
430 Drop : Truncation := Error);
432 ------------------------------------
433 -- String Constructor Subprograms --
434 ------------------------------------
436 -- Note: in some of the following routines, there is an extra parameter
437 -- Max_Length which specifies the value of the maximum length for the
438 -- resulting Super_String value.
442 Right : Wide_Character;
443 Max_Length : Positive) return Super_String;
444 -- Note the additional parameter Max_Length
449 Max_Length : Positive) return Super_String;
450 -- Note the additional parameter Max_Length
454 Right : Super_String) return Super_String;
456 function Super_Replicate
458 Item : Wide_Character;
459 Drop : Truncation := Error;
460 Max_Length : Positive) return Super_String;
461 -- Note the additional parameter Max_Length
463 function Super_Replicate
466 Drop : Truncation := Error;
467 Max_Length : Positive) return Super_String;
468 -- Note the additional parameter Max_Length
470 function Super_Replicate
473 Drop : Truncation := Error) return Super_String;
476 -- Pragma Inline declarations
479 pragma Inline (Less);
480 pragma Inline (Less_Or_Equal);
481 pragma Inline (Greater);
482 pragma Inline (Greater_Or_Equal);
483 pragma Inline (Concat);
484 pragma Inline (Super_Count);
485 pragma Inline (Super_Element);
486 pragma Inline (Super_Find_Token);
487 pragma Inline (Super_Index);
488 pragma Inline (Super_Index_Non_Blank);
489 pragma Inline (Super_Length);
490 pragma Inline (Super_Replace_Element);
491 pragma Inline (Super_Slice);
492 pragma Inline (Super_To_String);
494 end Ada.Strings.Wide_Superbounded;