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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>NEXUS CLASS LIBRARY: NxsSetReader Class</title>
<style type="text/css">
<!--
@import url(ncl.css);
.quickref {font-family: Arial, sans-serif}
.public {font-weight: bold; color: black; background: white;}
.protected {font-weight: bold; color: teal; background: white;}
.private {font-weight: bold; color: red; background: white;}
.groupheading {font-size: large; font-weight: bold;}
.classy {font-family: Arial, sans-serif; color: navy;}
.variablename {font-weight: bold; color: maroon;}
-->
</style>
</head>
<body>
<table border="1" width="100%">
<tr><td>
<table border="0" width="100%">
<tr>
<td align="left"><span class="classy">NEXUS CLASS LIBRARY</span></td>
<td align="right"><span class="classy"><a href="v2.0index.html">home</a> | <a href="classes.html">classes</a> | <a href="functions.html">functions</a></span></td>
</tr>
</table>
</td></tr>
</table>
<h1>Class NxsSetReader</h1>
<h2>Enums</h2>
<a href="#NxsSetReaderEnum"><span class="quickref">NxsSetReaderEnum</span></a>
<h2>Data Members</h2>
<a href="#block"><span class="quickref">block</span></a>, <a href="#max"><span class="quickref">max</span></a>, <a href="#nxsset"><span class="quickref">nxsset</span></a>, <a href="#settype"><span class="quickref">settype</span></a>, <a href="#token"><span class="quickref">token</span></a>
<h2>Member Functions</h2>
<a href="#AddRange47"><span class="quickref">AddRange</span></a><a href="#GetTokenValue70"><span class="quickref">, GetTokenValue</span></a><a href="#NxsSetReader26"><span class="quickref">, NxsSetReader</span></a><a href="#Run101"><span class="quickref">, Run</span></a>
<h2>Class Description</h2>
<p>
A class for reading NEXUS set objects and storing them in a set of int values. The NxsUnsignedSet <span class="variablename">nxsset</span> will be cleared, and <span class="variablename">nxsset</span> will be built up as the set is read, with each element in the list storing a member of the set (ranges are stored as individual elements). This class handles set descriptions of the following form:<pre> 4-7 15 20-.3;
</pre> The above set includes every number from 4 to 7 (inclusive), 15 and every third number from 20 to max, where <span class="variablename">max</span> would ordinarily be set to either the last character (if <span class="variablename">settype</span> is `NxsSetReaderEnum::charset') or the last taxon (if <span class="variablename">settype</span> is `NxsSetReaderEnum::taxset'). If <span class="variablename">max</span> equaled 30, the example above would be stored as follows (remember that internally the numbers are stored with offset 0, even though in the NEXUS data file the numbers always start at 1.<pre> 3, 4, 5, 6, 14, 19, 22, 25, 28
</pre> The following example of how NxsSetReader is used comes from the <a href="NxsCharactersBlock.html">NxsCharactersBlock</a> ::HandleEliminate function:<pre> NxsSetReader(token, ncharTotal, eliminated, *this, NxsSetReader::charset).Run();
</pre> This reads in a set of eliminated characters from a NEXUS data file, storing the resulting set in the data member <span class="variablename">eliminated</span>. In this case <span class="variablename">max</span> is set to <span class="variablename">ncharTotal</span> (the total number of characters), and the block reference is set to the <a href="NxsCharactersBlock.html">NxsCharactersBlock</a> object, which provides a
<h3>Key to symbols and colors</h3>
<p><span class="public">public</span>, <span class="protected">protected</span>, <span class="private">private</span>, <code>A</code> = abstract, <code>C</code> = constructor, <code>D</code> = destructor, <code>I</code> = inline, <code>S</code> = static, <code>V</code> = virtual, <code>F</code> = friend</p>
<p> </p>
<center>
<table border="5" cellpadding="1" cellspacing="0" width="95%">
<tr bgcolor="#CCCCFF">
<td><span class="groupheading">Enums</span></td>
</tr>
</table>
<table border="1" cellpadding="3" cellspacing="0" width="95%">
<tr><td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td>
<table border="0" width="100%" cellpadding="1">
<tr>
<td align="left" width="25%"><code class="public"><a name="NxsSetReaderEnum">enum NxsSetReaderEnum</a></code></td>
<td></td>
</tr>
</table>
</td></tr>
<tr><td>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="15%"> </td>
<td align="left" colspan="2"><code>generic = 1</code></td>
</tr>
<tr>
<td width="15%"> </td>
<td width="10%"> </td>
<td>means expect a generic set (say, characters weights)</td>
</tr>
</table>
</td></tr>
<tr><td>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="15%"> </td>
<td align="left" colspan="2"><code>charset = 2</code></td>
</tr>
<tr>
<td width="15%"> </td>
<td width="10%"> </td>
<td>means expect a character set</td>
</tr>
</table>
</td></tr>
<tr><td>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="15%"> </td>
<td align="left" colspan="2"><code>taxset = 3</code></td>
</tr>
<tr>
<td width="15%"> </td>
<td width="10%"> </td>
<td>means expect a taxon set</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
</center>
<p> </p>
<center>
<table border="5" cellpadding="1" cellspacing="0" width="95%">
<tr bgcolor="#CCCCFF">
<td><span class="groupheading">Data Members</span></td>
</table>
<table border="1" cellpadding="3" cellspacing="0" width="95%">
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code> <a href="NxsBlock.html">NxsBlock</a></code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="private"><a name="block">&block</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>reference to the block object used for looking up labels</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code> unsigned</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="private"><a name="max">max</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>maximum number of elements in the set</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code> NxsUnsignedSet</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="private"><a name="nxsset">&nxsset</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>reference to the NxsUnsignedSet set being read</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code> unsigned</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="private"><a name="settype">settype</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>the type of set being read (see the NxsSetReaderEnum enumeration)</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code> <a href="NxsToken.html">NxsToken</a></code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="private"><a name="token">&token</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>reference to the token being used to parse the NEXUS data file</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>
<p> </p>
<center>
<table border="5" cellpadding="1" cellspacing="0" width="95%">
<tr bgcolor="#CCCCFF">
<td><span class="groupheading">Member Functions</span></td>
</table>
<table border="1" cellpadding="3" cellspacing="0" width="95%">
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="AddRange47">AddRange</a></code><code>(unsigned first, unsigned last, unsigned modulus)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Adds the range specified by <span class="variablename">first</span>, <span class="variablename">last</span>, and <span class="variablename">modulus</span> to the set. If <span class="variablename">modulus</span> is zero it is ignored. The parameters <span class="variablename">first</span> and <span class="variablename">last</span> refer to numbers found in the data file itself, and thus have range [1..<span class="variablename">max</span>]. They are stored in <span class="variablename">nxsset</span>, however, with offset 0. For example, if the data file says "4-102" this function would be called with <span class="variablename">first</span> = 4, <span class="variablename">last</span> = 10 and <span class="variablename">modulus</span> = 2, and the values stored in <span class="variablename">nxsset</span> would be 3, 5, 7, 9. The return value is true unless <span class="variablename">last</span> is greater than <span class="variablename">max</span>, <span class="variablename">first</span> is less than 1, or <span class="variablename">first</span> is greater than <span class="variablename">last</span>: in any of these cases, the return value is false to indicate failure to store this range.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetTokenValue70">GetTokenValue</a></code><code>()</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Tries to interpret <span class="variablename">token</span> as a number. Failing that, tries to interpret <span class="variablename">token</span> as a character or taxon label, which it then converts to a number. Failing that, it throws a <a href="NxsException.html">NxsException</a> exception.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>C</td>
<td> </td>
<td align="right" valign="top" width="15%"><code></code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="NxsSetReader26">NxsSetReader</a></code><code>(NxsToken &t, unsigned maxValue, NxsUnsignedSet &iset, NxsBlock &nxsblk, unsigned type)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Initializes <span class="variablename">max</span> to maxValue, <span class="variablename">settype</span> to <span class="variablename">type</span>, <span class="variablename">token</span> to <span class="variablename">t</span>, <span class="variablename">block</span> to <span class="variablename">nxsblk</span> and <span class="variablename">nxsset</span> to <span class="variablename">iset</span>, then clears <span class="variablename">nxsset</span>.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td> </td>
<td> </td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Run101">Run</a></code><code>()</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Reads in a set from a NEXUS data file. Returns true if the set was terminated by a semicolon, false otherwise.</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>
|