| 1 |
@comment{ $Source: e:\\cvsroot/ARM/Source/pre_strings.mss,v $ } |
| 2 |
@comment{ $Revision: 1.52 $ $Date: 2006/10/19 06:40:33 $ $Author: Randy $ } |
| 3 |
@Part(predefstrings, Root="ada.mss") |
| 4 |
@Comment{$Date: 2006/10/19 06:40:33 $} |
| 5 |
|
| 6 |
@LabeledClause{String Handling} |
| 7 |
|
| 8 |
@begin{Intro} |
| 9 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 10 |
This clause presents the specifications of the package Strings and |
| 11 |
several child packages, which provide facilities for dealing with |
| 12 |
string data. Fixed-length, |
| 13 |
bounded-length, and unbounded-length strings are supported, for @Chg{Version=[2],New=[],Old=[both]} |
| 14 |
String@Chg{Version=[2],New=[,],Old=[ and]} Wide_String@Chg{Version=[2],New=[, |
| 15 |
and Wide_Wide_String],Old=[]}. |
| 16 |
The string-handling subprograms include searches for pattern strings |
| 17 |
and for characters in program-specified sets, |
| 18 |
translation (via a character-to-character mapping), and transformation |
| 19 |
(replacing, inserting, overwriting, and deleting of substrings). |
| 20 |
@end{Intro} |
| 21 |
|
| 22 |
@begin{Extend83} |
| 23 |
@Defn{extensions to Ada 83} |
| 24 |
This clause is new to Ada 95. |
| 25 |
@end{Extend83} |
| 26 |
|
| 27 |
@begin{Diffword95} |
| 28 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 29 |
@ChgAdded{Version=[2],Text=[Included Wide_Wide_String in this description; |
| 30 |
the individual changes are documented as extensions as needed.]} |
| 31 |
@end{Diffword95} |
| 32 |
|
| 33 |
|
| 34 |
@LabeledSubClause{The Package Strings} |
| 35 |
@begin{Intro} |
| 36 |
The package Strings provides declarations |
| 37 |
common to the string handling packages. |
| 38 |
@end{Intro} |
| 39 |
|
| 40 |
@begin{StaticSem} |
| 41 |
@Leading@;The library package Strings has the following declaration: |
| 42 |
@begin{example} |
| 43 |
@ChildUnit{Parent=[Ada],Child=[Strings]}@key[package] Ada.Strings @key[is] |
| 44 |
@key[pragma] Pure(Strings); |
| 45 |
|
| 46 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 47 |
@AdaObjDefn{Space} : @key[constant] Character := ' '; |
| 48 |
@AdaObjDefn{Wide_Space} : @key[constant] Wide_Character := ' ';@Chg{Version=[2],New=[ |
| 49 |
@AdaObjDefn{Wide_Wide_Space} : @key[constant] Wide_Wide_Character := ' ';],Old=[]} |
| 50 |
|
| 51 |
@AdaExcDefn{Length_Error}, @AdaExcDefn{Pattern_Error}, @AdaExcDefn{Index_Error}, @AdaExcDefn{Translation_Error} : @key[exception]; |
| 52 |
|
| 53 |
@key[type] @AdaTypeDefn{Alignment} @key[is] (Left, Right, Center); |
| 54 |
@key[type] @AdaTypeDefn{Truncation} @key[is] (Left, Right, Error); |
| 55 |
@key[type] @AdaTypeDefn{Membership} @key[is] (Inside, Outside); |
| 56 |
@key[type] @AdaTypeDefn{Direction} @key[is] (Forward, Backward); |
| 57 |
@key[type] @AdaTypeDefn{Trim_End} @key[is] (Left, Right, Both); |
| 58 |
@key[end] Ada.Strings; |
| 59 |
@end{example} |
| 60 |
@end{StaticSem} |
| 61 |
|
| 62 |
@begin{Incompatible95} |
| 63 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 64 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 65 |
Constant Wide_Wide_Space is newly added to Ada.Strings. If Ada.Strings is |
| 66 |
referenced in a @nt{use_clause}, and an entity @i<E> with a |
| 67 |
@nt{defining_identifier} of Wide_Wide_Space is defined in a package that is |
| 68 |
also referenced in a @nt{use_clause}, the entity @i<E> may no longer be |
| 69 |
use-visible, resulting in errors. This should be rare and is easily fixed if |
| 70 |
it does occur.]} |
| 71 |
@end{Incompatible95} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
@Comment{@RmNewPage Insert page break so printed Ada 95 w/ Corr RM looks better.} |
| 76 |
@LabeledSubClause{The Package Strings.Maps} |
| 77 |
@begin{Intro} |
| 78 |
The package Strings.Maps defines the types, operations, and other |
| 79 |
entities needed for character sets and character-to-character mappings. |
| 80 |
@end{Intro} |
| 81 |
|
| 82 |
@begin{StaticSem} |
| 83 |
@Leading@;The library package Strings.Maps has the following declaration: |
| 84 |
@begin{example} |
| 85 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]} |
| 86 |
@ChildUnit{Parent=[Ada.Strings],Child=[Maps]}@key[package] Ada.Strings.Maps @key[is] |
| 87 |
@key[pragma] @Chg{Version=[2],New=[Pure],Old=[Preelaborate]}(Maps); |
| 88 |
|
| 89 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]} |
| 90 |
--@RI{ Representation for a set of character values:} |
| 91 |
@key[type] @AdaTypeDefn{Character_Set} @key[is] @key[private];@Chg{Version=[2],New=[ |
| 92 |
@key[pragma] Preelaborable_Initialization(Character_Set);],Old=[]} |
| 93 |
|
| 94 |
@AdaObjDefn{Null_Set} : @key[constant] Character_Set; |
| 95 |
|
| 96 |
@key[type] @AdaTypeDefn{Character_Range} @key[is] |
| 97 |
@Key[record] |
| 98 |
Low : Character; |
| 99 |
High : Character; |
| 100 |
@key[end] @key[record]; |
| 101 |
-- @RI[Represents Character range Low..High] |
| 102 |
|
| 103 |
@key[type] @AdaTypeDefn{Character_Ranges} @key[is] @key[array] (Positive @key[range] <>) @key[of] Character_Range; |
| 104 |
|
| 105 |
@key[function] @AdaSubDefn{To_Set} (Ranges : @key[in] Character_Ranges)@key[return] Character_Set; |
| 106 |
|
| 107 |
@key[function] @AdaSubDefn{To_Set} (Span : @key[in] Character_Range)@key[return] Character_Set; |
| 108 |
|
| 109 |
@key[function] @AdaSubDefn{To_Ranges} (Set : @key[in] Character_Set) @key[return] Character_Ranges; |
| 110 |
|
| 111 |
@key[function] "=" (Left, Right : @key[in] Character_Set) @key[return] Boolean; |
| 112 |
|
| 113 |
@key[function] "@key[not]" (Right : @key[in] Character_Set) @key[return] Character_Set; |
| 114 |
@key[function] "@key[and]" (Left, Right : @key[in] Character_Set) @key[return] Character_Set; |
| 115 |
@key[function] "@key[or]" (Left, Right : @key[in] Character_Set) @key[return] Character_Set; |
| 116 |
@key[function] "@key[xor]" (Left, Right : @key[in] Character_Set) @key[return] Character_Set; |
| 117 |
@key[function] "-" (Left, Right : @key[in] Character_Set) @key[return] Character_Set; |
| 118 |
|
| 119 |
@key[function] @AdaSubDefn{Is_In} (Element : @key[in] Character; |
| 120 |
Set : @key[in] Character_Set) |
| 121 |
@key[return] Boolean; |
| 122 |
|
| 123 |
@key[function] @AdaSubDefn{Is_Subset} (Elements : @key[in] Character_Set; |
| 124 |
Set : @key[in] Character_Set) |
| 125 |
@key[return] Boolean; |
| 126 |
|
| 127 |
@key[function] "<=" (Left : @key[in] Character_Set; |
| 128 |
Right : @key[in] Character_Set) |
| 129 |
@key[return] Boolean @key[renames] Is_Subset; |
| 130 |
|
| 131 |
|
| 132 |
--@RI{ Alternative representation for a set of character values:} |
| 133 |
@key[subtype] @AdaSubtypeDefn{Name=[Character_Sequence],Of=[String]} @key[is] String; |
| 134 |
|
| 135 |
@key[function] @AdaSubDefn{To_Set} (Sequence : @key[in] Character_Sequence)@key[return] Character_Set; |
| 136 |
|
| 137 |
@key[function] @AdaSubDefn{To_Set} (Singleton : @key[in] Character) @key[return] Character_Set; |
| 138 |
|
| 139 |
@key[function] @AdaSubDefn{To_Sequence} (Set : @key[in] Character_Set) @key[return] Character_Sequence; |
| 140 |
|
| 141 |
|
| 142 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]} |
| 143 |
--@RI{ Representation for a character to character mapping:} |
| 144 |
@key[type] @AdaTypeDefn{Character_Mapping} @key[is] @key[private];@Chg{Version=[2],New=[ |
| 145 |
@key[pragma] Preelaborable_Initialization(Character_Mapping);],Old=[]} |
| 146 |
|
| 147 |
@key[function] @AdaSubDefn{Value} (Map : @key[in] Character_Mapping; |
| 148 |
Element : @key[in] Character) |
| 149 |
@key[return] Character; |
| 150 |
|
| 151 |
@AdaObjDefn{Identity} : @key[constant] Character_Mapping; |
| 152 |
|
| 153 |
@key[function] @AdaSubDefn{To_Mapping} (From, To : @key[in] Character_Sequence) |
| 154 |
@key[return] Character_Mapping; |
| 155 |
|
| 156 |
@key[function] @AdaSubDefn{To_Domain} (Map : @key[in] Character_Mapping) |
| 157 |
@key[return] Character_Sequence; |
| 158 |
@key[function] @AdaSubDefn{To_Range} (Map : @key[in] Character_Mapping) |
| 159 |
@key[return] Character_Sequence; |
| 160 |
|
| 161 |
@key{type} @AdaTypeDefn{Character_Mapping_Function} @key{is} |
| 162 |
@key{access} @key{function} (From : @key{in} Character) @key{return} Character; |
| 163 |
|
| 164 |
@key[private] |
| 165 |
... -- @RI{not specified by the language} |
| 166 |
@key[end] Ada.Strings.Maps; |
| 167 |
@end{example} |
| 168 |
|
| 169 |
An object of type Character_Set represents a set of characters. |
| 170 |
|
| 171 |
Null_Set represents the set containing no characters. |
| 172 |
|
| 173 |
An object Obj of type Character_Range represents the set of characters |
| 174 |
in the range Obj.Low .. Obj.High. |
| 175 |
|
| 176 |
An object Obj of type Character_Ranges represents the |
| 177 |
union of the sets corresponding to Obj(I) for I in Obj'Range. |
| 178 |
@begin{DescribeCode} |
| 179 |
@begin{Example}@Keepnext |
| 180 |
@key[function] To_Set (Ranges : @key[in] Character_Ranges) @key[return] Character_Set; |
| 181 |
@end{Example} |
| 182 |
@Trailing@;If Ranges'Length=0 then Null_Set is returned; |
| 183 |
otherwise the returned value represents the set corresponding to Ranges. |
| 184 |
|
| 185 |
@begin{Example}@Keepnext |
| 186 |
@key[function] To_Set (Span : @key[in] Character_Range) @key[return] Character_Set; |
| 187 |
@end{Example} |
| 188 |
|
| 189 |
The returned value represents the set containing each character in Span. |
| 190 |
@begin{Example}@Keepnext |
| 191 |
@key[function] To_Ranges (Set : @key[in] Character_Set) @key[return] Character_Ranges; |
| 192 |
@end{Example} |
| 193 |
@Trailing@;If Set = Null_Set then an empty Character_Ranges array is returned; |
| 194 |
otherwise the shortest array of contiguous ranges of Character |
| 195 |
values in Set, in increasing order of Low, is returned. |
| 196 |
|
| 197 |
@begin{Example}@Keepnext |
| 198 |
@key[function] "=" (Left, Right : @key[in] Character_Set) @key[return] Boolean; |
| 199 |
@end{Example} |
| 200 |
@Trailing@;The function "=" returns True if Left and Right represent identical sets, |
| 201 |
and False otherwise. |
| 202 |
@end{DescribeCode} |
| 203 |
|
| 204 |
@Trailing@;Each of the logical operators "@key[not]", "@key[and]", "@key[or]", |
| 205 |
and "@key[xor]" returns |
| 206 |
a Character_Set value that represents the set obtained by applying |
| 207 |
the corresponding operation to the set(s) represented by the parameter(s) |
| 208 |
of the operator. |
| 209 |
"@en"(Left, Right) is equivalent to "and"(Left, "not"(Right)). |
| 210 |
@begin{reason} |
| 211 |
The set minus operator is provided for efficiency.@end{reason} |
| 212 |
|
| 213 |
@begin{DescribeCode} |
| 214 |
@begin{Example}@Keepnext |
| 215 |
@key[function] Is_In (Element : @key[in] Character; |
| 216 |
Set : @key[in] Character_Set); |
| 217 |
@key[return] Boolean; |
| 218 |
@end{Example} |
| 219 |
@Trailing@;Is_In returns True if Element is in Set, and False otherwise. |
| 220 |
|
| 221 |
@begin{Example}@Keepnext |
| 222 |
@key[function] Is_Subset (Elements : @key[in] Character_Set; |
| 223 |
Set : @key[in] Character_Set) |
| 224 |
@key[return] Boolean; |
| 225 |
@end{Example} |
| 226 |
@Trailing@;Is_Subset returns True if |
| 227 |
Elements is a subset of Set, and False otherwise. |
| 228 |
|
| 229 |
@begin{Example}@Keepnext |
| 230 |
@key[subtype] Character_Sequence @key[is] String; |
| 231 |
@end{Example} |
| 232 |
@Trailing@;The Character_Sequence subtype is used to portray a set of character |
| 233 |
values and also to identify the domain and range of a character |
| 234 |
mapping. |
| 235 |
@begin{reason} |
| 236 |
Although a named subtype is redundant @em the predefined type String |
| 237 |
could have been used for the parameter to To_Set and To_Mapping |
| 238 |
below @em the use of a differently named subtype identifies the intended |
| 239 |
purpose of the parameter. |
| 240 |
@end{reason} |
| 241 |
|
| 242 |
@begin{Example}@Keepnext |
| 243 |
@key[function] To_Set (Sequence : @key[in] Character_Sequence) @key[return] Character_Set;@* |
| 244 |
@key[function] To_Set (Singleton : @key[in] Character) @key[return] Character_Set; |
| 245 |
@end{Example} |
| 246 |
@Trailing@;Sequence portrays the set of character values that it explicitly |
| 247 |
contains (ignoring duplicates). |
| 248 |
Singleton portrays the set comprising a single Character. |
| 249 |
Each of the To_Set functions |
| 250 |
returns a Character_Set value that represents |
| 251 |
the set portrayed by Sequence or Singleton. |
| 252 |
|
| 253 |
@begin{Example}@Keepnext |
| 254 |
@key[function] To_Sequence (Set : @key[in] Character_Set) @key[return] Character_Sequence; |
| 255 |
@end{Example} |
| 256 |
@Trailing@;The function To_Sequence returns a Character_Sequence value |
| 257 |
containing each of the characters in the set represented by Set, in |
| 258 |
ascending order with no duplicates. |
| 259 |
|
| 260 |
@begin{Example}@Keepnext |
| 261 |
@key[type] Character_Mapping @key[is] @key[private]; |
| 262 |
@end{Example} |
| 263 |
@Trailing@;An object of type Character_Mapping represents a |
| 264 |
Character-to-Character mapping. |
| 265 |
|
| 266 |
@begin{Example}@Keepnext |
| 267 |
@key[function] Value (Map : @key[in] Character_Mapping; |
| 268 |
Element : @key[in] Character) |
| 269 |
@key[return] Character; |
| 270 |
@end{Example} |
| 271 |
@Trailing@;The function Value returns the Character value to which Element maps |
| 272 |
with respect to the mapping represented by Map. |
| 273 |
@end{DescribeCode} |
| 274 |
|
| 275 |
@Defn2{Term=[match], Sec=(a character to a pattern character)} |
| 276 |
A character C @i{matches} a pattern character P |
| 277 |
with respect to a given Character_Mapping value Map if |
| 278 |
Value(Map, C) = P. |
| 279 |
@Defn2{Term=[match], Sec=(a string to a pattern string)} |
| 280 |
A string S @i{matches} a pattern string P with respect to a |
| 281 |
given Character_Mapping if their lengths are the same |
| 282 |
and if each character in S matches its corresponding character in |
| 283 |
the pattern string P. |
| 284 |
@begin{Discussion} |
| 285 |
In an earlier version of the string handling packages, |
| 286 |
the definition of matching was symmetrical, namely |
| 287 |
C matches P if Value(Map,C) = Value(Map,P). |
| 288 |
However, applying the mapping |
| 289 |
to the pattern was confusing according to some reviewers. |
| 290 |
Furthermore, if the symmetrical version is needed, it can |
| 291 |
be achieved by applying the mapping to the pattern (via translation) prior to |
| 292 |
passing it as a parameter. |
| 293 |
@end{Discussion} |
| 294 |
|
| 295 |
String handling subprograms that deal with character mappings have |
| 296 |
parameters whose type is Character_Mapping. |
| 297 |
@begin{DescribeCode} |
| 298 |
@begin{Example}@Keepnext |
| 299 |
Identity : @key[constant] Character_Mapping; |
| 300 |
@end{Example} |
| 301 |
@Trailing@;Identity maps each Character to itself. |
| 302 |
|
| 303 |
@begin{Example}@Keepnext |
| 304 |
@key[function] To_Mapping (From, To : @key[in] Character_Sequence) |
| 305 |
@key[return] Character_Mapping; |
| 306 |
@end{Example} |
| 307 |
@Trailing@;To_Mapping produces a Character_Mapping such that |
| 308 |
each element of From maps to the corresponding element of To, |
| 309 |
and each other character maps to itself. |
| 310 |
If From'Length /= To'Length, or |
| 311 |
if some character is repeated in From, then Translation_Error |
| 312 |
is propagated. |
| 313 |
|
| 314 |
@begin{Example}@Keepnext |
| 315 |
@key[function] To_Domain (Map : @key[in] Character_Mapping) @key[return] Character_Sequence; |
| 316 |
@end{Example} |
| 317 |
@Trailing@;To_Domain returns the shortest Character_Sequence value D such that |
| 318 |
each character not in D maps to itself, and such that |
| 319 |
the characters in D are in ascending order. |
| 320 |
The lower bound of D is 1. |
| 321 |
|
| 322 |
@begin{Example}@Keepnext |
| 323 |
@key[function] To_Range (Map : @key[in] Character_Mapping) @key[return] Character_Sequence; |
| 324 |
@end{Example} |
| 325 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0048],ARef=[AI95-00151-01]} |
| 326 |
@Trailing@;To_Range returns the Character_Sequence value R, |
| 327 |
@Chg{New=[],Old=[with lower bound 1 and upper bound Map'Length,]} |
| 328 |
such that if D = To_Domain(Map)@Chg{New=[, then R has the same bounds as D, |
| 329 |
and],Old=[ then]} D(I) maps to R(I) for each I in D'Range. |
| 330 |
@end{DescribeCode} |
| 331 |
|
| 332 |
An object F of type Character_Mapping_Function maps a Character |
| 333 |
value C to the Character value F.@key{all}(C), which is said to |
| 334 |
@i{match} C with respect to mapping function F. |
| 335 |
@Defn2[term=<match>,sec=<a character to a pattern character, with |
| 336 |
respect to a character mapping function>] |
| 337 |
@end{StaticSem} |
| 338 |
|
| 339 |
@begin{Notes} |
| 340 |
Character_Mapping and Character_Mapping_Function |
| 341 |
are used both for character equivalence |
| 342 |
mappings in the search subprograms (such as for case insensitivity) and |
| 343 |
as transformational mappings in the Translate subprograms. |
| 344 |
|
| 345 |
To_Domain(Identity) and To_Range(Identity) each returns the null string. |
| 346 |
@begin{Reason} |
| 347 |
Package Strings.Maps is not pure, since it declares an |
| 348 |
access-to-subprogram type. |
| 349 |
@end{Reason} |
| 350 |
@end{Notes} |
| 351 |
|
| 352 |
@begin{Examples} |
| 353 |
To_Mapping("ABCD", "ZZAB") returns a Character_Mapping that maps 'A' |
| 354 |
and 'B' to 'Z', 'C' to 'A', 'D' to 'B', and each other Character to |
| 355 |
itself. |
| 356 |
@end{Examples} |
| 357 |
|
| 358 |
@begin{Extend95} |
| 359 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]} |
| 360 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 361 |
@b[Amendment Correction:] Added @nt{pragma} Preelaborable_Initialization to |
| 362 |
types Character_Set and Character_Mapping, so that they can be used |
| 363 |
to declare default-initialized objects in preelaborated units.]} |
| 364 |
|
| 365 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]} |
| 366 |
@ChgAdded{Version=[2],Text=[Strings.Maps is now Pure, |
| 367 |
so it can be used in pure units.]} |
| 368 |
@end{Extend95} |
| 369 |
|
| 370 |
@begin{DiffWord95} |
| 371 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0048],ARef=[AI95-00151-01]} |
| 372 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the definition of |
| 373 |
the range of the result of To_Range, since the Ada 95 definition makes no |
| 374 |
sense.]} |
| 375 |
@end{DiffWord95} |
| 376 |
|
| 377 |
|
| 378 |
@LabeledSubClause{Fixed-Length String Handling} |
| 379 |
@begin{Intro} |
| 380 |
The language-defined package Strings.Fixed provides string-handling subprograms |
| 381 |
for fixed-length strings; |
| 382 |
that is, for values of type Standard.String. |
| 383 |
Several of these subprograms are procedures that modify the contents of |
| 384 |
a String that is passed as an @key[out] or an @key[in] @key[out] parameter; |
| 385 |
each has additional |
| 386 |
parameters to control the effect when the logical length of the result |
| 387 |
differs from the parameter's length. |
| 388 |
|
| 389 |
For each function that returns a String, the lower bound of the returned |
| 390 |
value is 1. |
| 391 |
@begin{Discussion} |
| 392 |
@Chgref{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]} |
| 393 |
Most operations that @Chg{Version=[2],New=[yield],Old=[yields]} a String |
| 394 |
are provided both as a |
| 395 |
function and as a procedure. The functional form is possibly a more aesthetic |
| 396 |
style but may introduce overhead due to extra copying or dynamic memory |
| 397 |
usage in some implementations. Thus a procedural form, with an @key[in] |
| 398 |
@key[out] parameter so that all copying is done `in place', is also |
| 399 |
supplied.@end{discussion} |
| 400 |
|
| 401 |
The basic model embodied in the package is that a fixed-length string |
| 402 |
comprises significant characters and possibly padding |
| 403 |
(with space characters) |
| 404 |
on either or both |
| 405 |
ends. When a shorter string is copied to a longer string, padding |
| 406 |
is inserted, and when a longer string is copied to a shorter one, |
| 407 |
padding is stripped. The Move procedure in Strings.Fixed, which takes a |
| 408 |
String as an @key[out] parameter, allows the programmer to control these |
| 409 |
effects. Similar control is provided by the string transformation |
| 410 |
procedures. |
| 411 |
@end{Intro} |
| 412 |
|
| 413 |
@begin{StaticSem} |
| 414 |
@Leading@keepnext |
| 415 |
@Leading@;The library package Strings.Fixed has the following declaration: |
| 416 |
@begin{example} |
| 417 |
@key[with] Ada.Strings.Maps; |
| 418 |
@ChildUnit{Parent=[Ada.Strings],Child=[Fixed]}@key[package] Ada.Strings.Fixed @key[is] |
| 419 |
@key[pragma] Preelaborate(Fixed); |
| 420 |
|
| 421 |
|
| 422 |
--@RI{ "Copy" procedure for strings of possibly different lengths} |
| 423 |
|
| 424 |
@key[procedure] @AdaSubDefn{Move} (Source : @key[in] String; |
| 425 |
Target : @key[out] String; |
| 426 |
Drop : @key[in] Truncation := Error; |
| 427 |
Justify : @key[in] Alignment := Left; |
| 428 |
Pad : @key[in] Character := Space); |
| 429 |
|
| 430 |
|
| 431 |
--@RI{ Search subprograms} |
| 432 |
|
| 433 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 434 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] String; |
| 435 |
Pattern : @key[in] String; |
| 436 |
From : @key[in] Positive; |
| 437 |
Going : @key[in] Direction := Forward; |
| 438 |
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity) |
| 439 |
@key[return] Natural;]} |
| 440 |
|
| 441 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 442 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] String; |
| 443 |
Pattern : @key[in] String; |
| 444 |
From : @key[in] Positive; |
| 445 |
Going : @key[in] Direction := Forward; |
| 446 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 447 |
@key[return] Natural;]} |
| 448 |
|
| 449 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] String; |
| 450 |
Pattern : @key[in] String; |
| 451 |
Going : @key[in] Direction := Forward; |
| 452 |
Mapping : @key[in] Maps.Character_Mapping |
| 453 |
:= Maps.Identity) |
| 454 |
@key[return] Natural; |
| 455 |
|
| 456 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] String; |
| 457 |
Pattern : @key[in] String; |
| 458 |
Going : @key[in] Direction := Forward; |
| 459 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 460 |
@key[return] Natural; |
| 461 |
|
| 462 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 463 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] String; |
| 464 |
Set : @key[in] Maps.Character_Set; |
| 465 |
From : @key[in] Positive; |
| 466 |
Test : @key[in] Membership := Inside; |
| 467 |
Going : @key[in] Direction := Forward) |
| 468 |
@key[return] Natural;]} |
| 469 |
|
| 470 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] String; |
| 471 |
Set : @key[in] Maps.Character_Set; |
| 472 |
Test : @key[in] Membership := Inside; |
| 473 |
Going : @key[in] Direction := Forward) |
| 474 |
@key[return] Natural; |
| 475 |
|
| 476 |
|
| 477 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 478 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] String; |
| 479 |
From : @key[in] Positive; |
| 480 |
Going : @key[in] Direction := Forward) |
| 481 |
@key[return] Natural;]} |
| 482 |
|
| 483 |
@key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] String; |
| 484 |
Going : @key[in] Direction := Forward) |
| 485 |
@key[return] Natural; |
| 486 |
|
| 487 |
|
| 488 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] String; |
| 489 |
Pattern : @key[in] String; |
| 490 |
Mapping : @key[in] Maps.Character_Mapping |
| 491 |
:= Maps.Identity) |
| 492 |
@key[return] Natural; |
| 493 |
|
| 494 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] String; |
| 495 |
Pattern : @key[in] String; |
| 496 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 497 |
@key[return] Natural; |
| 498 |
|
| 499 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] String; |
| 500 |
Set : @key[in] Maps.Character_Set) |
| 501 |
@key[return] Natural; |
| 502 |
|
| 503 |
|
| 504 |
@key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] String; |
| 505 |
Set : @key[in] Maps.Character_Set; |
| 506 |
Test : @key[in] Membership; |
| 507 |
First : @key[out] Positive; |
| 508 |
Last : @key[out] Natural); |
| 509 |
|
| 510 |
|
| 511 |
@Keepnext@;--@RI{ String translation subprograms} |
| 512 |
|
| 513 |
@key[function] @AdaSubDefn{Translate} (Source : @key[in] String; |
| 514 |
Mapping : @key[in] Maps.Character_Mapping) |
| 515 |
@key[return] String; |
| 516 |
|
| 517 |
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] String; |
| 518 |
Mapping : @key[in] Maps.Character_Mapping); |
| 519 |
|
| 520 |
|
| 521 |
@key[function] @AdaSubDefn{Translate} (Source : @key[in] String; |
| 522 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 523 |
@key[return] String; |
| 524 |
|
| 525 |
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] String; |
| 526 |
Mapping : @key[in] Maps.Character_Mapping_Function); |
| 527 |
|
| 528 |
@Keepnext@;--@RI{ String transformation subprograms} |
| 529 |
|
| 530 |
@key[function] @AdaSubDefn{Replace_Slice} (Source : @key[in] String; |
| 531 |
Low : @key[in] Positive; |
| 532 |
High : @key[in] Natural; |
| 533 |
By : @key[in] String) |
| 534 |
@key[return] String; |
| 535 |
|
| 536 |
@key[procedure] @AdaSubDefn{Replace_Slice} (Source : @key[in] @key[out] String; |
| 537 |
Low : @key[in] Positive; |
| 538 |
High : @key[in] Natural; |
| 539 |
By : @key[in] String; |
| 540 |
Drop : @key[in] Truncation := Error; |
| 541 |
Justify : @key[in] Alignment := Left; |
| 542 |
Pad : @key[in] Character := Space); |
| 543 |
|
| 544 |
|
| 545 |
@key[function] @AdaSubDefn{Insert} (Source : @key[in] String; |
| 546 |
Before : @key[in] Positive; |
| 547 |
New_Item : @key[in] String) |
| 548 |
@key[return] String; |
| 549 |
|
| 550 |
@key[procedure] @AdaSubDefn{Insert} (Source : @key[in] @key[out] String; |
| 551 |
Before : @key[in] Positive; |
| 552 |
New_Item : @key[in] String; |
| 553 |
Drop : @key[in] Truncation := Error); |
| 554 |
|
| 555 |
|
| 556 |
@key[function] @AdaSubDefn{Overwrite} (Source : @key[in] String; |
| 557 |
Position : @key[in] Positive; |
| 558 |
New_Item : @key[in] String) |
| 559 |
@key[return] String; |
| 560 |
|
| 561 |
@key[procedure] @AdaSubDefn{Overwrite} (Source : @key[in] @key[out] String; |
| 562 |
Position : @key[in] Positive; |
| 563 |
New_Item : @key[in] String; |
| 564 |
Drop : @key[in] Truncation := Right); |
| 565 |
|
| 566 |
|
| 567 |
@key[function] @AdaSubDefn{Delete} (Source : @key[in] String; |
| 568 |
From : @key[in] Positive; |
| 569 |
Through : @key[in] Natural) |
| 570 |
@key[return] String; |
| 571 |
|
| 572 |
@key[procedure] @AdaSubDefn{Delete} (Source : @key[in] @key[out] String; |
| 573 |
From : @key[in] Positive; |
| 574 |
Through : @key[in] Natural; |
| 575 |
Justify : @key[in] Alignment := Left; |
| 576 |
Pad : @key[in] Character := Space); |
| 577 |
|
| 578 |
--@RI{String selector subprograms} |
| 579 |
@key[function] @AdaSubDefn{Trim} (Source : @key[in] String; |
| 580 |
Side : @key[in] Trim_End) |
| 581 |
@key[return] String; |
| 582 |
|
| 583 |
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] String; |
| 584 |
Side : @key[in] Trim_End; |
| 585 |
Justify : @key[in] Alignment := Left; |
| 586 |
Pad : @key[in] Character := Space); |
| 587 |
|
| 588 |
@key[function] @AdaSubDefn{Trim} (Source : @key[in] String; |
| 589 |
Left : @key[in] Maps.Character_Set; |
| 590 |
Right : @key[in] Maps.Character_Set) |
| 591 |
@key[return] String; |
| 592 |
|
| 593 |
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] String; |
| 594 |
Left : @key[in] Maps.Character_Set; |
| 595 |
Right : @key[in] Maps.Character_Set; |
| 596 |
Justify : @key[in] Alignment := Strings.Left; |
| 597 |
Pad : @key[in] Character := Space); |
| 598 |
|
| 599 |
|
| 600 |
@key[function] @AdaSubDefn{Head} (Source : @key[in] String; |
| 601 |
Count : @key[in] Natural; |
| 602 |
Pad : @key[in] Character := Space) |
| 603 |
@key[return] String; |
| 604 |
|
| 605 |
@key[procedure] @AdaSubDefn{Head} (Source : @key[in] @key[out] String; |
| 606 |
Count : @key[in] Natural; |
| 607 |
Justify : @key[in] Alignment := Left; |
| 608 |
Pad : @key[in] Character := Space); |
| 609 |
|
| 610 |
@key[function] @AdaSubDefn{Tail} (Source : @key[in] String; |
| 611 |
Count : @key[in] Natural; |
| 612 |
Pad : @key[in] Character := Space) |
| 613 |
@key[return] String; |
| 614 |
|
| 615 |
@key[procedure] @AdaSubDefn{Tail} (Source : @key[in] @key[out] String; |
| 616 |
Count : @key[in] Natural; |
| 617 |
Justify : @key[in] Alignment := Left; |
| 618 |
Pad : @key[in] Character := Space); |
| 619 |
|
| 620 |
@keepnext@;--@RI{String constructor functions} |
| 621 |
|
| 622 |
@key[function] "*" (Left : @key[in] Natural; |
| 623 |
Right : @key[in] Character) @key[return] String; |
| 624 |
|
| 625 |
@key[function] "*" (Left : @key[in] Natural; |
| 626 |
Right : @key[in] String) @key[return] String; |
| 627 |
|
| 628 |
@key[end] Ada.Strings.Fixed; |
| 629 |
@end{example} |
| 630 |
|
| 631 |
The effects of the above subprograms are as follows. |
| 632 |
@begin{DescribeCode} |
| 633 |
@begin{Example}@Keepnext |
| 634 |
@key[procedure] Move (Source : @key[in] String; |
| 635 |
Target : @key[out] String; |
| 636 |
Drop : @key[in] Truncation := Error; |
| 637 |
Justify : @key[in] Alignment := Left; |
| 638 |
Pad : @key[in] Character := Space); |
| 639 |
@end{Example} |
| 640 |
@Leading@;The Move procedure copies characters from Source to Target. |
| 641 |
If Source has the same length as Target, then the effect is |
| 642 |
to assign Source to Target. |
| 643 |
If Source is shorter than Target then: |
| 644 |
@begin{itemize} |
| 645 |
If Justify=Left, then Source is copied into the first Source'Length |
| 646 |
characters of Target. |
| 647 |
|
| 648 |
If Justify=Right, then Source is copied into the last Source'Length |
| 649 |
characters of Target. |
| 650 |
|
| 651 |
If Justify=Center, then Source is copied into |
| 652 |
the middle Source'Length characters of Target. |
| 653 |
In this case, if the difference in length between |
| 654 |
Target and Source is odd, then the extra Pad character |
| 655 |
is on the right. |
| 656 |
|
| 657 |
Pad is copied to each Target character not otherwise assigned. |
| 658 |
@end{itemize} |
| 659 |
|
| 660 |
If Source is longer than Target, then the effect is based on |
| 661 |
Drop. |
| 662 |
@begin{itemize} |
| 663 |
If Drop=Left, then the rightmost Target'Length characters |
| 664 |
of Source are copied into Target. |
| 665 |
|
| 666 |
If Drop=Right, then the leftmost Target'Length characters |
| 667 |
of Source are copied into Target. |
| 668 |
|
| 669 |
@Leading@;If Drop=Error, then the effect depends on the value of the Justify |
| 670 |
parameter and also on whether any characters in Source other than |
| 671 |
Pad would fail to be copied: |
| 672 |
@begin{inneritemize} |
| 673 |
If Justify=Left, and if each of the rightmost Source'Length-Target'Length |
| 674 |
characters in Source is Pad, then the leftmost Target'Length characters |
| 675 |
of Source are copied to Target. |
| 676 |
|
| 677 |
If Justify=Right, and if each of the leftmost Source'Length-Target'Length |
| 678 |
characters in Source is Pad, then the rightmost Target'Length characters |
| 679 |
of Source are copied to Target. |
| 680 |
|
| 681 |
@Trailing@;Otherwise, Length_Error is propagated. |
| 682 |
@end{inneritemize} |
| 683 |
@end{itemize} |
| 684 |
@begin{ramification} |
| 685 |
The Move procedure will work even if Source and Target |
| 686 |
overlap.@end{ramification} |
| 687 |
@begin{reason} |
| 688 |
The order of parameters (Source before Target) corresponds to |
| 689 |
the order in COBOL's MOVE verb.@end{reason} |
| 690 |
|
| 691 |
@begin{Example} |
| 692 |
@ChgRef{Version=[2],Kind=[Added]} |
| 693 |
@ChgAdded{Version=[2],Text=[@key[function] Index (Source : @key[in] String; |
| 694 |
Pattern : @key[in] String; |
| 695 |
From : @key[in] Positive; |
| 696 |
Going : @key[in] Direction := Forward; |
| 697 |
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity) |
| 698 |
@key[return] Natural;@* |
| 699 |
@key[function] Index (Source : @key[in] String; |
| 700 |
Pattern : @key[in] String; |
| 701 |
From : @key[in] Positive; |
| 702 |
Going : @key[in] Direction := Forward; |
| 703 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 704 |
@key[return] Natural;]} |
| 705 |
@end{Example} |
| 706 |
|
| 707 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 708 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Each Index function searches, starting from From, for a slice of |
| 709 |
Source, with length Pattern'Length, that matches Pattern with respect to |
| 710 |
Mapping; the parameter Going indicates the direction of the lookup. If |
| 711 |
From is not in Source'Range, then Index_Error is propagated. If Going = |
| 712 |
Forward, then Index returns the smallest index I which is greater than or equal |
| 713 |
to From such that the slice of Source starting at I matches Pattern. If Going = |
| 714 |
Backward, then Index returns the largest index I such that the slice of Source |
| 715 |
starting at I matches Pattern and has an upper bound less than or equal to |
| 716 |
From. If there is no such slice, then 0 is returned. If Pattern is the null |
| 717 |
string, then Pattern_Error is propagated.]} |
| 718 |
|
| 719 |
@begin{Discussion} |
| 720 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 721 |
@ChgAdded{Version=[2],Text=[There is no default parameter for From; the |
| 722 |
default value would need to depend on other parameters (the bounds of Source |
| 723 |
and the direction Going). It is better to use overloaded functions rather |
| 724 |
than a special value to represent the default.]} |
| 725 |
|
| 726 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 727 |
@ChgAdded{Version=[2],Text=[There is no default value for the Mapping |
| 728 |
parameter that is a Character_Mapping_Function; if there were, a call would |
| 729 |
be ambiguous since there is also a default for the Mapping parameter that is |
| 730 |
a Character_Mapping.]} |
| 731 |
@end{Discussion} |
| 732 |
|
| 733 |
@begin{Example}@Keepnext |
| 734 |
@key[function] Index (Source : @key[in] String; |
| 735 |
Pattern : @key[in] String; |
| 736 |
Going : @key[in] Direction := Forward; |
| 737 |
Mapping : @key[in] Maps.Character_Mapping |
| 738 |
:= Maps.Identity) |
| 739 |
@key[return] Natural;@* |
| 740 |
@key[function] Index (Source : @key[in] String; |
| 741 |
Pattern : @key[in] String; |
| 742 |
Going : @key[in] Direction := Forward; |
| 743 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 744 |
@key[return] Natural; |
| 745 |
@end{Example} |
| 746 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]} |
| 747 |
@Comment{@ChgDeleted{Version=[2],Type=[Trailing],Text=[]}@Comment{Fake to hold conditional format.}Can't have both.} |
| 748 |
@ChgAdded{Version=[2],Type=[Leading],Text=[]}@Comment{Fake to hold conditional format.} |
| 749 |
@Chg{Version=[2],New=[If Going = Forward, returns], |
| 750 |
Old=[Each Index function searches for a slice of Source, with length |
| 751 |
Pattern'Length, that matches Pattern |
| 752 |
with respect to Mapping; |
| 753 |
the parameter Going indicates the direction of the lookup. |
| 754 |
If Going = Forward, then Index |
| 755 |
returns the smallest index I such that |
| 756 |
the slice of Source starting at I matches Pattern. |
| 757 |
If Going = Backward, then Index |
| 758 |
returns the largest index I such that |
| 759 |
the slice of Source starting at I matches Pattern. |
| 760 |
If there is no such slice, then 0 is returned. |
| 761 |
If Pattern is the null string then Pattern_Error is propagated.]} |
| 762 |
@begin{Example} |
| 763 |
@ChgRef{Version=[2],Kind=[Added]} |
| 764 |
@ChgAdded{Version=[2],Text=[ Index (Source, Pattern, Source'First, Forward, Mapping);]} |
| 765 |
@end{Example} |
| 766 |
@ChgRef{Version=[2],Kind=[Added]} |
| 767 |
@ChgAdded{Version=[2],Type=[Leading],Text=[otherwise returns]} |
| 768 |
@begin{Example} |
| 769 |
@ChgRef{Version=[2],Kind=[Added]} |
| 770 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[ Index (Source, Pattern, Source'Last, Backward, Mapping);]} |
| 771 |
@end{Example} |
| 772 |
@begin{discussion} |
| 773 |
@ChgRef{Version=[2],Kind=[Deleted]}@ChgNote{Moved up} |
| 774 |
@ChgAdded{Version=[2],Text=[There is no default value for the Mapping |
| 775 |
parameter that is a Character_Mapping_Function; if there were, a call would |
| 776 |
be ambiguous since there is also a default for the Mapping parameter that is |
| 777 |
a Character_Mapping.]} |
| 778 |
@end{discussion} |
| 779 |
|
| 780 |
@begin{Example} |
| 781 |
@ChgRef{Version=[2],Kind=[Added]} |
| 782 |
@ChgAdded{Version=[2],Text=[@key[function] Index (Source : @key[in] String; |
| 783 |
Set : @key[in] Maps.Character_Set; |
| 784 |
From : @key[in] Positive; |
| 785 |
Test : @key[in] Membership := Inside; |
| 786 |
Going : @key[in] Direction := Forward) |
| 787 |
@key[return] Natural;]} |
| 788 |
@end{Example} |
| 789 |
|
| 790 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 791 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Index searches for the first or |
| 792 |
last occurrence of any of a set of characters (when Test=Inside), or any of the |
| 793 |
complement of a set of characters (when Test=Outside). If From is not in |
| 794 |
Source'Range, then Index_Error is propagated. Otherwise, it returns the |
| 795 |
smallest index I >= From (if Going=Forward) or the largest index I <= From (if |
| 796 |
Going=Backward) such that Source(I) satisfies the Test condition with respect |
| 797 |
to Set; it returns 0 if there is no such Character in Source.]} |
| 798 |
|
| 799 |
@begin{Example}@Keepnext |
| 800 |
@key[function] Index (Source : @key[in] String; |
| 801 |
Set : @key[in] Maps.Character_Set; |
| 802 |
Test : @key[in] Membership := Inside; |
| 803 |
Going : @key[in] Direction := Forward) |
| 804 |
@key[return] Natural; |
| 805 |
@end{Example} |
| 806 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]} |
| 807 |
@Comment{@ChgDeleted{Version=[2],Type=[Trailing],Text=[]}@Comment{Fake to hold conditional format.}Can't have both.} |
| 808 |
@ChgAdded{Version=[2],Type=[Leading],Text=[]}@Comment{Fake to hold conditional format.} |
| 809 |
@Chg{Version=[2],New=[If Going = Forward, returns], |
| 810 |
Old=[Index searches for the first or last occurrence of any of a set of |
| 811 |
characters (when Test=Inside), |
| 812 |
or any of the complement of a set of characters (when Test=Outside). |
| 813 |
It returns the smallest index I (if Going=Forward) or the largest index I |
| 814 |
(if Going=Backward) such that |
| 815 |
Source(I) satisfies the Test condition with respect to Set; |
| 816 |
it returns 0 if there is no such Character in Source.]} |
| 817 |
@begin{Example} |
| 818 |
@ChgRef{Version=[2],Kind=[Added]} |
| 819 |
@ChgAdded{Version=[2],Text=[ Index (Source, Set, Source'First, Test, Forward);]} |
| 820 |
@end{Example} |
| 821 |
@ChgRef{Version=[2],Kind=[Added]} |
| 822 |
@ChgAdded{Version=[2],Type=[Leading],Text=[otherwise returns]} |
| 823 |
@begin{Example} |
| 824 |
@ChgRef{Version=[2],Kind=[Added]} |
| 825 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[ Index (Source, Set, Source'Last, Test, Backward);]} |
| 826 |
@end{Example} |
| 827 |
|
| 828 |
@begin{Example} |
| 829 |
@ChgRef{Version=[2],Kind=[Added]} |
| 830 |
@ChgAdded{Version=[2],Text=[@key[function] Index_Non_Blank (Source : @key[in] String; |
| 831 |
From : @key[in] Positive; |
| 832 |
Going : @key[in] Direction := Forward) |
| 833 |
@key[return] Natural;]} |
| 834 |
@end{Example} |
| 835 |
|
| 836 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 837 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns Index (Source, Maps.To_Set(Space), From, Outside, Going);]} |
| 838 |
|
| 839 |
@begin{Example}@Keepnext |
| 840 |
@key[function] Index_Non_Blank (Source : @key[in] String; |
| 841 |
Going : @key[in] Direction := Forward) |
| 842 |
@key[return] Natural; |
| 843 |
@end{Example} |
| 844 |
@Trailing@;Returns Index(Source, Maps.To_Set(Space), Outside, Going) |
| 845 |
|
| 846 |
@begin{Example}@Keepnext |
| 847 |
@key[function] Count (Source : @key[in] String; |
| 848 |
Pattern : @key[in] String; |
| 849 |
Mapping : @key[in] Maps.Character_Mapping |
| 850 |
:= Maps.Identity) |
| 851 |
@key[return] Natural;@* |
| 852 |
@key[function] Count (Source : @key[in] String; |
| 853 |
Pattern : @key[in] String; |
| 854 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 855 |
@key[return] Natural; |
| 856 |
@end{Example} |
| 857 |
@Trailing@;Returns the maximum number of nonoverlapping slices of Source that |
| 858 |
match Pattern with respect to Mapping. |
| 859 |
If Pattern is the null string then Pattern_Error is propagated. |
| 860 |
@begin{reason} |
| 861 |
We say `maximum number' because it is possible to slice a source |
| 862 |
string in different ways yielding different numbers of matches. For |
| 863 |
example if Source is "ABABABA" and Pattern is "ABA", then Count yields |
| 864 |
2, although there is a partitioning of Source that yields just 1 match, |
| 865 |
for the middle slice. Saying `maximum number' is equivalent to saying |
| 866 |
that the pattern match starts either at the low index or the high index |
| 867 |
position. |
| 868 |
@end{reason} |
| 869 |
|
| 870 |
@begin{Example}@Keepnext |
| 871 |
@key[function] Count (Source : @key[in] String; |
| 872 |
Set : @key[in] Maps.Character_Set) |
| 873 |
@key[return] Natural; |
| 874 |
@end{Example} |
| 875 |
@Trailing@;Returns the number of occurrences in Source of characters that |
| 876 |
are in Set. |
| 877 |
|
| 878 |
@begin{Example}@Keepnext |
| 879 |
@key[procedure] Find_Token (Source : @key[in] String; |
| 880 |
Set : @key[in] Maps.Character_Set; |
| 881 |
Test : @key[in] Membership; |
| 882 |
First : @key[out] Positive; |
| 883 |
Last : @key[out] Natural); |
| 884 |
@end{Example} |
| 885 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 886 |
@Trailing@;Find_Token returns in First and Last the indices of the beginning |
| 887 |
and end of the first slice of Source all of whose elements |
| 888 |
satisfy the Test condition, and such that the elements |
| 889 |
(if any) immediately before and after the slice do not |
| 890 |
satisfy the Test condition. |
| 891 |
If no such slice exists, then the value returned for Last is zero, and |
| 892 |
the value returned for First is Source'First@Chg{New=[; however, if |
| 893 |
Source'First is not in Positive then Constraint_Error |
| 894 |
@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)} |
| 895 |
is raised],Old=[]}. |
| 896 |
|
| 897 |
@begin{Example}@Keepnext |
| 898 |
@key[function] Translate (Source : @key[in] String; |
| 899 |
Mapping : @key[in] Maps.Character_Mapping) |
| 900 |
@key[return] String;@* |
| 901 |
@key[function] Translate (Source : @key[in] String; |
| 902 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 903 |
@key[return] String; |
| 904 |
@end{Example} |
| 905 |
@Trailing@;Returns the string S whose length is Source'Length and such |
| 906 |
that S(I) is the character to which Mapping maps the corresponding |
| 907 |
element of Source, for I in 1..Source'Length. |
| 908 |
|
| 909 |
@begin{Example}@Keepnext |
| 910 |
@key[procedure] Translate (Source : @key[in] @key[out] String; |
| 911 |
Mapping : @key[in] Maps.Character_Mapping);@* |
| 912 |
@key[procedure] Translate (Source : @key[in] @key[out] String; |
| 913 |
Mapping : @key[in] Maps.Character_Mapping_Function); |
| 914 |
@end{Example} |
| 915 |
@Trailing@;Equivalent to Source := Translate(Source, Mapping). |
| 916 |
|
| 917 |
@begin{Example}@Keepnext |
| 918 |
@key[function] Replace_Slice (Source : @key[in] String; |
| 919 |
Low : @key[in] Positive; |
| 920 |
High : @key[in] Natural; |
| 921 |
By : @key[in] String) |
| 922 |
@key[return] String; |
| 923 |
@end{Example} |
| 924 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 925 |
@Chg{New=[@Leading],Old=[@Trailing]}If Low > Source'Last+1, or |
| 926 |
High < Source'First@en@;1, then Index_Error is propagated. |
| 927 |
Otherwise@Chg{New=[:],Old=[, if High >= Low then the returned string |
| 928 |
comprises Source(Source'First..Low@en@;1) & By & Source(High+1..Source'Last), |
| 929 |
and if High < Low then the returned string is |
| 930 |
Insert(Source, Before=>Low, New_Item=>By).]} |
| 931 |
|
| 932 |
@begin{Itemize} |
| 933 |
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 934 |
@ChgAdded{Version=[1],Text=[If High >= Low, then the returned string comprises |
| 935 |
Source(Source'First..Low@en@;1) & By & Source(High+1..Source'Last), but with |
| 936 |
lower bound 1.@Trailing]} |
| 937 |
|
| 938 |
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 939 |
@ChgAdded{Version=[1],Text=[If High < Low, then the returned string is |
| 940 |
Insert(Source, Before=>Low, New_Item=>By).]} |
| 941 |
@end{Itemize} |
| 942 |
|
| 943 |
@begin{Example}@Keepnext |
| 944 |
@key[procedure] Replace_Slice (Source : @key[in] @key[out] String; |
| 945 |
Low : @key[in] Positive; |
| 946 |
High : @key[in] Natural; |
| 947 |
By : @key[in] String; |
| 948 |
Drop : @key[in] Truncation := Error; |
| 949 |
Justify : @key[in] Alignment := Left; |
| 950 |
Pad : @key[in] Character := Space); |
| 951 |
@end{Example} |
| 952 |
@Trailing@;Equivalent to Move(Replace_Slice(Source, Low, High, |
| 953 |
By), Source, Drop, Justify, Pad). |
| 954 |
|
| 955 |
@begin{Example}@Keepnext |
| 956 |
@key[function] Insert (Source : @key[in] String; |
| 957 |
Before : @key[in] Positive; |
| 958 |
New_Item : @key[in] String) |
| 959 |
@key[return] String; |
| 960 |
@end{Example} |
| 961 |
@Trailing@;Propagates Index_Error if Before is not in Source'First .. Source'Last+1; |
| 962 |
otherwise |
| 963 |
returns Source(Source'First..Before@en@;1) & New_Item & |
| 964 |
Source(Before..Source'Last), but with lower bound 1. |
| 965 |
|
| 966 |
|
| 967 |
@begin{Example}@Keepnext |
| 968 |
@key[procedure] Insert (Source : @key[in] @key[out] String; |
| 969 |
Before : @key[in] Positive; |
| 970 |
New_Item : @key[in] String; |
| 971 |
Drop : @key[in] Truncation := Error); |
| 972 |
@end{Example} |
| 973 |
@Trailing@;Equivalent to Move(Insert(Source, Before, New_Item), Source, Drop). |
| 974 |
|
| 975 |
@begin{Example}@Keepnext |
| 976 |
@key[function] Overwrite (Source : @key[in] String; |
| 977 |
Position : @key[in] Positive; |
| 978 |
New_Item : @key[in] String) |
| 979 |
@key[return] String; |
| 980 |
@end{Example} |
| 981 |
@Trailing@;Propagates Index_Error if Position is not in Source'First .. Source'Last+1; |
| 982 |
otherwise |
| 983 |
returns the string obtained from Source by consecutively replacing |
| 984 |
characters starting at Position with corresponding characters from |
| 985 |
New_Item. If the end of Source is reached before the characters in |
| 986 |
New_Item are exhausted, the remaining characters from New_Item are |
| 987 |
appended to the string. |
| 988 |
|
| 989 |
@begin{Example}@Keepnext |
| 990 |
@key[procedure] Overwrite (Source : @key[in] @key[out] String; |
| 991 |
Position : @key[in] Positive; |
| 992 |
New_Item : @key[in] String; |
| 993 |
Drop : @key[in] Truncation := Right); |
| 994 |
@end{Example} |
| 995 |
@Trailing@;Equivalent to Move(Overwrite(Source, Position, |
| 996 |
New_Item), Source, Drop). |
| 997 |
|
| 998 |
@begin{Example}@Keepnext |
| 999 |
@key[function] Delete (Source : @key[in] String; |
| 1000 |
From : @key[in] Positive; |
| 1001 |
Through : @key[in] Natural) |
| 1002 |
@key[return] String; |
| 1003 |
@end{Example} |
| 1004 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1005 |
@Trailing@;If From <= Through, the returned string is Replace_Slice(Source, From, |
| 1006 |
Through, ""), otherwise it is Source@Chg{New=[ with lower bound 1],Old=[]}. |
| 1007 |
|
| 1008 |
@begin{Example}@Keepnext |
| 1009 |
@key[procedure] Delete (Source : @key[in] @key[out] String; |
| 1010 |
From : @key[in] Positive; |
| 1011 |
Through : @key[in] Natural; |
| 1012 |
Justify : @key[in] Alignment := Left; |
| 1013 |
Pad : @key[in] Character := Space); |
| 1014 |
@end{Example} |
| 1015 |
@Trailing@;Equivalent to Move(Delete(Source, From, Through), |
| 1016 |
Source, Justify => Justify, Pad => Pad). |
| 1017 |
|
| 1018 |
@begin{Example}@Keepnext |
| 1019 |
@key[function] Trim (Source : @key[in] String; |
| 1020 |
Side : @key[in] Trim_End) |
| 1021 |
@key[return] String; |
| 1022 |
@end{Example} |
| 1023 |
@Trailing@;Returns the string obtained by removing from Source all leading |
| 1024 |
Space characters (if Side = Left), all trailing Space characters |
| 1025 |
(if Side = Right), or all leading and trailing Space characters |
| 1026 |
(if Side = Both). |
| 1027 |
|
| 1028 |
@begin{Example}@Keepnext |
| 1029 |
@key[procedure] Trim (Source : @key[in] @key[out] String; |
| 1030 |
Side : @key[in] Trim_End; |
| 1031 |
Justify : @key[in] Alignment := Left; |
| 1032 |
Pad : @key[in] Character := Space); |
| 1033 |
@end{Example} |
| 1034 |
@Trailing@;Equivalent to Move(Trim(Source, Side), Source, Justify=>Justify, Pad=>Pad). |
| 1035 |
|
| 1036 |
@begin{Example}@Keepnext |
| 1037 |
@key[function] Trim (Source : @key[in] String; |
| 1038 |
Left : @key[in] Maps.Character_Set; |
| 1039 |
Right : @key[in] Maps.Character_Set) |
| 1040 |
@key[return] String; |
| 1041 |
@end{Example} |
| 1042 |
@Trailing@;Returns the string obtained by removing from Source all leading |
| 1043 |
characters in Left and all trailing characters in Right. |
| 1044 |
|
| 1045 |
@begin{Example}@Keepnext |
| 1046 |
@key[procedure] Trim (Source : @key[in] @key[out] String; |
| 1047 |
Left : @key[in] Maps.Character_Set; |
| 1048 |
Right : @key[in] Maps.Character_Set; |
| 1049 |
Justify : @key[in] Alignment := Strings.Left; |
| 1050 |
Pad : @key[in] Character := Space); |
| 1051 |
@end{Example} |
| 1052 |
@Trailing@;Equivalent to Move(Trim(Source, Left, Right), Source, |
| 1053 |
Justify => Justify, Pad=>Pad). |
| 1054 |
|
| 1055 |
@begin{Example}@Keepnext |
| 1056 |
@key[function] Head (Source : @key[in] String; |
| 1057 |
Count : @key[in] Natural; |
| 1058 |
Pad : @key[in] Character := Space) |
| 1059 |
@key[return] String; |
| 1060 |
@end{Example} |
| 1061 |
@Trailing@;Returns a string of length Count. If Count <= Source'Length, the |
| 1062 |
string comprises the first Count characters of Source. Otherwise its contents |
| 1063 |
are Source concatenated with Count@en@;Source'Length Pad characters. |
| 1064 |
|
| 1065 |
@begin{Example}@Keepnext |
| 1066 |
@key[procedure] Head (Source : @key[in] @key[out] String; |
| 1067 |
Count : @key[in] Natural; |
| 1068 |
Justify : @key[in] Alignment := Left; |
| 1069 |
Pad : @key[in] Character := Space); |
| 1070 |
@end{Example} |
| 1071 |
@Trailing@;Equivalent to Move(Head(Source, Count, Pad), Source, Drop=>Error, |
| 1072 |
Justify=>Justify, Pad=>Pad). |
| 1073 |
|
| 1074 |
@begin{Example}@Keepnext |
| 1075 |
@key[function] Tail (Source : @key[in] String; |
| 1076 |
Count : @key[in] Natural; |
| 1077 |
Pad : @key[in] Character := Space) |
| 1078 |
@key[return] String; |
| 1079 |
@end{Example} |
| 1080 |
@Trailing@;Returns a string of length Count. If Count <= Source'Length, the |
| 1081 |
string comprises the last Count characters of Source. Otherwise its contents |
| 1082 |
are Count-Source'Length Pad characters concatenated with Source. |
| 1083 |
|
| 1084 |
@begin{Example}@Keepnext |
| 1085 |
@key[procedure] Tail (Source : @key[in] @key[out] String; |
| 1086 |
Count : @key[in] Natural; |
| 1087 |
Justify : @key[in] Alignment := Left; |
| 1088 |
Pad : @key[in] Character := Space); |
| 1089 |
@end{Example} |
| 1090 |
@Trailing@;Equivalent to Move(Tail(Source, Count, Pad), Source, Drop=>Error, |
| 1091 |
Justify=>Justify, Pad=>Pad). |
| 1092 |
|
| 1093 |
@begin{Example}@Keepnext |
| 1094 |
@key[function] "*" (Left : @key[in] Natural; |
| 1095 |
Right : @key[in] Character) @key[return] String;@* |
| 1096 |
@key[function] "*" (Left : @key[in] Natural; |
| 1097 |
Right : @key[in] String) @key[return] String; |
| 1098 |
@end{Example} |
| 1099 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1100 |
These functions replicate a character or string a specified number |
| 1101 |
of times. The first function returns a string whose length is Left and each |
| 1102 |
of whose elements is Right. The second function returns a string whose |
| 1103 |
length is Left*Right'Length and whose value is the null |
| 1104 |
string if Left = 0 and @Chg{New=[otherwise ],Old=[]}is |
| 1105 |
(Left@en@;1)*Right & Right @Chg{New=[with lower bound 1],Old=[otherwise]}. |
| 1106 |
@end{DescribeCode} |
| 1107 |
@end{StaticSem} |
| 1108 |
|
| 1109 |
@begin{Notes} |
| 1110 |
In the Index and Count functions taking Pattern and Mapping parameters, |
| 1111 |
the actual String parameter passed to Pattern should comprise characters |
| 1112 |
occurring as target characters of the mapping. Otherwise the pattern |
| 1113 |
will not match. |
| 1114 |
|
| 1115 |
In the Insert subprograms, inserting at the end of a string is obtained |
| 1116 |
by passing Source'Last+1 as the Before parameter. |
| 1117 |
|
| 1118 |
@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)} |
| 1119 |
If a null Character_Mapping_Function is passed to any of the |
| 1120 |
string handling subprograms, Constraint_Error is propagated. |
| 1121 |
@end{Notes} |
| 1122 |
|
| 1123 |
@begin{Incompatible95} |
| 1124 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]} |
| 1125 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 1126 |
Overloaded versions of Index and Index_Non_Blank are newly added to |
| 1127 |
Strings.Fixed. If Strings.Fixed is referenced in a @nt{use_clause}, and an |
| 1128 |
entity @i<E> with a @nt{defining_identifier} of Index or Index_Non_Blank is |
| 1129 |
defined in a package that is also referenced in a @nt{use_clause}, the entity |
| 1130 |
@i<E> may no longer be use-visible, resulting in errors. This should be rare |
| 1131 |
and is easily fixed if it does occur.]} |
| 1132 |
@end{Incompatible95} |
| 1133 |
|
| 1134 |
@begin{DiffWord95} |
| 1135 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1136 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that Find_Token |
| 1137 |
may raise Constraint_Error if Source'First is not in Positive (which is |
| 1138 |
only possible for a null string).]} |
| 1139 |
|
| 1140 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1141 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified that Replace_Slice, |
| 1142 |
Delete, and "*" always return a string with lower bound 1.]} |
| 1143 |
@end{DiffWord95} |
| 1144 |
|
| 1145 |
|
| 1146 |
@LabeledSubClause{Bounded-Length String Handling} |
| 1147 |
@begin{Intro} |
| 1148 |
The language-defined package Strings.Bounded provides a generic package |
| 1149 |
each of whose instances yields a private type Bounded_String and a |
| 1150 |
set of operations. An object of a particular Bounded_String type |
| 1151 |
represents a String whose low bound is 1 and whose length |
| 1152 |
can vary conceptually |
| 1153 |
between 0 and a maximum size established at the |
| 1154 |
generic instantiation. |
| 1155 |
The subprograms for fixed-length string handling |
| 1156 |
are either overloaded directly for Bounded_String, or are modified as |
| 1157 |
needed to reflect the variability in length. Additionally, since the |
| 1158 |
Bounded_String type is private, appropriate constructor and selector |
| 1159 |
operations are provided. |
| 1160 |
@begin{reason} |
| 1161 |
Strings.Bounded declares an inner generic package, versus itself |
| 1162 |
being directly a generic child of Strings, in order to retain |
| 1163 |
compatibility with a version of the string-handling packages that |
| 1164 |
is generic with respect to the character and string types.@end{reason} |
| 1165 |
@begin{reason} |
| 1166 |
The bound of a bounded-length string is specified as a parameter |
| 1167 |
to a generic, versus as the value for a discriminant, because of the |
| 1168 |
inappropriateness of assignment and equality of discriminated types for |
| 1169 |
the copying and comparison of bounded strings.@end{reason} |
| 1170 |
@end{Intro} |
| 1171 |
|
| 1172 |
@begin{StaticSem} |
| 1173 |
@Leading@Keepnext@;The library package Strings.Bounded has the following declaration: |
| 1174 |
@begin{example} |
| 1175 |
@key[with] Ada.Strings.Maps; |
| 1176 |
@ChildUnit{Parent=[Ada.Strings],Child=[Bounded]}@key[package] Ada.Strings.Bounded @key[is] |
| 1177 |
@key[pragma] Preelaborate(Bounded); |
| 1178 |
|
| 1179 |
|
| 1180 |
@key[generic] |
| 1181 |
Max : Positive; --@RI{ Maximum length of a Bounded_String} |
| 1182 |
@key[package] @AdaPackDefn{Generic_Bounded_Length} @key[is] |
| 1183 |
|
| 1184 |
@AdaObjDefn{Max_Length} : @key[constant] Positive := Max; |
| 1185 |
|
| 1186 |
@key[type] @AdaTypeDefn{Bounded_String} @key[is] @key[private]; |
| 1187 |
|
| 1188 |
@AdaObjDefn{Null_Bounded_String} : @key[constant] Bounded_String; |
| 1189 |
|
| 1190 |
@key[subtype] @AdaSubtypeDefn{Name=[Length_Range],Of=[Natural]} @key[is] Natural @key[range] 0 .. Max_Length; |
| 1191 |
|
| 1192 |
@key[function] @AdaSubDefn{Length} (Source : @key[in] Bounded_String) @key[return] Length_Range; |
| 1193 |
|
| 1194 |
|
| 1195 |
--@RI{ Conversion, Concatenation, and Selection functions} |
| 1196 |
|
| 1197 |
@key[function] @AdaSubDefn{To_Bounded_String} (Source : @key[in] String; |
| 1198 |
Drop : @key[in] Truncation := Error) |
| 1199 |
@key[return] Bounded_String; |
| 1200 |
|
| 1201 |
@key[function] @AdaSubDefn{To_String} (Source : @key[in] Bounded_String) @key[return] String; |
| 1202 |
|
| 1203 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1204 |
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Set_Bounded_String} |
| 1205 |
(Target : @key[out] Bounded_String; |
| 1206 |
Source : @key[in] String; |
| 1207 |
Drop : @key[in] Truncation := Error);]} |
| 1208 |
|
| 1209 |
@key[function] @AdaSubDefn{Append} (Left, Right : @key[in] Bounded_String; |
| 1210 |
Drop : @key[in] Truncation := Error) |
| 1211 |
@key[return] Bounded_String; |
| 1212 |
|
| 1213 |
@key[function] @AdaSubDefn{Append} (Left : @key[in] Bounded_String; |
| 1214 |
Right : @key[in] String; |
| 1215 |
Drop : @key[in] Truncation := Error) |
| 1216 |
@key[return] Bounded_String; |
| 1217 |
|
| 1218 |
@key[function] @AdaSubDefn{Append} (Left : @key[in] String; |
| 1219 |
Right : @key[in] Bounded_String; |
| 1220 |
Drop : @key[in] Truncation := Error) |
| 1221 |
@key[return] Bounded_String; |
| 1222 |
|
| 1223 |
@key[function] @AdaSubDefn{Append} (Left : @key[in] Bounded_String; |
| 1224 |
Right : @key[in] Character; |
| 1225 |
Drop : @key[in] Truncation := Error) |
| 1226 |
@key[return] Bounded_String; |
| 1227 |
|
| 1228 |
@key[function] @AdaSubDefn{Append} (Left : @key[in] Character; |
| 1229 |
Right : @key[in] Bounded_String; |
| 1230 |
Drop : @key[in] Truncation := Error) |
| 1231 |
@key[return] Bounded_String; |
| 1232 |
|
| 1233 |
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Bounded_String; |
| 1234 |
New_Item : @key[in] Bounded_String; |
| 1235 |
Drop : @key[in] Truncation := Error); |
| 1236 |
|
| 1237 |
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Bounded_String; |
| 1238 |
New_Item : @key[in] String; |
| 1239 |
Drop : @key[in] Truncation := Error); |
| 1240 |
|
| 1241 |
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Bounded_String; |
| 1242 |
New_Item : @key[in] Character; |
| 1243 |
Drop : @key[in] Truncation := Error); |
| 1244 |
|
| 1245 |
@key[function] "&" (Left, Right : @key[in] Bounded_String) |
| 1246 |
@key[return] Bounded_String; |
| 1247 |
|
| 1248 |
@key[function] "&" (Left : @key[in] Bounded_String; Right : @key[in] String) |
| 1249 |
@key[return] Bounded_String; |
| 1250 |
|
| 1251 |
@key[function] "&" (Left : @key[in] String; Right : @key[in] Bounded_String) |
| 1252 |
@key[return] Bounded_String; |
| 1253 |
|
| 1254 |
@key[function] "&" (Left : @key[in] Bounded_String; Right : @key[in] Character) |
| 1255 |
@key[return] Bounded_String; |
| 1256 |
|
| 1257 |
@key[function] "&" (Left : @key[in] Character; Right : @key[in] Bounded_String) |
| 1258 |
@key[return] Bounded_String; |
| 1259 |
|
| 1260 |
|
| 1261 |
@key[function] @AdaSubDefn{Element} (Source : @key[in] Bounded_String; |
| 1262 |
Index : @key[in] Positive) |
| 1263 |
@key[return] Character; |
| 1264 |
|
| 1265 |
@key[procedure] @AdaSubDefn{Replace_Element} (Source : @key[in] @key[out] Bounded_String; |
| 1266 |
Index : @key[in] Positive; |
| 1267 |
By : @key[in] Character); |
| 1268 |
|
| 1269 |
|
| 1270 |
@key[function] @AdaSubDefn{Slice} (Source : @key[in] Bounded_String; |
| 1271 |
Low : @key[in] Positive; |
| 1272 |
High : @key[in] Natural) |
| 1273 |
@key[return] String; |
| 1274 |
|
| 1275 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1276 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Bounded_Slice} |
| 1277 |
(Source : @key[in] Bounded_String; |
| 1278 |
Low : @key[in] Positive; |
| 1279 |
High : @key[in] Natural) |
| 1280 |
@key[return] Bounded_String;]} |
| 1281 |
|
| 1282 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1283 |
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Bounded_Slice} |
| 1284 |
(Source : @key[in] Bounded_String; |
| 1285 |
Target : @key[out] Bounded_String; |
| 1286 |
Low : @key[in] Positive; |
| 1287 |
High : @key[in] Natural);]} |
| 1288 |
|
| 1289 |
@key[function] "=" (Left, Right : @key[in] Bounded_String) @key[return] Boolean; |
| 1290 |
@key[function] "=" (Left : @key[in] Bounded_String; Right : @key[in] String) |
| 1291 |
@key[return] Boolean; |
| 1292 |
|
| 1293 |
@key[function] "=" (Left : @key[in] String; Right : @key[in] Bounded_String) |
| 1294 |
@key[return] Boolean; |
| 1295 |
|
| 1296 |
|
| 1297 |
@key[function] "<" (Left, Right : @key[in] Bounded_String) @key[return] Boolean; |
| 1298 |
|
| 1299 |
@key[function] "<" (Left : @key[in] Bounded_String; Right : @key[in] String) |
| 1300 |
@key[return] Boolean; |
| 1301 |
|
| 1302 |
@key[function] "<" (Left : @key[in] String; Right : @key[in] Bounded_String) |
| 1303 |
@key[return] Boolean; |
| 1304 |
|
| 1305 |
@key[function] "<=" (Left, Right : @key[in] Bounded_String) @key[return] Boolean; |
| 1306 |
|
| 1307 |
@key[function] "<=" (Left : @key[in] Bounded_String; Right : @key[in] String) |
| 1308 |
@key[return] Boolean; |
| 1309 |
|
| 1310 |
@key[function] "<=" (Left : @key[in] String; Right : @key[in] Bounded_String) |
| 1311 |
@key[return] Boolean; |
| 1312 |
|
| 1313 |
@key[function] ">" (Left, Right : @key[in] Bounded_String) @key[return] Boolean; |
| 1314 |
|
| 1315 |
@key[function] ">" (Left : @key[in] Bounded_String; Right : @key[in] String) |
| 1316 |
@key[return] Boolean; |
| 1317 |
|
| 1318 |
@key[function] ">" (Left : @key[in] String; Right : @key[in] Bounded_String) |
| 1319 |
@key[return] Boolean; |
| 1320 |
|
| 1321 |
@key[function] ">=" (Left, Right : @key[in] Bounded_String) @key[return] Boolean; |
| 1322 |
|
| 1323 |
@key[function] ">=" (Left : @key[in] Bounded_String; Right : @key[in] String) |
| 1324 |
@key[return] Boolean; |
| 1325 |
|
| 1326 |
@key[function] ">=" (Left : @key[in] String; Right : @key[in] Bounded_String) |
| 1327 |
@key[return] Boolean; |
| 1328 |
|
| 1329 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]} |
| 1330 |
--@RI{ Search @Chg{Version=[2],New=[subprograms],Old=[functions]}} |
| 1331 |
|
| 1332 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1333 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String; |
| 1334 |
Pattern : @key[in] String; |
| 1335 |
From : @key[in] Positive; |
| 1336 |
Going : @key[in] Direction := Forward; |
| 1337 |
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity) |
| 1338 |
@key[return] Natural;]} |
| 1339 |
|
| 1340 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1341 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String; |
| 1342 |
Pattern : @key[in] String; |
| 1343 |
From : @key[in] Positive; |
| 1344 |
Going : @key[in] Direction := Forward; |
| 1345 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 1346 |
@key[return] Natural;]} |
| 1347 |
|
| 1348 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String; |
| 1349 |
Pattern : @key[in] String; |
| 1350 |
Going : @key[in] Direction := Forward; |
| 1351 |
Mapping : @key[in] Maps.Character_Mapping |
| 1352 |
:= Maps.Identity) |
| 1353 |
@key[return] Natural; |
| 1354 |
|
| 1355 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String; |
| 1356 |
Pattern : @key[in] String; |
| 1357 |
Going : @key[in] Direction := Forward; |
| 1358 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 1359 |
@key[return] Natural; |
| 1360 |
|
| 1361 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1362 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String; |
| 1363 |
Set : @key[in] Maps.Character_Set; |
| 1364 |
From : @key[in] Positive; |
| 1365 |
Test : @key[in] Membership := Inside; |
| 1366 |
Going : @key[in] Direction := Forward) |
| 1367 |
@key[return] Natural;]} |
| 1368 |
|
| 1369 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] Bounded_String; |
| 1370 |
Set : @key[in] Maps.Character_Set; |
| 1371 |
Test : @key[in] Membership := Inside; |
| 1372 |
Going : @key[in] Direction := Forward) |
| 1373 |
@key[return] Natural; |
| 1374 |
|
| 1375 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1376 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Bounded_String; |
| 1377 |
From : @key[in] Positive; |
| 1378 |
Going : @key[in] Direction := Forward) |
| 1379 |
@key[return] Natural;]} |
| 1380 |
|
| 1381 |
@key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Bounded_String; |
| 1382 |
Going : @key[in] Direction := Forward) |
| 1383 |
@key[return] Natural; |
| 1384 |
|
| 1385 |
|
| 1386 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] Bounded_String; |
| 1387 |
Pattern : @key[in] String; |
| 1388 |
Mapping : @key[in] Maps.Character_Mapping |
| 1389 |
:= Maps.Identity) |
| 1390 |
@key[return] Natural; |
| 1391 |
|
| 1392 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] Bounded_String; |
| 1393 |
Pattern : @key[in] String; |
| 1394 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 1395 |
@key[return] Natural; |
| 1396 |
|
| 1397 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] Bounded_String; |
| 1398 |
Set : @key[in] Maps.Character_Set) |
| 1399 |
@key[return] Natural; |
| 1400 |
|
| 1401 |
|
| 1402 |
@key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] Bounded_String; |
| 1403 |
Set : @key[in] Maps.Character_Set; |
| 1404 |
Test : @key[in] Membership; |
| 1405 |
First : @key[out] Positive; |
| 1406 |
Last : @key[out] Natural); |
| 1407 |
|
| 1408 |
@Keepnext@; --@RI{ String translation subprograms} |
| 1409 |
|
| 1410 |
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Bounded_String; |
| 1411 |
Mapping : @key[in] Maps.Character_Mapping) |
| 1412 |
@key[return] Bounded_String; |
| 1413 |
|
| 1414 |
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Bounded_String; |
| 1415 |
Mapping : @key[in] Maps.Character_Mapping); |
| 1416 |
|
| 1417 |
|
| 1418 |
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Bounded_String; |
| 1419 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 1420 |
@key[return] Bounded_String; |
| 1421 |
|
| 1422 |
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Bounded_String; |
| 1423 |
Mapping : @key[in] Maps.Character_Mapping_Function); |
| 1424 |
|
| 1425 |
@Keepnext@; --@RI{ String transformation subprograms} |
| 1426 |
|
| 1427 |
@key[function] @AdaSubDefn{Replace_Slice} (Source : @key[in] Bounded_String; |
| 1428 |
Low : @key[in] Positive; |
| 1429 |
High : @key[in] Natural; |
| 1430 |
By : @key[in] String; |
| 1431 |
Drop : @key[in] Truncation := Error) |
| 1432 |
@key[return] Bounded_String; |
| 1433 |
|
| 1434 |
|
| 1435 |
@key[procedure] @AdaSubDefn{Replace_Slice} (Source : @key[in] @key[out] Bounded_String; |
| 1436 |
Low : @key[in] Positive; |
| 1437 |
High : @key[in] Natural; |
| 1438 |
By : @key[in] String; |
| 1439 |
Drop : @key[in] Truncation := Error); |
| 1440 |
|
| 1441 |
|
| 1442 |
@key[function] @AdaSubDefn{Insert} (Source : @key[in] Bounded_String; |
| 1443 |
Before : @key[in] Positive; |
| 1444 |
New_Item : @key[in] String; |
| 1445 |
Drop : @key[in] Truncation := Error) |
| 1446 |
@key[return] Bounded_String; |
| 1447 |
|
| 1448 |
@key[procedure] @AdaSubDefn{Insert} (Source : @key[in] @key[out] Bounded_String; |
| 1449 |
Before : @key[in] Positive; |
| 1450 |
New_Item : @key[in] String; |
| 1451 |
Drop : @key[in] Truncation := Error); |
| 1452 |
|
| 1453 |
|
| 1454 |
@key[function] @AdaSubDefn{Overwrite} (Source : @key[in] Bounded_String; |
| 1455 |
Position : @key[in] Positive; |
| 1456 |
New_Item : @key[in] String; |
| 1457 |
Drop : @key[in] Truncation := Error) |
| 1458 |
@key[return] Bounded_String; |
| 1459 |
|
| 1460 |
@key[procedure] @AdaSubDefn{Overwrite} (Source : @key[in] @key[out] Bounded_String; |
| 1461 |
Position : @key[in] Positive; |
| 1462 |
New_Item : @key[in] String; |
| 1463 |
Drop : @key[in] Truncation := Error); |
| 1464 |
|
| 1465 |
@key[function] @AdaSubDefn{Delete} (Source : @key[in] Bounded_String; |
| 1466 |
From : @key[in] Positive; |
| 1467 |
Through : @key[in] Natural) |
| 1468 |
@key[return] Bounded_String; |
| 1469 |
|
| 1470 |
@key[procedure] @AdaSubDefn{Delete} (Source : @key[in] @key[out] Bounded_String; |
| 1471 |
From : @key[in] Positive; |
| 1472 |
Through : @key[in] Natural); |
| 1473 |
|
| 1474 |
--@RI{String selector subprograms} |
| 1475 |
|
| 1476 |
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Bounded_String; |
| 1477 |
Side : @key[in] Trim_End) |
| 1478 |
@key[return] Bounded_String; |
| 1479 |
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Bounded_String; |
| 1480 |
Side : @key[in] Trim_End); |
| 1481 |
|
| 1482 |
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Bounded_String; |
| 1483 |
Left : @key[in] Maps.Character_Set; |
| 1484 |
Right : @key[in] Maps.Character_Set) |
| 1485 |
@key[return] Bounded_String; |
| 1486 |
|
| 1487 |
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Bounded_String; |
| 1488 |
Left : @key[in] Maps.Character_Set; |
| 1489 |
Right : @key[in] Maps.Character_Set); |
| 1490 |
|
| 1491 |
@key[function] @AdaSubDefn{Head} (Source : @key[in] Bounded_String; |
| 1492 |
Count : @key[in] Natural; |
| 1493 |
Pad : @key[in] Character := Space; |
| 1494 |
Drop : @key[in] Truncation := Error) |
| 1495 |
@key[return] Bounded_String; |
| 1496 |
|
| 1497 |
@key[procedure] @AdaSubDefn{Head} (Source : @key[in] @key[out] Bounded_String; |
| 1498 |
Count : @key[in] Natural; |
| 1499 |
Pad : @key[in] Character := Space; |
| 1500 |
Drop : @key[in] Truncation := Error); |
| 1501 |
|
| 1502 |
@key[function] @AdaSubDefn{Tail} (Source : @key[in] Bounded_String; |
| 1503 |
Count : @key[in] Natural; |
| 1504 |
Pad : @key[in] Character := Space; |
| 1505 |
Drop : @key[in] Truncation := Error) |
| 1506 |
@key[return] Bounded_String; |
| 1507 |
|
| 1508 |
@key[procedure] @AdaSubDefn{Tail} (Source : @key[in] @key[out] Bounded_String; |
| 1509 |
Count : @key[in] Natural; |
| 1510 |
Pad : @key[in] Character := Space; |
| 1511 |
Drop : @key[in] Truncation := Error); |
| 1512 |
|
| 1513 |
--@RI{String constructor subprograms} |
| 1514 |
|
| 1515 |
@key[function] "*" (Left : @key[in] Natural; |
| 1516 |
Right : @key[in] Character) |
| 1517 |
@key[return] Bounded_String; |
| 1518 |
|
| 1519 |
@key[function] "*" (Left : @key[in] Natural; |
| 1520 |
Right : @key[in] String) |
| 1521 |
@key[return] Bounded_String; |
| 1522 |
|
| 1523 |
@key[function] "*" (Left : @key[in] Natural; |
| 1524 |
Right : @key[in] Bounded_String) |
| 1525 |
@key[return] Bounded_String; |
| 1526 |
|
| 1527 |
|
| 1528 |
@key[function] @AdaSubDefn{Replicate} (Count : @key[in] Natural; |
| 1529 |
Item : @key[in] Character; |
| 1530 |
Drop : @key[in] Truncation := Error) |
| 1531 |
@key[return] Bounded_String; |
| 1532 |
|
| 1533 |
@key[function] @AdaSubDefn{Replicate} (Count : @key[in] Natural; |
| 1534 |
Item : @key[in] String; |
| 1535 |
Drop : @key[in] Truncation := Error) |
| 1536 |
@key[return] Bounded_String; |
| 1537 |
|
| 1538 |
@key[function] @AdaSubDefn{Replicate} (Count : @key[in] Natural; |
| 1539 |
Item : @key[in] Bounded_String; |
| 1540 |
Drop : @key[in] Truncation := Error) |
| 1541 |
@key[return] Bounded_String; |
| 1542 |
|
| 1543 |
@key[private] |
| 1544 |
... -- @RI{not specified by the language} |
| 1545 |
@key[end] Generic_Bounded_Length; |
| 1546 |
|
| 1547 |
@key[end] Ada.Strings.Bounded; |
| 1548 |
@end{example} |
| 1549 |
|
| 1550 |
@begin{ImplNote} |
| 1551 |
@ChgRef{Version=[1],Kind=[Added],Ref=[8652/0097],ARef=[AI95-00115-01]} |
| 1552 |
@ChgRef{Version=[2],Kind=[DeletedAdded],ARef=[AI95-00344-01]} |
| 1553 |
@ChgDeleted{Version=[2],Text=[@Chg{Version=[1],New=[Bounded_String cannot be |
| 1554 |
implemented as a (directly) controlled type, |
| 1555 |
as Ada.Strings.Bounded.Generic_Bounded_Length can be instantiated at any |
| 1556 |
nesting depth. Bounded_String could have |
| 1557 |
a component of a controlled type, as long as that type is declared in some |
| 1558 |
other (non-generic) package (including directly in Ada.Strings.Bounded).],Old=[]}]} |
| 1559 |
@ChgNote{AI-344 allows controlled types to be declared at |
| 1560 |
any nesting depth, so this note is obsolete.} |
| 1561 |
|
| 1562 |
@end{ImplNote} |
| 1563 |
|
| 1564 |
Null_Bounded_String represents the null string. |
| 1565 |
If an object of type Bounded_String is not otherwise initialized, it |
| 1566 |
will be initialized to the same value as Null_Bounded_String. |
| 1567 |
@begin{DescribeCode} |
| 1568 |
@begin{Example}@Keepnext |
| 1569 |
@key[function] Length (Source : @key[in] Bounded_String) @key[return] Length_Range; |
| 1570 |
@end{Example} |
| 1571 |
@Trailing@;The Length function returns the length of the string represented by |
| 1572 |
Source. |
| 1573 |
|
| 1574 |
@begin{Example}@Keepnext |
| 1575 |
@key[function] To_Bounded_String (Source : @key[in] String; |
| 1576 |
Drop : @key[in] Truncation := Error) |
| 1577 |
@key[return] Bounded_String; |
| 1578 |
@end{Example} |
| 1579 |
@Leading@;If Source'Length <= Max_Length then this function |
| 1580 |
returns a Bounded_String that represents Source. |
| 1581 |
Otherwise the effect depends on the value of Drop: |
| 1582 |
@begin{itemize} |
| 1583 |
If Drop=Left, then |
| 1584 |
the result is a Bounded_String that represents the string comprising |
| 1585 |
the rightmost Max_Length characters of Source. |
| 1586 |
|
| 1587 |
If Drop=Right, then |
| 1588 |
the result is a Bounded_String that represents the string comprising |
| 1589 |
the leftmost Max_Length characters of Source. |
| 1590 |
|
| 1591 |
@Trailing@;If Drop=Error, then Strings.Length_Error is propagated. |
| 1592 |
@end{itemize} |
| 1593 |
|
| 1594 |
@begin{Example}@Keepnext |
| 1595 |
@key[function] To_String (Source : @key[in] Bounded_String) @key[return] String; |
| 1596 |
@end{Example} |
| 1597 |
@Trailing@;To_String returns the String value with lower bound 1 represented by |
| 1598 |
Source. If B is a Bounded_String, then B = To_Bounded_String(To_String(B)). |
| 1599 |
|
| 1600 |
@begin{Example} |
| 1601 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1602 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key[procedure] Set_Bounded_String |
| 1603 |
(Target : @key[out] Bounded_String; |
| 1604 |
Source : @key[in] String; |
| 1605 |
Drop : @key[in] Truncation := Error);]} |
| 1606 |
@end{Example} |
| 1607 |
|
| 1608 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1609 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Target := To_Bounded_String (Source, Drop);]} |
| 1610 |
|
| 1611 |
@end{DescribeCode} |
| 1612 |
|
| 1613 |
Each of the Append functions returns a Bounded_String obtained by concatenating |
| 1614 |
the string or character given or represented by one of the parameters, |
| 1615 |
with the string or character given or represented by the other parameter, |
| 1616 |
and applying To_Bounded_String to the concatenation result string, |
| 1617 |
with Drop as provided to the Append function. |
| 1618 |
|
| 1619 |
Each of the procedures Append(Source, New_Item, Drop) has the same |
| 1620 |
effect as the corresponding assignment Source := |
| 1621 |
Append(Source, New_Item, Drop). |
| 1622 |
|
| 1623 |
Each of the "&" functions has the same effect as the corresponding |
| 1624 |
Append function, with Error as the Drop parameter. |
| 1625 |
@begin{DescribeCode} |
| 1626 |
@begin{Example}@Keepnext |
| 1627 |
@key[function] Element (Source : @key[in] Bounded_String; |
| 1628 |
Index : @key[in] Positive) |
| 1629 |
@key[return] Character; |
| 1630 |
@end{Example} |
| 1631 |
@Trailing@;Returns the character at position Index in the string represented |
| 1632 |
by Source; propagates Index_Error if Index > Length(Source). |
| 1633 |
|
| 1634 |
@begin{Example}@Keepnext |
| 1635 |
@key[procedure] Replace_Element (Source : @key[in] @key[out] Bounded_String; |
| 1636 |
Index : @key[in] Positive; |
| 1637 |
By : @key[in] Character); |
| 1638 |
@end{Example} |
| 1639 |
@Trailing@;Updates Source such that the character at position Index in the |
| 1640 |
string represented by Source is By; |
| 1641 |
propagates Index_Error if Index > Length(Source). |
| 1642 |
|
| 1643 |
@begin{Example}@Keepnext |
| 1644 |
@key[function] Slice (Source : @key[in] Bounded_String; |
| 1645 |
Low : @key[in] Positive; |
| 1646 |
High : @key[in] Natural) |
| 1647 |
@key[return] String; |
| 1648 |
@end{Example} |
| 1649 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1650 |
@ChgRef{Version=[1],Kind=[Revised],ARef=[AI95-00238-01]} |
| 1651 |
@Trailing@;Returns the slice at positions Low through High in the string |
| 1652 |
represented by Source; propagates Index_Error if |
| 1653 |
Low > Length(Source)+1@Chg{New=[ or High > Length(Source)],Old=[]}.@Chg{Version=[2], |
| 1654 |
New=[ The bounds of the returned string are Low and High.],Old=[]}. |
| 1655 |
|
| 1656 |
@begin{Example} |
| 1657 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1658 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key[function] Bounded_Slice |
| 1659 |
(Source : @key[in] Bounded_String; |
| 1660 |
Low : @key[in] Positive; |
| 1661 |
High : @key[in] Natural) |
| 1662 |
@key[return] Bounded_String;]} |
| 1663 |
@end{Example} |
| 1664 |
|
| 1665 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1666 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns the slice at positions Low |
| 1667 |
through High in the string represented by Source as a bounded string; |
| 1668 |
propagates Index_Error if Low > Length(Source)+1 or High > Length(Source).]} |
| 1669 |
|
| 1670 |
@begin{Example} |
| 1671 |
@ChgRef{Version=[2],Kind=[Added]} |
| 1672 |
@ChgAdded{Version=[2],KeepNext=[T],Text=[@key[procedure] Bounded_Slice |
| 1673 |
(Source : @key[in] Bounded_String; |
| 1674 |
Target : @key[out] Bounded_String; |
| 1675 |
Low : @key[in] Positive; |
| 1676 |
High : @key[in] Natural);]} |
| 1677 |
@end{Example} |
| 1678 |
|
| 1679 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1680 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Equivalent to Target := Bounded_Slice (Source, Low, High);]} |
| 1681 |
|
| 1682 |
@end{DescribeCode} |
| 1683 |
|
| 1684 |
Each of the functions "=", "<", ">", "<=", and ">=" |
| 1685 |
returns the same result as the corresponding String |
| 1686 |
operation applied to the String values given or represented by |
| 1687 |
the two parameters. |
| 1688 |
|
| 1689 |
Each of the search subprograms (Index, Index_Non_Blank, |
| 1690 |
Count, Find_Token) has the |
| 1691 |
same effect as the corresponding subprogram in Strings.Fixed applied |
| 1692 |
to the string represented by the Bounded_String parameter. |
| 1693 |
|
| 1694 |
Each of the Translate subprograms, when applied to a Bounded_String, has |
| 1695 |
an analogous effect to the corresponding subprogram in Strings.Fixed. |
| 1696 |
For the Translate function, |
| 1697 |
the translation is applied to the string represented by the Bounded_String |
| 1698 |
parameter, and the result is converted (via To_Bounded_String) to a |
| 1699 |
Bounded_String. |
| 1700 |
For the Translate procedure, the string represented by the Bounded_String |
| 1701 |
parameter after the translation is given by the Translate function for |
| 1702 |
fixed-length strings applied to the string represented by the |
| 1703 |
original value of the parameter. |
| 1704 |
|
| 1705 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1706 |
Each of the transformation subprograms (Replace_Slice, Insert, |
| 1707 |
Overwrite, Delete), selector subprograms (Trim, Head, Tail), |
| 1708 |
and constructor functions ("*") has an effect based on its |
| 1709 |
corresponding subprogram in Strings.Fixed, and Replicate is based on |
| 1710 |
Fixed."*". @Chg{New=[In the case of a function], |
| 1711 |
Old=[For each of these subprograms]}, the corresponding |
| 1712 |
fixed-length string subprogram is applied to the string represented by |
| 1713 |
the Bounded_String parameter. To_Bounded_String is applied the result |
| 1714 |
string, with Drop (or Error in the case of Generic_Bounded_Length."*") |
| 1715 |
determining the effect when the string length exceeds Max_Length. |
| 1716 |
@Chg{New=[In the case of a procedure, the corresponding function in |
| 1717 |
Strings.@!Bounded.@!Generic_@!Bounded_@!Length is applied, with the result |
| 1718 |
assigned into the Source parameter.],Old=[]} |
| 1719 |
@begin{Ramification} |
| 1720 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00114-01]} |
| 1721 |
The "/=" operations between Bounded_String and String, and between String |
| 1722 |
and Bounded_String, are automatically defined based on the @Chg{Version=[2], |
| 1723 |
New=[corresponding],Old=[corrsponding]} |
| 1724 |
"=" operations. |
| 1725 |
@end{Ramification} |
| 1726 |
@end{StaticSem} |
| 1727 |
|
| 1728 |
@begin{ImplAdvice} |
| 1729 |
Bounded string objects should not be implemented by implicit |
| 1730 |
pointers and dynamic allocation. |
| 1731 |
@ChgImplAdvice{Version=[2],Kind=[Added],Text=[@ChgAdded{Version=[2], |
| 1732 |
Text=[Bounded string objects should not be implemented by implicit |
| 1733 |
pointers and dynamic allocation.]}]} |
| 1734 |
@begin{ImplNote} |
| 1735 |
@Leading@;The following is a possible implementation of the private part |
| 1736 |
of the package: |
| 1737 |
@begin{example} |
| 1738 |
@key[type] Bounded_String_Internals (Length : Length_Range := 0) @key[is] |
| 1739 |
@key[record] |
| 1740 |
Data : String(1..Length); |
| 1741 |
@key[end] @key[record]; |
| 1742 |
|
| 1743 |
@key[type] Bounded_String @key[is] |
| 1744 |
@key[record] |
| 1745 |
Data : Bounded_String_Internals; --@RI{ Unconstrained} |
| 1746 |
@key[end] @key[record]; |
| 1747 |
|
| 1748 |
Null_Bounded_String : @key[constant] Bounded_String := |
| 1749 |
(Data => (Length => 0, |
| 1750 |
Data => (1..0 => ' '))); |
| 1751 |
@end{example} |
| 1752 |
@end{ImplNote} |
| 1753 |
@end{ImplAdvice} |
| 1754 |
|
| 1755 |
|
| 1756 |
@begin{Inconsistent95} |
| 1757 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00238-01]} |
| 1758 |
@ChgAdded{Version=[2],Text=[@Defn{inconsistencies with Ada 95} |
| 1759 |
@B[Amendment Correction:] The bounds of the string returned from |
| 1760 |
Slice are now defined. This is technically an inconsistency; if a program |
| 1761 |
depended on some other lower bound for the string returned from Slice, |
| 1762 |
it could fail when compiled with Ada 2005. Such code is not portable even |
| 1763 |
between Ada 95 implementations, so it should be very rare.]} |
| 1764 |
@end{Inconsistent95} |
| 1765 |
|
| 1766 |
@begin{Incompatible95} |
| 1767 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]} |
| 1768 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 1769 |
Procedure Set_Bounded_String, two Bounded_Slice subprograms, and overloaded |
| 1770 |
versions of Index and Index_Non_Blank are newly added to Strings.Bounded. |
| 1771 |
If Strings.Bounded is |
| 1772 |
referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 1773 |
@nt{defining_identifier} as a new entity in Strings.Bounded is defined in a |
| 1774 |
package that is also referenced in a @nt{use_clause}, the entity @i<E> may no |
| 1775 |
longer be use-visible, resulting in errors. This should be rare and is easily |
| 1776 |
fixed if it does occur.]} |
| 1777 |
@end{Incompatible95} |
| 1778 |
|
| 1779 |
@begin{DiffWord95} |
| 1780 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1781 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the conditions for |
| 1782 |
which Slice raises Index_Error.]} |
| 1783 |
|
| 1784 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0049],ARef=[AI95-00128-01]} |
| 1785 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Clarified the meaning of |
| 1786 |
transformation, selector, and constructor subprograms by describing the |
| 1787 |
effects of procedures and functions separately.]} |
| 1788 |
@end{DiffWord95} |
| 1789 |
|
| 1790 |
|
| 1791 |
@LabeledSubClause{Unbounded-Length String Handling} |
| 1792 |
@begin{Intro} |
| 1793 |
The language-defined package Strings.Unbounded provides a |
| 1794 |
private type Unbounded_String and a |
| 1795 |
set of operations. An object of type Unbounded_String represents a String |
| 1796 |
whose low bound is 1 and whose length |
| 1797 |
can vary conceptually between 0 and Natural'Last. |
| 1798 |
The subprograms for fixed-length string handling |
| 1799 |
are either overloaded directly for Unbounded_String, or are modified as |
| 1800 |
needed to reflect the flexibility in length. Since the |
| 1801 |
Unbounded_String type is private, relevant constructor and selector |
| 1802 |
operations are provided. |
| 1803 |
@begin{reason} |
| 1804 |
The transformation operations for fixed- and bounded-length strings that |
| 1805 |
are not necessarily length preserving are supplied for Unbounded_String |
| 1806 |
as procedures as well as functions. |
| 1807 |
This allows an implementation to do an initial allocation for |
| 1808 |
an unbounded string and to avoid further allocations as long |
| 1809 |
as the length does not exceed the allocated length. |
| 1810 |
@end{reason} |
| 1811 |
@end{Intro} |
| 1812 |
|
| 1813 |
@begin{StaticSem} |
| 1814 |
@Leading@;The library package Strings.Unbounded has the following declaration: |
| 1815 |
@begin{example} |
| 1816 |
@key[with] Ada.Strings.Maps; |
| 1817 |
@ChildUnit{Parent=[Ada.Strings],Child=[Unbounded]}@key[package] Ada.Strings.Unbounded @key[is] |
| 1818 |
@key[pragma] Preelaborate(Unbounded); |
| 1819 |
|
| 1820 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]} |
| 1821 |
@key[type] @AdaTypeDefn{Unbounded_String} @key[is] @key[private];@Chg{Version=[2],New=[ |
| 1822 |
@key[pragma] Preelaborable_Initialization(Unbounded_String);],Old=[]} |
| 1823 |
|
| 1824 |
@AdaObjDefn{Null_Unbounded_String} : @key[constant] Unbounded_String; |
| 1825 |
|
| 1826 |
@key[function] @AdaSubDefn{Length} (Source : @key[in] Unbounded_String) @key[return] Natural; |
| 1827 |
|
| 1828 |
@key[type] @AdaTypeDefn{String_Access} @key[is] @key[access] @key[all] String; |
| 1829 |
@key[procedure] @AdaSubDefn{Free} (X : @key[in] @key[out] String_Access); |
| 1830 |
|
| 1831 |
--@RI{ Conversion, Concatenation, and Selection functions} |
| 1832 |
|
| 1833 |
@key[function] @AdaSubDefn{To_Unbounded_String} (Source : @key[in] String) |
| 1834 |
@key[return] Unbounded_String; |
| 1835 |
|
| 1836 |
@key[function] @AdaSubDefn{To_Unbounded_String} (Length : @key[in] Natural) |
| 1837 |
@key[return] Unbounded_String; |
| 1838 |
|
| 1839 |
@key[function] @AdaSubDefn{To_String} (Source : @key[in] Unbounded_String) @key[return] String; |
| 1840 |
|
| 1841 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1842 |
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Set_Unbounded_String} |
| 1843 |
(Target : @key[out] Unbounded_String; |
| 1844 |
Source : @key[in] String);]} |
| 1845 |
|
| 1846 |
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Unbounded_String; |
| 1847 |
New_Item : @key[in] Unbounded_String); |
| 1848 |
|
| 1849 |
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Unbounded_String; |
| 1850 |
New_Item : @key[in] String); |
| 1851 |
|
| 1852 |
@key[procedure] @AdaSubDefn{Append} (Source : @key[in out] Unbounded_String; |
| 1853 |
New_Item : @key[in] Character); |
| 1854 |
|
| 1855 |
@key[function] "&" (Left, Right : @key[in] Unbounded_String) |
| 1856 |
@key[return] Unbounded_String; |
| 1857 |
|
| 1858 |
@key[function] "&" (Left : @key[in] Unbounded_String; Right : @key[in] String) |
| 1859 |
@key[return] Unbounded_String; |
| 1860 |
|
| 1861 |
@key[function] "&" (Left : @key[in] String; Right : @key[in] Unbounded_String) |
| 1862 |
@key[return] Unbounded_String; |
| 1863 |
|
| 1864 |
@key[function] "&" (Left : @key[in] Unbounded_String; Right : @key[in] Character) |
| 1865 |
@key[return] Unbounded_String; |
| 1866 |
|
| 1867 |
@key[function] "&" (Left : @key[in] Character; Right : @key[in] Unbounded_String) |
| 1868 |
@key[return] Unbounded_String; |
| 1869 |
|
| 1870 |
|
| 1871 |
@key[function] @AdaSubDefn{Element} (Source : @key[in] Unbounded_String; |
| 1872 |
Index : @key[in] Positive) |
| 1873 |
@key[return] Character; |
| 1874 |
|
| 1875 |
@key[procedure] @AdaSubDefn{Replace_Element} (Source : @key[in] @key[out] Unbounded_String; |
| 1876 |
Index : @key[in] Positive; |
| 1877 |
By : @key[in] Character); |
| 1878 |
|
| 1879 |
|
| 1880 |
@key[function] @AdaSubDefn{Slice} (Source : @key[in] Unbounded_String; |
| 1881 |
Low : @key[in] Positive; |
| 1882 |
High : @key[in] Natural) |
| 1883 |
@key[return] String; |
| 1884 |
|
| 1885 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1886 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Unbounded_Slice} |
| 1887 |
(Source : @key[in] Unbounded_String; |
| 1888 |
Low : @key[in] Positive; |
| 1889 |
High : @key[in] Natural) |
| 1890 |
@key[return] Unbounded_String;]} |
| 1891 |
|
| 1892 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1893 |
@ChgAdded{Version=[2],Text=[ @key[procedure] @AdaSubDefn{Unbounded_Slice} |
| 1894 |
(Source : @key[in] Unbounded_String; |
| 1895 |
Target : @key[out] Unbounded_String; |
| 1896 |
Low : @key[in] Positive; |
| 1897 |
High : @key[in] Natural);]} |
| 1898 |
|
| 1899 |
@key[function] "=" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean; |
| 1900 |
|
| 1901 |
@key[function] "=" (Left : @key[in] Unbounded_String; Right : @key[in] String) |
| 1902 |
@key[return] Boolean; |
| 1903 |
|
| 1904 |
@key[function] "=" (Left : @key[in] String; Right : @key[in] Unbounded_String) |
| 1905 |
@key[return] Boolean; |
| 1906 |
|
| 1907 |
@key[function] "<" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean; |
| 1908 |
|
| 1909 |
@key[function] "<" (Left : @key[in] Unbounded_String; Right : @key[in] String) |
| 1910 |
@key[return] Boolean; |
| 1911 |
|
| 1912 |
@key[function] "<" (Left : @key[in] String; Right : @key[in] Unbounded_String) |
| 1913 |
@key[return] Boolean; |
| 1914 |
|
| 1915 |
@key[function] "<=" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean; |
| 1916 |
|
| 1917 |
@key[function] "<=" (Left : @key[in] Unbounded_String; Right : @key[in] String) |
| 1918 |
@key[return] Boolean; |
| 1919 |
|
| 1920 |
@key[function] "<=" (Left : @key[in] String; Right : @key[in] Unbounded_String) |
| 1921 |
@key[return] Boolean; |
| 1922 |
|
| 1923 |
@key[function] ">" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean; |
| 1924 |
|
| 1925 |
@key[function] ">" (Left : @key[in] Unbounded_String; Right : @key[in] String) |
| 1926 |
@key[return] Boolean; |
| 1927 |
|
| 1928 |
@key[function] ">" (Left : @key[in] String; Right : @key[in] Unbounded_String) |
| 1929 |
@key[return] Boolean; |
| 1930 |
|
| 1931 |
@key[function] ">=" (Left, Right : @key[in] Unbounded_String) @key[return] Boolean; |
| 1932 |
|
| 1933 |
@key[function] ">=" (Left : @key[in] Unbounded_String; Right : @key[in] String) |
| 1934 |
@key[return] Boolean; |
| 1935 |
|
| 1936 |
@key[function] ">=" (Left : @key[in] String; Right : @key[in] Unbounded_String) |
| 1937 |
@key[return] Boolean; |
| 1938 |
|
| 1939 |
|
| 1940 |
--@RI{ Search subprograms} |
| 1941 |
|
| 1942 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1943 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String; |
| 1944 |
Pattern : @key[in] String; |
| 1945 |
From : @key[in] Positive; |
| 1946 |
Going : @key[in] Direction := Forward; |
| 1947 |
Mapping : @key[in] Maps.Character_Mapping := Maps.Identity) |
| 1948 |
@key[return] Natural;]} |
| 1949 |
|
| 1950 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1951 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String; |
| 1952 |
Pattern : @key[in] String; |
| 1953 |
From : @key[in] Positive; |
| 1954 |
Going : @key[in] Direction := Forward; |
| 1955 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 1956 |
@key[return] Natural;]} |
| 1957 |
|
| 1958 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String; |
| 1959 |
Pattern : @key[in] String; |
| 1960 |
Going : @key[in] Direction := Forward; |
| 1961 |
Mapping : @key[in] Maps.Character_Mapping |
| 1962 |
:= Maps.Identity) |
| 1963 |
@key[return] Natural; |
| 1964 |
|
| 1965 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String; |
| 1966 |
Pattern : @key[in] String; |
| 1967 |
Going : @key[in] Direction := Forward; |
| 1968 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 1969 |
@key[return] Natural; |
| 1970 |
|
| 1971 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1972 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String; |
| 1973 |
Set : @key[in] Maps.Character_Set; |
| 1974 |
From : @key[in] Positive; |
| 1975 |
Test : @key[in] Membership := Inside; |
| 1976 |
Going : @key[in] Direction := Forward) |
| 1977 |
@key[return] Natural;]} |
| 1978 |
|
| 1979 |
@key[function] @AdaSubDefn{Index} (Source : @key[in] Unbounded_String; |
| 1980 |
Set : @key[in] Maps.Character_Set; |
| 1981 |
Test : @key[in] Membership := Inside; |
| 1982 |
Going : @key[in] Direction := Forward) @key[return] Natural; |
| 1983 |
|
| 1984 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 1985 |
@ChgAdded{Version=[2],Text=[ @key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Unbounded_String; |
| 1986 |
From : @key[in] Positive; |
| 1987 |
Going : @key[in] Direction := Forward) |
| 1988 |
@key[return] Natural;]} |
| 1989 |
|
| 1990 |
@key[function] @AdaSubDefn{Index_Non_Blank} (Source : @key[in] Unbounded_String; |
| 1991 |
Going : @key[in] Direction := Forward) |
| 1992 |
@key[return] Natural; |
| 1993 |
|
| 1994 |
|
| 1995 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] Unbounded_String; |
| 1996 |
Pattern : @key[in] String; |
| 1997 |
Mapping : @key[in] Maps.Character_Mapping |
| 1998 |
:= Maps.Identity) |
| 1999 |
@key[return] Natural; |
| 2000 |
|
| 2001 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] Unbounded_String; |
| 2002 |
Pattern : @key[in] String; |
| 2003 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 2004 |
@key[return] Natural; |
| 2005 |
|
| 2006 |
@key[function] @AdaSubDefn{Count} (Source : @key[in] Unbounded_String; |
| 2007 |
Set : @key[in] Maps.Character_Set) |
| 2008 |
@key[return] Natural; |
| 2009 |
|
| 2010 |
|
| 2011 |
@key[procedure] @AdaSubDefn{Find_Token} (Source : @key[in] Unbounded_String; |
| 2012 |
Set : @key[in] Maps.Character_Set; |
| 2013 |
Test : @key[in] Membership; |
| 2014 |
First : @key[out] Positive; |
| 2015 |
Last : @key[out] Natural); |
| 2016 |
|
| 2017 |
|
| 2018 |
@Keepnext@;--@RI{ String translation subprograms} |
| 2019 |
|
| 2020 |
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Unbounded_String; |
| 2021 |
Mapping : @key[in] Maps.Character_Mapping) |
| 2022 |
@key[return] Unbounded_String; |
| 2023 |
|
| 2024 |
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Unbounded_String; |
| 2025 |
Mapping : @key[in] Maps.Character_Mapping); |
| 2026 |
|
| 2027 |
@key[function] @AdaSubDefn{Translate} (Source : @key[in] Unbounded_String; |
| 2028 |
Mapping : @key[in] Maps.Character_Mapping_Function) |
| 2029 |
@key[return] Unbounded_String; |
| 2030 |
|
| 2031 |
@key[procedure] @AdaSubDefn{Translate} (Source : @key[in] @key[out] Unbounded_String; |
| 2032 |
Mapping : @key[in] Maps.Character_Mapping_Function); |
| 2033 |
|
| 2034 |
@Keepnext@;--@RI{ String transformation subprograms} |
| 2035 |
|
| 2036 |
@key[function] @AdaSubDefn{Replace_Slice} (Source : @key[in] Unbounded_String; |
| 2037 |
Low : @key[in] Positive; |
| 2038 |
High : @key[in] Natural; |
| 2039 |
By : @key[in] String) |
| 2040 |
@key[return] Unbounded_String; |
| 2041 |
|
| 2042 |
@key[procedure] @AdaSubDefn{Replace_Slice} (Source : @key[in] @key[out] Unbounded_String; |
| 2043 |
Low : @key[in] Positive; |
| 2044 |
High : @key[in] Natural; |
| 2045 |
By : @key[in] String); |
| 2046 |
|
| 2047 |
@key[function] @AdaSubDefn{Insert} (Source : @key[in] Unbounded_String; |
| 2048 |
Before : @key[in] Positive; |
| 2049 |
New_Item : @key[in] String) |
| 2050 |
@key[return] Unbounded_String; |
| 2051 |
|
| 2052 |
@key[procedure] @AdaSubDefn{Insert} (Source : @key[in] @key[out] Unbounded_String; |
| 2053 |
Before : @key[in] Positive; |
| 2054 |
New_Item : @key[in] String); |
| 2055 |
|
| 2056 |
@key[function] @AdaSubDefn{Overwrite} (Source : @key[in] Unbounded_String; |
| 2057 |
Position : @key[in] Positive; |
| 2058 |
New_Item : @key[in] String) |
| 2059 |
@key[return] Unbounded_String; |
| 2060 |
|
| 2061 |
@key[procedure] @AdaSubDefn{Overwrite} (Source : @key[in] @key[out] Unbounded_String; |
| 2062 |
Position : @key[in] Positive; |
| 2063 |
New_Item : @key[in] String); |
| 2064 |
|
| 2065 |
@key[function] @AdaSubDefn{Delete} (Source : @key[in] Unbounded_String; |
| 2066 |
From : @key[in] Positive; |
| 2067 |
Through : @key[in] Natural) |
| 2068 |
@key[return] Unbounded_String; |
| 2069 |
|
| 2070 |
@key[procedure] @AdaSubDefn{Delete} (Source : @key[in] @key[out] Unbounded_String; |
| 2071 |
From : @key[in] Positive; |
| 2072 |
Through : @key[in] Natural); |
| 2073 |
|
| 2074 |
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Unbounded_String; |
| 2075 |
Side : @key[in] Trim_End) |
| 2076 |
@key[return] Unbounded_String; |
| 2077 |
|
| 2078 |
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Unbounded_String; |
| 2079 |
Side : @key[in] Trim_End); |
| 2080 |
|
| 2081 |
@key[function] @AdaSubDefn{Trim} (Source : @key[in] Unbounded_String; |
| 2082 |
Left : @key[in] Maps.Character_Set; |
| 2083 |
Right : @key[in] Maps.Character_Set) |
| 2084 |
@key[return] Unbounded_String; |
| 2085 |
|
| 2086 |
@key[procedure] @AdaSubDefn{Trim} (Source : @key[in] @key[out] Unbounded_String; |
| 2087 |
Left : @key[in] Maps.Character_Set; |
| 2088 |
Right : @key[in] Maps.Character_Set); |
| 2089 |
|
| 2090 |
|
| 2091 |
@key[function] @AdaSubDefn{Head} (Source : @key[in] Unbounded_String; |
| 2092 |
Count : @key[in] Natural; |
| 2093 |
Pad : @key[in] Character := Space) |
| 2094 |
@key[return] Unbounded_String; |
| 2095 |
|
| 2096 |
@key[procedure] @AdaSubDefn{Head} (Source : @key[in] @key[out] Unbounded_String; |
| 2097 |
Count : @key[in] Natural; |
| 2098 |
Pad : @key[in] Character := Space); |
| 2099 |
|
| 2100 |
@key[function] @AdaSubDefn{Tail} (Source : @key[in] Unbounded_String; |
| 2101 |
Count : @key[in] Natural; |
| 2102 |
Pad : @key[in] Character := Space) |
| 2103 |
@key[return] Unbounded_String; |
| 2104 |
|
| 2105 |
@key[procedure] @AdaSubDefn{Tail} (Source : @key[in] @key[out] Unbounded_String; |
| 2106 |
Count : @key[in] Natural; |
| 2107 |
Pad : @key[in] Character := Space); |
| 2108 |
|
| 2109 |
@key[function] "*" (Left : @key[in] Natural; |
| 2110 |
Right : @key[in] Character) |
| 2111 |
@key[return] Unbounded_String; |
| 2112 |
|
| 2113 |
@key[function] "*" (Left : @key[in] Natural; |
| 2114 |
Right : @key[in] String) |
| 2115 |
@key[return] Unbounded_String; |
| 2116 |
|
| 2117 |
@key[function] "*" (Left : @key[in] Natural; |
| 2118 |
Right : @key[in] Unbounded_String) |
| 2119 |
@key[return] Unbounded_String; |
| 2120 |
|
| 2121 |
@key[private] |
| 2122 |
... -- @RI{not specified by the language} |
| 2123 |
@key[end] Ada.Strings.Unbounded; |
| 2124 |
@end{example} |
| 2125 |
|
| 2126 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00360-01]} |
| 2127 |
@ChgAdded{Version=[2],Text=[The type Unbounded_String needs finalization |
| 2128 |
(see @RefSecNum{User-Defined Assignment and Finalization}).]} |
| 2129 |
|
| 2130 |
Null_Unbounded_String represents the null String. |
| 2131 |
If an object of type Unbounded_String is not otherwise initialized, it |
| 2132 |
will be initialized to the same value as Null_Unbounded_String. |
| 2133 |
|
| 2134 |
The function Length returns the length of the String represented by Source. |
| 2135 |
|
| 2136 |
The type String_Access provides a (non-private) access type for explicit |
| 2137 |
processing of unbounded-length strings. The procedure Free performs |
| 2138 |
an unchecked deallocation of an object of type String_Access. |
| 2139 |
|
| 2140 |
The function To_Unbounded_String(Source : in String) |
| 2141 |
returns an Unbounded_String that represents Source. |
| 2142 |
The function To_Unbounded_String(Length : in Natural) |
| 2143 |
returns an Unbounded_String that represents an uninitialized String |
| 2144 |
whose length is Length. |
| 2145 |
|
| 2146 |
@Leading@;The function To_String returns the String with lower bound 1 |
| 2147 |
represented by Source. To_String and To_Unbounded_String are related as follows: |
| 2148 |
@begin{itemize} |
| 2149 |
If S is a String, then To_String(To_Unbounded_String(S)) = S. |
| 2150 |
|
| 2151 |
If U is an Unbounded_String, then To_Unbounded_String(To_String(U)) = U. |
| 2152 |
@end{itemize} |
| 2153 |
|
| 2154 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 2155 |
@ChgAdded{Version=[2],Text=[The procedure Set_Unbounded_String sets Target to an Unbounded_String that |
| 2156 |
represents Source.]} |
| 2157 |
|
| 2158 |
For each of the Append procedures, |
| 2159 |
the resulting string represented by the Source parameter is given |
| 2160 |
by the concatenation of the original value of Source and the value |
| 2161 |
of New_Item. |
| 2162 |
|
| 2163 |
Each of the "&" functions returns an Unbounded_String obtained by concatenating |
| 2164 |
the string or character given or represented by one of the parameters, |
| 2165 |
with the string or character given or represented by the other parameter, |
| 2166 |
and applying To_Unbounded_String to the concatenation result string. |
| 2167 |
|
| 2168 |
The Element, Replace_Element, and Slice subprograms have the same effect |
| 2169 |
as the corresponding bounded-length string subprograms. |
| 2170 |
|
| 2171 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 2172 |
@ChgAdded{Version=[2],Text=[The function Unbounded_Slice returns the slice at |
| 2173 |
positions Low through High in the string represented by Source as an |
| 2174 |
Unbounded_String. The procedure Unbounded_Slice sets Target to the |
| 2175 |
Unbounded_String representing the slice at positions Low through High in the |
| 2176 |
string represented by Source. Both routines propagate Index_Error if Low > |
| 2177 |
Length(Source)+1 or High > Length(Source).]} |
| 2178 |
|
| 2179 |
Each of the functions "=", "<", ">", "<=", and ">=" |
| 2180 |
returns the same result as the corresponding String |
| 2181 |
operation applied to the String values given or represented by Left and Right. |
| 2182 |
|
| 2183 |
Each of the search subprograms (Index, Index_Non_Blank, Count, Find_Token) |
| 2184 |
has the same effect as the corresponding subprogram in Strings.Fixed applied |
| 2185 |
to the string represented by the Unbounded_String parameter. |
| 2186 |
|
| 2187 |
The Translate function has |
| 2188 |
an analogous effect to the corresponding subprogram in Strings.Fixed. |
| 2189 |
The translation is applied to the string represented by the Unbounded_String |
| 2190 |
parameter, and the result is converted (via To_Unbounded_String) to an |
| 2191 |
Unbounded_String. |
| 2192 |
|
| 2193 |
Each of the transformation functions (Replace_Slice, Insert, Overwrite, |
| 2194 |
Delete), selector functions (Trim, Head, Tail), and constructor functions |
| 2195 |
("*") is likewise analogous to its corresponding |
| 2196 |
subprogram in Strings.Fixed. For each of the subprograms, |
| 2197 |
the corresponding fixed-length string subprogram is applied to the string |
| 2198 |
represented by the Unbounded_String parameter, and |
| 2199 |
To_Unbounded_String is applied the result string. |
| 2200 |
|
| 2201 |
For each of the procedures Translate, |
| 2202 |
Replace_Slice, Insert, Overwrite, Delete, |
| 2203 |
Trim, Head, and Tail, the resulting string represented by the Source parameter |
| 2204 |
is given by the corresponding function for fixed-length strings applied to |
| 2205 |
the string represented by Source's original value. |
| 2206 |
@end{StaticSem} |
| 2207 |
|
| 2208 |
@begin{ImplReq} |
| 2209 |
No storage associated |
| 2210 |
with an Unbounded_String object shall be |
| 2211 |
lost upon assignment or scope exit. |
| 2212 |
@begin{ImplNote} |
| 2213 |
|
| 2214 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00301-01]} |
| 2215 |
A sample implementation of the private part of |
| 2216 |
the package and several of the subprograms appears in the @Chg{Version=[2], |
| 2217 |
New=[Ada 95 ],Old=[]}Rationale. |
| 2218 |
|
| 2219 |
@end{ImplNote} |
| 2220 |
@end{ImplReq} |
| 2221 |
|
| 2222 |
@begin{Incompatible95} |
| 2223 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00360-01]} |
| 2224 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 2225 |
@b[Amendment Correction:] Type Unbounded_String is defined to need |
| 2226 |
finalization. If the restriction No_Nested_Finalization (see |
| 2227 |
@RefSecNum{Tasking Restrictions}) applies to the partition, and |
| 2228 |
Unbounded_String does not have a controlled part, it will not be allowed in |
| 2229 |
local objects in Ada 2005 whereas it would be allowed in original Ada 95. |
| 2230 |
Such code is not portable, as most Ada compilers have a controlled part in |
| 2231 |
Unbounded_String, and thus would be illegal.]} |
| 2232 |
|
| 2233 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]} |
| 2234 |
@ChgAdded{Version=[2],Text=[ |
| 2235 |
Procedure Set_Unbounded_String, two Unbounded_Slice subprograms, and overloaded |
| 2236 |
versions of Index and Index_Non_Blank are newly added to Strings.Unbounded. |
| 2237 |
If Strings.Unbounded is |
| 2238 |
referenced in a @nt{use_clause}, and an entity @i<E> with the same |
| 2239 |
@nt{defining_identifier} as a new entity in Strings.Unbounded is defined in a |
| 2240 |
package that is also referenced in a @nt{use_clause}, the entity @i<E> may no |
| 2241 |
longer be use-visible, resulting in errors. This should be rare and is easily |
| 2242 |
fixed if it does occur.]} |
| 2243 |
@end{Incompatible95} |
| 2244 |
|
| 2245 |
@begin{Extend95} |
| 2246 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]} |
| 2247 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2248 |
@b[Amendment Correction:] Added a @nt{pragma} Preelaborable_Initialization to |
| 2249 |
type Unbounded_String, so that it can be used to declare default-initialized |
| 2250 |
objects in preelaborated units.]} |
| 2251 |
@end{Extend95} |
| 2252 |
|
| 2253 |
|
| 2254 |
@LabeledSubClause{String-Handling Sets and Mappings} |
| 2255 |
|
| 2256 |
@begin{Intro} |
| 2257 |
|
| 2258 |
The language-defined package Strings.Maps.Constants declares |
| 2259 |
Character_Set |
| 2260 |
and Character_Mapping |
| 2261 |
constants corresponding to classification and conversion functions |
| 2262 |
in package Characters.Handling. |
| 2263 |
@begin{discussion} |
| 2264 |
The Constants package is a child of Strings.Maps since it needs |
| 2265 |
visibility of the private part of Strings.Maps in order to |
| 2266 |
initialize the constants |
| 2267 |
in a preelaborable way (i.e. via aggregates versus function calls). |
| 2268 |
@end{discussion} |
| 2269 |
|
| 2270 |
@end{Intro} |
| 2271 |
|
| 2272 |
@begin{StaticSem} |
| 2273 |
@Leading@;The library package Strings.Maps.Constants has the following declaration: |
| 2274 |
|
| 2275 |
@begin{example} |
| 2276 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00362-01]} |
| 2277 |
@ChildUnit{Parent=[Ada.Strings.Maps],Child=[Constants]}@key[package] Ada.Strings.Maps.Constants @key[is] |
| 2278 |
@key[pragma] @Chg{Version=[2],New=[Pure],Old=[Preelaborate]}(Constants); |
| 2279 |
|
| 2280 |
@AdaObjDefn{Control_Set} : @key[constant] Character_Set; |
| 2281 |
@AdaObjDefn{Graphic_Set} : @key[constant] Character_Set; |
| 2282 |
@AdaObjDefn{Letter_Set} : @key[constant] Character_Set; |
| 2283 |
@AdaObjDefn{Lower_Set} : @key[constant] Character_Set; |
| 2284 |
@AdaObjDefn{Upper_Set} : @key[constant] Character_Set; |
| 2285 |
@AdaObjDefn{Basic_Set} : @key[constant] Character_Set; |
| 2286 |
@AdaObjDefn{Decimal_Digit_Set} : @key[constant] Character_Set; |
| 2287 |
@AdaObjDefn{Hexadecimal_Digit_Set} : @key[constant] Character_Set; |
| 2288 |
@AdaObjDefn{Alphanumeric_Set} : @key[constant] Character_Set; |
| 2289 |
@AdaObjDefn{Special_Set} : @key[constant] Character_Set; |
| 2290 |
@AdaObjDefn{ISO_646_Set} : @key[constant] Character_Set; |
| 2291 |
|
| 2292 |
@AdaObjDefn{Lower_Case_Map} : @key[constant] Character_Mapping; |
| 2293 |
--@RI{Maps to lower case for letters, else identity} |
| 2294 |
@AdaObjDefn{Upper_Case_Map} : @key[constant] Character_Mapping; |
| 2295 |
--@RI{Maps to upper case for letters, else identity} |
| 2296 |
@AdaObjDefn{Basic_Map} : @key[constant] Character_Mapping; |
| 2297 |
--@RI{Maps to basic letter for letters, else identity} |
| 2298 |
|
| 2299 |
@key[private] |
| 2300 |
... -- @RI{not specified by the language} |
| 2301 |
@key[end] Ada.Strings.Maps.Constants; |
| 2302 |
@end{example} |
| 2303 |
|
| 2304 |
|
| 2305 |
Each of these constants represents a correspondingly named |
| 2306 |
set of characters or |
| 2307 |
character mapping in Characters.Handling |
| 2308 |
(see @refsecnum(The Package Characters.Handling)). |
| 2309 |
@end{StaticSem} |
| 2310 |
|
| 2311 |
@begin{Extend95} |
| 2312 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]} |
| 2313 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2314 |
Strings.Maps.Constants is now Pure, |
| 2315 |
so it can be used in pure units.]} |
| 2316 |
@end{Extend95} |
| 2317 |
|
| 2318 |
|
| 2319 |
@LabeledSubClause{Wide_String Handling} |
| 2320 |
|
| 2321 |
@begin{Intro} |
| 2322 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00302-03]} |
| 2323 |
Facilities for handling strings of Wide_Character elements are |
| 2324 |
found in the packages Strings.@!Wide_Maps, Strings.@!Wide_Fixed, |
| 2325 |
Strings.@!Wide_@!Bounded, Strings.@!Wide_@!Unbounded, |
| 2326 |
and Strings.@!Wide_Maps.@!Wide_@!Constants@Chg{Version=[2],New=[, and in the |
| 2327 |
functions Strings.@!Wide_Hash, Strings.@!Wide_Fixed.@!Wide_Hash, |
| 2328 |
Strings.@!Wide_Bounded.@!Wide_Hash, and Strings.@!Wide_Unbounded.@!Wide_Hash],Old=[]}. |
| 2329 |
They provide the same string-handling operations |
| 2330 |
as the corresponding packages@Chg{Version=[2],New=[ and functions],Old=[]} |
| 2331 |
for strings of Character elements. |
| 2332 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Fixed]} |
| 2333 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Bounded]} |
| 2334 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Unbounded]} |
| 2335 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Hash]} |
| 2336 |
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Fixed],Child=[Wide_@!Hash]} |
| 2337 |
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Bounded],Child=[Wide_@!Hash]} |
| 2338 |
@SubChildUnit{Parent=[Ada.Strings.Wide_@!Unbounded],Child=[Wide_@!Hash]} |
| 2339 |
@ChildUnit{Parent=[Ada.Strings.Wide_@!Maps],Child=[Wide_@!Constants]} |
| 2340 |
@end{Intro} |
| 2341 |
|
| 2342 |
@begin{StaticSem} |
| 2343 |
The package Strings.Wide_Maps has the following declaration. |
| 2344 |
@begin{example} |
| 2345 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_@!Maps]}@key[package] Ada.Strings.Wide_Maps @key[is] |
| 2346 |
@key[pragma] Preelaborate(Wide_Maps); |
| 2347 |
|
| 2348 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]} |
| 2349 |
--@RI{ Representation for a set of Wide_Character values:} |
| 2350 |
@key[type] @AdaTypeDefn{Wide_Character_Set} @key[is] @key[private];@Chg{Version=[2],New=[ |
| 2351 |
@key[pragma] Preelaborable_Initialization(Wide_Character_Set);],Old=[]} |
| 2352 |
|
| 2353 |
@AdaObjDefn{Null_Set} : @key[constant] Wide_Character_Set; |
| 2354 |
|
| 2355 |
@key[type] @AdaTypeDefn{Wide_Character_Range} @key[is] |
| 2356 |
@key[record] |
| 2357 |
Low : Wide_Character; |
| 2358 |
High : Wide_Character; |
| 2359 |
@key[end] @key[record]; |
| 2360 |
-- @RI{Represents Wide_Character range Low..High} |
| 2361 |
|
| 2362 |
@key[type] @AdaTypeDefn{Wide_Character_Ranges} @key[is] @key[array] (Positive @key[range] <>) |
| 2363 |
@key[of] Wide_Character_Range; |
| 2364 |
|
| 2365 |
@key[function] @AdaSubDefn{To_Set} (Ranges : @key[in] Wide_Character_Ranges) |
| 2366 |
@key[return] Wide_Character_Set; |
| 2367 |
|
| 2368 |
@key[function] @AdaSubDefn{To_Set} (Span : @key[in] Wide_Character_Range) |
| 2369 |
@key[return] Wide_Character_Set; |
| 2370 |
|
| 2371 |
@key[function] @AdaSubDefn{To_Ranges} (Set : @key[in] Wide_Character_Set) |
| 2372 |
@key[return] Wide_Character_Ranges; |
| 2373 |
|
| 2374 |
@key[function] "=" (Left, Right : @key[in] Wide_Character_Set) @key[return] Boolean; |
| 2375 |
|
| 2376 |
@key[function] "@key[not]" (Right : @key[in] Wide_Character_Set) |
| 2377 |
@key[return] Wide_Character_Set; |
| 2378 |
@key[function] "@key[and]" (Left, Right : @key[in] Wide_Character_Set) |
| 2379 |
@key[return] Wide_Character_Set; |
| 2380 |
@key[function] "@key[or]" (Left, Right : @key[in] Wide_Character_Set) |
| 2381 |
@key[return] Wide_Character_Set; |
| 2382 |
@key[function] "@key[xor]" (Left, Right : @key[in] Wide_Character_Set) |
| 2383 |
@key[return] Wide_Character_Set; |
| 2384 |
@key[function] "-" (Left, Right : @key[in] Wide_Character_Set) |
| 2385 |
@key[return] Wide_Character_Set; |
| 2386 |
|
| 2387 |
@key[function] @AdaSubDefn{Is_In} (Element : @key[in] Wide_Character; |
| 2388 |
Set : @key[in] Wide_Character_Set) |
| 2389 |
@key[return] Boolean; |
| 2390 |
|
| 2391 |
@key[function] @AdaSubDefn{Is_Subset} (Elements : @key[in] Wide_Character_Set; |
| 2392 |
Set : @key[in] Wide_Character_Set) |
| 2393 |
@key[return] Boolean; |
| 2394 |
|
| 2395 |
@key[function] "<=" (Left : @key[in] Wide_Character_Set; |
| 2396 |
Right : @key[in] Wide_Character_Set) |
| 2397 |
@key[return] Boolean @key[renames] Is_Subset; |
| 2398 |
|
| 2399 |
|
| 2400 |
--@RI{ Alternative representation for a set of Wide_Character values:} |
| 2401 |
@key[subtype] @AdaSubtypeDefn{Name=[Wide_Character_Sequence],Of=[Wide_String]} @key[is] Wide_String; |
| 2402 |
|
| 2403 |
@key[function] @AdaSubDefn{To_Set} (Sequence : @key[in] Wide_Character_Sequence) |
| 2404 |
@key[return] Wide_Character_Set; |
| 2405 |
|
| 2406 |
@key[function] @AdaSubDefn{To_Set} (Singleton : @key[in] Wide_Character) |
| 2407 |
@key[return] Wide_Character_Set; |
| 2408 |
|
| 2409 |
@key[function] @AdaSubDefn{To_Sequence} (Set : @key[in] Wide_Character_Set) |
| 2410 |
@key[return] Wide_Character_Sequence; |
| 2411 |
|
| 2412 |
|
| 2413 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00161-01]} |
| 2414 |
--@RI{ Representation for a Wide_Character to Wide_Character mapping:} |
| 2415 |
@key[type] @AdaTypeDefn{Wide_Character_Mapping} @key[is] @key[private];@Chg{Version=[2],New=[ |
| 2416 |
@key[pragma] Preelaborable_Initialization(Wide_Character_Mapping);],Old=[]} |
| 2417 |
|
| 2418 |
@key[function] @AdaSubDefn{Value} (Map : @key[in] Wide_Character_Mapping; |
| 2419 |
Element : @key[in] Wide_Character) |
| 2420 |
@key[return] Wide_Character; |
| 2421 |
|
| 2422 |
@AdaObjDefn{Identity} : @key[constant] Wide_Character_Mapping; |
| 2423 |
|
| 2424 |
@key[function] @AdaSubDefn{To_Mapping} (From, To : @key[in] Wide_Character_Sequence) |
| 2425 |
@key[return] Wide_Character_Mapping; |
| 2426 |
|
| 2427 |
@key[function] @AdaSubDefn{To_Domain} (Map : @key[in] Wide_Character_Mapping) |
| 2428 |
@key[return] Wide_Character_Sequence; |
| 2429 |
|
| 2430 |
@key[function] @AdaSubDefn{To_Range} (Map : @key[in] Wide_Character_Mapping) |
| 2431 |
@key[return] Wide_Character_Sequence; |
| 2432 |
|
| 2433 |
|
| 2434 |
@key{type} @AdaTypeDefn{Wide_Character_Mapping_Function} @key{is} |
| 2435 |
@key{access} @key{function} (From : @key{in} Wide_Character) @key{return} Wide_Character; |
| 2436 |
|
| 2437 |
@key[private] |
| 2438 |
... -- @RI{not specified by the language} |
| 2439 |
@key[end] Ada.Strings.Wide_Maps; |
| 2440 |
@end{example} |
| 2441 |
|
| 2442 |
The context clause for each of the packages Strings.Wide_Fixed, |
| 2443 |
Strings.Wide_Bounded, and Strings.Wide_Unbounded |
| 2444 |
identifies Strings.Wide_Maps instead of Strings.Maps. |
| 2445 |
|
| 2446 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00302-03]} |
| 2447 |
@Leading@;For each of the packages Strings.Fixed, Strings.Bounded, |
| 2448 |
Strings.Unbounded, and Strings.Maps.Constants@Chg{Version=[2],New=[, and |
| 2449 |
for functions Strings.Hash, Strings.Fixed.Hash, Strings.Bounded.Hash, |
| 2450 |
and Strings.Unbounded.Hash,],Old=[]} |
| 2451 |
the corresponding wide string package has the same contents except that |
| 2452 |
@begin{itemize} |
| 2453 |
Wide_Space replaces Space |
| 2454 |
|
| 2455 |
Wide_Character replaces Character |
| 2456 |
|
| 2457 |
Wide_String replaces String |
| 2458 |
|
| 2459 |
Wide_Character_Set replaces Character_Set |
| 2460 |
|
| 2461 |
Wide_Character_Mapping replaces Character_Mapping |
| 2462 |
|
| 2463 |
Wide_Character_Mapping_Function replaces Character_Mapping_Function |
| 2464 |
|
| 2465 |
Wide_Maps replaces Maps |
| 2466 |
|
| 2467 |
Bounded_Wide_String replaces Bounded_String |
| 2468 |
|
| 2469 |
Null_Bounded_Wide_String replaces Null_Bounded_String |
| 2470 |
|
| 2471 |
To_Bounded_Wide_String replaces To_Bounded_String |
| 2472 |
|
| 2473 |
To_Wide_String replaces To_String |
| 2474 |
|
| 2475 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 2476 |
@ChgAdded{Version=[2],Text=[Set_Bounded_Wide_String replaces Set_Bounded_String]} |
| 2477 |
|
| 2478 |
Unbounded_Wide_String replaces Unbounded_String |
| 2479 |
|
| 2480 |
Null_Unbounded_Wide_String replaces Null_Unbounded_String |
| 2481 |
|
| 2482 |
Wide_String_Access replaces String_Access |
| 2483 |
|
| 2484 |
To_Unbounded_Wide_String replaces To_Unbounded_String |
| 2485 |
|
| 2486 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00301-01]} |
| 2487 |
@ChgAdded{Version=[2],Text=[Set_Unbounded_Wide_String replaces Set_Unbounded_String]} |
| 2488 |
|
| 2489 |
@end{Itemize} |
| 2490 |
|
| 2491 |
@Leading@keepnext@;The following additional declaration is present in |
| 2492 |
Strings.Wide_Maps.Wide_Constants: |
| 2493 |
@begin{example} |
| 2494 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01],ARef=[AI95-00395-01]} |
| 2495 |
@AdaObjDefn{Character_Set} : @key[constant] Wide_Maps.Wide_Character_Set; |
| 2496 |
--@RI{Contains each Wide_Character value WC such that}@Chg{Version=[2],New=[ |
| 2497 |
--],Old=[]}@RI{Characters.@Chg{Version=[2],New=[Conversions.],Old=[]}Is_Character(WC) is True} |
| 2498 |
@end{example} |
| 2499 |
@end{StaticSem} |
| 2500 |
|
| 2501 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00395-01]} |
| 2502 |
@ChgAdded{Version=[2],Text=[Each Wide_Character_Set constant in the package |
| 2503 |
Strings.Wide_Maps.Wide_Constants contains no values outside the Character |
| 2504 |
portion of Wide_Character. Similarly, each Wide_Character_Mapping constant in |
| 2505 |
this package is the identity mapping when applied to any element outside the |
| 2506 |
Character portion of Wide_Character.]} |
| 2507 |
|
| 2508 |
@ChgRef{Version=[2],Kind=[Added],ARef=[AI95-00362-01]} |
| 2509 |
@ChgAdded{Version=[2],Text=[@nt{Pragma} Pure is replaced by |
| 2510 |
@nt{pragma} Preelaborate in Strings.Wide_Maps.Wide_Constants.]} |
| 2511 |
|
| 2512 |
@begin{Notes} |
| 2513 |
@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)} |
| 2514 |
If a null Wide_Character_Mapping_Function is passed to any of the |
| 2515 |
Wide_String handling subprograms, Constraint_Error is propagated. |
| 2516 |
|
| 2517 |
@ChgRef{Version=[2],Kind=[Deleted],ARef=[AI95-00395-01]} |
| 2518 |
@ChgDeleted{Version=[2],Text=[Each Wide_Character_Set constant in the package |
| 2519 |
Strings.Wide_Maps.Wide_Constants contains no values outside the Character |
| 2520 |
portion of Wide_Character. Similarly, each Wide_Character_Mapping |
| 2521 |
constant in this package is the identity mapping when applied to |
| 2522 |
any element outside the Character portion of Wide_Character.]} |
| 2523 |
@end{Notes} |
| 2524 |
|
| 2525 |
@begin{Incompatible95} |
| 2526 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]} |
| 2527 |
@ChgAdded{Version=[2],Text=[@Defn{incompatibilities with Ada 95} |
| 2528 |
Various new operations are added to Strings.Wide_Fixed, Strings.Wide_Bounded, |
| 2529 |
and Strings.Wide_Unbounded. If one of these packages is referenced in a |
| 2530 |
@nt{use_clause}, and an entity @i<E> with the same @nt{defining_identifier} |
| 2531 |
as a new entity is defined in a package that is also referenced in a |
| 2532 |
@nt{use_clause}, the entity @i<E> may no longer be use-visible, resulting in |
| 2533 |
errors. This should be rare and is easily fixed if it does occur.]} |
| 2534 |
@end{Incompatible95} |
| 2535 |
|
| 2536 |
@begin{Extend95} |
| 2537 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00161-01]} |
| 2538 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2539 |
@b[Amendment Correction:] Added @nt{pragma} Preelaborable_Initialization to |
| 2540 |
types Wide_Character_Set and Wide_Character_Mapping, so that they can be |
| 2541 |
used to declare default-initialized objects in preelaborated units.]} |
| 2542 |
@end{Extend95} |
| 2543 |
|
| 2544 |
@begin{DiffWord95} |
| 2545 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 2546 |
@ChgAdded{Version=[2],Text=[Corrected the description of Character_Set.]} |
| 2547 |
|
| 2548 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2549 |
@ChgAdded{Version=[2],Text=[Added wide versions of Strings.Hash and |
| 2550 |
Strings.Unbounded.Hash.]} |
| 2551 |
|
| 2552 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00362-01]} |
| 2553 |
@ChgAdded{Version=[2],Text=[Added wording so that |
| 2554 |
Strings.Wide_Maps.Wide_Constants does not change to Pure.]} |
| 2555 |
|
| 2556 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00395-01]} |
| 2557 |
@ChgAdded{Version=[2],Text=[The second Note is now normative text, since |
| 2558 |
there is no way to derive it from the other rules. It's a little |
| 2559 |
weird given the use of Unicode character classifications in Ada 2005; |
| 2560 |
but changing it would be inconsistent with Ada 95 and a one-to-one |
| 2561 |
mapping isn't necessarily correct anyway.]} |
| 2562 |
@end{DiffWord95} |
| 2563 |
|
| 2564 |
|
| 2565 |
@LabeledAddedSubClause{Version=[2],Name=[Wide_Wide_String Handling]} |
| 2566 |
|
| 2567 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01],ARef=[AI95-00395-01]} |
| 2568 |
@ChgAdded{Version=[2],Text=[Facilities for handling strings of |
| 2569 |
Wide_Wide_Character elements are found in |
| 2570 |
the packages Strings.@!Wide_Wide_@!Maps, Strings.@!Wide_Wide_@!Fixed, |
| 2571 |
Strings.@!Wide_Wide_@!Bounded, Strings.@!Wide_Wide_@!Unbounded, and |
| 2572 |
Strings.@!Wide_Wide_@!Maps.@!Wide_Wide_@!Constants, and in the |
| 2573 |
functions Strings.@!Wide_Wide_@!Hash, Strings.@!Wide_Wide_@!Fixed.@!Wide_Wide_@!Hash, |
| 2574 |
Strings.@!Wide_Wide_@!Bounded.@!Wide_@!Wide_@!Hash, and |
| 2575 |
Strings.@!Wide_Wide_@!Unbounded.@!Wide_@!Wide_@!Hash. |
| 2576 |
They provide the same |
| 2577 |
string-handling operations as the corresponding packages and functions |
| 2578 |
for strings of Character elements. |
| 2579 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Fixed]} |
| 2580 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Bounded]} |
| 2581 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Unbounded]} |
| 2582 |
@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_@!Hash]} |
| 2583 |
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Fixed],Child=[Wide_Wide_@!Hash]} |
| 2584 |
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Bounded],Child=[Wide_Wide_@!Hash]} |
| 2585 |
@SubChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Unbounded],Child=[Wide_Wide_@!Hash]} |
| 2586 |
@ChildUnit{Parent=[Ada.Strings.Wide_Wide_@!Maps],Child=[Wide_Wide_@!Constants]}]} |
| 2587 |
|
| 2588 |
@begin{StaticSem} |
| 2589 |
|
| 2590 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 2591 |
@ChgAdded{Version=[2],Type=[Leading],Text=[The library package Strings.Wide_Wide_Maps has the following declaration.]} |
| 2592 |
|
| 2593 |
@begin{Example} |
| 2594 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2595 |
@ChgAdded{Version=[2],Text=[@key<package> Ada.Strings.Wide_Wide_Maps @key<is>@ChildUnit{Parent=[Ada.Strings],Child=[Wide_Wide_Maps]} |
| 2596 |
@key<pragma> Preelaborate(Wide_Wide_Maps);]} |
| 2597 |
|
| 2598 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2599 |
@ChgAdded{Version=[2],Text=[ -- @RI[Representation for a set of Wide_Wide_Character values:] |
| 2600 |
@key<type> @AdaTypeDefn{Wide_Wide_Character_Set} @key<is private>; |
| 2601 |
@key<pragma> Preelaborable_Initialization(Wide_Wide_Character_Set);]} |
| 2602 |
|
| 2603 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2604 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Null_Set} : @key<constant> Wide_Wide_Character_Set;]} |
| 2605 |
|
| 2606 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2607 |
@ChgAdded{Version=[2],Text=[ @key<type> @AdaTypeDefn{Wide_Wide_Character_Range} @key<is> |
| 2608 |
@key<record> |
| 2609 |
Low : Wide_Wide_Character; |
| 2610 |
High : Wide_Wide_Character; |
| 2611 |
@key<end record>; |
| 2612 |
-- @RI[Represents Wide_Wide_Character range Low..High]]} |
| 2613 |
|
| 2614 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2615 |
@ChgAdded{Version=[2],Text=[ @key<type> @AdaTypeDefn{Wide_Wide_Character_Ranges} @key<is array> (Positive @key<range> <>) |
| 2616 |
@key<of> Wide_Wide_Character_Range;]} |
| 2617 |
|
| 2618 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2619 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Ranges : @key<in> Wide_Wide_Character_Ranges) |
| 2620 |
@key<return> Wide_Wide_Character_Set;]} |
| 2621 |
|
| 2622 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2623 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Span : @key<in> Wide_Wide_Character_Range) |
| 2624 |
@key<return> Wide_Wide_Character_Set;]} |
| 2625 |
|
| 2626 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2627 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Ranges} (Set : @key<in> Wide_Wide_Character_Set) |
| 2628 |
@key<return> Wide_Wide_Character_Ranges;]} |
| 2629 |
|
| 2630 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2631 |
@ChgAdded{Version=[2],Text=[ @key<function> "=" (Left, Right : @key<in> Wide_Wide_Character_Set) @key<return> Boolean;]} |
| 2632 |
|
| 2633 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2634 |
@ChgAdded{Version=[2],Text=[ @key<function> "@key<not>" (Right : @key<in> Wide_Wide_Character_Set) |
| 2635 |
@key<return> Wide_Wide_Character_Set; |
| 2636 |
@key<function> "@key<and>" (Left, Right : @key<in> Wide_Wide_Character_Set) |
| 2637 |
@key<return> Wide_Wide_Character_Set; |
| 2638 |
@key<function> "@key<or>" (Left, Right : @key<in> Wide_Wide_Character_Set) |
| 2639 |
@key<return> Wide_Wide_Character_Set; |
| 2640 |
@key<function> "@key<xor>" (Left, Right : @key<in> Wide_Wide_Character_Set) |
| 2641 |
@key<return> Wide_Wide_Character_Set; |
| 2642 |
@key<function> "-" (Left, Right : @key<in> Wide_Wide_Character_Set) |
| 2643 |
@key<return> Wide_Wide_Character_Set;]} |
| 2644 |
|
| 2645 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2646 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{Is_In} (Element : @key<in> Wide_Wide_Character; |
| 2647 |
Set : @key<in> Wide_Wide_Character_Set) |
| 2648 |
@key<return> Boolean;]} |
| 2649 |
|
| 2650 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2651 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{Is_Subset} (Elements : @key<in> Wide_Wide_Character_Set; |
| 2652 |
Set : @key<in> Wide_Wide_Character_Set) |
| 2653 |
@key<return> Boolean;]} |
| 2654 |
|
| 2655 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2656 |
@ChgAdded{Version=[2],Text=[ @key<function> "<=" (Left : @key<in> Wide_Wide_Character_Set; |
| 2657 |
Right : @key<in> Wide_Wide_Character_Set) |
| 2658 |
@key<return> Boolean @key<renames> Is_Subset;]} |
| 2659 |
|
| 2660 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2661 |
@ChgAdded{Version=[2],Text=[ -- @RI[Alternative representation for a set of Wide_Wide_Character values:] |
| 2662 |
@key<subtype> @AdaSubtypeDefn{Name=[Wide_Wide_Character_Sequence],Of=[Wide_Wide_String]} @key<is> Wide_Wide_String;]} |
| 2663 |
|
| 2664 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2665 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Sequence : @key<in> Wide_Wide_Character_Sequence) |
| 2666 |
@key<return> Wide_Wide_Character_Set;]} |
| 2667 |
|
| 2668 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2669 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Set} (Singleton : @key<in> Wide_Wide_Character) |
| 2670 |
@key<return> Wide_Wide_Character_Set;]} |
| 2671 |
|
| 2672 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2673 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Sequence} (Set : @key<in> Wide_Wide_Character_Set) |
| 2674 |
@key<return> Wide_Wide_Character_Sequence;]} |
| 2675 |
|
| 2676 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2677 |
@ChgAdded{Version=[2],Text=[ -- @RI[Representation for a Wide_Wide_Character to Wide_Wide_Character] |
| 2678 |
-- @RI[mapping:] |
| 2679 |
@key<type> @AdaTypeDefn{Wide_Wide_Character_Mapping} @key<is private>; |
| 2680 |
@key<pragma> Preelaborable_Initialization(Wide_Wide_Character_Mapping);]} |
| 2681 |
|
| 2682 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2683 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{Value} (Map : @key<in> Wide_Wide_Character_Mapping; |
| 2684 |
Element : @key<in> Wide_Wide_Character) |
| 2685 |
@key<return> Wide_Wide_Character;]} |
| 2686 |
|
| 2687 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2688 |
@ChgAdded{Version=[2],Text=[ @AdaObjDefn{Identity} : @key<constant> Wide_Wide_Character_Mapping;]} |
| 2689 |
|
| 2690 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2691 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Mapping} (From, To : @key<in> Wide_Wide_Character_Sequence) |
| 2692 |
@key<return> Wide_Wide_Character_Mapping;]} |
| 2693 |
|
| 2694 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2695 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Domain} (Map : @key<in> Wide_Wide_Character_Mapping) |
| 2696 |
@key<return> Wide_Wide_Character_Sequence;]} |
| 2697 |
|
| 2698 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2699 |
@ChgAdded{Version=[2],Text=[ @key<function> @AdaSubDefn{To_Range} (Map : @key<in> Wide_Wide_Character_Mapping) |
| 2700 |
@key<return> Wide_Wide_Character_Sequence;]} |
| 2701 |
|
| 2702 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2703 |
@ChgAdded{Version=[2],Text=[ @key<type> @AdaTypeDefn{Wide_Wide_Character_Mapping_Function} @key<is> |
| 2704 |
@key<access function> (From : @key<in> Wide_Wide_Character) |
| 2705 |
@key<return> Wide_Wide_Character;]} |
| 2706 |
|
| 2707 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2708 |
@ChgAdded{Version=[2],Text=[@key<private> |
| 2709 |
... -- @RI[not specified by the language] |
| 2710 |
@key<end> Ada.Strings.Wide_Wide_Maps;]} |
| 2711 |
@end{Example} |
| 2712 |
|
| 2713 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 2714 |
@ChgAdded{Version=[2],Text=[@ChildUnit{Parent=[Ada.Strings.Wide_@!Maps],Child=[Wide_@!Constants]} |
| 2715 |
The context clause for each of the packages Strings.Wide_Wide_Fixed, |
| 2716 |
Strings.Wide_Wide_Bounded, and Strings.Wide_Wide_Unbounded identifies |
| 2717 |
Strings.Wide_Wide_Maps instead of Strings.Maps.]} |
| 2718 |
|
| 2719 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 2720 |
@ChgAdded{Version=[2],Type=[Leading],Text=[For each of the packages |
| 2721 |
Strings.@!Fixed, Strings.@!Bounded, Strings.@!Unbounded, and Strings.@!Maps.Constants, |
| 2722 |
and for functions Strings.@!Hash, Strings.@!Fixed.Hash, Strings.@!Bounded.Hash, |
| 2723 |
and Strings.@!Unbounded.Hash, |
| 2724 |
the corresponding wide wide string package or function has the same contents |
| 2725 |
except that]} |
| 2726 |
|
| 2727 |
@begin{Itemize} |
| 2728 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2729 |
@ChgAdded{Version=[2],Text=[Wide_Wide_Space replaces Space]} |
| 2730 |
|
| 2731 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2732 |
@ChgAdded{Version=[2],Text=[Wide_Wide_Character replaces Character]} |
| 2733 |
|
| 2734 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2735 |
@ChgAdded{Version=[2],Text=[Wide_Wide_String replaces String]} |
| 2736 |
|
| 2737 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2738 |
@ChgAdded{Version=[2],Text=[Wide_Wide_Character_Set replaces Character_Set]} |
| 2739 |
|
| 2740 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2741 |
@ChgAdded{Version=[2],Text=[Wide_Wide_Character_Mapping replaces Character_Mapping]} |
| 2742 |
|
| 2743 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2744 |
@ChgAdded{Version=[2],Text=[Wide_Wide_Character_Mapping_Function replaces Character_Mapping_Function]} |
| 2745 |
|
| 2746 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2747 |
@ChgAdded{Version=[2],Text=[Wide_Wide_Maps replaces Maps]} |
| 2748 |
|
| 2749 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2750 |
@ChgAdded{Version=[2],Text=[Bounded_Wide_Wide_String replaces Bounded_String]} |
| 2751 |
|
| 2752 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2753 |
@ChgAdded{Version=[2],Text=[Null_Bounded_Wide_Wide_String replaces Null_Bounded_String]} |
| 2754 |
|
| 2755 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2756 |
@ChgAdded{Version=[2],Text=[To_Bounded_Wide_Wide_String replaces To_Bounded_String]} |
| 2757 |
|
| 2758 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2759 |
@ChgAdded{Version=[2],Text=[To_Wide_Wide_String replaces To_String]} |
| 2760 |
|
| 2761 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]} |
| 2762 |
@ChgAdded{Version=[2],Text=[Set_Bounded_Wide_Wide_String replaces Set_Bounded_String]} |
| 2763 |
|
| 2764 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2765 |
@ChgAdded{Version=[2],Text=[Unbounded_Wide_Wide_String replaces Unbounded_String]} |
| 2766 |
|
| 2767 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2768 |
@ChgAdded{Version=[2],Text=[Null_Unbounded_Wide_Wide_String replaces Null_Unbounded_String]} |
| 2769 |
|
| 2770 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2771 |
@ChgAdded{Version=[2],Text=[Wide_Wide_String_Access replaces String_Access]} |
| 2772 |
|
| 2773 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2774 |
@ChgAdded{Version=[2],Text=[To_Unbounded_Wide_Wide_String replaces To_Unbounded_String]} |
| 2775 |
|
| 2776 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00301-01]} |
| 2777 |
@ChgAdded{Version=[2],Text=[Set_Unbounded_Wide_Wide_String replaces Set_Unbounded_String]} |
| 2778 |
|
| 2779 |
@end{Itemize} |
| 2780 |
|
| 2781 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01],ARef=[AI95-00395-01]} |
| 2782 |
@ChgAdded{Version=[2],Type=[Leading],Keepnext=[T],Text=[The following |
| 2783 |
additional declarations are present in |
| 2784 |
Strings.Wide_Wide_Maps.Wide_Wide_Constants:]} |
| 2785 |
|
| 2786 |
@begin{Example} |
| 2787 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2788 |
@ChgAdded{Version=[2],Text=[@AdaObjDefn{Character_Set} : @key<constant> Wide_Wide_Maps.Wide_Wide_Character_Set; |
| 2789 |
-- @RI[Contains each Wide_Wide_Character value WWC such that] |
| 2790 |
-- @RI[Characters.Conversions.Is_Character(WWC) is True] |
| 2791 |
@AdaObjDefn{Wide_Character_Set} : @key<constant> Wide_Wide_Maps.Wide_Wide_Character_Set; |
| 2792 |
-- @RI[Contains each Wide_Wide_Character value WWC such that] |
| 2793 |
-- @RI[Characters.Conversions.Is_Wide_Character(WWC) is True]]} |
| 2794 |
@end{Example} |
| 2795 |
|
| 2796 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00395-01]} |
| 2797 |
@ChgAdded{Version=[2],Text=[Each Wide_Wide_Character_Set constant in the package |
| 2798 |
Strings.@!Wide_Wide_@!Maps.@!Wide_Wide_@!Constants contains no values outside the Character |
| 2799 |
portion of Wide_Wide_@!Character. Similarly, each Wide_Wide_@!Character_@!Mapping constant in |
| 2800 |
this package is the identity mapping when applied to any element outside the |
| 2801 |
Character portion of Wide_Wide_Character.]} |
| 2802 |
|
| 2803 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00395-01]} |
| 2804 |
@ChgAdded{Version=[2],Text=[@nt{Pragma} Pure is replaced by |
| 2805 |
@nt{pragma} Preelaborate in Strings.Wide_Wide_Maps.Wide_Wide_Constants.]} |
| 2806 |
|
| 2807 |
@end{StaticSem} |
| 2808 |
|
| 2809 |
@begin{Notes} |
| 2810 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 2811 |
@ChgAdded{Version=[2],Text=[@Defn2{Term=[Constraint_Error],Sec=(raised by failure of run-time check)} |
| 2812 |
If a null Wide_Wide_Character_Mapping_Function is passed to any of the |
| 2813 |
Wide_Wide_String handling subprograms, Constraint_Error is propagated.]} |
| 2814 |
@end{Notes} |
| 2815 |
|
| 2816 |
@begin{Extend95} |
| 2817 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01],ARef=[AI95-00395-01]} |
| 2818 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2819 |
The double-wide string-handling packages (Strings.Wide_Wide_Maps, |
| 2820 |
Strings.Wide_Wide_Fixed, Strings.Wide_Wide_Bounded, |
| 2821 |
Strings.Wide_Wide_Unbounded, and Strings.Wide_Wide_Maps.Wide_Wide_Constants), |
| 2822 |
and functions Strings.Wide_Wide_Hash and |
| 2823 |
Strings.Wide_Wide_Unbounded.Wide_Wide_Hash are new.]} |
| 2824 |
@end{Extend95} |
| 2825 |
|
| 2826 |
|
| 2827 |
@LabeledAddedSubClause{Version=[2],Name=[String Hashing]} |
| 2828 |
|
| 2829 |
@begin{StaticSem} |
| 2830 |
|
| 2831 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2832 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library |
| 2833 |
function Strings.Hash has the following declaration:]} |
| 2834 |
@begin{Example} |
| 2835 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2836 |
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers; |
| 2837 |
@key<function> Ada.Strings.Hash (Key : String) @key<return> Containers.Hash_Type;@SubChildUnit{Parent=[Ada.Strings],Child=[Hash]} |
| 2838 |
@key<pragma> Pure(Hash);]} |
| 2839 |
@end{Example} |
| 2840 |
|
| 2841 |
@begin{DescribeCode} |
| 2842 |
|
| 2843 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2844 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Returns an implementation-defined |
| 2845 |
value which is a function of the value of Key. If @i<A> and @i<B> are strings |
| 2846 |
such that @i<A> equals @i<B>, Hash(@i<A>) equals Hash(@i<B>).]} |
| 2847 |
@ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2848 |
Text=[The values returned by Strings.Hash.]}]} |
| 2849 |
|
| 2850 |
@end{DescribeCode} |
| 2851 |
|
| 2852 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2853 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library |
| 2854 |
function Strings.Fixed.Hash has the following declaration:]} |
| 2855 |
@begin{Example} |
| 2856 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2857 |
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers, Ada.Strings.Hash; |
| 2858 |
@key<function> Ada.Strings.Fixed.Hash (Key : String) @key<return> Containers.Hash_Type |
| 2859 |
@key<renames> Ada.Strings.Hash; |
| 2860 |
@key<pragma> Pure(Hash);]} |
| 2861 |
@end{Example} |
| 2862 |
|
| 2863 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2864 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The generic library |
| 2865 |
function Strings.Bounded.Hash has the following declaration:]} |
| 2866 |
@begin{Example} |
| 2867 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2868 |
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers; |
| 2869 |
@key<generic>@SubChildUnit{Parent=[Ada.Strings.Bounded],Child=[Hash]} |
| 2870 |
@key<with package> Bounded @key<is> |
| 2871 |
@key<new> Ada.Strings.Bounded.Generic_Bounded_Length (<>); |
| 2872 |
@key<function> Ada.Strings.Bounded.Hash (Key : Bounded.Bounded_String) |
| 2873 |
@key<return> Containers.Hash_Type; |
| 2874 |
@key<pragma> Preelaborate(Hash);]} |
| 2875 |
@end{Example} |
| 2876 |
|
| 2877 |
@begin{DescribeCode} |
| 2878 |
|
| 2879 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2880 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Strings.Bounded.Hash is |
| 2881 |
equivalent to the function call |
| 2882 |
Strings.Hash (Bounded.To_String (Key));]} |
| 2883 |
|
| 2884 |
@end{DescribeCode} |
| 2885 |
|
| 2886 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2887 |
@ChgAdded{Version=[2],KeepNext=[T],Type=[Leading],Text=[The library |
| 2888 |
function Strings.Unbounded.Hash has the following declaration:]} |
| 2889 |
@begin{Example} |
| 2890 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2891 |
@ChgAdded{Version=[2],Text=[@key<with> Ada.Containers; |
| 2892 |
@key<function> Ada.Strings.Unbounded.Hash (Key : Unbounded_String)@SubChildUnit{Parent=[Ada.Strings.Unbounded],Child=[Hash]} |
| 2893 |
@key<return> Containers.Hash_Type; |
| 2894 |
@key<pragma> Preelaborate(Hash);]} |
| 2895 |
@end{Example} |
| 2896 |
|
| 2897 |
@begin{DescribeCode} |
| 2898 |
|
| 2899 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2900 |
@ChgAdded{Version=[2],Type=[Trailing],Text=[Strings.Unbounded.Hash is |
| 2901 |
equivalent to the function call Strings.Hash (To_String (Key));]} |
| 2902 |
|
| 2903 |
@end{DescribeCode} |
| 2904 |
|
| 2905 |
|
| 2906 |
@end{StaticSem} |
| 2907 |
|
| 2908 |
|
| 2909 |
@begin{ImplAdvice} |
| 2910 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2911 |
@ChgAdded{Version=[2],Text=[The Hash functions should be good hash |
| 2912 |
functions, returning a wide spread of values for different string values. It |
| 2913 |
should be unlikely for similar strings to return the same value.]} |
| 2914 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 2915 |
Text=[Strings.Hash should be good a hash |
| 2916 |
function, returning a wide spread of values for different string values, |
| 2917 |
and similar strings should rarely return the same value.]}]} |
| 2918 |
@begin{Ramification} |
| 2919 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 2920 |
@ChgAdded{Version=[2],Text=[The other functions are defined in terms of |
| 2921 |
Strings.Hash, so they don't need separate advice in the Annex.]} |
| 2922 |
@end{Ramification} |
| 2923 |
@end{ImplAdvice} |
| 2924 |
|
| 2925 |
|
| 2926 |
@begin{Extend95} |
| 2927 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00302-03]} |
| 2928 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 2929 |
The Strings.Hash, Strings.Fixed.Hash, Strings.Bounded.Hash, and |
| 2930 |
Strings.Unbounded.Hash functions are new.]} |
| 2931 |
@end{Extend95} |
| 2932 |
|