File: NxsBlock.html

package info (click to toggle)
libncl 2.1.18%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,344 kB
  • ctags: 3,526
  • sloc: xml: 43,716; cpp: 30,400; sh: 10,658; python: 231; makefile: 190
file content (461 lines) | stat: -rw-r--r-- 18,638 bytes parent folder | download | duplicates (5)
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>NEXUS CLASS LIBRARY: NxsBlock 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 NxsBlock</h1>

<h2>Friends</h2>
class <a href="NxsReader.html"><span class="quickref">NxsReader</span></a>
<h2>Data Members</h2>
<a href="#errormsg"><span class="quickref">errormsg</span></a>, <a href="#id"><span class="quickref">id</span></a>, <a href="#isEmpty"><span class="quickref">isEmpty</span></a>, <a href="#isEnabled"><span class="quickref">isEnabled</span></a>, <a href="#isUserSupplied"><span class="quickref">isUserSupplied</span></a>, <a href="#next"><span class="quickref">next</span></a>, <a href="#nexus"><span class="quickref">nexus</span></a>
<h2>Member Functions</h2>
<a href="#CharLabelToNumber51"><span class="quickref">CharLabelToNumber</span></a><a href="#Disable66"><span class="quickref">, Disable</span></a><a href="#Enable77"><span class="quickref">, Enable</span></a><a href="#GetID117"><span class="quickref">, GetID</span></a><a href="#IsEmpty109"><span class="quickref">, IsEmpty</span></a><a href="#IsEnabled88"><span class="quickref">, IsEnabled</span></a><a href="#IsUserSupplied99"><span class="quickref">, IsUserSupplied</span></a><a href="#NxsBlock26"><span class="quickref">, NxsBlock</span></a><a href="#NxsBlock41"><span class="quickref">, ~NxsBlock</span></a><a href="#Read129"><span class="quickref">, Read</span></a><a href="#Report149"><span class="quickref">, Report</span></a><a href="#Reset142"><span class="quickref">, Reset</span></a><a href="#SetNexus160"><span class="quickref">, SetNexus</span></a><a href="#SkippingCommand171"><span class="quickref">, SkippingCommand</span></a><a href="#TaxonLabelToNumber185"><span class="quickref">, TaxonLabelToNumber</span></a>
<h2>Class Description</h2>

<p>
This is the base class from which all block classes are derived. A NxsBlock-derived class encapsulates a Nexus block (e.g. DATA block, TREES block, etc.). The abstract virtual function Read must be overridden for each derived class  to provide the ability to read everything following the block name (which is read by the  <a href="NxsReader.html">NxsReader</a>  object) to the  end or endblock statement. Derived classes must provide their own data storage and access functions. The abstract virtual function Report must be overridden to provide some feedback to user on contents of block. The abstract virtual function Reset must be overridden to empty the block of all its contents, restoring it to its  just-constructed state.


