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 -- Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is
49 -- derived from Super_String, with the constraint of the maximum length.
51 type Super_String
(Max_Length
: Positive) is record
52 Current_Length
: Natural := 0;
53 Data
: Wide_Wide_String
(1 .. Max_Length
);
54 -- A previous version had a default initial value for Data, which is
55 -- no longer necessary, because we now special-case this type in the
56 -- compiler, so "=" composes properly for descendants of this type.
57 -- Leaving it out is more efficient.
60 -- The subprograms defined for Super_String are similar to those defined
61 -- for Bounded_Wide_Wide_String, except that they have different names, so
62 -- that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length.
64 function Super_Length
(Source
: Super_String
) return Natural;
66 --------------------------------------------------------
67 -- Conversion, Concatenation, and Selection Functions --
68 --------------------------------------------------------
70 function To_Super_String
71 (Source
: Wide_Wide_String
;
73 Drop
: Truncation
:= Error
) return Super_String
;
74 -- Note the additional parameter Max_Length, which specifies the maximum
75 -- length setting of the resulting Super_String value.
77 -- The following procedures have declarations (and semantics) that are
78 -- exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded.
80 function Super_To_String
(Source
: Super_String
) return Wide_Wide_String
;
82 procedure Set_Super_String
83 (Target
: out Super_String
;
84 Source
: Wide_Wide_String
;
85 Drop
: Truncation
:= Error
);
90 Drop
: Truncation
:= Error
) return Super_String
;
94 Right
: Wide_Wide_String
;
95 Drop
: Truncation
:= Error
) return Super_String
;
98 (Left
: Wide_Wide_String
;
100 Drop
: Truncation
:= Error
) return Super_String
;
102 function Super_Append
103 (Left
: Super_String
;
104 Right
: Wide_Wide_Character
;
105 Drop
: Truncation
:= Error
) return Super_String
;
107 function Super_Append
108 (Left
: Wide_Wide_Character
;
109 Right
: Super_String
;
110 Drop
: Truncation
:= Error
) return Super_String
;
112 procedure Super_Append
113 (Source
: in out Super_String
;
114 New_Item
: Super_String
;
115 Drop
: Truncation
:= Error
);
117 procedure Super_Append
118 (Source
: in out Super_String
;
119 New_Item
: Wide_Wide_String
;
120 Drop
: Truncation
:= Error
);
122 procedure Super_Append
123 (Source
: in out Super_String
;
124 New_Item
: Wide_Wide_Character
;
125 Drop
: Truncation
:= Error
);
128 (Left
: Super_String
;
129 Right
: Super_String
) return Super_String
;
132 (Left
: Super_String
;
133 Right
: Wide_Wide_String
) return Super_String
;
136 (Left
: Wide_Wide_String
;
137 Right
: Super_String
) return Super_String
;
140 (Left
: Super_String
;
141 Right
: Wide_Wide_Character
) return Super_String
;
144 (Left
: Wide_Wide_Character
;
145 Right
: Super_String
) return Super_String
;
147 function Super_Element
148 (Source
: Super_String
;
149 Index
: Positive) return Wide_Wide_Character
;
151 procedure Super_Replace_Element
152 (Source
: in out Super_String
;
154 By
: Wide_Wide_Character
);
157 (Source
: Super_String
;
159 High
: Natural) return Wide_Wide_String
;
162 (Source
: Super_String
;
164 High
: Natural) return Super_String
;
166 procedure Super_Slice
167 (Source
: Super_String
;
168 Target
: out Super_String
;
173 (Left
: Super_String
;
174 Right
: Super_String
) return Boolean;
177 (Left
: Super_String
;
178 Right
: Super_String
) return Boolean renames "=";
181 (Left
: Super_String
;
182 Right
: Wide_Wide_String
) return Boolean;
185 (Left
: Wide_Wide_String
;
186 Right
: Super_String
) return Boolean;
189 (Left
: Super_String
;
190 Right
: Super_String
) return Boolean;
193 (Left
: Super_String
;
194 Right
: Wide_Wide_String
) return Boolean;
197 (Left
: Wide_Wide_String
;
198 Right
: Super_String
) return Boolean;
200 function Less_Or_Equal
201 (Left
: Super_String
;
202 Right
: Super_String
) return Boolean;
204 function Less_Or_Equal
205 (Left
: Super_String
;
206 Right
: Wide_Wide_String
) return Boolean;
208 function Less_Or_Equal
209 (Left
: Wide_Wide_String
;
210 Right
: Super_String
) return Boolean;
213 (Left
: Super_String
;
214 Right
: Super_String
) return Boolean;
217 (Left
: Super_String
;
218 Right
: Wide_Wide_String
) return Boolean;
221 (Left
: Wide_Wide_String
;
222 Right
: Super_String
) return Boolean;
224 function Greater_Or_Equal
225 (Left
: Super_String
;
226 Right
: Super_String
) return Boolean;
228 function Greater_Or_Equal
229 (Left
: Super_String
;
230 Right
: Wide_Wide_String
) return Boolean;
232 function Greater_Or_Equal
233 (Left
: Wide_Wide_String
;
234 Right
: Super_String
) return Boolean;
236 ----------------------
237 -- Search Functions --
238 ----------------------
241 (Source
: Super_String
;
242 Pattern
: Wide_Wide_String
;
243 Going
: Direction
:= Forward
;
244 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
245 Wide_Wide_Maps
.Identity
)
249 (Source
: Super_String
;
250 Pattern
: Wide_Wide_String
;
251 Going
: Direction
:= Forward
;
252 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
256 (Source
: Super_String
;
257 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
258 Test
: Membership
:= Inside
;
259 Going
: Direction
:= Forward
) return Natural;
262 (Source
: Super_String
;
263 Pattern
: Wide_Wide_String
;
265 Going
: Direction
:= Forward
;
266 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
267 Wide_Wide_Maps
.Identity
)
271 (Source
: Super_String
;
272 Pattern
: Wide_Wide_String
;
274 Going
: Direction
:= Forward
;
275 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
279 (Source
: Super_String
;
280 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
282 Test
: Membership
:= Inside
;
283 Going
: Direction
:= Forward
) return Natural;
285 function Super_Index_Non_Blank
286 (Source
: Super_String
;
287 Going
: Direction
:= Forward
) return Natural;
289 function Super_Index_Non_Blank
290 (Source
: Super_String
;
292 Going
: Direction
:= Forward
) return Natural;
295 (Source
: Super_String
;
296 Pattern
: Wide_Wide_String
;
297 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
298 Wide_Wide_Maps
.Identity
)
302 (Source
: Super_String
;
303 Pattern
: Wide_Wide_String
;
304 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
308 (Source
: Super_String
;
309 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Natural;
311 procedure Super_Find_Token
312 (Source
: Super_String
;
313 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
316 First
: out Positive;
319 procedure Super_Find_Token
320 (Source
: Super_String
;
321 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
323 First
: out Positive;
326 ------------------------------------
327 -- String Translation Subprograms --
328 ------------------------------------
330 function Super_Translate
331 (Source
: Super_String
;
332 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
)
335 procedure Super_Translate
336 (Source
: in out Super_String
;
337 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
);
339 function Super_Translate
340 (Source
: Super_String
;
341 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
344 procedure Super_Translate
345 (Source
: in out Super_String
;
346 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
);
348 ---------------------------------------
349 -- String Transformation Subprograms --
350 ---------------------------------------
352 function Super_Replace_Slice
353 (Source
: Super_String
;
356 By
: Wide_Wide_String
;
357 Drop
: Truncation
:= Error
) return Super_String
;
359 procedure Super_Replace_Slice
360 (Source
: in out Super_String
;
363 By
: Wide_Wide_String
;
364 Drop
: Truncation
:= Error
);
366 function Super_Insert
367 (Source
: Super_String
;
369 New_Item
: Wide_Wide_String
;
370 Drop
: Truncation
:= Error
) return Super_String
;
372 procedure Super_Insert
373 (Source
: in out Super_String
;
375 New_Item
: Wide_Wide_String
;
376 Drop
: Truncation
:= Error
);
378 function Super_Overwrite
379 (Source
: Super_String
;
381 New_Item
: Wide_Wide_String
;
382 Drop
: Truncation
:= Error
) return Super_String
;
384 procedure Super_Overwrite
385 (Source
: in out Super_String
;
387 New_Item
: Wide_Wide_String
;
388 Drop
: Truncation
:= Error
);
390 function Super_Delete
391 (Source
: Super_String
;
393 Through
: Natural) return Super_String
;
395 procedure Super_Delete
396 (Source
: in out Super_String
;
400 ---------------------------------
401 -- String Selector Subprograms --
402 ---------------------------------
405 (Source
: Super_String
;
406 Side
: Trim_End
) return Super_String
;
409 (Source
: in out Super_String
;
413 (Source
: Super_String
;
414 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
415 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Super_String
;
418 (Source
: in out Super_String
;
419 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
420 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
);
423 (Source
: Super_String
;
425 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
426 Drop
: Truncation
:= Error
) return Super_String
;
429 (Source
: in out Super_String
;
431 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
432 Drop
: Truncation
:= Error
);
435 (Source
: Super_String
;
437 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
438 Drop
: Truncation
:= Error
) return Super_String
;
441 (Source
: in out Super_String
;
443 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
444 Drop
: Truncation
:= Error
);
446 ------------------------------------
447 -- String Constructor Subprograms --
448 ------------------------------------
450 -- Note: in some of the following routines, there is an extra parameter
451 -- Max_Length which specifies the value of the maximum length for the
452 -- resulting Super_String value.
456 Right
: Wide_Wide_Character
;
457 Max_Length
: Positive) return Super_String
;
458 -- Note the additional parameter Max_Length
462 Right
: Wide_Wide_String
;
463 Max_Length
: Positive) return Super_String
;
464 -- Note the additional parameter Max_Length
468 Right
: Super_String
) return Super_String
;
470 function Super_Replicate
472 Item
: Wide_Wide_Character
;
473 Drop
: Truncation
:= Error
;
474 Max_Length
: Positive) return Super_String
;
475 -- Note the additional parameter Max_Length
477 function Super_Replicate
479 Item
: Wide_Wide_String
;
480 Drop
: Truncation
:= Error
;
481 Max_Length
: Positive) return Super_String
;
482 -- Note the additional parameter Max_Length
484 function Super_Replicate
487 Drop
: Truncation
:= Error
) return Super_String
;
490 -- Pragma Inline declarations
493 pragma Inline
(Less
);
494 pragma Inline
(Less_Or_Equal
);
495 pragma Inline
(Greater
);
496 pragma Inline
(Greater_Or_Equal
);
497 pragma Inline
(Concat
);
498 pragma Inline
(Super_Count
);
499 pragma Inline
(Super_Element
);
500 pragma Inline
(Super_Find_Token
);
501 pragma Inline
(Super_Index
);
502 pragma Inline
(Super_Index_Non_Blank
);
503 pragma Inline
(Super_Length
);
504 pragma Inline
(Super_Replace_Element
);
505 pragma Inline
(Super_Slice
);
506 pragma Inline
(Super_To_String
);
508 end Ada
.Strings
.Wide_Wide_Superbounded
;