本文整理汇总了C++中Shard::next方法的典型用法代码示例。如果您正苦于以下问题:C++ Shard::next方法的具体用法?C++ Shard::next怎么用?C++ Shard::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shard
的用法示例。
在下文中一共展示了Shard::next方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: Linkable
Macro::Macro(const String& n, Shard *macroShard, const String& args)
: Linkable()
{
_name = n;
_argTypes = args;
if (macroShard)
{
// Steal macroShard's children.
Shard *next;
for (Shard *it = macroShard->first(); it; it = next)
{
next = it->next();
_shard.add(macroShard->remove(it));
}
}
}
示例4: 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);
}
}
示例5: init
void GemTest::init(Token *first)
{
enum testArgType_e { TA_NONE = 0, TA_NUMBER, TA_TEXT};
struct { const char *name; GemTestID cmdId; testArgType_e argType; } tests[] =
{
{ "try", BeginTry, TA_NONE },
{ "pass", CheckIfPassed, TA_NONE },
{ "top", IsTop, TA_NONE },
{ "me", IsMe, TA_NONE },
{ "myparent", IsMyParent, TA_NONE },
{ "myancestor", IsMyAncestor, TA_NONE },
{ "break", IsBreak, TA_NONE },
{ "br", IsLineBreak, TA_NONE },
{ "control", IsControl, TA_NONE },
{ "@", GoSelf, TA_NONE },
{ "final", GoFinal, TA_NONE },
{ "child", NthChild, TA_NUMBER },
{ "order", NthOrder, TA_NUMBER },
{ "count", ChildCount, TA_NUMBER },
{ "width", CellWidth, TA_NUMBER },
{ "text", Text, TA_TEXT },
{ "begins", TextBegins, TA_TEXT },
{ 0, InvalidGemTest, TA_NONE }
};
struct { const char *condition; GemClass::GemType type; } gemTypes[] =
{
{ "gem", GemClass::Gem },
{ "indent", GemClass::Indent },
{ "list", GemClass::List },
{ "deflist", GemClass::DefinitionList },
{ "table", GemClass::Table },
{ "part", GemClass::PartTitle },
{ "chapter", GemClass::ChapterTitle },
{ "section", GemClass::SectionTitle },
{ "subsec", GemClass::SubSectionTitle },
{ "sub2sec", GemClass::Sub2SectionTitle },
{ "sub3sec", GemClass::Sub3SectionTitle },
{ "sub4sec", GemClass::Sub4SectionTitle },
{ "contents", GemClass::Contents },
{ 0, GemClass::None }
};
struct { const char* condition; GemClass::FlushMode mode; } gemFlushModes[] =
{
{ "left", GemClass::FlushLeft },
{ "right", GemClass::FlushRight },
{ "center", GemClass::FlushCenter },
{ 0, GemClass::FlushInherit }
};
int i;
// Destroy existing commands.
_commands.destroy();
// Next we'll convert all the shards to test commands.
for(Shard *it = first; it; it = it->next())
{
String con = ((Token*)it)->unEscape();
if(con.isEmpty()) continue;
// This'll report unknown commands.
_addedBit = false;
// Normally 'false' is the failing condition.
_failBit = false;
while(con[0] == '!')
{
// Use a negative test.
con.remove(0, 1);
_failBit = !_failBit;
}
// Check for escalation.
_escalateBit = false;
if(con[0] == '^')
{
con.remove(0, 1);
_escalateBit = true;
}
// Navigation of the test pointer.
if((i = CompareCount(con, "parent"))) newTest(GoParent, i);
else if((i = CompareCount(con, "next"))) newTest(GoNext, i);
else if((i = CompareCount(con, "prev"))) newTest(GoPrev, i);
else if((i = CompareCount(con, "first"))) newTest(GoFirst, i);
else if((i = CompareCount(con, "last"))) newTest(GoLast, i);
else if((i = CompareCount(con, "following"))) newTest(GoFollowing, i);
else if((i = CompareCount(con, "preceding"))) newTest(GoPreceding, i);
for(i = 0; tests[i].name; i++)
if(con == tests[i].name)
{
if(tests[i].argType == TA_NUMBER)
{
int arg = 0;
if(it->next())
{
it = it->next();
arg = ((Token*)it)->token().toInt();
}
newTest(tests[i].cmdId, arg);
//.........这里部分代码省略.........