本文整理汇总了C++中BSONField::getDefault方法的典型用法代码示例。如果您正苦于以下问题:C++ BSONField::getDefault方法的具体用法?C++ BSONField::getDefault怎么用?C++ BSONField::getDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSONField
的用法示例。
在下文中一共展示了BSONField::getDefault方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extract
FieldParser::FieldState FieldParser::extract(BSONElement elem,
const BSONField<bool>& field,
bool* out,
string* errMsg) {
if (elem.eoo()) {
if (field.hasDefault()) {
*out = field.getDefault();
return FIELD_DEFAULT;
} else {
return FIELD_NONE;
}
}
if (elem.type() == Bool) {
*out = elem.boolean();
return FIELD_SET;
}
_genFieldErrMsg(elem, field, "boolean", errMsg);
return FIELD_INVALID;
}
示例2: extractNumber
FieldParser::FieldState FieldParser::extractNumber(BSONElement elem,
const BSONField<double>& field,
double* out,
string* errMsg) {
if (elem.eoo()) {
if (field.hasDefault()) {
*out = field.getDefault();
return FIELD_DEFAULT;
} else {
return FIELD_NONE;
}
}
if (elem.isNumber()) {
*out = elem.numberDouble();
return FIELD_SET;
}
_genFieldErrMsg(elem, field, "number", errMsg);
return FIELD_INVALID;
}
示例3: extractID
FieldParser::FieldState FieldParser::extractID(BSONElement elem,
const BSONField<BSONObj>& field,
BSONObj* out,
string* errMsg) {
if (elem.eoo()) {
if (field.hasDefault()) {
*out = field.getDefault().firstElement().wrap("");
return FIELD_DEFAULT;
} else {
return FIELD_NONE;
}
}
if (elem.type() != Array) {
*out = elem.wrap("").getOwned();
return FIELD_SET;
}
_genFieldErrMsg(elem, field, "id", errMsg);
return FIELD_INVALID;
}
示例4: extract
FieldParser::FieldState FieldParser::extract(BSONObj doc,
const BSONField<BSONObj>& field,
BSONObj* out,
string* errMsg)
{
BSONElement elem = doc[field.name()];
if (elem.eoo()) {
if (field.hasDefault()) {
*out = field.getDefault();
return FIELD_DEFAULT;
}
else {
return FIELD_NONE;
}
}
if (elem.type() == Object) {
*out = elem.embeddedObject().getOwned();
return FIELD_SET;
}
_genFieldErrMsg(doc, field, "object", errMsg);
return FIELD_INVALID;
}
示例5: extractNumber
FieldParser::FieldState FieldParser::extractNumber(BSONObj doc,
const BSONField<long long>& field,
long long* out,
string* errMsg)
{
BSONElement elem = doc[field.name()];
if (elem.eoo()) {
if (field.hasDefault()) {
*out = field.getDefault();
return FIELD_DEFAULT;
}
else {
return FIELD_NONE;
}
}
if (elem.isNumber()) {
*out = elem.numberLong();
return FIELD_SET;
}
_genFieldErrMsg(doc, field, "number", errMsg);
return FIELD_INVALID;
}