当前位置: 首页>>代码示例>>C++>>正文


C++ NxsToken类代码示例

本文整理汇总了C++中NxsToken的典型用法代码示例。如果您正苦于以下问题:C++ NxsToken类的具体用法?C++ NxsToken怎么用?C++ NxsToken使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NxsToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InterpretTokenAsIndices

/**
|	returns the number of indices added.
*/
unsigned NxsSetReader::InterpretTokenAsIndices(NxsToken &token, 
  const NxsLabelToIndicesMapper & mapper, 
  const char * setType, 
  const char * cmdName, 
  NxsUnsignedSet * destination)
	{
	try {
		const std::string t = token.GetToken();
		if (NxsString::case_insensitive_equals(t.c_str(), "ALL"))
			{
			unsigned m = mapper.GetMaxIndex();
			NxsUnsignedSet s;
			for (unsigned i = 0; i <= m; ++i)
				s.insert(i);
			destination->insert(s.begin(), s.end());
			return (unsigned)s.size();
			}
		return mapper.GetIndicesForLabel(t, destination);
		}
	catch (const NxsException & x)
		{
		NxsString errormsg = "Error in the ";
		errormsg << setType << " descriptor of a " << cmdName << " command.\n";
		errormsg += x.msg;
		throw NxsException(errormsg, token);
		}
	catch (...)
		{
		NxsString errormsg = "Expecting a ";
		errormsg << setType << " descriptor (number or label) in the " << cmdName << ".  Encountered ";
		errormsg <<  token.GetToken();
		throw NxsException(errormsg, token);
		}
	}
开发者ID:rforge,项目名称:phylobase,代码行数:37,代码来源:nxssetreader.cpp

示例2: Read

