OSDN Git Service

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