本文整理汇总了C++中NxsToken::ProcessAsSimpleKeyValuePairs方法的典型用法代码示例。如果您正苦于以下问题:C++ NxsToken::ProcessAsSimpleKeyValuePairs方法的具体用法?C++ NxsToken::ProcessAsSimpleKeyValuePairs怎么用?C++ NxsToken::ProcessAsSimpleKeyValuePairs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxsToken
的用法示例。
在下文中一共展示了NxsToken::ProcessAsSimpleKeyValuePairs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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.
}
}
}