1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME COMPONENTS --
|
4 |
|
|
-- --
|
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 --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2003-2010, 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 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. --
|
17 |
|
|
-- --
|
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. --
|
21 |
|
|
-- --
|
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/>. --
|
26 |
|
|
-- --
|
27 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
28 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
29 |
|
|
-- --
|
30 |
|
|
------------------------------------------------------------------------------
|
31 |
|
|
|
32 |
|
|
-- This non generic package contains most of the implementation of the
|
33 |
|
|
-- generic package Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
|
34 |
|
|
|
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_Bounded.Generic_Bounded_Length use this type with
|
38 |
|
|
-- an appropriate discriminant value set.
|
39 |
|
|
|
40 |
|
|
with Ada.Strings.Wide_Maps;
|
41 |
|
|
|
42 |
|
|
package Ada.Strings.Wide_Superbounded is
|
43 |
|
|
pragma Preelaborate;
|
44 |
|
|
|
45 |
|
|
Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
|
46 |
|
|
|
47 |
|
|
type Super_String (Max_Length : Positive) is record
|
48 |
|
|
Current_Length : Natural := 0;
|
49 |
|
|
Data : Wide_String (1 .. Max_Length) := (others => Wide_NUL);
|
50 |
|
|
end record;
|
51 |
|
|
-- Ada.Strings.Wide_Bounded.Generic_Bounded_Length.Wide_Bounded_String is
|
52 |
|
|
-- derived from this type, with the constraint of the maximum length.
|
53 |
|
|
|
54 |
|
|
-- The subprograms defined for Super_String are similar to those defined
|
55 |
|
|
-- for Bounded_Wide_String, except that they have different names, so that
|
56 |
|
|
-- they can be renamed in Ada.Strings.Wide_Bounded.Generic_Bounded_Length.
|
57 |
|
|
|
58 |
|
|
function Super_Length (Source : Super_String) return Natural;
|
59 |
|
|
|
60 |
|
|
--------------------------------------------------------
|
61 |
|
|
-- Conversion, Concatenation, and Selection Functions --
|
62 |
|
|
--------------------------------------------------------
|
63 |
|
|
|
64 |
|
|
function To_Super_String
|
65 |
|
|
(Source : Wide_String;
|
66 |
|
|
Max_Length : Natural;
|
67 |
|
|
Drop : Truncation := Error) return Super_String;
|
68 |
|
|
-- Note the additional parameter Max_Length, which specifies the maximum
|
69 |
|
|
-- length setting of the resulting Super_String value.
|
70 |
|
|
|
71 |
|
|
-- The following procedures have declarations (and semantics) that are
|
72 |
|
|
-- exactly analogous to those declared in Ada.Strings.Wide_Bounded.
|
73 |
|
|
|
74 |
|
|
function Super_To_String (Source : Super_String) return Wide_String;
|
75 |
|
|
|
76 |
|
|
procedure Set_Super_String
|
77 |
|
|
(Target : out Super_String;
|
78 |
|
|
Source : Wide_String;
|
79 |
|
|
Drop : Truncation := Error);
|
80 |
|
|
|
81 |
|
|
function Super_Append
|
82 |
|
|
(Left : Super_String;
|
83 |
|
|
Right : Super_String;
|
84 |
|
|
Drop : Truncation := Error) return Super_String;
|
85 |
|
|
|
86 |
|
|
function Super_Append
|
87 |
|
|
(Left : Super_String;
|
88 |
|
|
Right : Wide_String;
|
89 |
|
|
Drop : Truncation := Error) return Super_String;
|
90 |
|
|
|
91 |
|
|
function Super_Append
|
92 |
|
|
(Left : Wide_String;
|
93 |
|
|
Right : Super_String;
|
94 |
|
|
Drop : Truncation := Error) return Super_String;
|
95 |
|
|
|
96 |
|
|
function Super_Append
|
97 |
|
|
(Left : Super_String;
|
98 |
|
|
Right : Wide_Character;
|
99 |
|
|
Drop : Truncation := Error) return Super_String;
|
100 |
|
|
|
101 |
|
|
function Super_Append
|
102 |
|
|
(Left : Wide_Character;
|
103 |
|
|
Right : Super_String;
|
104 |
|
|
Drop : Truncation := Error) return Super_String;
|
105 |
|
|
|
106 |
|
|
procedure Super_Append
|
107 |
|
|
(Source : in out Super_String;
|
108 |
|
|
New_Item : Super_String;
|
109 |
|
|
Drop : Truncation := Error);
|
110 |
|
|
|
111 |
|
|
procedure Super_Append
|
112 |
|
|
(Source : in out Super_String;
|
113 |
|
|
New_Item : Wide_String;
|
114 |
|
|
Drop : Truncation := Error);
|
115 |
|
|
|
116 |
|
|
procedure Super_Append
|
117 |
|
|
(Source : in out Super_String;
|
118 |
|
|
New_Item : Wide_Character;
|
119 |
|
|
Drop : Truncation := Error);
|
120 |
|
|
|
121 |
|
|
function Concat
|
122 |
|
|
(Left : Super_String;
|
123 |
|
|
Right : Super_String) return Super_String;
|
124 |
|
|
|
125 |
|
|
function Concat
|
126 |
|
|
(Left : Super_String;
|
127 |
|
|
Right : Wide_String) return Super_String;
|
128 |
|
|
|
129 |
|
|
function Concat
|
130 |
|
|
(Left : Wide_String;
|
131 |
|
|
Right : Super_String) return Super_String;
|
132 |
|
|
|
133 |
|
|
function Concat
|
134 |
|
|
(Left : Super_String;
|
135 |
|
|
Right : Wide_Character) return Super_String;
|
136 |
|
|
|
137 |
|
|
function Concat
|
138 |
|
|
(Left : Wide_Character;
|
139 |
|
|
Right : Super_String) return Super_String;
|
140 |
|
|
|
141 |
|
|
function Super_Element
|
142 |
|
|
(Source : Super_String;
|
143 |
|
|
Index : Positive) return Wide_Character;
|
144 |
|
|
|
145 |
|
|
procedure Super_Replace_Element
|
146 |
|
|
(Source : in out Super_String;
|
147 |
|
|
Index : Positive;
|
148 |
|
|
By : Wide_Character);
|
149 |
|
|
|
150 |
|
|
function Super_Slice
|
151 |
|
|
(Source : Super_String;
|
152 |
|
|
Low : Positive;
|
153 |
|
|
High : Natural) return Wide_String;
|
154 |
|
|
|
155 |
|
|
function Super_Slice
|
156 |
|
|
(Source : Super_String;
|
157 |
|
|
Low : Positive;
|
158 |
|
|
High : Natural) return Super_String;
|
159 |
|
|
|
160 |
|
|
procedure Super_Slice
|
161 |
|
|
(Source : Super_String;
|
162 |
|
|
Target : out Super_String;
|
163 |
|
|
Low : Positive;
|
164 |
|
|
High : Natural);
|
165 |
|
|
|
166 |
|
|
function "="
|
167 |
|
|
(Left : Super_String;
|
168 |
|
|
Right : Super_String) return Boolean;
|
169 |
|
|
|
170 |
|
|
function Equal
|
171 |
|
|
(Left : Super_String;
|
172 |
|
|
Right : Super_String) return Boolean renames "=";
|
173 |
|
|
|
174 |
|
|
function Equal
|
175 |
|
|
(Left : Super_String;
|
176 |
|
|
Right : Wide_String) return Boolean;
|
177 |
|
|
|
178 |
|
|
function Equal
|
179 |
|
|
(Left : Wide_String;
|
180 |
|
|
Right : Super_String) return Boolean;
|
181 |
|
|
|
182 |
|
|
function Less
|
183 |
|
|
(Left : Super_String;
|
184 |
|
|
Right : Super_String) return Boolean;
|
185 |
|
|
|
186 |
|
|
function Less
|
187 |
|
|
(Left : Super_String;
|
188 |
|
|
Right : Wide_String) return Boolean;
|
189 |
|
|
|
190 |
|
|
function Less
|
191 |
|
|
(Left : Wide_String;
|
192 |
|
|
Right : Super_String) return Boolean;
|
193 |
|
|
|
194 |
|
|
function Less_Or_Equal
|
195 |
|
|
(Left : Super_String;
|
196 |
|
|
Right : Super_String) return Boolean;
|
197 |
|
|
|
198 |
|
|
function Less_Or_Equal
|
199 |
|
|
(Left : Super_String;
|
200 |
|
|
Right : Wide_String) return Boolean;
|
201 |
|
|
|
202 |
|
|
function Less_Or_Equal
|
203 |
|
|
(Left : Wide_String;
|
204 |
|
|
Right : Super_String) return Boolean;
|
205 |
|
|
|
206 |
|
|
function Greater
|
207 |
|
|
(Left : Super_String;
|
208 |
|
|
Right : Super_String) return Boolean;
|
209 |
|
|
|
210 |
|
|
function Greater
|
211 |
|
|
(Left : Super_String;
|
212 |
|
|
Right : Wide_String) return Boolean;
|
213 |
|
|
|
214 |
|
|
function Greater
|
215 |
|
|
(Left : Wide_String;
|
216 |
|
|
Right : Super_String) return Boolean;
|
217 |
|
|
|
218 |
|
|
function Greater_Or_Equal
|
219 |
|
|
(Left : Super_String;
|
220 |
|
|
Right : Super_String) return Boolean;
|
221 |
|
|
|
222 |
|
|
function Greater_Or_Equal
|
223 |
|
|
(Left : Super_String;
|
224 |
|
|
Right : Wide_String) return Boolean;
|
225 |
|
|
|
226 |
|
|
function Greater_Or_Equal
|
227 |
|
|
(Left : Wide_String;
|
228 |
|
|
Right : Super_String) return Boolean;
|
229 |
|
|
|
230 |
|
|
----------------------
|
231 |
|
|
-- Search Functions --
|
232 |
|
|
----------------------
|
233 |
|
|
|
234 |
|
|
function Super_Index
|
235 |
|
|
(Source : Super_String;
|
236 |
|
|
Pattern : Wide_String;
|
237 |
|
|
Going : Direction := Forward;
|
238 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
|
239 |
|
|
return Natural;
|
240 |
|
|
|
241 |
|
|
function Super_Index
|
242 |
|
|
(Source : Super_String;
|
243 |
|
|
Pattern : Wide_String;
|
244 |
|
|
Going : Direction := Forward;
|
245 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
|
246 |
|
|
|
247 |
|
|
function Super_Index
|
248 |
|
|
(Source : Super_String;
|
249 |
|
|
Set : Wide_Maps.Wide_Character_Set;
|
250 |
|
|
Test : Membership := Inside;
|
251 |
|
|
Going : Direction := Forward) return Natural;
|
252 |
|
|
|
253 |
|
|
function Super_Index
|
254 |
|
|
(Source : Super_String;
|
255 |
|
|
Pattern : Wide_String;
|
256 |
|
|
From : Positive;
|
257 |
|
|
Going : Direction := Forward;
|
258 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
|
259 |
|
|
return Natural;
|
260 |
|
|
|
261 |
|
|
function Super_Index
|
262 |
|
|
(Source : Super_String;
|
263 |
|
|
Pattern : Wide_String;
|
264 |
|
|
From : Positive;
|
265 |
|
|
Going : Direction := Forward;
|
266 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
|
267 |
|
|
|
268 |
|
|
function Super_Index
|
269 |
|
|
(Source : Super_String;
|
270 |
|
|
Set : Wide_Maps.Wide_Character_Set;
|
271 |
|
|
From : Positive;
|
272 |
|
|
Test : Membership := Inside;
|
273 |
|
|
Going : Direction := Forward) return Natural;
|
274 |
|
|
|
275 |
|
|
function Super_Index_Non_Blank
|
276 |
|
|
(Source : Super_String;
|
277 |
|
|
Going : Direction := Forward) return Natural;
|
278 |
|
|
|
279 |
|
|
function Super_Index_Non_Blank
|
280 |
|
|
(Source : Super_String;
|
281 |
|
|
From : Positive;
|
282 |
|
|
Going : Direction := Forward) return Natural;
|
283 |
|
|
|
284 |
|
|
function Super_Count
|
285 |
|
|
(Source : Super_String;
|
286 |
|
|
Pattern : Wide_String;
|
287 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
|
288 |
|
|
return Natural;
|
289 |
|
|
|
290 |
|
|
function Super_Count
|
291 |
|
|
(Source : Super_String;
|
292 |
|
|
Pattern : Wide_String;
|
293 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural;
|
294 |
|
|
|
295 |
|
|
function Super_Count
|
296 |
|
|
(Source : Super_String;
|
297 |
|
|
Set : Wide_Maps.Wide_Character_Set) return Natural;
|
298 |
|
|
|
299 |
|
|
procedure Super_Find_Token
|
300 |
|
|
(Source : Super_String;
|
301 |
|
|
Set : Wide_Maps.Wide_Character_Set;
|
302 |
|
|
From : Positive;
|
303 |
|
|
Test : Membership;
|
304 |
|
|
First : out Positive;
|
305 |
|
|
Last : out Natural);
|
306 |
|
|
|
307 |
|
|
procedure Super_Find_Token
|
308 |
|
|
(Source : Super_String;
|
309 |
|
|
Set : Wide_Maps.Wide_Character_Set;
|
310 |
|
|
Test : Membership;
|
311 |
|
|
First : out Positive;
|
312 |
|
|
Last : out Natural);
|
313 |
|
|
|
314 |
|
|
------------------------------------
|
315 |
|
|
-- String Translation Subprograms --
|
316 |
|
|
------------------------------------
|
317 |
|
|
|
318 |
|
|
function Super_Translate
|
319 |
|
|
(Source : Super_String;
|
320 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping) return Super_String;
|
321 |
|
|
|
322 |
|
|
procedure Super_Translate
|
323 |
|
|
(Source : in out Super_String;
|
324 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping);
|
325 |
|
|
|
326 |
|
|
function Super_Translate
|
327 |
|
|
(Source : Super_String;
|
328 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Super_String;
|
329 |
|
|
|
330 |
|
|
procedure Super_Translate
|
331 |
|
|
(Source : in out Super_String;
|
332 |
|
|
Mapping : Wide_Maps.Wide_Character_Mapping_Function);
|
333 |
|
|
|
334 |
|
|
---------------------------------------
|
335 |
|
|
-- String Transformation Subprograms --
|
336 |
|
|
---------------------------------------
|
337 |
|
|
|
338 |
|
|
function Super_Replace_Slice
|
339 |
|
|
(Source : Super_String;
|
340 |
|
|
Low : Positive;
|
341 |
|
|
High : Natural;
|
342 |
|
|
By : Wide_String;
|
343 |
|
|
Drop : Truncation := Error) return Super_String;
|
344 |
|
|
|
345 |
|
|
procedure Super_Replace_Slice
|
346 |
|
|
(Source : in out Super_String;
|
347 |
|
|
Low : Positive;
|
348 |
|
|
High : Natural;
|
349 |
|
|
By : Wide_String;
|
350 |
|
|
Drop : Truncation := Error);
|
351 |
|
|
|
352 |
|
|
function Super_Insert
|
353 |
|
|
(Source : Super_String;
|
354 |
|
|
Before : Positive;
|
355 |
|
|
New_Item : Wide_String;
|
356 |
|
|
Drop : Truncation := Error) return Super_String;
|
357 |
|
|
|
358 |
|
|
procedure Super_Insert
|
359 |
|
|
(Source : in out Super_String;
|
360 |
|
|
Before : Positive;
|
361 |
|
|
New_Item : Wide_String;
|
362 |
|
|
Drop : Truncation := Error);
|
363 |
|
|
|
364 |
|
|
function Super_Overwrite
|
365 |
|
|
(Source : Super_String;
|
366 |
|
|
Position : Positive;
|
367 |
|
|
New_Item : Wide_String;
|
368 |
|
|
Drop : Truncation := Error) return Super_String;
|
369 |
|
|
|
370 |
|
|
procedure Super_Overwrite
|
371 |
|
|
(Source : in out Super_String;
|
372 |
|
|
Position : Positive;
|
373 |
|
|
New_Item : Wide_String;
|
374 |
|
|
Drop : Truncation := Error);
|
375 |
|
|
|
376 |
|
|
function Super_Delete
|
377 |
|
|
(Source : Super_String;
|
378 |
|
|
From : Positive;
|
379 |
|
|
Through : Natural) return Super_String;
|
380 |
|
|
|
381 |
|
|
procedure Super_Delete
|
382 |
|
|
(Source : in out Super_String;
|
383 |
|
|
From : Positive;
|
384 |
|
|
Through : Natural);
|
385 |
|
|
|
386 |
|
|
---------------------------------
|
387 |
|
|
-- String Selector Subprograms --
|
388 |
|
|
---------------------------------
|
389 |
|
|
|
390 |
|
|
function Super_Trim
|
391 |
|
|
(Source : Super_String;
|
392 |
|
|
Side : Trim_End) return Super_String;
|
393 |
|
|
|
394 |
|
|
procedure Super_Trim
|
395 |
|
|
(Source : in out Super_String;
|
396 |
|
|
Side : Trim_End);
|
397 |
|
|
|
398 |
|
|
function Super_Trim
|
399 |
|
|
(Source : Super_String;
|
400 |
|
|
Left : Wide_Maps.Wide_Character_Set;
|
401 |
|
|
Right : Wide_Maps.Wide_Character_Set) return Super_String;
|
402 |
|
|
|
403 |
|
|
procedure Super_Trim
|
404 |
|
|
(Source : in out Super_String;
|
405 |
|
|
Left : Wide_Maps.Wide_Character_Set;
|
406 |
|
|
Right : Wide_Maps.Wide_Character_Set);
|
407 |
|
|
|
408 |
|
|
function Super_Head
|
409 |
|
|
(Source : Super_String;
|
410 |
|
|
Count : Natural;
|
411 |
|
|
Pad : Wide_Character := Wide_Space;
|
412 |
|
|
Drop : Truncation := Error) return Super_String;
|
413 |
|
|
|
414 |
|
|
procedure Super_Head
|
415 |
|
|
(Source : in out Super_String;
|
416 |
|
|
Count : Natural;
|
417 |
|
|
Pad : Wide_Character := Wide_Space;
|
418 |
|
|
Drop : Truncation := Error);
|
419 |
|
|
|
420 |
|
|
function Super_Tail
|
421 |
|
|
(Source : Super_String;
|
422 |
|
|
Count : Natural;
|
423 |
|
|
Pad : Wide_Character := Wide_Space;
|
424 |
|
|
Drop : Truncation := Error) return Super_String;
|
425 |
|
|
|
426 |
|
|
procedure Super_Tail
|
427 |
|
|
(Source : in out Super_String;
|
428 |
|
|
Count : Natural;
|
429 |
|
|
Pad : Wide_Character := Wide_Space;
|
430 |
|
|
Drop : Truncation := Error);
|
431 |
|
|
|
432 |
|
|
------------------------------------
|
433 |
|
|
-- String Constructor Subprograms --
|
434 |
|
|
------------------------------------
|
435 |
|
|
|
436 |
|
|
-- Note: in some of the following routines, there is an extra parameter
|
437 |
|
|
-- Max_Length which specifies the value of the maximum length for the
|
438 |
|
|
-- resulting Super_String value.
|
439 |
|
|
|
440 |
|
|
function Times
|
441 |
|
|
(Left : Natural;
|
442 |
|
|
Right : Wide_Character;
|
443 |
|
|
Max_Length : Positive) return Super_String;
|
444 |
|
|
-- Note the additional parameter Max_Length
|
445 |
|
|
|
446 |
|
|
function Times
|
447 |
|
|
(Left : Natural;
|
448 |
|
|
Right : Wide_String;
|
449 |
|
|
Max_Length : Positive) return Super_String;
|
450 |
|
|
-- Note the additional parameter Max_Length
|
451 |
|
|
|
452 |
|
|
function Times
|
453 |
|
|
(Left : Natural;
|
454 |
|
|
Right : Super_String) return Super_String;
|
455 |
|
|
|
456 |
|
|
function Super_Replicate
|
457 |
|
|
(Count : Natural;
|
458 |
|
|
Item : Wide_Character;
|
459 |
|
|
Drop : Truncation := Error;
|
460 |
|
|
Max_Length : Positive) return Super_String;
|
461 |
|
|
-- Note the additional parameter Max_Length
|
462 |
|
|
|
463 |
|
|
function Super_Replicate
|
464 |
|
|
(Count : Natural;
|
465 |
|
|
Item : Wide_String;
|
466 |
|
|
Drop : Truncation := Error;
|
467 |
|
|
Max_Length : Positive) return Super_String;
|
468 |
|
|
-- Note the additional parameter Max_Length
|
469 |
|
|
|
470 |
|
|
function Super_Replicate
|
471 |
|
|
(Count : Natural;
|
472 |
|
|
Item : Super_String;
|
473 |
|
|
Drop : Truncation := Error) return Super_String;
|
474 |
|
|
|
475 |
|
|
private
|
476 |
|
|
-- Pragma Inline declarations
|
477 |
|
|
|
478 |
|
|
pragma Inline ("=");
|
479 |
|
|
pragma Inline (Less);
|
480 |
|
|
pragma Inline (Less_Or_Equal);
|
481 |
|
|
pragma Inline (Greater);
|
482 |
|
|
pragma Inline (Greater_Or_Equal);
|
483 |
|
|
pragma Inline (Concat);
|
484 |
|
|
pragma Inline (Super_Count);
|
485 |
|
|
pragma Inline (Super_Element);
|
486 |
|
|
pragma Inline (Super_Find_Token);
|
487 |
|
|
pragma Inline (Super_Index);
|
488 |
|
|
pragma Inline (Super_Index_Non_Blank);
|
489 |
|
|
pragma Inline (Super_Length);
|
490 |
|
|
pragma Inline (Super_Replace_Element);
|
491 |
|
|
pragma Inline (Super_Slice);
|
492 |
|
|
pragma Inline (Super_To_String);
|
493 |
|
|
|
494 |
|
|
end Ada.Strings.Wide_Superbounded;
|