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 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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_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
39 -- Strings.Wide_Bounded.Generic_Bounded_Length use this type with
40 -- an appropriate discriminant value set.
42 with Ada
.Strings
.Wide_Maps
;
44 package Ada
.Strings
.Wide_Superbounded
is
45 pragma Preelaborate
(Wide_Superbounded
);
47 Wide_NUL
: constant Wide_Character := Wide_Character'Val (0);
49 type Super_String
(Max_Length
: Positive) is record
50 Current_Length
: Natural := 0;
51 Data
: Wide_String (1 .. Max_Length
) := (others => Wide_NUL
);
53 -- Type Wide_Bounded_String in
54 -- Ada.Strings.Wide_Bounded.Generic_Bounded_Length is derived from this
55 -- type, with the constraint of the maximum length.
57 -- The subprograms defined for Super_String are similar to those
58 -- defined for Wide_Bounded_String, except that they have different names,
59 -- so that they can be renamed in
60 -- Ada.Strings.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_String;
71 Drop
: Truncation
:= Error
)
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.Bounded.
79 function Super_To_String
(Source
: Super_String
) return Wide_String;
82 (Left
, Right
: Super_String
;
83 Drop
: Truncation
:= Error
)
89 Drop
: Truncation
:= Error
)
95 Drop
: Truncation
:= Error
)
100 Right
: Wide_Character;
101 Drop
: Truncation
:= Error
)
104 function Super_Append
105 (Left
: Wide_Character;
106 Right
: Super_String
;
107 Drop
: Truncation
:= Error
)
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_String;
118 Drop
: Truncation
:= Error
);
120 procedure Super_Append
121 (Source
: in out Super_String
;
122 New_Item
: Wide_Character;
123 Drop
: Truncation
:= Error
);
126 (Left
, Right
: Super_String
)
130 (Left
: Super_String
;
136 Right
: Super_String
)
140 (Left
: Super_String
;
141 Right
: Wide_Character)
145 (Left
: Wide_Character;
146 Right
: Super_String
)
149 function Super_Element
150 (Source
: Super_String
;
152 return Wide_Character;
154 procedure Super_Replace_Element
155 (Source
: in out Super_String
;
157 By
: Wide_Character);
160 (Source
: Super_String
;
165 function "=" (Left
, Right
: Super_String
) return Boolean;
167 function Equal
(Left
, Right
: Super_String
) return Boolean renames "=";
170 (Left
: Super_String
;
176 Right
: Super_String
)
179 function Less
(Left
, Right
: Super_String
) return Boolean;
182 (Left
: Super_String
;
188 Right
: Super_String
)
191 function Less_Or_Equal
(Left
, Right
: Super_String
) return Boolean;
193 function Less_Or_Equal
194 (Left
: Super_String
;
198 function Less_Or_Equal
200 Right
: Super_String
)
203 function Greater
(Left
, Right
: Super_String
) return Boolean;
206 (Left
: Super_String
;
212 Right
: Super_String
)
215 function Greater_Or_Equal
(Left
, Right
: Super_String
) return Boolean;
217 function Greater_Or_Equal
218 (Left
: Super_String
;
222 function Greater_Or_Equal
224 Right
: Super_String
)
227 ----------------------
228 -- Search Functions --
229 ----------------------
232 (Source
: Super_String
;
233 Pattern
: Wide_String;
234 Going
: Direction
:= Forward
;
235 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
239 (Source
: Super_String
;
240 Pattern
: Wide_String;
241 Going
: Direction
:= Forward
;
242 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
)
246 (Source
: Super_String
;
247 Set
: Wide_Maps
.Wide_Character_Set
;
248 Test
: Membership
:= Inside
;
249 Going
: Direction
:= Forward
)
252 function Super_Index_Non_Blank
253 (Source
: Super_String
;
254 Going
: Direction
:= Forward
)
258 (Source
: Super_String
;
259 Pattern
: Wide_String;
260 Mapping
: Wide_Maps
.Wide_Character_Mapping
:= Wide_Maps
.Identity
)
264 (Source
: Super_String
;
265 Pattern
: Wide_String;
266 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
)
270 (Source
: Super_String
;
271 Set
: Wide_Maps
.Wide_Character_Set
)
274 procedure Super_Find_Token
275 (Source
: Super_String
;
276 Set
: Wide_Maps
.Wide_Character_Set
;
278 First
: out Positive;
281 -----------------------------------------
282 -- Wide_String Translation Subprograms --
283 -----------------------------------------
285 function Super_Translate
286 (Source
: Super_String
;
287 Mapping
: Wide_Maps
.Wide_Character_Mapping
)
290 procedure Super_Translate
291 (Source
: in out Super_String
;
292 Mapping
: Wide_Maps
.Wide_Character_Mapping
);
294 function Super_Translate
295 (Source
: Super_String
;
296 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
)
299 procedure Super_Translate
300 (Source
: in out Super_String
;
301 Mapping
: Wide_Maps
.Wide_Character_Mapping_Function
);
303 --------------------------------------------
304 -- Wide_String Transformation Subprograms --
305 --------------------------------------------
307 function Super_Replace_Slice
308 (Source
: Super_String
;
312 Drop
: Truncation
:= Error
)
315 procedure Super_Replace_Slice
316 (Source
: in out Super_String
;
320 Drop
: Truncation
:= Error
);
322 function Super_Insert
323 (Source
: Super_String
;
325 New_Item
: Wide_String;
326 Drop
: Truncation
:= Error
)
329 procedure Super_Insert
330 (Source
: in out Super_String
;
332 New_Item
: Wide_String;
333 Drop
: Truncation
:= Error
);
335 function Super_Overwrite
336 (Source
: Super_String
;
338 New_Item
: Wide_String;
339 Drop
: Truncation
:= Error
)
342 procedure Super_Overwrite
343 (Source
: in out Super_String
;
345 New_Item
: Wide_String;
346 Drop
: Truncation
:= Error
);
348 function Super_Delete
349 (Source
: Super_String
;
354 procedure Super_Delete
355 (Source
: in out Super_String
;
359 --------------------------------------
360 -- Wide_String Selector Subprograms --
361 --------------------------------------
364 (Source
: Super_String
;
369 (Source
: in out Super_String
;
373 (Source
: Super_String
;
374 Left
: Wide_Maps
.Wide_Character_Set
;
375 Right
: Wide_Maps
.Wide_Character_Set
)
379 (Source
: in out Super_String
;
380 Left
: Wide_Maps
.Wide_Character_Set
;
381 Right
: Wide_Maps
.Wide_Character_Set
);
384 (Source
: Super_String
;
386 Pad
: Wide_Character := Wide_Space
;
387 Drop
: Truncation
:= Error
)
391 (Source
: in out Super_String
;
393 Pad
: Wide_Character := Wide_Space
;
394 Drop
: Truncation
:= Error
);
397 (Source
: Super_String
;
399 Pad
: Wide_Character := Wide_Space
;
400 Drop
: Truncation
:= Error
)
404 (Source
: in out Super_String
;
406 Pad
: Wide_Character := Wide_Space
;
407 Drop
: Truncation
:= Error
);
409 ------------------------------------
410 -- Wide_String Constructor Subprograms --
411 ------------------------------------
413 -- Note: in some of the following routines, there is an extra parameter
414 -- Max_Length which specifies the value of the maximum length for the
415 -- resulting Super_String value.
419 Right
: Wide_Character;
420 Max_Length
: Positive)
422 -- Note the additional parameter Max_Length
427 Max_Length
: Positive)
429 -- Note the additional parameter Max_Length
433 Right
: Super_String
)
436 function Super_Replicate
438 Item
: Wide_Character;
439 Drop
: Truncation
:= Error
;
440 Max_Length
: Positive)
442 -- Note the additional parameter Max_Length
444 function Super_Replicate
447 Drop
: Truncation
:= Error
;
448 Max_Length
: Positive)
450 -- Note the additional parameter Max_Length
452 function Super_Replicate
455 Drop
: Truncation
:= Error
)
460 -- Pragma Inline declarations
463 pragma Inline
(Less
);
464 pragma Inline
(Less_Or_Equal
);
465 pragma Inline
(Greater
);
466 pragma Inline
(Greater_Or_Equal
);
467 pragma Inline
(Concat
);
468 pragma Inline
(Super_Count
);
469 pragma Inline
(Super_Element
);
470 pragma Inline
(Super_Find_Token
);
471 pragma Inline
(Super_Index
);
472 pragma Inline
(Super_Index_Non_Blank
);
473 pragma Inline
(Super_Length
);
474 pragma Inline
(Super_Replace_Element
);
475 pragma Inline
(Super_Slice
);
476 pragma Inline
(Super_To_String
);
478 end Ada
.Strings
.Wide_Superbounded
;