OSDN Git Service

* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads,
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-stwibo.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUN-TIME COMPONENTS                         --
4 --                                                                          --
5 --             A D A . S T R I N G S . W I D E _ B O U N D E D              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.8 $                              --
10 --                                                                          --
11 --          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- This specification is derived from the Ada Reference Manual for use with --
14 -- GNAT. The copyright notice above, and the license provisions that follow --
15 -- apply solely to the  contents of the part following the private keyword. --
16 --                                                                          --
17 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
18 -- terms of the  GNU General Public License as published  by the Free Soft- --
19 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
20 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
21 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
22 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
23 -- for  more details.  You should have  received  a copy of the GNU General --
24 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
25 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
26 -- MA 02111-1307, USA.                                                      --
27 --                                                                          --
28 -- As a special exception,  if other files  instantiate  generics from this --
29 -- unit, or you link  this unit with other files  to produce an executable, --
30 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
31 -- covered  by the  GNU  General  Public  License.  This exception does not --
32 -- however invalidate  any other reasons why  the executable file  might be --
33 -- covered by the  GNU Public License.                                      --
34 --                                                                          --
35 -- GNAT was originally developed  by the GNAT team at  New York University. --
36 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
37 --                                                                          --
38 ------------------------------------------------------------------------------
39
40 with Ada.Strings.Wide_Maps;
41
42 package Ada.Strings.Wide_Bounded is
43 pragma Preelaborate (Wide_Bounded);
44
45    generic
46       Max : Positive;
47       --  Maximum length of a Bounded_Wide_String
48
49    package Generic_Bounded_Length is
50
51       Max_Length : constant Positive := Max;
52
53       type Bounded_Wide_String is private;
54
55       Null_Bounded_Wide_String : constant Bounded_Wide_String;
56
57       subtype Length_Range is Natural range 0 .. Max_Length;
58
59       function Length (Source : in Bounded_Wide_String) return Length_Range;
60
61       --------------------------------------------------------
62       -- Conversion, Concatenation, and Selection Functions --
63       --------------------------------------------------------
64
65       function To_Bounded_Wide_String
66         (Source : in Wide_String;
67          Drop   : in Truncation := Error)
68          return   Bounded_Wide_String;
69
70       function To_Wide_String
71         (Source : in Bounded_Wide_String)
72          return   Wide_String;
73
74       function Append
75         (Left, Right : in Bounded_Wide_String;
76          Drop        : in Truncation  := Error)
77          return        Bounded_Wide_String;
78
79       function Append
80         (Left  : in Bounded_Wide_String;
81          Right : in Wide_String;
82          Drop  : in Truncation := Error)
83          return  Bounded_Wide_String;
84
85       function Append
86         (Left  : in Wide_String;
87          Right : in Bounded_Wide_String;
88          Drop  : in Truncation := Error)
89          return  Bounded_Wide_String;
90
91       function Append
92         (Left  : in Bounded_Wide_String;
93          Right : in Wide_Character;
94          Drop  : in Truncation := Error)
95          return  Bounded_Wide_String;
96
97       function Append
98         (Left  : in Wide_Character;
99          Right : in Bounded_Wide_String;
100          Drop  : in Truncation := Error)
101          return  Bounded_Wide_String;
102
103       procedure Append
104         (Source   : in out Bounded_Wide_String;
105          New_Item : in Bounded_Wide_String;
106          Drop     : in Truncation  := Error);
107
108       procedure Append
109         (Source   : in out Bounded_Wide_String;
110          New_Item : in Wide_String;
111          Drop     : in Truncation  := Error);
112
113       procedure Append
114         (Source   : in out Bounded_Wide_String;
115          New_Item : in Wide_Character;
116          Drop     : in Truncation  := Error);
117
118       function "&"
119         (Left, Right : in Bounded_Wide_String)
120          return        Bounded_Wide_String;
121
122       function "&"
123         (Left  : in Bounded_Wide_String;
124          Right : in Wide_String)
125          return  Bounded_Wide_String;
126
127       function "&"
128         (Left  : in Wide_String;
129          Right : in Bounded_Wide_String)
130          return  Bounded_Wide_String;
131
132       function "&"
133         (Left  : in Bounded_Wide_String;
134          Right : in Wide_Character)
135          return  Bounded_Wide_String;
136
137       function "&"
138         (Left  : in Wide_Character;
139          Right : in Bounded_Wide_String)
140          return  Bounded_Wide_String;
141
142       function Element
143         (Source : in Bounded_Wide_String;
144          Index  : in Positive)
145          return   Wide_Character;
146
147       procedure Replace_Element
148         (Source : in out Bounded_Wide_String;
149          Index  : in Positive;
150          By     : in Wide_Character);
151
152       function Slice
153         (Source : in Bounded_Wide_String;
154          Low    : in Positive;
155          High   : in Natural)
156          return   Wide_String;
157
158       function "="
159         (Left  : in Bounded_Wide_String;
160          Right : in Bounded_Wide_String)
161          return  Boolean;
162
163       function "="
164         (Left  : in Bounded_Wide_String;
165          Right : in Wide_String)
166          return  Boolean;
167
168       function "="
169         (Left  : in Wide_String;
170          Right : in Bounded_Wide_String)
171          return  Boolean;
172
173       function "<"
174         (Left  : in Bounded_Wide_String;
175          Right : in Bounded_Wide_String)
176          return  Boolean;
177
178       function "<"
179         (Left  : in Bounded_Wide_String;
180          Right : in Wide_String)
181          return  Boolean;
182
183       function "<"
184         (Left  : in Wide_String;
185          Right : in Bounded_Wide_String)
186          return  Boolean;
187
188       function "<="
189         (Left  : in Bounded_Wide_String;
190          Right : in Bounded_Wide_String)
191          return  Boolean;
192
193       function "<="
194         (Left  : in Bounded_Wide_String;
195          Right : in Wide_String)
196          return  Boolean;
197
198       function "<="
199         (Left  : in Wide_String;
200          Right : in Bounded_Wide_String)
201          return  Boolean;
202
203       function ">"
204         (Left  : in Bounded_Wide_String;
205          Right : in Bounded_Wide_String)
206          return  Boolean;
207
208       function ">"
209         (Left  : in Bounded_Wide_String;
210          Right : in Wide_String)
211          return  Boolean;
212
213       function ">"
214         (Left  : in Wide_String;
215          Right : in Bounded_Wide_String)
216          return  Boolean;
217
218       function ">="
219         (Left  : in Bounded_Wide_String;
220          Right : in Bounded_Wide_String)
221          return  Boolean;
222
223       function ">="
224         (Left  : in Bounded_Wide_String;
225          Right : in Wide_String)
226          return  Boolean;
227
228       function ">="
229         (Left  : in Wide_String;
230          Right : in Bounded_Wide_String)
231          return  Boolean;
232
233       ----------------------
234       -- Search Functions --
235       ----------------------
236
237       function Index
238         (Source  : in Bounded_Wide_String;
239          Pattern : in Wide_String;
240          Going   : in Direction := Forward;
241          Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
242          return    Natural;
243
244       function Index
245         (Source  : in Bounded_Wide_String;
246          Pattern : in Wide_String;
247          Going   : in Direction := Forward;
248          Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
249          return    Natural;
250
251       function Index
252         (Source : in Bounded_Wide_String;
253          Set    : in Wide_Maps.Wide_Character_Set;
254          Test   : in Membership := Inside;
255          Going  : in Direction  := Forward)
256          return   Natural;
257
258       function Index_Non_Blank
259         (Source : in Bounded_Wide_String;
260          Going  : in Direction := Forward)
261          return   Natural;
262
263       function Count
264         (Source  : in Bounded_Wide_String;
265          Pattern : in Wide_String;
266          Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity)
267          return    Natural;
268
269       function Count
270         (Source  : in Bounded_Wide_String;
271          Pattern : in Wide_String;
272          Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
273          return    Natural;
274
275       function Count
276         (Source : in Bounded_Wide_String;
277          Set    : in Wide_Maps.Wide_Character_Set)
278          return   Natural;
279
280       procedure Find_Token
281         (Source : in Bounded_Wide_String;
282          Set    : in Wide_Maps.Wide_Character_Set;
283          Test   : in Membership;
284          First  : out Positive;
285          Last   : out Natural);
286
287       ------------------------------------
288       -- Wide_String Translation Subprograms --
289       ------------------------------------
290
291       function Translate
292         (Source   : in Bounded_Wide_String;
293          Mapping  : in Wide_Maps.Wide_Character_Mapping)
294          return     Bounded_Wide_String;
295
296       procedure Translate
297         (Source   : in out Bounded_Wide_String;
298          Mapping  : in Wide_Maps.Wide_Character_Mapping);
299
300       function Translate
301         (Source  : in Bounded_Wide_String;
302          Mapping : in Wide_Maps.Wide_Character_Mapping_Function)
303          return    Bounded_Wide_String;
304
305       procedure Translate
306         (Source  : in out Bounded_Wide_String;
307          Mapping : in Wide_Maps.Wide_Character_Mapping_Function);
308
309       ---------------------------------------
310       -- Wide_String Transformation Subprograms --
311       ---------------------------------------
312
313       function Replace_Slice
314         (Source   : in Bounded_Wide_String;
315          Low      : in Positive;
316          High     : in Natural;
317          By       : in Wide_String;
318          Drop     : in Truncation := Error)
319          return     Bounded_Wide_String;
320
321       procedure Replace_Slice
322         (Source   : in out Bounded_Wide_String;
323          Low      : in Positive;
324          High     : in Natural;
325          By       : in Wide_String;
326          Drop     : in Truncation := Error);
327
328       function Insert
329         (Source   : in Bounded_Wide_String;
330          Before   : in Positive;
331          New_Item : in Wide_String;
332          Drop     : in Truncation := Error)
333          return     Bounded_Wide_String;
334
335       procedure Insert
336         (Source   : in out Bounded_Wide_String;
337          Before   : in Positive;
338          New_Item : in Wide_String;
339          Drop     : in Truncation := Error);
340
341       function Overwrite
342         (Source    : in Bounded_Wide_String;
343          Position  : in Positive;
344          New_Item  : in Wide_String;
345          Drop      : in Truncation := Error)
346          return      Bounded_Wide_String;
347
348       procedure Overwrite
349         (Source    : in out Bounded_Wide_String;
350          Position  : in Positive;
351          New_Item  : in Wide_String;
352          Drop      : in Truncation := Error);
353
354       function Delete
355         (Source  : in Bounded_Wide_String;
356          From    : in Positive;
357          Through : in Natural)
358          return    Bounded_Wide_String;
359
360       procedure Delete
361         (Source  : in out Bounded_Wide_String;
362          From    : in Positive;
363          Through : in Natural);
364
365       ---------------------------------
366       -- Wide_String Selector Subprograms --
367       ---------------------------------
368
369       function Trim
370         (Source : in Bounded_Wide_String;
371          Side   : in Trim_End)
372          return   Bounded_Wide_String;
373
374       procedure Trim
375         (Source : in out Bounded_Wide_String;
376          Side   : in Trim_End);
377
378       function Trim
379         (Source  : in Bounded_Wide_String;
380           Left   : in Wide_Maps.Wide_Character_Set;
381           Right  : in Wide_Maps.Wide_Character_Set)
382           return   Bounded_Wide_String;
383
384       procedure Trim
385         (Source : in out Bounded_Wide_String;
386          Left   : in Wide_Maps.Wide_Character_Set;
387          Right  : in Wide_Maps.Wide_Character_Set);
388
389       function Head
390         (Source : in Bounded_Wide_String;
391          Count  : in Natural;
392          Pad    : in Wide_Character := Wide_Space;
393          Drop   : in Truncation := Error)
394          return   Bounded_Wide_String;
395
396       procedure Head
397         (Source : in out Bounded_Wide_String;
398          Count  : in Natural;
399          Pad    : in Wide_Character  := Wide_Space;
400          Drop   : in Truncation := Error);
401
402       function Tail
403         (Source : in Bounded_Wide_String;
404          Count  : in Natural;
405          Pad    : in Wide_Character  := Wide_Space;
406          Drop   : in Truncation := Error)
407          return Bounded_Wide_String;
408
409       procedure Tail
410         (Source : in out Bounded_Wide_String;
411          Count  : in Natural;
412          Pad    : in Wide_Character  := Wide_Space;
413          Drop   : in Truncation := Error);
414
415       ------------------------------------
416       -- Wide_String Constructor Subprograms --
417       ------------------------------------
418
419       function "*"
420         (Left  : in Natural;
421          Right : in Wide_Character)
422          return  Bounded_Wide_String;
423
424       function "*"
425         (Left  : in Natural;
426          Right : in Wide_String)
427          return  Bounded_Wide_String;
428
429       function "*"
430         (Left  : in Natural;
431          Right : in Bounded_Wide_String)
432          return  Bounded_Wide_String;
433
434       function Replicate
435         (Count : in Natural;
436          Item  : in Wide_Character;
437          Drop  : in Truncation := Error)
438          return  Bounded_Wide_String;
439
440       function Replicate
441         (Count : in Natural;
442          Item  : in Wide_String;
443          Drop  : in Truncation := Error)
444          return  Bounded_Wide_String;
445
446       function Replicate
447         (Count : in Natural;
448          Item  : in Bounded_Wide_String;
449          Drop  : in Truncation := Error)
450          return  Bounded_Wide_String;
451
452    private
453       Wide_NUL : constant Wide_Character := Wide_Character'Val (0);
454
455       type Bounded_Wide_String is record
456          Length : Length_Range := 0;
457          Data   : Wide_String (1 .. Max_Length);
458       end record;
459
460       Null_Bounded_Wide_String : constant Bounded_Wide_String :=
461                (Length => 0, Data => (1 .. Max_Length => Wide_NUL));
462
463       --  Pragma Inline declarations (GNAT specific additions)
464
465       pragma Inline ("=");
466       pragma Inline ("<");
467       pragma Inline ("<=");
468       pragma Inline (">");
469       pragma Inline (">=");
470       pragma Inline ("&");
471       pragma Inline (Count);
472       pragma Inline (Element);
473       pragma Inline (Find_Token);
474       pragma Inline (Index);
475       pragma Inline (Index_Non_Blank);
476       pragma Inline (Length);
477       pragma Inline (Replace_Element);
478       pragma Inline (Slice);
479       pragma Inline (To_Bounded_Wide_String);
480       pragma Inline (To_Wide_String);
481
482    end Generic_Bounded_Length;
483
484 end Ada.Strings.Wide_Bounded;