1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - Unbounded-Length String Handling</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-A-4-4.html">Previous</A> <A HREF="AA-A-4-6.html">Next</A></P>
<HR>
<H1> A.4.5 Unbounded-Length String Handling</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> The language-defined package Strings.Unbounded
provides a private type Unbounded_String and a set of operations. An
object of type Unbounded_String represents a String whose low bound is
1 and whose length can vary conceptually between 0 and Natural'Last.
The subprograms for fixed-length string handling are either overloaded
directly for Unbounded_String, or are modified as needed to reflect the
flexibility in length. Since the Unbounded_String type is private, relevant
constructor and selector operations are provided. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>1.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The transformation
operations for fixed- and bounded-length strings that are not necessarily
length preserving are supplied for Unbounded_String as procedures as
well as functions. This allows an implementation to do an initial allocation
for an unbounded string and to avoid further allocations as long as the
length does not exceed the allocated length. </FONT></DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The library package
Strings.Unbounded has the following declaration: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Examples"><TT><B>with</B> Ada.Strings.Maps;<BR>
<A NAME="I5343"></A><A NAME="I5344"></A><A NAME="I5345"></A><B>package</B> Ada.Strings.Unbounded <B>is</B><BR>
<B>pragma</B> Preelaborate(Unbounded);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I5346"></A><A NAME="I5347"></A>Unbounded_String <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I5348"></A>Null_Unbounded_String : <B>constant</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5349"></A><A NAME="I5350"></A>Length (Source : <B>in</B> Unbounded_String) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I5351"></A><A NAME="I5352"></A>String_Access <B>is</B> <B>access</B> <B>all</B> String;<BR>
<B>procedure</B> <A NAME="I5353"></A><A NAME="I5354"></A>Free (X : <B>in</B> <B>out</B> String_Access);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT>--<I> Conversion, Concatenation, and Selection functions</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5355"></A><A NAME="I5356"></A>To_Unbounded_String (Source : <B>in</B> String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5357"></A><A NAME="I5358"></A>To_Unbounded_String (Length : <B>in</B> Natural)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5359"></A><A NAME="I5360"></A>To_String (Source : <B>in</B> Unbounded_String) <B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5361"></A><A NAME="I5362"></A>Append (Source : <B>in out</B> Unbounded_String;<BR>
New_Item : <B>in</B> Unbounded_String);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5363"></A><A NAME="I5364"></A>Append (Source : <B>in out</B> Unbounded_String;<BR>
New_Item : <B>in</B> String);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5365"></A><A NAME="I5366"></A>Append (Source : <B>in out</B> Unbounded_String;<BR>
New_Item : <B>in</B> Character);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "&" (Left, Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "&" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "&" (Left : <B>in</B> String; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "&" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> Character)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "&" (Left : <B>in</B> Character; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5367"></A><A NAME="I5368"></A>Element (Source : <B>in</B> Unbounded_String;<BR>
Index : <B>in</B> Positive)<BR>
<B>return</B> Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5369"></A><A NAME="I5370"></A>Replace_Element (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Index : <B>in</B> Positive;<BR>
By : <B>in</B> Character);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5371"></A><A NAME="I5372"></A>Slice (Source : <B>in</B> Unbounded_String;<BR>
Low : <B>in</B> Positive;<BR>
High : <B>in</B> Natural)<BR>
<B>return</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "=" (Left, Right : <B>in</B> Unbounded_String) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "=" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "=" (Left : <B>in</B> String; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<" (Left, Right : <B>in</B> Unbounded_String) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<" (Left : <B>in</B> String; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<=" (Left, Right : <B>in</B> Unbounded_String) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<=" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<=" (Left : <B>in</B> String; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> ">" (Left, Right : <B>in</B> Unbounded_String) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> ">" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> ">" (Left : <B>in</B> String; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> ">=" (Left, Right : <B>in</B> Unbounded_String) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> ">=" (Left : <B>in</B> Unbounded_String; Right : <B>in</B> String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> ">=" (Left : <B>in</B> String; Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Examples"><TT>--<I> Search subprograms</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5373"></A><A NAME="I5374"></A>Index (Source : <B>in</B> Unbounded_String;<BR>
Pattern : <B>in</B> String;<BR>
Going : <B>in</B> Direction := Forward;<BR>
Mapping : <B>in</B> Maps.Character_Mapping<BR>
:= Maps.Identity)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5375"></A><A NAME="I5376"></A>Index (Source : <B>in</B> Unbounded_String;<BR>
Pattern : <B>in</B> String;<BR>
Going : <B>in</B> Direction := Forward;<BR>
Mapping : <B>in</B> Maps.Character_Mapping_Function)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5377"></A><A NAME="I5378"></A>Index (Source : <B>in</B> Unbounded_String;<BR>
Set : <B>in</B> Maps.Character_Set;<BR>
Test : <B>in</B> Membership := Inside;<BR>
Going : <B>in</B> Direction := Forward) <B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5379"></A><A NAME="I5380"></A>Index_Non_Blank (Source : <B>in</B> Unbounded_String;<BR>
Going : <B>in</B> Direction := Forward)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5381"></A><A NAME="I5382"></A>Count (Source : <B>in</B> Unbounded_String;<BR>
Pattern : <B>in</B> String;<BR>
Mapping : <B>in</B> Maps.Character_Mapping<BR>
:= Maps.Identity)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5383"></A><A NAME="I5384"></A>Count (Source : <B>in</B> Unbounded_String;<BR>
Pattern : <B>in</B> String;<BR>
Mapping : <B>in</B> Maps.Character_Mapping_Function)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5385"></A><A NAME="I5386"></A>Count (Source : <B>in</B> Unbounded_String;<BR>
Set : <B>in</B> Maps.Character_Set)<BR>
<B>return</B> Natural;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5387"></A><A NAME="I5388"></A>Find_Token (Source : <B>in</B> Unbounded_String;<BR>
Set : <B>in</B> Maps.Character_Set;<BR>
Test : <B>in</B> Membership;<BR>
First : <B>out</B> Positive;<BR>
Last : <B>out</B> Natural);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<DIV Class="Examples"><TT>--<I> String translation subprograms</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5389"></A><A NAME="I5390"></A>Translate (Source : <B>in</B> Unbounded_String;<BR>
Mapping : <B>in</B> Maps.Character_Mapping)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5391"></A><A NAME="I5392"></A>Translate (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Mapping : <B>in</B> Maps.Character_Mapping);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5393"></A><A NAME="I5394"></A>Translate (Source : <B>in</B> Unbounded_String;<BR>
Mapping : <B>in</B> Maps.Character_Mapping_Function)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5395"></A><A NAME="I5396"></A>Translate (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Mapping : <B>in</B> Maps.Character_Mapping_Function);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52</FONT></DIV>
<DIV Class="Examples"><TT>--<I> String transformation subprograms</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>53</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5397"></A><A NAME="I5398"></A>Replace_Slice (Source : <B>in</B> Unbounded_String;<BR>
Low : <B>in</B> Positive;<BR>
High : <B>in</B> Natural;<BR>
By : <B>in</B> String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>54</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5399"></A><A NAME="I5400"></A>Replace_Slice (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Low : <B>in</B> Positive;<BR>
High : <B>in</B> Natural;<BR>
By : <B>in</B> String);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>55</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5401"></A><A NAME="I5402"></A>Insert (Source : <B>in</B> Unbounded_String;<BR>
Before : <B>in</B> Positive;<BR>
New_Item : <B>in</B> String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>56</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5403"></A><A NAME="I5404"></A>Insert (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Before : <B>in</B> Positive;<BR>
New_Item : <B>in</B> String);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>57</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5405"></A><A NAME="I5406"></A>Overwrite (Source : <B>in</B> Unbounded_String;<BR>
Position : <B>in</B> Positive;<BR>
New_Item : <B>in</B> String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>58</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5407"></A><A NAME="I5408"></A>Overwrite (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Position : <B>in</B> Positive;<BR>
New_Item : <B>in</B> String);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>59</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5409"></A><A NAME="I5410"></A>Delete (Source : <B>in</B> Unbounded_String;<BR>
From : <B>in</B> Positive;<BR>
Through : <B>in</B> Natural)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5411"></A><A NAME="I5412"></A>Delete (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
From : <B>in</B> Positive;<BR>
Through : <B>in</B> Natural);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>61</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5413"></A><A NAME="I5414"></A>Trim (Source : <B>in</B> Unbounded_String;<BR>
Side : <B>in</B> Trim_End)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>62</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5415"></A><A NAME="I5416"></A>Trim (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Side : <B>in</B> Trim_End);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>63</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5417"></A><A NAME="I5418"></A>Trim (Source : <B>in</B> Unbounded_String;<BR>
Left : <B>in</B> Maps.Character_Set;<BR>
Right : <B>in</B> Maps.Character_Set)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>64</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5419"></A><A NAME="I5420"></A>Trim (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Left : <B>in</B> Maps.Character_Set;<BR>
Right : <B>in</B> Maps.Character_Set);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>65</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5421"></A><A NAME="I5422"></A>Head (Source : <B>in</B> Unbounded_String;<BR>
Count : <B>in</B> Natural;<BR>
Pad : <B>in</B> Character := Space)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>66</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5423"></A><A NAME="I5424"></A>Head (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Count : <B>in</B> Natural;<BR>
Pad : <B>in</B> Character := Space);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>67</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5425"></A><A NAME="I5426"></A>Tail (Source : <B>in</B> Unbounded_String;<BR>
Count : <B>in</B> Natural;<BR>
Pad : <B>in</B> Character := Space)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>68</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I5427"></A><A NAME="I5428"></A>Tail (Source : <B>in</B> <B>out</B> Unbounded_String;<BR>
Count : <B>in</B> Natural;<BR>
Pad : <B>in</B> Character := Space);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>69</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "*" (Left : <B>in</B> Natural;<BR>
Right : <B>in</B> Character)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>70</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "*" (Left : <B>in</B> Natural;<BR>
Right : <B>in</B> String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>71</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "*" (Left : <B>in</B> Natural;<BR>
Right : <B>in</B> Unbounded_String)<BR>
<B>return</B> Unbounded_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>72</FONT></DIV>
<DIV Class="Examples"><TT><B>private</B><BR>
... -- <I>not specified by the language</I><BR>
<B>end</B> Ada.Strings.Unbounded;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>73</FONT></DIV>
<DIV Class="Normal"> Null_Unbounded_String represents the null String.
If an object of type Unbounded_String is not otherwise initialized, it
will be initialized to the same value as Null_Unbounded_String.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>74</FONT></DIV>
<DIV Class="Normal"> The function Length returns the length of the
String represented by Source.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>75</FONT></DIV>
<DIV Class="Normal"> The type String_Access provides a (non-private)
access type for explicit processing of unbounded-length strings. The
procedure Free performs an unchecked deallocation of an object of type
String_Access.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>76</FONT></DIV>
<DIV Class="Normal"> The function To_Unbounded_String(Source : in
String) returns an Unbounded_String that represents Source. The function
To_Unbounded_String(Length : in Natural) returns an Unbounded_String
that represents an uninitialized String whose length is Length.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>77</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The function To_String
returns the String with lower bound 1 represented by Source. To_String
and To_Unbounded_String are related as follows: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>78</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>If S is a String, then To_String(To_Unbounded_String(S))
= S.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>79</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>If U is an Unbounded_String, then To_Unbounded_String(To_String(U))
= U. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>80</FONT></DIV>
<DIV Class="Normal"> For each of the Append procedures, the resulting
string represented by the Source parameter is given by the concatenation
of the original value of Source and the value of New_Item.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>81</FONT></DIV>
<DIV Class="Normal"> Each of the "&" functions returns
an Unbounded_String obtained by concatenating the string or character
given or represented by one of the parameters, with the string or character
given or represented by the other parameter, and applying To_Unbounded_String
to the concatenation result string.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>82</FONT></DIV>
<DIV Class="Normal"> The Element, Replace_Element, and Slice subprograms
have the same effect as the corresponding bounded-length string subprograms.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>83</FONT></DIV>
<DIV Class="Normal"> Each of the functions "=", "<",
">","<=", and ">=" returns the
same result as the corresponding String operation applied to the String
values given or represented by Left and Right.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>84</FONT></DIV>
<DIV Class="Normal"> Each of the search subprograms (Index, Index_Non_Blank,
Count, Find_Token) has the same effect as the corresponding subprogram
in Strings.Fixed applied to the string represented by the Unbounded_String
parameter.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>85</FONT></DIV>
<DIV Class="Normal"> The Translate function has an analogous effect
to the corresponding subprogram in Strings.Fixed. The translation is
applied to the string represented by the Unbounded_String parameter,
and the result is converted (via To_Unbounded_String) to an Unbounded_String.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>86</FONT></DIV>
<DIV Class="Normal"> Each of the transformation functions (Replace_Slice,
Insert, Overwrite, Delete), selector functions (Trim, Head, Tail), and
constructor functions ("*") is likewise analogous to its corresponding
subprogram in Strings.Fixed. For each of the subprograms, the corresponding
fixed-length string subprogram is applied to the string represented by
the Unbounded_String parameter, and To_Unbounded_String is applied the
result string.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>87</FONT></DIV>
<DIV Class="Normal"> For each of the procedures Translate, Replace_Slice,
Insert, Overwrite, Delete, Trim, Head, and Tail, the resulting string
represented by the Source parameter is given by the corresponding function
for fixed-length strings applied to the string represented by Source's
original value. </DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>88</FONT></DIV>
<DIV Class="Normal"> No storage associated with an Unbounded_String
object shall be lost upon assignment or scope exit. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>88.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>A
sample implementation of the private part of the package and several
of the subprograms appears in the Rationale.</FONT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-A-4-4.html">Previous</A> <A HREF="AA-A-4-6.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|