1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . S T R I N G S . W I D E _ W I D E _ S U P E R B O U N D E D --
9 -- Copyright (C) 2003-2012, 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_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_Wide_Bounded.Generic_Bounded_Length use this type with
38 -- an appropriate discriminant value set.
40 with Ada
.Strings
.Wide_Wide_Maps
;
42 package Ada
.Strings
.Wide_Wide_Superbounded
is
45 Wide_Wide_NUL
: constant Wide_Wide_Character
:=
46 Wide_Wide_Character
'Val (0);
48 type Super_String
(Max_Length
: Positive) is record
49 Current_Length
: Natural := 0;
50 Data
: Wide_Wide_String
(1 .. Max_Length
);
51 -- A previous version had a default initial value for Data, which is no
52 -- longer necessary, because we now special-case this type in the
53 -- compiler, so "=" composes properly for descendants of this
54 -- type. Leaving it out is more efficient.
56 -- Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is
57 -- derived from this type, with the constraint of the maximum length.
59 -- The subprograms defined for Super_String are similar to those defined
60 -- for Bounded_Wide_Wide_String, except that they have different names, so
61 -- that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length.
63 function Super_Length
(Source
: Super_String
) return Natural;
65 --------------------------------------------------------
66 -- Conversion, Concatenation, and Selection Functions --
67 --------------------------------------------------------
69 function To_Super_String
70 (Source
: Wide_Wide_String
;
72 Drop
: Truncation
:= Error
) return Super_String
;
73 -- Note the additional parameter Max_Length, which specifies the maximum
74 -- length setting of the resulting Super_String value.
76 -- The following procedures have declarations (and semantics) that are
77 -- exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded.
79 function Super_To_String
(Source
: Super_String
) return Wide_Wide_String
;
81 procedure Set_Super_String
82 (Target
: out Super_String
;
83 Source
: Wide_Wide_String
;
84 Drop
: Truncation
:= Error
);
89 Drop
: Truncation
:= Error
) return Super_String
;
93 Right
: Wide_Wide_String
;
94 Drop
: Truncation
:= Error
) return Super_String
;
97 (Left
: Wide_Wide_String
;
99 Drop
: Truncation
:= Error
) return Super_String
;
101 function Super_Append
102 (Left
: Super_String
;
103 Right
: Wide_Wide_Character
;
104 Drop
: Truncation
:= Error
) return Super_String
;
106 function Super_Append
107 (Left
: Wide_Wide_Character
;
108 Right
: Super_String
;
109 Drop
: Truncation
:= Error
) return Super_String
;
111 procedure Super_Append
112 (Source
: in out Super_String
;
113 New_Item
: Super_String
;
114 Drop
: Truncation
:= Error
);
116 procedure Super_Append
117 (Source
: in out Super_String
;
118 New_Item
: Wide_Wide_String
;
119 Drop
: Truncation
:= Error
);
121 procedure Super_Append
122 (Source
: in out Super_String
;
123 New_Item
: Wide_Wide_Character
;
124 Drop
: Truncation
:= Error
);
127 (Left
: Super_String
;
128 Right
: Super_String
) return Super_String
;
131 (Left
: Super_String
;
132 Right
: Wide_Wide_String
) return Super_String
;
135 (Left
: Wide_Wide_String
;
136 Right
: Super_String
) return Super_String
;
139 (Left
: Super_String
;
140 Right
: Wide_Wide_Character
) return Super_String
;
143 (Left
: Wide_Wide_Character
;
144 Right
: Super_String
) return Super_String
;
146 function Super_Element
147 (Source
: Super_String
;
148 Index
: Positive) return Wide_Wide_Character
;
150 procedure Super_Replace_Element
151 (Source
: in out Super_String
;
153 By
: Wide_Wide_Character
);
156 (Source
: Super_String
;
158 High
: Natural) return Wide_Wide_String
;
161 (Source
: Super_String
;
163 High
: Natural) return Super_String
;
165 procedure Super_Slice
166 (Source
: Super_String
;
167 Target
: out Super_String
;
172 (Left
: Super_String
;
173 Right
: Super_String
) return Boolean;
176 (Left
: Super_String
;
177 Right
: Super_String
) return Boolean renames "=";
180 (Left
: Super_String
;
181 Right
: Wide_Wide_String
) return Boolean;
184 (Left
: Wide_Wide_String
;
185 Right
: Super_String
) return Boolean;
188 (Left
: Super_String
;
189 Right
: Super_String
) return Boolean;
192 (Left
: Super_String
;
193 Right
: Wide_Wide_String
) return Boolean;
196 (Left
: Wide_Wide_String
;
197 Right
: Super_String
) return Boolean;
199 function Less_Or_Equal
200 (Left
: Super_String
;
201 Right
: Super_String
) return Boolean;
203 function Less_Or_Equal
204 (Left
: Super_String
;
205 Right
: Wide_Wide_String
) return Boolean;
207 function Less_Or_Equal
208 (Left
: Wide_Wide_String
;
209 Right
: Super_String
) return Boolean;
212 (Left
: Super_String
;
213 Right
: Super_String
) return Boolean;
216 (Left
: Super_String
;
217 Right
: Wide_Wide_String
) return Boolean;
220 (Left
: Wide_Wide_String
;
221 Right
: Super_String
) return Boolean;
223 function Greater_Or_Equal
224 (Left
: Super_String
;
225 Right
: Super_String
) return Boolean;
227 function Greater_Or_Equal
228 (Left
: Super_String
;
229 Right
: Wide_Wide_String
) return Boolean;
231 function Greater_Or_Equal
232 (Left
: Wide_Wide_String
;
233 Right
: Super_String
) return Boolean;
235 ----------------------
236 -- Search Functions --
237 ----------------------
240 (Source
: Super_String
;
241 Pattern
: Wide_Wide_String
;
242 Going
: Direction
:= Forward
;
243 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
244 Wide_Wide_Maps
.Identity
)
248 (Source
: Super_String
;
249 Pattern
: Wide_Wide_String
;
250 Going
: Direction
:= Forward
;
251 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
255 (Source
: Super_String
;
256 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
257 Test
: Membership
:= Inside
;
258 Going
: Direction
:= Forward
) return Natural;
261 (Source
: Super_String
;
262 Pattern
: Wide_Wide_String
;
264 Going
: Direction
:= Forward
;
265 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
266 Wide_Wide_Maps
.Identity
)
270 (Source
: Super_String
;
271 Pattern
: Wide_Wide_String
;
273 Going
: Direction
:= Forward
;
274 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
278 (Source
: Super_String
;
279 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
281 Test
: Membership
:= Inside
;
282 Going
: Direction
:= Forward
) return Natural;
284 function Super_Index_Non_Blank
285 (Source
: Super_String
;
286 Going
: Direction
:= Forward
) return Natural;
288 function Super_Index_Non_Blank
289 (Source
: Super_String
;
291 Going
: Direction
:= Forward
) return Natural;
294 (Source
: Super_String
;
295 Pattern
: Wide_Wide_String
;
296 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
297 Wide_Wide_Maps
.Identity
)
301 (Source
: Super_String
;
302 Pattern
: Wide_Wide_String
;
303 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
307 (Source
: Super_String
;
308 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Natural;
310 procedure Super_Find_Token
311 (Source
: Super_String
;
312 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
315 First
: out Positive;
318 procedure Super_Find_Token
319 (Source
: Super_String
;
320 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
322 First
: out Positive;
325 ------------------------------------
326 -- String Translation Subprograms --
327 ------------------------------------
329 function Super_Translate
330 (Source
: Super_String
;
331 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
)
334 procedure Super_Translate
335 (Source
: in out Super_String
;
336 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
);
338 function Super_Translate
339 (Source
: Super_String
;
340 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
343 procedure Super_Translate
344 (Source
: in out Super_String
;
345 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
);
347 ---------------------------------------
348 -- String Transformation Subprograms --
349 ---------------------------------------
351 function Super_Replace_Slice
352 (Source
: Super_String
;
355 By
: Wide_Wide_String
;
356 Drop
: Truncation
:= Error
) return Super_String
;
358 procedure Super_Replace_Slice
359 (Source
: in out Super_String
;
362 By
: Wide_Wide_String
;
363 Drop
: Truncation
:= Error
);
365 function Super_Insert
366 (Source
: Super_String
;
368 New_Item
: Wide_Wide_String
;
369 Drop
: Truncation
:= Error
) return Super_String
;
371 procedure Super_Insert
372 (Source
: in out Super_String
;
374 New_Item
: Wide_Wide_String
;
375 Drop
: Truncation
:= Error
);
377 function Super_Overwrite
378 (Source
: Super_String
;
380 New_Item
: Wide_Wide_String
;
381 Drop
: Truncation
:= Error
) return Super_String
;
383 procedure Super_Overwrite
384 (Source
: in out Super_String
;
386 New_Item
: Wide_Wide_String
;
387 Drop
: Truncation
:= Error
);
389 function Super_Delete
390 (Source
: Super_String
;
392 Through
: Natural) return Super_String
;
394 procedure Super_Delete
395 (Source
: in out Super_String
;
399 ---------------------------------
400 -- String Selector Subprograms --
401 ---------------------------------
404 (Source
: Super_String
;
405 Side
: Trim_End
) return Super_String
;
408 (Source
: in out Super_String
;
412 (Source
: Super_String
;
413 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
414 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Super_String
;
417 (Source
: in out Super_String
;
418 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
419 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
);
422 (Source
: Super_String
;
424 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
425 Drop
: Truncation
:= Error
) return Super_String
;
428 (Source
: in out Super_String
;
430 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
431 Drop
: Truncation
:= Error
);
434 (Source
: Super_String
;
436 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
437 Drop
: Truncation
:= Error
) return Super_String
;
440 (Source
: in out Super_String
;
442 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
443 Drop
: Truncation
:= Error
);
445 ------------------------------------
446 -- String Constructor Subprograms --
447 ------------------------------------
449 -- Note: in some of the following routines, there is an extra parameter
450 -- Max_Length which specifies the value of the maximum length for the
451 -- resulting Super_String value.
455 Right
: Wide_Wide_Character
;
456 Max_Length
: Positive) return Super_String
;
457 -- Note the additional parameter Max_Length
461 Right
: Wide_Wide_String
;
462 Max_Length
: Positive) return Super_String
;
463 -- Note the additional parameter Max_Length
467 Right
: Super_String
) return Super_String
;
469 function Super_Replicate
471 Item
: Wide_Wide_Character
;
472 Drop
: Truncation
:= Error
;
473 Max_Length
: Positive) return Super_String
;
474 -- Note the additional parameter Max_Length
476 function Super_Replicate
478 Item
: Wide_Wide_String
;
479 Drop
: Truncation
:= Error
;
480 Max_Length
: Positive) return Super_String
;
481 -- Note the additional parameter Max_Length
483 function Super_Replicate
486 Drop
: Truncation
:= Error
) return Super_String
;
489 -- Pragma Inline declarations
492 pragma Inline
(Less
);
493 pragma Inline
(Less_Or_Equal
);
494 pragma Inline
(Greater
);
495 pragma Inline
(Greater_Or_Equal
);
496 pragma Inline
(Concat
);
497 pragma Inline
(Super_Count
);
498 pragma Inline
(Super_Element
);
499 pragma Inline
(Super_Find_Token
);
500 pragma Inline
(Super_Index
);
501 pragma Inline
(Super_Index_Non_Blank
);
502 pragma Inline
(Super_Length
);
503 pragma Inline
(Super_Replace_Element
);
504 pragma Inline
(Super_Slice
);
505 pragma Inline
(Super_To_String
);
507 end Ada
.Strings
.Wide_Wide_Superbounded
;