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


C++ OwnedPointerVector::release方法代码示例

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


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

示例1: patternIt

    /**
     * Currently the allowable shard keys are either
     * i) a hashed single field, e.g. { a : "hashed" }, or
     * ii) a compound list of ascending, potentially-nested field paths, e.g. { a : 1 , b.c : 1 }
     */
    static vector<FieldRef*> parseShardKeyPattern(const BSONObj& keyPattern) {

        OwnedPointerVector<FieldRef> parsedPaths;
        static const vector<FieldRef*> empty;

        BSONObjIterator patternIt(keyPattern);
        while (patternIt.more()) {

            BSONElement patternEl = patternIt.next();
            parsedPaths.push_back(new FieldRef(patternEl.fieldNameStringData()));
            const FieldRef& patternPath = *parsedPaths.back();

            // Empty path
            if (patternPath.numParts() == 0)
                return empty;

            // Extra "." in path?
            if (patternPath.dottedField() != patternEl.fieldNameStringData())
                return empty;

            // Empty parts of the path, ".."?
            for (size_t i = 0; i < patternPath.numParts(); ++i) {
                if (patternPath.getPart(i).size() == 0)
                    return empty;
            }

            // Numeric and ascending (1.0), or "hashed" and single field
            if (!patternEl.isNumber()) {
                if (keyPattern.nFields() != 1 || !isHashedPatternEl(patternEl))
                    return empty;
            }
            else if (patternEl.numberInt() != 1) {
                return empty;
            }
        }

        return parsedPaths.release();
    }
开发者ID:3rf,项目名称:mongo,代码行数:43,代码来源:shard_key_pattern.cpp


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