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-2005, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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.Wide_Wide_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 the package
39 -- Strings.Wide_Wide_Bounded.Generic_Bounded_Length use this type with
40 -- an appropriate discriminant value set.
42 with Ada
.Strings
.Wide_Wide_Maps
;
44 package Ada
.Strings
.Wide_Wide_Superbounded
is
47 Wide_Wide_NUL
: constant Wide_Wide_Character
:=
48 Wide_Wide_Character
'Val (0);
50 type Super_String
(Max_Length
: Positive) is record
51 Current_Length
: Natural := 0;
52 Data
: Wide_Wide_String
(1 .. Max_Length
) :=
53 (others => Wide_Wide_NUL
);
55 -- Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is
56 -- derived from this type, with the constraint of the maximum length.
58 -- The subprograms defined for Super_String are similar to those defined
59 -- for Bounded_Wide_Wide_String, except that they have different names, so
60 -- that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length.
62 function Super_Length
(Source
: Super_String
) return Natural;
64 --------------------------------------------------------
65 -- Conversion, Concatenation, and Selection Functions --
66 --------------------------------------------------------
68 function To_Super_String
69 (Source
: Wide_Wide_String
;
71 Drop
: Truncation
:= Error
) return Super_String
;
72 -- Note the additional parameter Max_Length, which specifies the maximum
73 -- length setting of the resulting Super_String value.
75 -- The following procedures have declarations (and semantics) that are
76 -- exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded.
78 function Super_To_String
(Source
: Super_String
) return Wide_Wide_String
;
80 procedure Set_Super_String
81 (Target
: out Super_String
;
82 Source
: Wide_Wide_String
;
83 Drop
: Truncation
:= Error
);
88 Drop
: Truncation
:= Error
) return Super_String
;
92 Right
: Wide_Wide_String
;
93 Drop
: Truncation
:= Error
) return Super_String
;
96 (Left
: Wide_Wide_String
;
98 Drop
: Truncation
:= Error
) return Super_String
;
100 function Super_Append
101 (Left
: Super_String
;
102 Right
: Wide_Wide_Character
;
103 Drop
: Truncation
:= Error
) return Super_String
;
105 function Super_Append
106 (Left
: Wide_Wide_Character
;
107 Right
: Super_String
;
108 Drop
: Truncation
:= Error
) return Super_String
;
110 procedure Super_Append
111 (Source
: in out Super_String
;
112 New_Item
: Super_String
;
113 Drop
: Truncation
:= Error
);
115 procedure Super_Append
116 (Source
: in out Super_String
;
117 New_Item
: Wide_Wide_String
;
118 Drop
: Truncation
:= Error
);
120 procedure Super_Append
121 (Source
: in out Super_String
;
122 New_Item
: Wide_Wide_Character
;
123 Drop
: Truncation
:= Error
);
126 (Left
: Super_String
;
127 Right
: Super_String
) return Super_String
;
130 (Left
: Super_String
;
131 Right
: Wide_Wide_String
) return Super_String
;
134 (Left
: Wide_Wide_String
;
135 Right
: Super_String
) return Super_String
;
138 (Left
: Super_String
;
139 Right
: Wide_Wide_Character
) return Super_String
;
142 (Left
: Wide_Wide_Character
;
143 Right
: Super_String
) return Super_String
;
145 function Super_Element
146 (Source
: Super_String
;
147 Index
: Positive) return Wide_Wide_Character
;
149 procedure Super_Replace_Element
150 (Source
: in out Super_String
;
152 By
: Wide_Wide_Character
);
155 (Source
: Super_String
;
157 High
: Natural) return Wide_Wide_String
;
160 (Source
: Super_String
;
162 High
: Natural) return Super_String
;
164 procedure Super_Slice
165 (Source
: Super_String
;
166 Target
: out Super_String
;
171 (Left
: Super_String
;
172 Right
: Super_String
) return Boolean;
175 (Left
: Super_String
;
176 Right
: Super_String
) return Boolean renames "=";
179 (Left
: Super_String
;
180 Right
: Wide_Wide_String
) return Boolean;
183 (Left
: Wide_Wide_String
;
184 Right
: Super_String
) return Boolean;
187 (Left
: Super_String
;
188 Right
: Super_String
) return Boolean;
191 (Left
: Super_String
;
192 Right
: Wide_Wide_String
) return Boolean;
195 (Left
: Wide_Wide_String
;
196 Right
: Super_String
) return Boolean;
198 function Less_Or_Equal
199 (Left
: Super_String
;
200 Right
: Super_String
) return Boolean;
202 function Less_Or_Equal
203 (Left
: Super_String
;
204 Right
: Wide_Wide_String
) return Boolean;
206 function Less_Or_Equal
207 (Left
: Wide_Wide_String
;
208 Right
: Super_String
) return Boolean;
211 (Left
: Super_String
;
212 Right
: Super_String
) return Boolean;
215 (Left
: Super_String
;
216 Right
: Wide_Wide_String
) return Boolean;
219 (Left
: Wide_Wide_String
;
220 Right
: Super_String
) return Boolean;
222 function Greater_Or_Equal
223 (Left
: Super_String
;
224 Right
: Super_String
) return Boolean;
226 function Greater_Or_Equal
227 (Left
: Super_String
;
228 Right
: Wide_Wide_String
) return Boolean;
230 function Greater_Or_Equal
231 (Left
: Wide_Wide_String
;
232 Right
: Super_String
) return Boolean;
234 ----------------------
235 -- Search Functions --
236 ----------------------
239 (Source
: Super_String
;
240 Pattern
: Wide_Wide_String
;
241 Going
: Direction
:= Forward
;
242 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
243 Wide_Wide_Maps
.Identity
)
247 (Source
: Super_String
;
248 Pattern
: Wide_Wide_String
;
249 Going
: Direction
:= Forward
;
250 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
254 (Source
: Super_String
;
255 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
256 Test
: Membership
:= Inside
;
257 Going
: Direction
:= Forward
) return Natural;
260 (Source
: Super_String
;
261 Pattern
: Wide_Wide_String
;
263 Going
: Direction
:= Forward
;
264 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
265 Wide_Wide_Maps
.Identity
)
269 (Source
: Super_String
;
270 Pattern
: Wide_Wide_String
;
272 Going
: Direction
:= Forward
;
273 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
277 (Source
: Super_String
;
278 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
280 Test
: Membership
:= Inside
;
281 Going
: Direction
:= Forward
) return Natural;
283 function Super_Index_Non_Blank
284 (Source
: Super_String
;
285 Going
: Direction
:= Forward
) return Natural;
287 function Super_Index_Non_Blank
288 (Source
: Super_String
;
290 Going
: Direction
:= Forward
) return Natural;
293 (Source
: Super_String
;
294 Pattern
: Wide_Wide_String
;
295 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
:=
296 Wide_Wide_Maps
.Identity
)
300 (Source
: Super_String
;
301 Pattern
: Wide_Wide_String
;
302 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
306 (Source
: Super_String
;
307 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Natural;
309 procedure Super_Find_Token
310 (Source
: Super_String
;
311 Set
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
313 First
: out Positive;
316 ------------------------------------
317 -- String Translation Subprograms --
318 ------------------------------------
320 function Super_Translate
321 (Source
: Super_String
;
322 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
)
325 procedure Super_Translate
326 (Source
: in out Super_String
;
327 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping
);
329 function Super_Translate
330 (Source
: Super_String
;
331 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
)
334 procedure Super_Translate
335 (Source
: in out Super_String
;
336 Mapping
: Wide_Wide_Maps
.Wide_Wide_Character_Mapping_Function
);
338 ---------------------------------------
339 -- String Transformation Subprograms --
340 ---------------------------------------
342 function Super_Replace_Slice
343 (Source
: Super_String
;
346 By
: Wide_Wide_String
;
347 Drop
: Truncation
:= Error
) return Super_String
;
349 procedure Super_Replace_Slice
350 (Source
: in out Super_String
;
353 By
: Wide_Wide_String
;
354 Drop
: Truncation
:= Error
);
356 function Super_Insert
357 (Source
: Super_String
;
359 New_Item
: Wide_Wide_String
;
360 Drop
: Truncation
:= Error
) return Super_String
;
362 procedure Super_Insert
363 (Source
: in out Super_String
;
365 New_Item
: Wide_Wide_String
;
366 Drop
: Truncation
:= Error
);
368 function Super_Overwrite
369 (Source
: Super_String
;
371 New_Item
: Wide_Wide_String
;
372 Drop
: Truncation
:= Error
) return Super_String
;
374 procedure Super_Overwrite
375 (Source
: in out Super_String
;
377 New_Item
: Wide_Wide_String
;
378 Drop
: Truncation
:= Error
);
380 function Super_Delete
381 (Source
: Super_String
;
383 Through
: Natural) return Super_String
;
385 procedure Super_Delete
386 (Source
: in out Super_String
;
390 ---------------------------------
391 -- String Selector Subprograms --
392 ---------------------------------
395 (Source
: Super_String
;
396 Side
: Trim_End
) return Super_String
;
399 (Source
: in out Super_String
;
403 (Source
: Super_String
;
404 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
405 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
) return Super_String
;
408 (Source
: in out Super_String
;
409 Left
: Wide_Wide_Maps
.Wide_Wide_Character_Set
;
410 Right
: Wide_Wide_Maps
.Wide_Wide_Character_Set
);
413 (Source
: Super_String
;
415 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
416 Drop
: Truncation
:= Error
) return Super_String
;
419 (Source
: in out Super_String
;
421 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
422 Drop
: Truncation
:= Error
);
425 (Source
: Super_String
;
427 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
428 Drop
: Truncation
:= Error
) return Super_String
;
431 (Source
: in out Super_String
;
433 Pad
: Wide_Wide_Character
:= Wide_Wide_Space
;
434 Drop
: Truncation
:= Error
);
436 ------------------------------------
437 -- String Constructor Subprograms --
438 ------------------------------------
440 -- Note: in some of the following routines, there is an extra parameter
441 -- Max_Length which specifies the value of the maximum length for the
442 -- resulting Super_String value.
446 Right
: Wide_Wide_Character
;
447 Max_Length
: Positive) return Super_String
;
448 -- Note the additional parameter Max_Length
452 Right
: Wide_Wide_String
;
453 Max_Length
: Positive) return Super_String
;
454 -- Note the additional parameter Max_Length
458 Right
: Super_String
) return Super_String
;
460 function Super_Replicate
462 Item
: Wide_Wide_Character
;
463 Drop
: Truncation
:= Error
;
464 Max_Length
: Positive) return Super_String
;
465 -- Note the additional parameter Max_Length
467 function Super_Replicate
469 Item
: Wide_Wide_String
;
470 Drop
: Truncation
:= Error
;
471 Max_Length
: Positive) return Super_String
;
472 -- Note the additional parameter Max_Length
474 function Super_Replicate
477 Drop
: Truncation
:= Error
) return Super_String
;
480 -- Pragma Inline declarations
483 pragma Inline
(Less
);
484 pragma Inline
(Less_Or_Equal
);
485 pragma Inline
(Greater
);
486 pragma Inline
(Greater_Or_Equal
);
487 pragma Inline
(Concat
);
488 pragma Inline
(Super_Count
);
489 pragma Inline
(Super_Element
);
490 pragma Inline
(Super_Find_Token
);
491 pragma Inline
(Super_Index
);
492 pragma Inline
(Super_Index_Non_Blank
);
493 pragma Inline
(Super_Length
);
494 pragma Inline
(Super_Replace_Element
);
495 pragma Inline
(Super_Slice
);
496 pragma Inline
(Super_To_String
);
498 end Ada
.Strings
.Wide_Wide_Superbounded
;