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