本文整理汇总了C++中Shard::first方法的典型用法代码示例。如果您正苦于以下问题:C++ Shard::first方法的具体用法?C++ Shard::first怎么用?C++ Shard::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shard
的用法示例。
在下文中一共展示了Shard::first方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
Token *Command::arg(int idx)
{
for(Shard *it = first(); it; it = it->next())
{
if(idx--) continue;
it = it->first();
if(!it || it->type() != BLOCK) break;
return (Token*) it->first();
}
return 0;
}
示例2: generateRule
/**
* An exception will be thrown if there is an error.
*/
void RuleSet::generateRule(Command *command)
{
Rule *rule;
Shard *it;
GemTest *terms;
// Create the rule object.
if(command->isName("format"))
{
rule = new FormatRule(((Block*)command->last()->first())->collect());
}
else
{
rule = new LengthRule;
}
terms = &rule->terms();
// Compile the terms (command -> shards -> blocks -> tokens).
for(it = command->first();
it && it != command->last(); it = it->next())
{
if(!it->first()) continue;
terms->addBefore(new GemTest((Token*)it->first()->first()));
}
if(command->isName("format"))
{
// There must not be format rules with matching terms.
removeMatching(*terms, Rule::FORMAT);
add(rule);
}
else
{
add(rule);
Length *len = &((LengthRule*)rule)->length();
// Set the lengths that were given.
// Get last argument -> block -> first token.
len->init((Token*)command->last()->first()->first());
// Was this all for naught?
if(len->isClear()) delete remove(rule);
}
}
示例3: hasArg
bool Command::hasArg(const String& str)
{
for(Shard *it = first(); it; it = it->next())
{
Block *block = (Block*) it->first();
if(!block || block->type() != BLOCK) continue;
for(Shard *arg = block->first(); arg; arg = arg->next())
{
// Blocks have only Tokens as children!
if(((Token*)arg)->token() == str) return true;
}
}
return false;
}