comparison gcc/ada/libgnat/a-stzunb.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
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 _ U N B O U N D E D --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
10 -- --
11 -- This specification is derived from the Ada Reference Manual for use with --
12 -- GNAT. The copyright notice above, and the license provisions that follow --
13 -- apply solely to the contents of the part following the private keyword. --
14 -- --
15 -- GNAT is free software; you can redistribute it and/or modify it under --
16 -- terms of the GNU General Public License as published by the Free Soft- --
17 -- ware Foundation; either version 3, or (at your option) any later ver- --
18 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
19 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20 -- or FITNESS FOR A PARTICULAR PURPOSE. --
21 -- --
22 -- As a special exception under Section 7 of GPL version 3, you are granted --
23 -- additional permissions described in the GCC Runtime Library Exception, --
24 -- version 3.1, as published by the Free Software Foundation. --
25 -- --
26 -- You should have received a copy of the GNU General Public License and --
27 -- a copy of the GCC Runtime Library Exception along with this program; --
28 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
29 -- <http://www.gnu.org/licenses/>. --
30 -- --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 -- --
34 ------------------------------------------------------------------------------
35
36 with Ada.Strings.Wide_Wide_Maps;
37 with Ada.Finalization;
38
39 package Ada.Strings.Wide_Wide_Unbounded is
40 pragma Preelaborate;
41
42 type Unbounded_Wide_Wide_String is private;
43 pragma Preelaborable_Initialization (Unbounded_Wide_Wide_String);
44
45 Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String;
46
47 function Length (Source : Unbounded_Wide_Wide_String) return Natural;
48
49 type Wide_Wide_String_Access is access all Wide_Wide_String;
50
51 procedure Free (X : in out Wide_Wide_String_Access);
52
53 --------------------------------------------------------
54 -- Conversion, Concatenation, and Selection Functions --
55 --------------------------------------------------------
56
57 function To_Unbounded_Wide_Wide_String
58 (Source : Wide_Wide_String) return Unbounded_Wide_Wide_String;
59
60 function To_Unbounded_Wide_Wide_String
61 (Length : Natural) return Unbounded_Wide_Wide_String;
62
63 function To_Wide_Wide_String
64 (Source : Unbounded_Wide_Wide_String) return Wide_Wide_String;
65
66 procedure Set_Unbounded_Wide_Wide_String
67 (Target : out Unbounded_Wide_Wide_String;
68 Source : Wide_Wide_String);
69 pragma Ada_05 (Set_Unbounded_Wide_Wide_String);
70
71 procedure Append
72 (Source : in out Unbounded_Wide_Wide_String;
73 New_Item : Unbounded_Wide_Wide_String);
74
75 procedure Append
76 (Source : in out Unbounded_Wide_Wide_String;
77 New_Item : Wide_Wide_String);
78
79 procedure Append
80 (Source : in out Unbounded_Wide_Wide_String;
81 New_Item : Wide_Wide_Character);
82
83 function "&"
84 (Left : Unbounded_Wide_Wide_String;
85 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
86
87 function "&"
88 (Left : Unbounded_Wide_Wide_String;
89 Right : Wide_Wide_String) return Unbounded_Wide_Wide_String;
90
91 function "&"
92 (Left : Wide_Wide_String;
93 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
94
95 function "&"
96 (Left : Unbounded_Wide_Wide_String;
97 Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String;
98
99 function "&"
100 (Left : Wide_Wide_Character;
101 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
102
103 function Element
104 (Source : Unbounded_Wide_Wide_String;
105 Index : Positive) return Wide_Wide_Character;
106
107 procedure Replace_Element
108 (Source : in out Unbounded_Wide_Wide_String;
109 Index : Positive;
110 By : Wide_Wide_Character);
111
112 function Slice
113 (Source : Unbounded_Wide_Wide_String;
114 Low : Positive;
115 High : Natural) return Wide_Wide_String;
116
117 function Unbounded_Slice
118 (Source : Unbounded_Wide_Wide_String;
119 Low : Positive;
120 High : Natural) return Unbounded_Wide_Wide_String;
121 pragma Ada_05 (Unbounded_Slice);
122
123 procedure Unbounded_Slice
124 (Source : Unbounded_Wide_Wide_String;
125 Target : out Unbounded_Wide_Wide_String;
126 Low : Positive;
127 High : Natural);
128 pragma Ada_05 (Unbounded_Slice);
129
130 function "="
131 (Left : Unbounded_Wide_Wide_String;
132 Right : Unbounded_Wide_Wide_String) return Boolean;
133
134 function "="
135 (Left : Unbounded_Wide_Wide_String;
136 Right : Wide_Wide_String) return Boolean;
137
138 function "="
139 (Left : Wide_Wide_String;
140 Right : Unbounded_Wide_Wide_String) return Boolean;
141
142 function "<"
143 (Left : Unbounded_Wide_Wide_String;
144 Right : Unbounded_Wide_Wide_String) return Boolean;
145
146 function "<"
147 (Left : Unbounded_Wide_Wide_String;
148 Right : Wide_Wide_String) return Boolean;
149
150 function "<"
151 (Left : Wide_Wide_String;
152 Right : Unbounded_Wide_Wide_String) return Boolean;
153
154 function "<="
155 (Left : Unbounded_Wide_Wide_String;
156 Right : Unbounded_Wide_Wide_String) return Boolean;
157
158 function "<="
159 (Left : Unbounded_Wide_Wide_String;
160 Right : Wide_Wide_String) return Boolean;
161
162 function "<="
163 (Left : Wide_Wide_String;
164 Right : Unbounded_Wide_Wide_String) return Boolean;
165
166 function ">"
167 (Left : Unbounded_Wide_Wide_String;
168 Right : Unbounded_Wide_Wide_String) return Boolean;
169
170 function ">"
171 (Left : Unbounded_Wide_Wide_String;
172 Right : Wide_Wide_String) return Boolean;
173
174 function ">"
175 (Left : Wide_Wide_String;
176 Right : Unbounded_Wide_Wide_String) return Boolean;
177
178 function ">="
179 (Left : Unbounded_Wide_Wide_String;
180 Right : Unbounded_Wide_Wide_String) return Boolean;
181
182 function ">="
183 (Left : Unbounded_Wide_Wide_String;
184 Right : Wide_Wide_String) return Boolean;
185
186 function ">="
187 (Left : Wide_Wide_String;
188 Right : Unbounded_Wide_Wide_String) return Boolean;
189
190 ------------------------
191 -- Search Subprograms --
192 ------------------------
193
194 function Index
195 (Source : Unbounded_Wide_Wide_String;
196 Pattern : Wide_Wide_String;
197 Going : Direction := Forward;
198 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
199 Wide_Wide_Maps.Identity)
200 return Natural;
201
202 function Index
203 (Source : Unbounded_Wide_Wide_String;
204 Pattern : Wide_Wide_String;
205 Going : Direction := Forward;
206 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
207 return Natural;
208
209 function Index
210 (Source : Unbounded_Wide_Wide_String;
211 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
212 Test : Membership := Inside;
213 Going : Direction := Forward) return Natural;
214
215 function Index
216 (Source : Unbounded_Wide_Wide_String;
217 Pattern : Wide_Wide_String;
218 From : Positive;
219 Going : Direction := Forward;
220 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
221 Wide_Wide_Maps.Identity)
222 return Natural;
223 pragma Ada_05 (Index);
224
225 function Index
226 (Source : Unbounded_Wide_Wide_String;
227 Pattern : Wide_Wide_String;
228 From : Positive;
229 Going : Direction := Forward;
230 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
231 return Natural;
232 pragma Ada_05 (Index);
233
234 function Index
235 (Source : Unbounded_Wide_Wide_String;
236 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
237 From : Positive;
238 Test : Membership := Inside;
239 Going : Direction := Forward) return Natural;
240 pragma Ada_05 (Index);
241
242 function Index_Non_Blank
243 (Source : Unbounded_Wide_Wide_String;
244 Going : Direction := Forward) return Natural;
245
246 function Index_Non_Blank
247 (Source : Unbounded_Wide_Wide_String;
248 From : Positive;
249 Going : Direction := Forward) return Natural;
250 pragma Ada_05 (Index_Non_Blank);
251
252 function Count
253 (Source : Unbounded_Wide_Wide_String;
254 Pattern : Wide_Wide_String;
255 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping :=
256 Wide_Wide_Maps.Identity)
257 return Natural;
258
259 function Count
260 (Source : Unbounded_Wide_Wide_String;
261 Pattern : Wide_Wide_String;
262 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
263 return Natural;
264
265 function Count
266 (Source : Unbounded_Wide_Wide_String;
267 Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural;
268
269 procedure Find_Token
270 (Source : Unbounded_Wide_Wide_String;
271 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
272 From : Positive;
273 Test : Membership;
274 First : out Positive;
275 Last : out Natural);
276 pragma Ada_2012 (Find_Token);
277
278 procedure Find_Token
279 (Source : Unbounded_Wide_Wide_String;
280 Set : Wide_Wide_Maps.Wide_Wide_Character_Set;
281 Test : Membership;
282 First : out Positive;
283 Last : out Natural);
284
285 ------------------------------------
286 -- String Translation Subprograms --
287 ------------------------------------
288
289 function Translate
290 (Source : Unbounded_Wide_Wide_String;
291 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping)
292 return Unbounded_Wide_Wide_String;
293
294 procedure Translate
295 (Source : in out Unbounded_Wide_Wide_String;
296 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping);
297
298 function Translate
299 (Source : Unbounded_Wide_Wide_String;
300 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function)
301 return Unbounded_Wide_Wide_String;
302
303 procedure Translate
304 (Source : in out Unbounded_Wide_Wide_String;
305 Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function);
306
307 ---------------------------------------
308 -- String Transformation Subprograms --
309 ---------------------------------------
310
311 function Replace_Slice
312 (Source : Unbounded_Wide_Wide_String;
313 Low : Positive;
314 High : Natural;
315 By : Wide_Wide_String) return Unbounded_Wide_Wide_String;
316
317 procedure Replace_Slice
318 (Source : in out Unbounded_Wide_Wide_String;
319 Low : Positive;
320 High : Natural;
321 By : Wide_Wide_String);
322
323 function Insert
324 (Source : Unbounded_Wide_Wide_String;
325 Before : Positive;
326 New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String;
327
328 procedure Insert
329 (Source : in out Unbounded_Wide_Wide_String;
330 Before : Positive;
331 New_Item : Wide_Wide_String);
332
333 function Overwrite
334 (Source : Unbounded_Wide_Wide_String;
335 Position : Positive;
336 New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String;
337
338 procedure Overwrite
339 (Source : in out Unbounded_Wide_Wide_String;
340 Position : Positive;
341 New_Item : Wide_Wide_String);
342
343 function Delete
344 (Source : Unbounded_Wide_Wide_String;
345 From : Positive;
346 Through : Natural) return Unbounded_Wide_Wide_String;
347
348 procedure Delete
349 (Source : in out Unbounded_Wide_Wide_String;
350 From : Positive;
351 Through : Natural);
352
353 function Trim
354 (Source : Unbounded_Wide_Wide_String;
355 Side : Trim_End) return Unbounded_Wide_Wide_String;
356
357 procedure Trim
358 (Source : in out Unbounded_Wide_Wide_String;
359 Side : Trim_End);
360
361 function Trim
362 (Source : Unbounded_Wide_Wide_String;
363 Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
364 Right : Wide_Wide_Maps.Wide_Wide_Character_Set)
365 return Unbounded_Wide_Wide_String;
366
367 procedure Trim
368 (Source : in out Unbounded_Wide_Wide_String;
369 Left : Wide_Wide_Maps.Wide_Wide_Character_Set;
370 Right : Wide_Wide_Maps.Wide_Wide_Character_Set);
371
372 function Head
373 (Source : Unbounded_Wide_Wide_String;
374 Count : Natural;
375 Pad : Wide_Wide_Character := Wide_Wide_Space)
376 return Unbounded_Wide_Wide_String;
377
378 procedure Head
379 (Source : in out Unbounded_Wide_Wide_String;
380 Count : Natural;
381 Pad : Wide_Wide_Character := Wide_Wide_Space);
382
383 function Tail
384 (Source : Unbounded_Wide_Wide_String;
385 Count : Natural;
386 Pad : Wide_Wide_Character := Wide_Wide_Space)
387 return Unbounded_Wide_Wide_String;
388
389 procedure Tail
390 (Source : in out Unbounded_Wide_Wide_String;
391 Count : Natural;
392 Pad : Wide_Wide_Character := Wide_Wide_Space);
393
394 function "*"
395 (Left : Natural;
396 Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String;
397
398 function "*"
399 (Left : Natural;
400 Right : Wide_Wide_String) return Unbounded_Wide_Wide_String;
401
402 function "*"
403 (Left : Natural;
404 Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String;
405
406 private
407 pragma Inline (Length);
408
409 package AF renames Ada.Finalization;
410
411 Null_Wide_Wide_String : aliased Wide_Wide_String := "";
412
413 function To_Unbounded_Wide
414 (S : Wide_Wide_String) return Unbounded_Wide_Wide_String
415 renames To_Unbounded_Wide_Wide_String;
416
417 type Unbounded_Wide_Wide_String is new AF.Controlled with record
418 Reference : Wide_Wide_String_Access := Null_Wide_Wide_String'Access;
419 Last : Natural := 0;
420 end record;
421
422 -- The Unbounded_Wide_Wide_String is using a buffered implementation to
423 -- increase speed of the Append/Delete/Insert procedures. The Reference
424 -- string pointer above contains the current string value and extra room
425 -- at the end to be used by the next Append routine. Last is the index of
426 -- the string ending character. So the current string value is really
427 -- Reference (1 .. Last).
428
429 pragma Stream_Convert
430 (Unbounded_Wide_Wide_String, To_Unbounded_Wide, To_Wide_Wide_String);
431
432 pragma Finalize_Storage_Only (Unbounded_Wide_Wide_String);
433 -- Finalization is required only for freeing storage
434
435 procedure Initialize (Object : in out Unbounded_Wide_Wide_String);
436 procedure Adjust (Object : in out Unbounded_Wide_Wide_String);
437 procedure Finalize (Object : in out Unbounded_Wide_Wide_String);
438 procedure Realloc_For_Chunk
439 (Source : in out Unbounded_Wide_Wide_String;
440 Chunk_Size : Natural);
441 -- Adjust the size allocated for the string. Add at least Chunk_Size so it
442 -- is safe to add a string of this size at the end of the current content.
443 -- The real size allocated for the string is Chunk_Size + x of the current
444 -- string size. This buffered handling makes the Append unbounded string
445 -- routines very fast.
446
447 Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String :=
448 (AF.Controlled with
449 Reference =>
450 Null_Wide_Wide_String'Access,
451 Last => 0);
452 end Ada.Strings.Wide_Wide_Unbounded;