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


C++ dictionary::keys方法代码示例

本文整理汇总了C++中dictionary::keys方法的典型用法代码示例。如果您正苦于以下问题:C++ dictionary::keys方法的具体用法?C++ dictionary::keys怎么用?C++ dictionary::keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dictionary的用法示例。


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

示例1: help

void help(string syntax,dictionary<string> options)
{
 //help

 options.add("--help","Prints this help");  
 
 //syntax
 
 log();
 log("Syntax is:");
 
 log(syntax.indent(1));
 
 //option
 
 options.update(options.keys().text().justify_left().lines().me(),options.values().me());
 
 log();
 log("Options are:");
   
 for(int i=0;i<options.count();i++)
 {
  auto& current=options.item(i);
  
  log(concat(current._first," ",current._second).indent(1));
 }
}
开发者ID:vmorgulys,项目名称:sandbox,代码行数:27,代码来源:function.tool.cpp

示例2: forAll

// Dictionary merging/editing.
// literalRE:
// - true: behave like dictionary::merge, i.e. add regexps just like
//   any other key.
// - false : interpret wildcard as a rule for items to be matched.
bool merge
(
    dictionary& thisDict,
    const dictionary& mergeDict,
    const bool literalRE
)
{
    static bool wildCardInMergeDict = false;

    bool changed = false;

    // Save current (non-wildcard) keys before adding items.
    HashSet<word> thisKeysSet;
    {
        List<keyType> keys = thisDict.keys(false);
        forAll(keys, i)
        {
            thisKeysSet.insert(keys[i]);
        }
    }
开发者ID:,项目名称:,代码行数:25,代码来源:

示例3: FatalIOErrorInFunction


//.........这里部分代码省略.........
    else
    {
        string::size_type dotPos = keyword.find('.');

        if (dotPos == string::npos)
        {
            // Non-scoped lookup
            if (overwrite)
            {
                dict.set(d);
            }
            else
            {
                dict.add(d, false);
            }
            return;
        }
        else
        {
            if (dotPos == 0)
            {
                // Starting with a '.'. Go up for every 2nd '.' found

                const dictionary* dictPtr = &dict;

                string::size_type begVar = dotPos + 1;
                string::const_iterator iter =
                    keyword.begin() + begVar;
                string::size_type endVar = begVar;
                while
                (
                    iter != keyword.end()
                    && *iter == '.'
                )
                {
                    ++iter;
                    ++endVar;

                    // Go to parent
                    if (&dictPtr->parent() == &dictionary::null)
                    {
                        FatalIOErrorInFunction(dict)
                                << "No parent of current dictionary"
                                << " when searching for "
                                <<  keyword.substr
                                (
                                    begVar,
                                    keyword.size() - begVar
                                )
                                << exit(FatalIOError);
                    }
                    dictPtr = &dictPtr->parent();
                }

                setScoped
                (
                    const_cast<dictionary&>(*dictPtr),
                    keyword.substr(endVar),
                    overwrite,
                    d
                );
                return;
            }
            else
            {
                // Extract the first word
                word firstWord = keyword.substr(0, dotPos);

                const entry* entPtr = dict.lookupScopedEntryPtr
                                      (
                                          firstWord,
                                          false,          // Recursive
                                          false
                                      );

                if (!entPtr || !entPtr->isDict())
                {
                    FatalIOErrorInFunction(dict)
                            << "keyword " << firstWord
                            << " is undefined in dictionary "
                            << dict.name() << " or is not a dictionary"
                            << endl
                            << "Valid keywords are " << dict.keys()
                            << exit(FatalIOError);
                }

                const dictionary& firstDict = entPtr->dict();

                setScoped
                (
                    const_cast<dictionary&>(firstDict),
                    keyword.substr(dotPos, keyword.size()-dotPos),
                    overwrite,
                    d
                );
                return;
            }
        }
    }
}
开发者ID:will-bainbridge,项目名称:OpenFOAM-dev,代码行数:101,代码来源:foamDictionary.C


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