本文整理汇总了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();
}