summaryrefslogtreecommitdiff
path: root/gcc/ada/a-stzsup.ads
blob: e5b6989b64cb0be804a586cba116505dc97e6265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT RUN-TIME COMPONENTS                         --
--                                                                          --
--  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    --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
--          Copyright (C) 2003-2005 Free Software Foundation, Inc.          --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
------------------------------------------------------------------------------

--  This non generic package contains most of the implementation of the
--  generic package Ada.Strings.Wide_Wide_Bounded.Generic_Bounded_Length.

--  It defines type Super_String as a discriminated record with the maximum
--  length as the discriminant. Individual instantiations of the package
--  Strings.Wide_Wide_Bounded.Generic_Bounded_Length use this type with
--  an appropriate discriminant value set.

with Ada.Strings.Wide_Wide_Maps;

package Ada.Strings.Wide_Wide_Superbounded is
pragma Preelaborate (Wide_Wide_Superbounded);

   Wide_Wide_NUL : constant Wide_Wide_Character :=
                     Wide_Wide_Character'Val (0);

   type Super_String (Max_Length : Positive) is record
      Current_Length : Natural := 0;
      Data           : Wide_Wide_String (1 .. Max_Length) :=
                         (others => Wide_Wide_NUL);
   end record;
   --  Wide_Wide_Bounded.Generic_Bounded_Length.Wide_Wide_Bounded_String is
   --  derived from this type, with the constraint of the maximum length.

   --  The subprograms defined for Super_String are similar to those defined
   --  for Bounded_Wide_Wide_String, except that they have different names, so
   --  that they can be renamed in Wide_Wide_Bounded.Generic_Bounded_Length.

   function Super_Length (Source : Super_String) return Natural;

   --------------------------------------------------------
   -- Conversion, Concatenation, and Selection Functions --
   --------------------------------------------------------

   function To_Super_String
     (Source     : Wide_Wide_String;
      Max_Length : Natural;
      Drop       : Truncation := Error) return Super_String;
   --  Note the additional parameter Max_Length, which specifies the maximum
   --  length setting of the resulting Super_String value.

   --  The following procedures have declarations (and semantics) that are
   --  exactly analogous to those declared in Ada.Strings.Wide_Wide_Bounded.

   function Super_To_String (Source : Super_String) return Wide_Wide_String;

   procedure Set_Super_String
     (Target : out Super_String;
      Source : Wide_Wide_String;
      Drop   : Truncation := Error);

   function Super_Append
     (Left  : Super_String;
      Right : Super_String;
      Drop  : Truncation := Error) return Super_String;

   function Super_Append
     (Left  : Super_String;
      Right : Wide_Wide_String;
      Drop  : Truncation := Error) return Super_String;

   function Super_Append
     (Left  : Wide_Wide_String;
      Right : Super_String;
      Drop  : Truncation := Error) return Super_String;

   function Super_Append
     (Left  : Super_String;
      Right : Wide_Wide_Character;
      Drop  : Truncation := Error) return Super_String;

   function Super_Append
     (Left  : Wide_Wide_Character;
      Right : Super_String;
      Drop  : Truncation := Error) return Super_String;

   procedure Super_Append
     (Source   : in out Super_String;
      New_Item : Super_String;
      Drop     : Truncation := Error);

   procedure Super_Append
     (Source   : in out Super_String;
      New_Item : Wide_Wide_String;
      Drop     : Truncation := Error);

   procedure Super_Append
     (Source   : in out Super_String;
      New_Item : Wide_Wide_Character;
      Drop     : Truncation := Error);

   function Concat
     (Left  : Super_String;
      Right : Super_String) return Super_String;

   function Concat
     (Left  : Super_String;
      Right : Wide_Wide_String) return Super_String;

   function Concat
     (Left  : Wide_Wide_String;
      Right : Super_String) return Super_String;

   function Concat
     (Left  : Super_String;
      Right : Wide_Wide_Character) return Super_String;

   function Concat
     (Left  : Wide_Wide_Character;
      Right : Super_String) return Super_String;

   function Super_Element
     (Source : Super_String;
      Index  : Positive) return Wide_Wide_Character;

   procedure Super_Replace_Element
     (Source : in out Super_String;
      Index  : Positive;
      By     : Wide_Wide_Character);

   function Super_Slice
     (Source : Super_String;
      Low    : Positive;
      High   : Natural) return Wide_Wide_String;

   function Super_Slice
     (Source : Super_String;
      Low    : Positive;
      High   : Natural) return Super_String;

   procedure Super_Slice
     (Source : Super_String;
      Target : out Super_String;
      Low    : Positive;
      High   : Natural);

   function "="
     (Left  : Super_String;
      Right : Super_String) return Boolean;

   function Equal
     (Left  : Super_String;
      Right : Super_String) return Boolean renames "=";

   function Equal
     (Left  : Super_String;
      Right : Wide_Wide_String) return Boolean;

   function Equal
     (Left  : Wide_Wide_String;
      Right : Super_String) return Boolean;

   function Less
     (Left  : Super_String;
      Right : Super_String) return Boolean;

   function Less
     (Left  : Super_String;
      Right : Wide_Wide_String) return Boolean;

   function Less
     (Left  : Wide_Wide_String;
      Right : Super_String) return Boolean;

   function Less_Or_Equal
     (Left  : Super_String;
      Right : Super_String) return Boolean;

   function Less_Or_Equal
     (Left  : Super_String;
      Right : Wide_Wide_String) return Boolean;

   function Less_Or_Equal
     (Left  : Wide_Wide_String;
      Right : Super_String) return Boolean;

   function Greater
     (Left  : Super_String;
      Right : Super_String) return Boolean;

   function Greater
     (Left  : Super_String;
      Right : Wide_Wide_String) return Boolean;

   function Greater
     (Left  : Wide_Wide_String;
      Right : Super_String) return Boolean;

   function Greater_Or_Equal
     (Left  : Super_String;
      Right : Super_String) return Boolean;

   function Greater_Or_Equal
     (Left  : Super_String;
      Right : Wide_Wide_String) return Boolean;

   function Greater_Or_Equal
     (Left  : Wide_Wide_String;
      Right : Super_String) return Boolean;

   ----------------------
   -- Search Functions --
   ----------------------

   function Super_Index
     (Source  : Super_String;
      Pattern : Wide_Wide_String;
      Going   : Direction := Forward;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
                  Wide_Wide_Maps.Identity)
      return Natural;

   function Super_Index
     (Source  : Super_String;
      Pattern : Wide_Wide_String;
      Going   : Direction := Forward;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
      return Natural;

   function Super_Index
     (Source : Super_String;
      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
      Test   : Membership := Inside;
      Going  : Direction  := Forward) return Natural;

   function Super_Index
     (Source  : Super_String;
      Pattern : Wide_Wide_String;
      From    : Positive;
      Going   : Direction := Forward;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
                  Wide_Wide_Maps.Identity)
      return Natural;

   function Super_Index
     (Source  : Super_String;
      Pattern : Wide_Wide_String;
      From    : Positive;
      Going   : Direction := Forward;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
      return Natural;

   function Super_Index
     (Source : Super_String;
      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
      From   : Positive;
      Test   : Membership := Inside;
      Going  : Direction := Forward) return Natural;

   function Super_Index_Non_Blank
     (Source : Super_String;
      Going  : Direction := Forward) return Natural;

   function Super_Index_Non_Blank
     (Source : Super_String;
      From   : Positive;
      Going  : Direction := Forward) return Natural;

   function Super_Count
     (Source  : Super_String;
      Pattern : Wide_Wide_String;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
                  Wide_Wide_Maps.Identity)
      return Natural;

   function Super_Count
     (Source  : Super_String;
      Pattern : Wide_Wide_String;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
      return Natural;

   function Super_Count
     (Source : Super_String;
      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;

   procedure Super_Find_Token
     (Source : Super_String;
      Set    : Wide_Wide_Maps.Wide_Wide_Character_Set;
      Test   : Membership;
      First  : out Positive;
      Last   : out Natural);

   ------------------------------------
   -- String Translation Subprograms --
   ------------------------------------

   function Super_Translate
     (Source  : Super_String;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
      return Super_String;

   procedure Super_Translate
     (Source   : in out Super_String;
      Mapping  : Wide_Wide_Maps.Wide_Wide_Character_Mapping);

   function Super_Translate
     (Source  : Super_String;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
      return Super_String;

   procedure Super_Translate
     (Source  : in out Super_String;
      Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);

   ---------------------------------------
   -- String Transformation Subprograms --
   ---------------------------------------

   function Super_Replace_Slice
     (Source : Super_String;
      Low    : Positive;
      High   : Natural;
      By     : Wide_Wide_String;
      Drop   : Truncation := Error) return Super_String;

   procedure Super_Replace_Slice
     (Source  : in out Super_String;
      Low     : Positive;
      High    : Natural;
      By      : Wide_Wide_String;
      Drop    : Truncation := Error);

   function Super_Insert
     (Source   : Super_String;
      Before   : Positive;
      New_Item : Wide_Wide_String;
      Drop     : Truncation := Error) return Super_String;

   procedure Super_Insert
     (Source   : in out Super_String;
      Before   : Positive;
      New_Item : Wide_Wide_String;
      Drop     : Truncation := Error);

   function Super_Overwrite
     (Source   : Super_String;
      Position : Positive;
      New_Item : Wide_Wide_String;
      Drop     : Truncation := Error) return Super_String;

   procedure Super_Overwrite
     (Source    : in out Super_String;
      Position  : Positive;
      New_Item  : Wide_Wide_String;
      Drop      : Truncation := Error);

   function Super_Delete
     (Source  : Super_String;
      From    : Positive;
      Through : Natural) return Super_String;

   procedure Super_Delete
     (Source  : in out Super_String;
      From    : Positive;
      Through : Natural);

   ---------------------------------
   -- String Selector Subprograms --
   ---------------------------------

   function Super_Trim
     (Source : Super_String;
      Side   : Trim_End) return Super_String;

   procedure Super_Trim
     (Source : in out Super_String;
      Side   : Trim_End);

   function Super_Trim
     (Source : Super_String;
      Left   : Wide_Wide_Maps.Wide_Wide_Character_Set;
      Right  : Wide_Wide_Maps.Wide_Wide_Character_Set) return Super_String;

   procedure Super_Trim
     (Source : in out Super_String;
      Left   : Wide_Wide_Maps.Wide_Wide_Character_Set;
      Right  : Wide_Wide_Maps.Wide_Wide_Character_Set);

   function Super_Head
     (Source : Super_String;
      Count  : Natural;
      Pad    : Wide_Wide_Character := Wide_Wide_Space;
      Drop   : Truncation := Error) return Super_String;

   procedure Super_Head
     (Source : in out Super_String;
      Count  : Natural;
      Pad    : Wide_Wide_Character := Wide_Wide_Space;
      Drop   : Truncation := Error);

   function Super_Tail
     (Source : Super_String;
      Count  : Natural;
      Pad    : Wide_Wide_Character := Wide_Wide_Space;
      Drop   : Truncation := Error) return Super_String;

   procedure Super_Tail
     (Source : in out Super_String;
      Count  : Natural;
      Pad    : Wide_Wide_Character := Wide_Wide_Space;
      Drop   : Truncation := Error);

   ------------------------------------
   -- String Constructor Subprograms --
   ------------------------------------

   --  Note: in some of the following routines, there is an extra parameter
   --  Max_Length which specifies the value of the maximum length for the
   --  resulting Super_String value.

   function Times
     (Left       : Natural;
      Right      : Wide_Wide_Character;
      Max_Length : Positive) return Super_String;
   --  Note the additional parameter Max_Length

   function Times
     (Left       : Natural;
      Right      : Wide_Wide_String;
      Max_Length : Positive) return Super_String;
   --  Note the additional parameter Max_Length

   function Times
     (Left  : Natural;
      Right : Super_String) return Super_String;

   function Super_Replicate
     (Count      : Natural;
      Item       : Wide_Wide_Character;
      Drop       : Truncation := Error;
      Max_Length : Positive) return Super_String;
   --  Note the additional parameter Max_Length

   function Super_Replicate
     (Count      : Natural;
      Item       : Wide_Wide_String;
      Drop       : Truncation := Error;
      Max_Length : Positive) return Super_String;
   --  Note the additional parameter Max_Length

   function Super_Replicate
     (Count : Natural;
      Item  : Super_String;
      Drop  : Truncation := Error) return Super_String;

private
      --  Pragma Inline declarations

      pragma Inline ("=");
      pragma Inline (Less);
      pragma Inline (Less_Or_Equal);
      pragma Inline (Greater);
      pragma Inline (Greater_Or_Equal);
      pragma Inline (Concat);
      pragma Inline (Super_Count);
      pragma Inline (Super_Element);
      pragma Inline (Super_Find_Token);
      pragma Inline (Super_Index);
      pragma Inline (Super_Index_Non_Blank);
      pragma Inline (Super_Length);
      pragma Inline (Super_Replace_Element);
      pragma Inline (Super_Slice);
      pragma Inline (Super_To_String);

end Ada.Strings.Wide_Wide_Superbounded;