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
|
// Copyright (C) 1999-2002 Paul O. Lewis
//
// This file is part of NCL (Nexus Class Library).
//
// NCL is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// NCL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with NCL; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "ncl/ncl.h"
// not used in rncl/phylobase
#if 0
/*----------------------------------------------------------------------------------------------------------------------
| Sets the base class data member `id' to the name of the block (i.e. "EMPTY") in NEXUS data files.
*/
NxsEmptyBlock::NxsEmptyBlock()
{
id = "EMPTY";
}
/*----------------------------------------------------------------------------------------------------------------------
| Nothing needs to be done.
*/
NxsEmptyBlock::~NxsEmptyBlock()
{
}
/*----------------------------------------------------------------------------------------------------------------------
| The code here is identical to the base class version (simply returns 0), so the code here should either be modified
| or this derived version eliminated altogether. Under what circumstances would you need to modify the default code,
| you ask? This function should be modified to something meaningful if this derived class needs to construct and run
| a NxsSetReader object to read a set involving characters. The NxsSetReader 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']; i.e., add one to the 0-offset index.
*/
unsigned NxsEmptyBlock::CharLabelToNumber(
NxsString s) /* the character label to be translated to character number */
{
return 0;
}
/*----------------------------------------------------------------------------------------------------------------------
| Called when the END or ENDBLOCK command needs to be parsed from within the EMPTY block. Basically just checks to
| make sure the next token in the data file is a semicolon.
*/
void NxsEmptyBlock::HandleEndblock(
NxsToken &token) /* the token used to read from `in' */
{
DemandEndSemicolon(token, "END or ENDBLOCK");
}
/*----------------------------------------------------------------------------------------------------------------------
| This function provides the ability to read everything following the block name (which is read by the NxsReader
| object) to the END or ENDBLOCK statement. Characters are read from the input stream `in'. Overrides the pure
| virtual function in the base class.
*/
void NxsEmptyBlock::Read(
NxsToken &token) /* the token used to read from `in'*/
{
isEmpty = false;
NxsString s;
s = "BEGIN "
s += id;
DemandEndSemicolon(token, s.c_str());
for(;;)
{
token.GetNextToken();
if (token.Equals("END"))
{
HandleEndblock(token);
break;
}
else if(token.Equals("ENDBLOCK"))
{
HandleEndblock(token);
break;
}
else
{
SkippingCommand(token.GetToken());
do
{
token.GetNextToken();
}
while (!token.AtEOF() && !token.Equals(";"));
if (token.AtEOF())
{
errormsg = "Unexpected end of file encountered";
throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
}
}
}
}
/*----------------------------------------------------------------------------------------------------------------------
| Sets `isEmpty' to true in preparation for reading a new EMPTY block. Overrides the pure virtual function in the
| base class.
*/
void NxsEmptyBlock::Reset()
{
NxsBlock::Reset();
}
/*----------------------------------------------------------------------------------------------------------------------
| This function outputs a brief report of the contents of this EMPTY block. Overrides the pure virtual function in
| the base class.
*/
void NxsEmptyBlock::Report(
ostream &out) /* the output stream to which to write the report */
{
out << endl;
out << id << " block contains...";
}
/*----------------------------------------------------------------------------------------------------------------------
| This function is called when an unknown command named `commandName' is about to be skipped. This version of the
| function (which is identical to the base class version) does nothing (i.e., no warning is issued that a command
| was unrecognized). Modify this virtual function to provide such warnings to the user (or eliminate it altogether
| since the base class version already does what this does).
*/
void NxsEmptyBlock::SkippingCommand(
NxsString commandName) /* the name of the command being skipped */
{
}
/*----------------------------------------------------------------------------------------------------------------------
| The code here is identical to the base class version (simply returns 0), so the code here should either be modified
| or this derived version eliminated altogether. Under what circumstances would you need to modify the default code,
| you ask? This function should be modified to something meaningful if this derived class needs to construct and run
| a NxsSetReader object to read a set involving taxa. The NxsSetReader 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]; i.e., add one to the 0-offset index.
*/
unsigned NxsEmptyBlock::TaxonLabelToNumber(
NxsString s) /* the taxon label to be translated to a taxon number */
{
return 0;
}
#endif
|