本文整理汇总了C++中BSONObj::md5方法的典型用法代码示例。如果您正苦于以下问题:C++ BSONObj::md5方法的具体用法?C++ BSONObj::md5怎么用?C++ BSONObj::md5使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSONObj
的用法示例。
在下文中一共展示了BSONObj::md5方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: from
void ReplSetConfig::from(BSONObj o) {
static const string legal[] = {"_id","version", "members","settings"};
static const set<string> legals(legal, legal + 4);
assertOnlyHas(o, legals);
md5 = o.md5();
_id = o["_id"].String();
if( o["version"].ok() ) {
version = o["version"].numberInt();
uassert(13115, "bad " + rsConfigNs + " config: version", version > 0);
}
if( o["settings"].ok() ) {
BSONObj settings = o["settings"].Obj();
if( settings["heartbeatConnRetries "].ok() )
ho.heartbeatConnRetries = settings["heartbeatConnRetries "].numberInt();
if( settings["heartbeatSleep"].ok() )
ho.heartbeatSleepMillis = (unsigned) (settings["heartbeatSleep"].Number() * 1000);
if( settings["heartbeatTimeout"].ok() )
ho.heartbeatTimeoutMillis = (unsigned) (settings["heartbeatTimeout"].Number() * 1000);
ho.check();
try { getLastErrorDefaults = settings["getLastErrorDefaults"].Obj().copy(); }
catch(...) { }
}
set<string> hosts;
set<int> ords;
vector<BSONElement> members;
try {
members = o["members"].Array();
}
catch(...) {
uasserted(13131, "replSet error parsing (or missing) 'members' field in config object");
}
unsigned localhosts = 0;
for( unsigned i = 0; i < members.size(); i++ ) {
BSONObj mobj = members[i].Obj();
MemberCfg m;
try {
static const string legal[] = {
"_id","votes","priority","host", "hidden","slaveDelay",
"arbiterOnly","buildIndexes","tags","initialSync" // deprecated
};
static const set<string> legals(legal, legal + 10);
assertOnlyHas(mobj, legals);
try {
m._id = (int) mobj["_id"].Number();
}
catch(...) {
/* TODO: use of string exceptions may be problematic for reconfig case! */
throw "_id must be numeric";
}
string s;
try {
s = mobj["host"].String();
m.h = HostAndPort(s);
}
catch(...) {
throw string("bad or missing host field? ") + mobj.toString();
}
if( m.h.isLocalHost() )
localhosts++;
m.arbiterOnly = mobj["arbiterOnly"].trueValue();
m.slaveDelay = mobj["slaveDelay"].numberInt();
if( mobj.hasElement("hidden") )
m.hidden = mobj["hidden"].trueValue();
if( mobj.hasElement("buildIndexes") )
m.buildIndexes = mobj["buildIndexes"].trueValue();
if( mobj.hasElement("priority") )
m.priority = mobj["priority"].Number();
if( mobj.hasElement("votes") )
m.votes = (unsigned) mobj["votes"].Number();
if( mobj.hasElement("tags") ) {
vector<BSONElement> v = mobj["tags"].Array();
for( unsigned i = 0; i < v.size(); i++ )
m.tags.insert( v[i].String() );
}
m.check();
}
catch( const char * p ) {
log() << "replSet cfg parsing exception for members[" << i << "] " << p << rsLog;
stringstream ss;
ss << "replSet members[" << i << "] " << p;
uassert(13107, ss.str(), false);
}
catch(DBException& e) {
log() << "replSet cfg parsing exception for members[" << i << "] " << e.what() << rsLog;
stringstream ss;
ss << "bad config for member[" << i << "] " << e.what();
uassert(13135, ss.str(), false);
}
if( !(ords.count(m._id) == 0 && hosts.count(m.h.toString()) == 0) ) {
log() << "replSet " << o.toString() << rsLog;
uassert(13108, "bad replset config -- duplicate hosts in the config object?", false);
}
hosts.insert(m.h.toString());
ords.insert(m._id);
this->members.push_back(m);
//.........这里部分代码省略.........