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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>NEXUS CLASS LIBRARY: MyNexusFileReader 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 MyNexusFileReader</h1>
<h2>Data Members</h2>
<a href="#inf"><span class="quickref">inf</span></a>, <a href="#infile_exists"><span class="quickref">infile_exists</span></a>, <a href="#outf"><span class="quickref">outf</span></a>
<h2>Member Functions</h2>
<a href="#DebugReportBlock172"><span class="quickref">DebugReportBlock</span></a><a href="#EnteringBlock82"><span class="quickref">, EnteringBlock</span></a><a href="#ExitingBlock94"><span class="quickref">, ExitingBlock</span></a><a href="#FileExists121"><span class="quickref">, FileExists</span></a><a href="#MyNexusFileReader53"><span class="quickref">, MyNexusFileReader</span></a><a href="#MyNexusFileReader72"><span class="quickref">, ~MyNexusFileReader</span></a><a href="#NexusError188"><span class="quickref">, NexusError</span></a><a href="#OutputComment106"><span class="quickref">, OutputComment</span></a><a href="#SkippingBlock146"><span class="quickref">, SkippingBlock</span></a><a href="#SkippingDisabledBlock160"><span class="quickref">, SkippingDisabledBlock</span></a>
<h2>Class Description</h2>
<p>
This class represents a NEXUS file reader that supervises the interpretation of a NEXUS-formatted data file. It overloads several important virtual base class functions, including EnteringBlock and ExitingBlock (which allow it to inform the user when particular blocks are being entered or exited), ExecuteStarting and ExecuteStopping (which allow any initialization before a NEXUS file is read or cleanup afterwards, respectively), SkippingBlock and SkippingDisabledBlock (which allow user to be informed when unknown NEXUS blocks are encountered in the data file or when NEXUS blocks are encountered that are known to this application but are being skipped because these blocks were temporarily disabled), OutputComment (which determines how user-specified printable comments in NEXUS files are displayed), and NexusError (which determines how errors encountered in the NEXUS data file are to be reported).
<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">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> ifstream</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="inf">inf</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>input file stream used for reading NEXUS file</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="infile_exists">infile_exists</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>true if input file is determined to exist, false otherwise</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> ofstream</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="outf">outf</a></code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>output file stream used for reporting progress</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>void</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="DebugReportBlock172">DebugReportBlock</a></code><code>(NxsBlock &nexusBlock)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. If a block of the type referenced by 'nexusBlock' has been read (i.e. the IsEmpty member function returns false), this function calls the Report member function of 'nexusBlock' to dump the contents of the block object to the output file stream outf.</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="EnteringBlock82">EnteringBlock</a></code><code>(NxsString blockName)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. Simply reports to both standard output and the output file stream outf that a block named 'blockName' was just entered by the NEXUS file reader. Always returns true.</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>void</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="ExitingBlock94">ExitingBlock</a></code><code>(NxsString blockName)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. Simply reports to both standard output and the output file stream outf that the NEXUS file reader just finished with a block named 'blockName'.</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="FileExists121">FileExists</a></code><code>(char *fn)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>A simple function to test for the existance of a file named 'fn'. Returns true if an attempt to open the file succeeds, and false otherwise. No attempt is made to diagnose failure to open the file, so this function may return false even when the file exists if the file could not be opened for some other reason (e.g. user does not have read permissions for that file).</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="MyNexusFileReader53">MyNexusFileReader</a></code><code>(char *infname, char *outfname)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Initializes infile_exists to true if a file by the name 'infname' exists and to false otherwise. If a file named 'infname' exists, proceeds to open the ifstream data member inf to that file and the ofstream data member outf to the file specified by the 'outfname' argument. Does not check for the existance of the output file beforehand, so will overwrite a file if one by than name already exists. In a real application, use the FileExists member function to check for the existance of the output file as well and warn the user before opening it.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>D</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="MyNexusFileReader72">~MyNexusFileReader</a></code><code>()</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Destructor simply closes the input file stream inf and the output file stream outf.</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>void</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="NexusError188">NexusError</a></code><code>(NxsString msg, file_pos pos, unsigned line, unsigned col)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. This function simply reports the error message contained in the string 'msg' and the file position, line and column (contained in 'pos', 'line' and 'col', respectively) to both the standard error stream and the output file stream outf. It then aborts the application by invoking exit(0).</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>void</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="OutputComment106">OutputComment</a></code><code>(const NxsString &s)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. Simply outputs the string 's' to both the standard output and the output stream outf. This function will be called when a printable NEXUS comment is found in a NEXUS file. The contents of the comment are provided in the string argument 's'.</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>void</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SkippingBlock146">SkippingBlock</a></code><code>(NxsString blockName)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. Simply reports to both the standard output and to the output stream outf that a block named 'blockName' is being skipped because this NEXUS file reader does not know how to interpret blocks by this name. This situation is common if the NEXUS file has private blocks, e.g. a PAUP block containing commands understood only by the program PAUP.</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>void</code></td>
<td> </td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SkippingDisabledBlock160">SkippingDisabledBlock</a></code><code>(NxsString blockName)</code></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><dd>Override of base class virtual function. Simply reports to both the standard output and to the output stream outf that a block named 'blockName' is being skipped because this block, though known to the NEXUS reader, is currently disabled. This situation arises when reading a treefile for instance (the application may disable all blocks except <a href="NxsTreesBlock.html">NxsTreesBlock</a> because only TREES blocks expected in a treefile. Overriding this function gives the application a chance to report to the user that NEXUS blocks were found in the file that were unexpected under the circumstances.</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>
|