// This file is part of BULL, a program for phylogenetic simulations // most of the code was written by Mark T. Holder. // It 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. // // Some of the code is from publically available source by Paul Lewis, Ziheng Yang, // John Huelsenbeck, David Swofford , and others (as noted in the code). // In fact the main structure of the program was created by modifying Paul Lewis' // basiccmdline.cpp from his NCL // // This code was used in Mark's dissertation, some changes were made in order to // get it to compile on gcc. It is possible that this porting introduced bugs (very // little debugging has been done on UNIX platforms). I would suggest checking // the simulator by generating data on trees with short branches, etc. // This file is part of BULL, a program for phylogenetic simulations // most of the code was written by Mark T. Holder. // It 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. // // Some of the code is from publically available source by Paul Lewis, Ziheng Yang, // John Huelsenbeck, David Swofford , and others (as noted in the code). // In fact the main structure of the program was created by modifying Paul Lewis' // basiccmdline.cpp from his NCL // // This code was used in Mark's dissertation, some changes were made in order to // get it to compile on gcc. It is possible that this porting introduced bugs (very // little debugging has been done on UNIX platforms). I would suggest checking // the simulator by generating data on trees with short branches, etc. #ifndef __NEXUSTOKEN_H #define __NEXUSTOKEN_H #include #if defined HAVE_CONFIG_H && HAVE_CONFIG_H # include #endif // NexusToken class // class NexusToken { std::istream& in; int newlineType; std::istream::pos_type filepos; long fileline; long filecol; std::string token; std::string comment; char saved; bool atEOF; bool atEOL; char special; int labileFlags; protected: void AppendToComment( char ch ); void AppendToToken( char ch ); char GetNextChar(); void GetComment(); void GetCurlyBracketedToken(); void GetDoubleQuotedToken(); void GetQuoted(); void GetParentheticalToken(); bool IsPunctuation( char ch ); bool IsWhitespace( char ch ); bool IsConsistentWithFirstPartOfSciNotation(); public: enum { saveCommandComments = 0x0001, parentheticalToken = 0x0002, curlyBracketedToken = 0x0004, doubleQuotedToken = 0x0008, singleCharacterToken = 0x0010, newlineIsToken = 0x0020, tildeIsPunctuation = 0x0040, useSpecialPunctuation = 0x0080 }; std::string errormsg; NexusToken(std::istream& i ); virtual ~NexusToken(); //////////////////////////////////////////////////////////////////////////// /// true if the input stream is exhausted or out of commission bool AtEOF() const { return atEOF; } //////////////////////////////////////////////////////////////////////////// /// true iff the last call to GetNextToken encountered the newline /// AND the newlineIsToken labile flag was in effect. bool AtEOL() const { return atEOL; } long GetFileColumn() const { return filecol; } std::iostream::pos_type GetFilePosition() const { return filepos; } long GetFileLine() const { return fileline; } const std::string & GetToken() const { return token; } std::size_t GetTokenLength() const { return GetToken().length(); } bool Abbreviation( std::string s ); bool Begins( std::string s, bool respect_case = false ); void BlanksToUnderscores(); bool Equals( std::string s, bool respect_case = false ); void GetNextToken(); bool IsPlusMinusToken(); bool IsPunctuationToken(); bool IsWhitespaceToken(); void ReplaceToken( const std::string s ); void ResetToken(); void SetSpecialPunctuationCharacter( char c ); void SetLabileFlagBit( int bit ); bool StoppedOn( char ch ); void StripWhitespace(); void Write(std::ostream& out ); void Writeln(std::ostream& out ); // MTH additions bool IsInteger(); long GetLongEquivalent();//should be called after IsInteger returns true // virtual function that should be overridden in derived classes virtual void OutputComment( std::string& msg ); }; #endif