objc/
[official-gcc.git] / gcc / ada / a-strsup.ads
blob42efe6def895402303167d565e29fba905651277
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . S T R I N G S . S U P E R B O U N D E D --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2003-2005 Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
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. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
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);
49 end record;
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
64 (Source : String;
65 Max_Length : Natural;
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;
77 Source : String;
78 Drop : Truncation := Error);
80 function Super_Append
81 (Left : Super_String;
82 Right : Super_String;
83 Drop : Truncation := Error) return Super_String;
85 function Super_Append
86 (Left : Super_String;
87 Right : String;
88 Drop : Truncation := Error) return Super_String;
90 function Super_Append
91 (Left : String;
92 Right : Super_String;
93 Drop : Truncation := Error) return Super_String;
95 function Super_Append
96 (Left : Super_String;
97 Right : Character;
98 Drop : Truncation := Error) return Super_String;
100 function Super_Append
101 (Left : Character;
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;
112 New_Item : String;
113 Drop : Truncation := Error);
115 procedure Super_Append
116 (Source : in out Super_String;
117 New_Item : Character;
118 Drop : Truncation := Error);
120 function Concat
121 (Left : Super_String;
122 Right : Super_String) return Super_String;
124 function Concat
125 (Left : Super_String;
126 Right : String) return Super_String;
128 function Concat
129 (Left : String;
130 Right : Super_String) return Super_String;
132 function Concat
133 (Left : Super_String;
134 Right : Character) return Super_String;
136 function Concat
137 (Left : Character;
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;
146 Index : Positive;
147 By : Character);
149 function Super_Slice
150 (Source : Super_String;
151 Low : Positive;
152 High : Natural) return String;
154 function Super_Slice
155 (Source : Super_String;
156 Low : Positive;
157 High : Natural) return Super_String;
159 procedure Super_Slice
160 (Source : Super_String;
161 Target : out Super_String;
162 Low : Positive;
163 High : Natural);
165 function "="
166 (Left : Super_String;
167 Right : Super_String) return Boolean;
169 function Equal
170 (Left : Super_String;
171 Right : Super_String) return Boolean renames "=";
173 function Equal
174 (Left : Super_String;
175 Right : String) return Boolean;
177 function Equal
178 (Left : String;
179 Right : Super_String) return Boolean;
181 function Less
182 (Left : Super_String;
183 Right : Super_String) return Boolean;
185 function Less
186 (Left : Super_String;
187 Right : String) return Boolean;
189 function Less
190 (Left : String;
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
202 (Left : String;
203 Right : Super_String) return Boolean;
205 function Greater
206 (Left : Super_String;
207 Right : Super_String) return Boolean;
209 function Greater
210 (Left : Super_String;
211 Right : String) return Boolean;
213 function Greater
214 (Left : String;
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
226 (Left : String;
227 Right : Super_String) return Boolean;
229 ----------------------
230 -- Search Functions --
231 ----------------------
233 function Super_Index
234 (Source : Super_String;
235 Pattern : String;
236 Going : Direction := Forward;
237 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
239 function Super_Index
240 (Source : Super_String;
241 Pattern : String;
242 Going : Direction := Forward;
243 Mapping : Maps.Character_Mapping_Function) return Natural;
245 function Super_Index
246 (Source : Super_String;
247 Set : Maps.Character_Set;
248 Test : Membership := Inside;
249 Going : Direction := Forward) return Natural;
251 function Super_Index
252 (Source : Super_String;
253 Pattern : String;
254 From : Positive;
255 Going : Direction := Forward;
256 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
258 function Super_Index
259 (Source : Super_String;
260 Pattern : String;
261 From : Positive;
262 Going : Direction := Forward;
263 Mapping : Maps.Character_Mapping_Function) return Natural;
265 function Super_Index
266 (Source : Super_String;
267 Set : Maps.Character_Set;
268 From : Positive;
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;
278 From : Positive;
279 Going : Direction := Forward) return Natural;
281 function Super_Count
282 (Source : Super_String;
283 Pattern : String;
284 Mapping : Maps.Character_Mapping := Maps.Identity) return Natural;
286 function Super_Count
287 (Source : Super_String;
288 Pattern : String;
289 Mapping : Maps.Character_Mapping_Function) return Natural;
291 function Super_Count
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;
298 Test : Membership;
299 First : out Positive;
300 Last : out Natural);
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;
328 Low : Positive;
329 High : Natural;
330 By : String;
331 Drop : Truncation := Error) return Super_String;
333 procedure Super_Replace_Slice
334 (Source : in out Super_String;
335 Low : Positive;
336 High : Natural;
337 By : String;
338 Drop : Truncation := Error);
340 function Super_Insert
341 (Source : Super_String;
342 Before : Positive;
343 New_Item : String;
344 Drop : Truncation := Error) return Super_String;
346 procedure Super_Insert
347 (Source : in out Super_String;
348 Before : Positive;
349 New_Item : String;
350 Drop : Truncation := Error);
352 function Super_Overwrite
353 (Source : Super_String;
354 Position : Positive;
355 New_Item : String;
356 Drop : Truncation := Error) return Super_String;
358 procedure Super_Overwrite
359 (Source : in out Super_String;
360 Position : Positive;
361 New_Item : String;
362 Drop : Truncation := Error);
364 function Super_Delete
365 (Source : Super_String;
366 From : Positive;
367 Through : Natural) return Super_String;
369 procedure Super_Delete
370 (Source : in out Super_String;
371 From : Positive;
372 Through : Natural);
374 ---------------------------------
375 -- String Selector Subprograms --
376 ---------------------------------
378 function Super_Trim
379 (Source : Super_String;
380 Side : Trim_End) return Super_String;
382 procedure Super_Trim
383 (Source : in out Super_String;
384 Side : Trim_End);
386 function Super_Trim
387 (Source : Super_String;
388 Left : Maps.Character_Set;
389 Right : Maps.Character_Set) return Super_String;
391 procedure Super_Trim
392 (Source : in out Super_String;
393 Left : Maps.Character_Set;
394 Right : Maps.Character_Set);
396 function Super_Head
397 (Source : Super_String;
398 Count : Natural;
399 Pad : Character := Space;
400 Drop : Truncation := Error) return Super_String;
402 procedure Super_Head
403 (Source : in out Super_String;
404 Count : Natural;
405 Pad : Character := Space;
406 Drop : Truncation := Error);
408 function Super_Tail
409 (Source : Super_String;
410 Count : Natural;
411 Pad : Character := Space;
412 Drop : Truncation := Error) return Super_String;
414 procedure Super_Tail
415 (Source : in out Super_String;
416 Count : Natural;
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.
428 function Times
429 (Left : Natural;
430 Right : Character;
431 Max_Length : Positive) return Super_String;
432 -- Note the additional parameter Max_Length
434 function Times
435 (Left : Natural;
436 Right : String;
437 Max_Length : Positive) return Super_String;
438 -- Note the additional parameter Max_Length
440 function Times
441 (Left : Natural;
442 Right : Super_String) return Super_String;
444 function Super_Replicate
445 (Count : Natural;
446 Item : Character;
447 Drop : Truncation := Error;
448 Max_Length : Positive) return Super_String;
449 -- Note the additional parameter Max_Length
451 function Super_Replicate
452 (Count : Natural;
453 Item : String;
454 Drop : Truncation := Error;
455 Max_Length : Positive) return Super_String;
456 -- Note the additional parameter Max_Length
458 function Super_Replicate
459 (Count : Natural;
460 Item : Super_String;
461 Drop : Truncation := Error) return Super_String;
463 private
464 -- Pragma Inline declarations
466 pragma Inline ("=");
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;