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