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


C++ Shard::first方法代码示例

本文整理汇总了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;
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:11,代码来源:command.cpp

示例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);
    }
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:45,代码来源:ruleset.cpp

示例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;
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:14,代码来源:command.cpp


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