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