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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - The Package Strings.Maps</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-1.html">Previous</A> <A HREF="AA-A-4-3.html">Next</A></P>
<HR>
<H1> A.4.2 The Package Strings.Maps</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> The package Strings.Maps defines the types, operations,
and other entities needed for character sets and character-to-character
mappings. </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.Maps has the following declaration: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Examples"><TT><A NAME="I5138"></A><A NAME="I5139"></A><A NAME="I5140"></A><B>package</B> Ada.Strings.Maps <B>is</B><BR>
<B>pragma</B> Preelaborate(Maps);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Examples"><TT> --<I> Representation for a set of character values:</I><BR>
<B>type</B> <A NAME="I5141"></A><A NAME="I5142"></A>Character_Set <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I5143"></A>Null_Set : <B>constant</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I5144"></A><A NAME="I5145"></A>Character_Range <B>is</B><BR>
<B>record</B><BR>
Low : Character;<BR>
High : Character;<BR>
<B>end</B> <B>record</B>;<BR>
-- <I>Represents Character range Low..High</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I5146"></A><A NAME="I5147"></A>Character_Ranges <B>is</B> <B>array</B> (Positive <B>range</B> <>) <B>of</B> Character_Range;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5148"></A><A NAME="I5149"></A>To_Set (Ranges : <B>in</B> Character_Ranges)<B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5150"></A><A NAME="I5151"></A>To_Set (Span : <B>in</B> Character_Range)<B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5152"></A><A NAME="I5153"></A>To_Ranges (Set : <B>in</B> Character_Set) <B>return</B> Character_Ranges;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "=" (Left, Right : <B>in</B> Character_Set) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<B>not</B>" (Right : <B>in</B> Character_Set) <B>return</B> Character_Set;<BR>
<B>function</B> "<B>and</B>" (Left, Right : <B>in</B> Character_Set) <B>return</B> Character_Set;<BR>
<B>function</B> "<B>or</B>" (Left, Right : <B>in</B> Character_Set) <B>return</B> Character_Set;<BR>
<B>function</B> "<B>xor</B>" (Left, Right : <B>in</B> Character_Set) <B>return</B> Character_Set;<BR>
<B>function</B> "-" (Left, Right : <B>in</B> Character_Set) <B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5154"></A><A NAME="I5155"></A>Is_In (Element : <B>in</B> Character;<BR>
Set : <B>in</B> Character_Set)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5156"></A><A NAME="I5157"></A>Is_Subset (Elements : <B>in</B> Character_Set;<BR>
Set : <B>in</B> Character_Set)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> "<=" (Left : <B>in</B> Character_Set;<BR>
Right : <B>in</B> Character_Set)<BR>
<B>return</B> Boolean <B>renames</B> Is_Subset;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT> --<I> Alternative representation for a set of character values:</I><BR>
<B>subtype</B> <A NAME="I5158"></A>Character_Sequence <B>is</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5159"></A><A NAME="I5160"></A>To_Set (Sequence : <B>in</B> Character_Sequence)<B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5161"></A><A NAME="I5162"></A>To_Set (Singleton : <B>in</B> Character) <B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5163"></A><A NAME="I5164"></A>To_Sequence (Set : <B>in</B> Character_Set) <B>return</B> Character_Sequence;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Examples"><TT> --<I> Representation for a character to character mapping:</I><BR>
<B>type</B> <A NAME="I5165"></A><A NAME="I5166"></A>Character_Mapping <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5167"></A><A NAME="I5168"></A>Value (Map : <B>in</B> Character_Mapping;<BR>
Element : <B>in</B> Character)<BR>
<B>return</B> Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT> <A NAME="I5169"></A>Identity : <B>constant</B> Character_Mapping;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5170"></A><A NAME="I5171"></A>To_Mapping (From, To : <B>in</B> Character_Sequence)<BR>
<B>return</B> Character_Mapping;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I5172"></A><A NAME="I5173"></A>To_Domain (Map : <B>in</B> Character_Mapping)<BR>
<B>return</B> Character_Sequence;<BR>
<B>function</B> <A NAME="I5174"></A><A NAME="I5175"></A>To_Range (Map : <B>in</B> Character_Mapping)<BR>
<B>return</B> Character_Sequence;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Examples"><TT> <B>type</B> <A NAME="I5176"></A><A NAME="I5177"></A>Character_Mapping_Function <B>is</B><BR>
<B>access</B> <B>function</B> (From : <B>in</B> Character) <B>return</B> Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT><B>private</B><BR>
... -- <I>not specified by the language</I><BR>
<B>end</B> Ada.Strings.Maps;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Normal"> An object of type Character_Set represents a
set of characters.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal"> Null_Set represents the set containing no characters.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Normal"> An object Obj of type Character_Range represents
the set of characters in the range Obj.Low .. Obj.High.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Normal"> An object Obj of type Character_Ranges represents
the union of the sets corresponding to Obj(I) for I in Obj'Range. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Set (Ranges : <B>in</B> Character_Ranges) <B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">If Ranges'Length=0
then Null_Set is returned; otherwise the returned value represents the
set corresponding to Ranges.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Set (Span : <B>in</B> Character_Range) <B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="CodeIndented">The returned value represents the set containing
each character in Span. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Ranges (Set : <B>in</B> Character_Set) <B>return</B> Character_Ranges;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">If Set = Null_Set
then an empty Character_Ranges array is returned; otherwise the shortest
array of contiguous ranges of Character values in Set, in increasing
order of Low, is returned.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> "=" (Left, Right : <B>in</B> Character_Set) <B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The function
"=" returns True if Left and Right represent identical sets,
and False otherwise. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.9em"> Each of the logical
operators "<B>not</B>", "<B>and</B>", "<B>or</B>",
and "<B>xor</B>" returns a Character_Set value that represents
the set obtained by applying the corresponding operation to the set(s)
represented by the parameter(s) of the operator. "-"(Left,
Right) is equivalent to "and"(Left, "not"(Right)).
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>The set minus operator
is provided for efficiency.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Is_In (Element : <B>in</B> Character;<BR>
Set : <B>in</B> Character_Set);<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Is_In returns
True if Element is in Set, and False otherwise.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Is_Subset (Elements : <B>in</B> Character_Set;<BR>
Set : <B>in</B> Character_Set)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Is_Subset returns
True if Elements is a subset of Set, and False otherwise.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<DIV Class="Examples"><TT><B>subtype</B> Character_Sequence <B>is</B> String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The Character_Sequence
subtype is used to portray a set of character values and also to identify
the domain and range of a character mapping. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Although a named
subtype is redundant -- the predefined type String could have been used
for the parameter to To_Set and To_Mapping below -- the use of a differently
named subtype identifies the intended purpose of the parameter. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Set (Sequence : <B>in</B> Character_Sequence) <B>return</B> Character_Set;<BR>
<BR>
<B>function</B> To_Set (Singleton : <B>in</B> Character) <B>return</B> Character_Set;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Sequence portrays
the set of character values that it explicitly contains (ignoring duplicates).
Singleton portrays the set comprising a single Character. Each of the
To_Set functions returns a Character_Set value that represents the set
portrayed by Sequence or Singleton.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Sequence (Set : <B>in</B> Character_Set) <B>return</B> Character_Sequence;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The function
To_Sequence returns a Character_Sequence value containing each of the
characters in the set represented by Set, in ascending order with no
duplicates.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<DIV Class="Examples"><TT><B>type</B> Character_Mapping <B>is</B> <B>private</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">An object of
type Character_Mapping represents a Character-to-Character mapping.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> Value (Map : <B>in</B> Character_Mapping;<BR>
Element : <B>in</B> Character)<BR>
<B>return</B> Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>53</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The function
Value returns the Character value to which Element maps with respect
to the mapping represented by Map. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>54</FONT></DIV>
<DIV Class="Normal"> <A NAME="I5178"></A>A character C <I>matches</I>
a pattern character P with respect to a given Character_Mapping value
Map if Value(Map, C) = P. <A NAME="I5179"></A>A string S <I>matches</I>
a pattern string P with respect to a given Character_Mapping if their
lengths are the same and if each character in S matches its corresponding
character in the pattern string P. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>54.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>In an earlier
version of the string handling packages, the definition of matching was
symmetrical, namely C matches P if Value(Map,C) = Value(Map,P). However,
applying the mapping to the pattern was confusing according to some reviewers.
Furthermore, if the symmetrical version is needed, it can be achieved
by applying the mapping to the pattern (via translation) prior to passing
it as a parameter. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>55</FONT></DIV>
<DIV Class="Normal"> String handling subprograms that deal with character
mappings have parameters whose type is Character_Mapping. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>56</FONT></DIV>
<DIV Class="Examples"><TT>Identity : <B>constant</B> Character_Mapping;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>57</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">Identity maps
each Character to itself.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>58</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Mapping (From, To : <B>in</B> Character_Sequence)<BR>
<B>return</B> Character_Mapping;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>59</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">To_Mapping produces
a Character_Mapping such that each element of From maps to the corresponding
element of To, and each other character maps to itself. If From'Length
/= To'Length, or if some character is repeated in From, then Translation_Error
is propagated.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Domain (Map : <B>in</B> Character_Mapping) <B>return</B> Character_Sequence;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>61</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">To_Domain returns
the shortest Character_Sequence value D such that each character not
in D maps to itself, and such that the characters in D are in ascending
order. The lower bound of D is 1.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>62</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B> To_Range (Map : <B>in</B> Character_Mapping) <B>return</B> Character_Sequence;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>63/1</FONT></DIV>
<DIV Class="CodeIndented">{<I><A HREF="defect1.html#8652/0048">8652/0048</A></I>}
To_Range returns the Character_Sequence value R, <S>with lower bound
1 and upper bound Map'Length,</S> such that if D = To_Domain(Map)<U>,
then R has the same bounds as D, and</U><S> then</S> D(I) maps to R(I)
for each I in D'Range. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>64</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.9em"> An object F of
type Character_Mapping_Function maps a Character value C to the Character
value F.<B>all</B>(C), which is said to <I>match</I> C with respect to
mapping function F. <A NAME="I5180"></A></DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>65</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>7 Character_Mapping and Character_Mapping_Function
are used both for character equivalence mappings in the search subprograms
(such as for case insensitivity) and as transformational mappings in
the Translate subprograms.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>66</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>8 To_Domain(Identity) and
To_Range(Identity) each returns the null string. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>66.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>Package Strings.Maps
is not pure, since it declares an access-to-subprogram type. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>67</FONT></DIV>
<DIV Class="Normal"> To_Mapping("ABCD", "ZZAB")
returns a Character_Mapping that maps 'A' and 'B' to 'Z', 'C' to 'A',
'D' to 'B', and each other Character to itself. </DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-A-4-1.html">Previous</A> <A HREF="AA-A-4-3.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|