本文整理汇总了C++中DBClientCursor::next方法的典型用法代码示例。如果您正苦于以下问题:C++ DBClientCursor::next方法的具体用法?C++ DBClientCursor::next怎么用?C++ DBClientCursor::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBClientCursor
的用法示例。
在下文中一共展示了DBClientCursor::next方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result_iterator
static int result_iterator(lua_State *L) {
DBClientCursor *cursor = userdata_to_cursor(L, lua_upvalueindex(1));
if (cursor->more()) {
bson_to_lua(L, cursor->next());
} else {
lua_pushnil(L);
}
return 1;
}
示例2: cursor_next
/*
* res = cursor:next()
*/
static int cursor_next(lua_State *L) {
DBClientCursor *cursor = userdata_to_cursor(L, 1);
if (cursor->more()) {
bson_to_lua(L, cursor->next());
} else {
lua_pushnil(L);
}
return 1;
}
示例3: out
// "./db testclient" to invoke
void testClient3() {
out() << "testClient()" << endl;
// DBClientConnection c(true);
DBClientPaired c;
string err;
if ( !c.connect("10.211.55.2", "1.2.3.4") ) {
// if( !c.connect("10.211.55.2", err) ) {
out() << "testClient: connect() failed" << endl;
}
else {
// temp:
out() << "test query returns: " << c.findOne("foo.bar", fromjson("{}")).toString() << endl;
}
again:
out() << "query foo.bar..." << endl;
auto_ptr<DBClientCursor> cursor =
c.query("foo.bar", BSONObj(), 0, 0, 0, Option_CursorTailable);
DBClientCursor *cc = cursor.get();
if ( cc == 0 ) {
out() << "query() returned 0, sleeping 10 secs" << endl;
sleepsecs(10);
goto again;
}
while ( 1 ) {
bool m;
try {
m = cc->more();
} catch (AssertionException&) {
out() << "more() asserted, sleeping 10 sec" << endl;
goto again;
}
out() << "more: " << m << " dead:" << cc->isDead() << endl;
if ( !m ) {
if ( cc->isDead() )
out() << "cursor dead, stopping" << endl;
else {
out() << "Sleeping 10 seconds" << endl;
sleepsecs(10);
continue;
}
break;
}
out() << cc->next().toString() << endl;
}
}