<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>&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;<a href="NxsString.html">NxsString</a></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="errormsg">errormsg</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>workspace for creating error messages</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;<a href="NxsString.html">NxsString</a></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="protected"><a name="id">id</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>holds name of block (e.g., "DATA", "TREES", etc.)</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="protected"><a name="isEmpty">isEmpty</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>true if this object is currently storing data</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="protected"><a name="isEnabled">isEnabled</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>true if this block is currently ebabled</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="protected"><a name="isUserSupplied">isUserSupplied</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>true if this object has been read from a file; false otherwise</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;NxsBlock</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="protected"><a name="next">*next</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>pointer to next block in list</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;<a href="NxsReader.html">NxsReader</a></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="protected"><a name="nexus">*nexus</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>pointer to the Nexus file reader object</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>
<p>&nbsp;</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>V</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="CharLabelToNumber51">CharLabelToNumber</a></code><code>(NxsString s)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>This base class version simply returns 0 but a derived class should override this function if it needs to construct and run a <a href="NxsSetReader.html">NxsSetReader</a> object to read a set involving characters. The <a href="NxsSetReader.html">NxsSetReader</a> object may need to use this  function to look up a character label encountered in the set. A class that overrides this method should return the character index in the range [1..nchar].</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Disable66">Disable</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets the value of isEnabled to false. A NxsBlock can be disabled (by calling this method) if blocks of that type are to be skipped during execution of the NEXUS file. If a disabled block is encountered, the virtual <a href="NxsReader.html">NxsReader</a>::SkippingDisabledBlock function is called, giving your application the opportunity to inform the user that a block was skipped.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Enable77">Enable</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets the value of isEnabled to true. A NxsBlock can be disabled (by calling Disable) if blocks of that type are to be skipped during execution of the NEXUS file. If a disabled block is encountered, the virtual  <a href="NxsReader.html">NxsReader</a>::SkippingDisabledBlock function is called, giving your application the opportunity to inform the user that a block was skipped.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code><a href="NxsString.html">NxsString</a></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetID117">GetID</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns the id <a href="NxsString.html">NxsString</a>.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsEmpty109">IsEmpty</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns true if Read function has not been called since the last Reset. This base class version simply returns the  value of the data member isEmpty. If you derive a new block class from NxsBlock, be sure to set isEmpty to true in  your Reset function and isEmpty to false in your Read function.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsEnabled88">IsEnabled</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns value of isEnabled, which can be controlled through use of the Enable and Disable member functions. A  NxsBlock should be disabled if blocks of that type are to be skipped during execution of the NEXUS file. If a  disabled block is encountered, the virtual <a href="NxsReader.html">NxsReader</a>::SkippingDisabledBlock function is called, giving your  application the opportunity to inform the user that a block was skipped.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsUserSupplied99">IsUserSupplied</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns value of isUserSupplied, which is true if and only if this block's Read function is called to process a  block of this type appearing in a data file. This is useful because in some cases, a block object may be created  internally (e.g. a <a href="NxsTaxaBlock.html">NxsTaxaBlock</a> may be populated using taxon names provided in a DATA block), and such blocks do  not require permission from the user to delete data stored therein.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>C</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="NxsBlock26">NxsBlock</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Initializes all pointer data members to NULL, and all bool data members to true except isUserSupplied, which is initialized to false.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>D</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="NxsBlock41">~NxsBlock</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Nothing to be done.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>V</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Read129">Read</a></code><code>(NxsToken &token)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>This virtual function must be overridden for each derived class to provide the ability to read everything following the block name (which is read by the <a href="NxsReader.html">NxsReader</a> object) to the end or endblock statement. Characters are read from  the input stream 'in'. Note that to get output comments displayed, you must derive a class from <a href="NxsToken.html">NxsToken</a>, override  the member function OutputComment to display a supplied comment, and then pass a reference to an object of the  derived class to this function.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>V</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Report149">Report</a></code><code>(ostream &out)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>This virtual function provides a brief report of the contents of the block.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>V</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Reset142">Reset</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>This virtual function should be overridden for each derived class to completely reset the block object in  preparation for reading in another block of this type. This function is called by the <a href="NxsReader.html">NxsReader</a> object just prior to calling the block object's Read function.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetNexus160">SetNexus</a></code><code>(NxsReader *nxsptr)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets the nexus data member of the NxsBlock object to 'nxsptr'.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>V</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SkippingCommand171">SkippingCommand</a></code><code>(NxsString commandName)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>This function is called when an unknown command named commandName is about to be skipped. This version of the  function does nothing (i.e., no warning is issued that a command was unrecognized). Override this virtual function  in a derived class to provide such warnings to the user.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>V</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="TaxonLabelToNumber185">TaxonLabelToNumber</a></code><code>(NxsString s)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>This base class version simply returns 0, but a derived class should override this function if it needs to construct and run a <a href="NxsSetReader.html">NxsSetReader</a> object to read a set involving taxa. The <a href="NxsSetReader.html">NxsSetReader</a> object may need to use this function to look up a taxon label encountered in the set. A class that overrides this method should return the taxon index in the range [1..ntax].</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>