void NxsTaxaAssociationBlock::Read(
    NxsToken &token) /* the token used to read from `in' */
{
    isEmpty = false;

    DemandEndSemicolon(token, "BEGIN TAXAASSOCIATION");

    for (;; )
    {
        token.GetNextToken();
        NxsBlock::NxsCommandResult res = HandleBasicBlockCommands(token);
        if (res == NxsBlock::NxsCommandResult(STOP_PARSING_BLOCK))
        {
            return;
        }
        if (res != NxsBlock::NxsCommandResult(HANDLED_COMMAND))
        {
            if (token.Equals("TAXA"))
            {
                HandleTaxaCommand(token);
            }
            else if (token.Equals("ASSOCIATES"))
            {
                HandleAssociatesCommand(token);
            }
            else
            {
                SkipCommand(token);
            }
        }
    }
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例3: HandleHelp

/*----------------------------------------------------------------------------------------------------------------------
|	Called when the HELP command needs to be parsed from within the GarliReader block.
*/
void GarliReader::HandleHelp(
    NxsToken &token)	/* the token used to read from `in' */
{
    // Retrieve all tokens for this command, stopping only in the event
    // of a semicolon or an unrecognized keyword
    //
    for (;;)
    {
        token.GetNextToken();

        if (token.Equals(";"))
        {
            break;
        }
        else
        {
            errormsg = "Unexpected keyword (";
            errormsg += token.GetToken();
            errormsg += ") encountered reading HELP command";
            throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
        }
    }

    message = "\nExamples of use of available commands:";
    message += "\n  help                     -> shows this message";
    message += "\n  log file=mylog.txt start -> opens log file named mylog.txt";
    message += "\n  log stop                 -> closes current log file";
    message += "\n  exe mydata.nex           -> executes nexus file mydata.nex";
    message += "\n  show                     -> reports on blocks currently stored";
    message += "\n  quit                     -> terminates application";
    message += "\n";
    PrintMessage();
}
开发者ID:rekepalli,项目名称:garli,代码行数:36,代码来源:garlireader.cpp

示例4: HandleBlockIDCommand

/*----------------------------------------------------------------------------------------------------------------------
|	Stores the next token as the this->blockid field.
*/
void NxsBlock::HandleBlockIDCommand(NxsToken & token)
	{
	token.GetNextToken();
	if (token.Equals(";"))
		GenerateUnexpectedTokenNxsException(token, "an id for the block");
	blockIDString = token.GetToken();
	DemandEndSemicolon(token, "BLOCKID");
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:11,代码来源:nxsblock.cpp

示例5: NxsException

*/void NxsBlock::DemandIsAtEquals(NxsToken &token, const char *contextString) const
	{
	if (!token.Equals("="))
		{
		errormsg = "Expecting '=' ";
		if (contextString)
			errormsg.append(contextString);
		errormsg << " but found " << token.GetToken() << " instead";
		throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
		}
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:11,代码来源:nxsblock.cpp

示例6: HandleLinkTaxaCommand

/*only used it the linkAPI is enabled*/
void NxsTaxaBlockSurrogate::HandleLinkTaxaCommand(NxsToken & token)
	{
	token.GetNextToken();
	const std::map<std::string, std::string> kv = token.ProcessAsSimpleKeyValuePairs("LINK");
	std::map<std::string, std::string>::const_iterator pairIt = kv.begin();
	for (;pairIt != kv.end(); ++pairIt)
		{
		NxsTaxaBlockAPI *entryTaxa = taxa;
		int entryTaxaLinkStatus = taxaLinkStatus;
		NxsString key(pairIt->first.c_str());
		key.ToUpper();
		NxsString value(pairIt->second.c_str());
		if (key == "TAXA")
			{
			if (taxa && !taxa->GetID().EqualsCaseInsensitive(value))
				{
				if (GetTaxaLinkStatus() & NxsBlock::BLOCK_LINK_USED)
					{
					NxsString errormsg = "LINK to a Taxa block must occur before commands that use a taxa block";
					throw NxsException(errormsg, token);
					}
				SetTaxaBlockPtr(NULL, NxsBlock::BLOCK_LINK_UNINITIALIZED);
				}
			if (!taxa)
				{
				if (!nxsReader)
					{
					NxsString errormsg =  "API Error: No nxsReader during parse in NxsTaxaBlockSurrogate::HandleLinkTaxaCommand";
					throw NxsNCLAPIException(errormsg, token);
					}
				NxsTaxaBlockAPI * cb = nxsReader->GetTaxaBlockByTitle(value.c_str(), NULL);
				if (cb == NULL)
					{
					NxsString errormsg = "Unknown TAXA block (";
					errormsg += value;
					errormsg +=") referred to in the LINK command";
					taxa = entryTaxa;
					taxaLinkStatus = entryTaxaLinkStatus;
					throw NxsException(errormsg, token);
					}
				SetTaxaBlockPtr(cb, NxsBlock::BLOCK_LINK_FROM_LINK_CMD);
				}				
			}
		else
			{
			NxsString errormsg = "Skipping unknown LINK subcommand: ";
			errormsg += pairIt->first.c_str();
			nxsReader->NexusWarnToken(errormsg, NxsReader::SKIPPING_CONTENT_WARNING, token);
			errormsg.clear(); //this token pos will be off a bit.
			}
		}
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:53,代码来源:nxstaxablock.cpp

示例7: GenerateUnexpectedTokenNxsException

/*----------------------------------------------------------------------------------------------------------------------
| throws a NxsException with the token info for `token` 
| `expected` should fill in the phrase "Expecting ${expected}, but found..."
| expected can be NULL.
|
| Sets this->errormsg
*/
void NxsBlock::GenerateUnexpectedTokenNxsException(NxsToken &token, const char *expected) const
	{
	errormsg = "Unexpected token";
	if (expected)
		{
		errormsg += ". Expecting ";
		errormsg += expected;
		errormsg += ", but found: ";
		}
	else
		{
		errormsg += ": ";
		}
	errormsg += token.GetToken();
	throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:23,代码来源:nxsblock.cpp

示例8:

NxsX_UnexpectedEOF::NxsX_UnexpectedEOF(NxsToken &token)
	:NxsException("Unexpected end-of-file", token)
	{
	std::string t = token.GetBlockName();
	NxsString::to_upper(t);
	if (!t.empty())
		msg << " while reading " << t << " block.";
	}
开发者ID:rforge,项目名称:phylobase,代码行数:8,代码来源:nxstoken.cpp

示例9: column

/*!
	Called from HandleMatrix function to read in the next state. Returns true if next token encountered is a comma,
	false otherwise. A comma signals the end of data for the current taxon in an UNALIGNED block.
*/
bool NxsUnalignedBlock::HandleNextState(
  NxsToken & token,			/* is the token used to read from `in' */
  unsigned taxNum,				/* is the row in range [0..ntax) (used for error reporting only) */
  unsigned charNum,				/* is the column (used for error reporting only) */
  NxsDiscreteStateRow & row, const NxsString &nameStr)	/* is the container for storing new state */
	{
	token.SetLabileFlagBit(NxsToken::parentheticalToken);
	token.SetLabileFlagBit(NxsToken::curlyBracketedToken);
	token.SetLabileFlagBit(NxsToken::singleCharacterToken);

	token.GetNextToken();

	if (token.Equals(",") || token.Equals(";"))
		return false;
	const NxsString stateAsNexus = token.GetToken();
	const NxsDiscreteStateCell stateCode = mapper.EncodeNexusStateString(stateAsNexus, token, taxNum, charNum, NULL, nameStr);
	if (charNum < row.size())
		row[charNum] = stateCode;
	else
		{
		while (charNum < row.size())
			row.push_back(NXS_INVALID_STATE_CODE);
		row.push_back(stateCode);
		}
	return true;
	}
开发者ID:cdesjardins,项目名称:ncl,代码行数:30,代码来源:nxsunalignedblock.cpp

示例10: HandleTitleCommand

/*----------------------------------------------------------------------------------------------------------------------
|	Stores the next token as the this->title field.
*/
void NxsBlock::HandleTitleCommand(NxsToken & token)
	{
	token.GetNextToken();
	if (token.Equals(";"))
		GenerateUnexpectedTokenNxsException(token, "a title for the block");
	if (!title.empty() && nexusReader)
		{
		errormsg = "Multiple TITLE commands were encountered the title \"";
		errormsg += title;
		errormsg += "\" will be replaced by \"";
		errormsg += token.GetToken() ;
		errormsg += '\"';
		nexusReader->NexusWarnToken(errormsg, NxsReader::OVERWRITING_CONTENT_WARNING, token);
		errormsg.clear();
		}
	title = token.GetToken();
	autoTitle = false;
	DemandEndSemicolon(token, "TITLE");
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:22,代码来源:nxsblock.cpp

示例11: SkipCommand

void NxsBlock::SkipCommand(NxsToken & token)
	{
	if (nexusReader)
		{
		errormsg = "Skipping command: ";
		errormsg << token.GetTokenReference();
		nexusReader->NexusWarnToken(errormsg, NxsReader::SKIPPING_CONTENT_WARNING, token);
		errormsg.clear();
		}
	if (!token.Equals(";"))
		SkippingCommand(token.GetToken());
	if (storeSkippedCommands)
		{
		ProcessedNxsCommand pnc;
		token.ProcessAsCommand(&pnc);
		skippedCommands.push_back(pnc);
		}
	else
		token.ProcessAsCommand(NULL);
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:20,代码来源:nxsblock.cpp

示例12: Read

void BlockParams::Read(NxsToken &token)
{
  DemandEndSemicolon(token, "PARAMS");
  nat idCtr = 0; 

  auto catsFound = std::unordered_set<Category>{}; 

  while(true)
    {
      token.GetNextToken();
      NxsBlock::NxsCommandResult res = HandleBasicBlockCommands(token); 

      if (res == NxsBlock::NxsCommandResult(STOP_PARSING_BLOCK))
	return;

      if (res != NxsBlock::NxsCommandResult(HANDLED_COMMAND))
	{	  
	  auto str = token.GetToken(false); 

	  auto cat = CategoryFuns::getCategoryFromLinkLabel(str); 	  
	  parseScheme(token, cat, idCtr); 

	  if(catsFound.find(cat) != catsFound.end())
	    {
	      cerr << "parsing error: found a linking scheme for category  " <<  CategoryFuns::getShortName(cat) << " twice. Aborting." ; 
	      exitFunction(-1, true); 
	    }

	  if( cat == Category::TOPOLOGY)
	    {
	      cerr <<  "not implemented"; 
	      assert(0); 
	    }	    
	}
    }
}
开发者ID:pombredanne,项目名称:exa-bayes,代码行数:36,代码来源:BlockParams.cpp

示例13: HandleDimensions

/*!
	Called when DIMENSIONS command needs to be parsed from within the UNALIGNED block. Deals with everything after the
	token DIMENSIONS up to and including the semicolon that terminates the DIMENSIONS command.
*/
void NxsUnalignedBlock::HandleDimensions(
  NxsToken & token)			/* the token used to read from `in' */
	{
	unsigned ntaxRead = 0;
	for (;;)
		{
		token.GetNextToken();
		if (token.Equals("NEWTAXA"))
			newtaxa = true;
		else if (token.Equals("NTAX"))
			{
			DemandEquals(token, "after NTAX in DIMENSIONS command");
			ntaxRead = DemandPositiveInt(token, "NTAX");
			}
		else if (token.Equals(";"))
			break;
		}
	if (newtaxa)
		{
		if (ntaxRead == 0)
			{
			errormsg = "DIMENSIONS command must have an NTAX subcommand when the NEWTAXA option is in effect.";
			throw NxsException(errormsg, token);
			}
		AssureTaxaBlock(createImpliedBlock, token, "Dimensions");
		if (!createImpliedBlock)
			{
			taxa->Reset();
			if (nexusReader)
				nexusReader->RemoveBlockFromUsedBlockList(taxa);
			}
		taxa->SetNtax(ntaxRead);
		nTaxWithData = ntaxRead;
		}
	else
		{
		AssureTaxaBlock(false, token, "Dimensions");
		const unsigned ntaxinblock = taxa->GetNTax();
		if (ntaxinblock == 0)
			{
			errormsg = "A TAXA block must be read before character data, or the DIMENSIONS command must use the NEWTAXA.";
			throw NxsException(errormsg, token);
			}
		if (ntaxinblock < ntaxRead)
			{
			errormsg = "NTAX in UNALIGNED block must be less than or equal to NTAX in TAXA block\nNote: one circumstance that can cause this error is \nforgetting to specify NTAX in DIMENSIONS command when \na TAXA block has not been provided";
			throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
			}
		nTaxWithData = (ntaxRead == 0 ? ntaxinblock : ntaxRead);
		}
	}
开发者ID:cdesjardins,项目名称:ncl,代码行数:55,代码来源:nxsunalignedblock.cpp

示例14: HandleTaxLabels

void NxsTaxaBlock::HandleTaxLabels(NxsToken &token)
	{
	if (dimNTax == 0) 
		{
		errormsg = "NTAX must be specified before TAXLABELS command";
		throw NxsException(errormsg, token.GetFilePosition(), token.GetFileLine(), token.GetFileColumn());
		}
	taxLabels.clear();
	labelToIndex.clear();
	for (unsigned i = 0; i < dimNTax; i++)
		{
		token.GetNextToken();
		try
			{
			NxsString t = token.GetToken();
			AddTaxonLabel(t);
			}
		catch (const NxsException & x)
			{
			throw NxsException(x.msg, token);
			}
		}
	DemandEndSemicolon(token, "TAXLABELS");
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:24,代码来源:nxstaxablock.cpp

示例15: blocks

/*----------------------------------------------------------------------------------------------------------------------
|	Hook to consolidate the handling of COMMANDS that are common to all blocks (TITLE, BLOCKID, END, ENDBLOCK -- and,
|		evenually, LINK).
|	HandleXYZ() where XYZ is the command name is then called.  
|	Returns NxsCommandResult(HANDLED_COMMAND), NxsCommandResult(HANDLED_COMMAND), or NxsCommandResult(UNKNOWN_COMMAND)
|		to tell the caller whether the command was recognized.
*/
NxsBlock::NxsCommandResult NxsBlock::HandleBasicBlockCommands(NxsToken & token)
	{
	if (token.Equals("TITLE"))
		{
		HandleTitleCommand(token);
		return NxsBlock::NxsCommandResult(HANDLED_COMMAND);
		}
	if (false && token.Equals("BLOCKID")) /*now we are skipping this to put it at the end of blocks*/
		{
		HandleBlockIDCommand(token);
		return NxsBlock::NxsCommandResult(HANDLED_COMMAND);
		}
	if (token.Equals("LINK") && this->ImplementsLinkAPI())
		{
		HandleLinkCommand(token);
		return NxsBlock::NxsCommandResult(HANDLED_COMMAND);
		}
	if (token.Equals("END") || token.Equals("ENDBLOCK"))
		{
		HandleEndblock(token);
		return NxsBlock::NxsCommandResult(STOP_PARSING_BLOCK);
		}
	return NxsBlock::NxsCommandResult(UNKNOWN_COMMAND);
	}
开发者ID:beiko-lab,项目名称:gengis,代码行数:31,代码来源:nxsblock.cpp


注:本文中的NxsToken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。