本文整理汇总了C++中poco::SharedPtr::setNumberToReturn方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::setNumberToReturn方法的具体用法?C++ SharedPtr::setNumberToReturn怎么用?C++ SharedPtr::setNumberToReturn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::SharedPtr
的用法示例。
在下文中一共展示了SharedPtr::setNumberToReturn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createQueryRequest
Poco::SharedPtr<Poco::MongoDB::QueryRequest> Database::createCountRequest(const std::string& collectionName) const
{
Poco::SharedPtr<Poco::MongoDB::QueryRequest> request = createQueryRequest("$cmd");
request->setNumberToReturn(1);
request->selector().add("count", collectionName);
return request;
}
示例2: authenticateMongoCR
bool MongoAuthentication::authenticateMongoCR(const std::string &user, const std::string &pwd)
{
bool ret = false;
_user = user;
_pwd = pwd;
try {
std::string nonce;
Poco::SharedPtr<Poco::MongoDB::QueryRequest> command = _db.createCommand();
command->selector().add<Poco::Int32>("getnonce", 1);
command->setNumberToReturn(1);
Poco::MongoDB::ResponseMessage response;
_conn.sendRequest(*command, response);
if (response.documents().size() > 0) {
Poco::MongoDB::Document::Ptr doc = response.documents()[0];
nonce = doc->get<std::string>("nonce", "");
std::string password = _user + ":mongo:" + _pwd;
Poco::MD5Engine md5;
md5.update(password);
std::string hashedPassword(Poco::DigestEngine::digestToHex(md5.digest()));
std::string key = nonce + _user + hashedPassword;
md5.reset();
md5.update(key);
std::string hashedKey(Poco::DigestEngine::digestToHex(md5.digest()));
Poco::SharedPtr<Poco::MongoDB::QueryRequest> command = _db.createCommand();
command->selector()
.add<Poco::Int32>("authenticate", 1)
.add<std::string>("user", _user)
.add<std::string>("nonce", nonce)
.add<std::string>("key", hashedKey); // hex_md5( n.nonce + username + hex_md5( username + ":mongo:" + password ) )
_conn.sendRequest(*command, response);
if (response.documents().size() > 0 && response.documents()[0]->get<double>("ok")) {
ret = true;
}
}
} catch (Poco::Exception &) {
throw Poco::ApplicationException("auth failed.");
}
return ret;
}
示例3: getLastErrorDoc
Document::Ptr Database::getLastErrorDoc(Connection& connection) const
{
Document::Ptr errorDoc;
Poco::SharedPtr<Poco::MongoDB::QueryRequest> request = createQueryRequest("$cmd");
request->setNumberToReturn(1);
request->selector().add("getLastError", 1);
Poco::MongoDB::ResponseMessage response;
connection.sendRequest(*request, response);
if ( response.documents().size() > 0 )
{
errorDoc = response.documents()[0];
}
return errorDoc;
}
示例4: sample9
// SELECT * FROM players LIMIT 1
void sample9(Poco::MongoDB::Connection& connection)
{
std::cout << "*** SAMPLE 9 ***" << std::endl;
// QueryRequest can be used directly
Poco::MongoDB::QueryRequest query("sample.players");
query.setNumberToReturn(1);
Poco::MongoDB::ResponseMessage response;
connection.sendRequest(query, response);
if ( response.hasDocuments() )
{
std::cout << response.documents()[0]->toString(2) << std::endl;
}
// QueryRequest can be created using the Database class
Poco::MongoDB::Database db("sample");
Poco::SharedPtr<Poco::MongoDB::QueryRequest> queryPtr = db.createQueryRequest("players");
queryPtr->setNumberToReturn(1);
connection.sendRequest(*queryPtr, response);
if ( response.hasDocuments() )
{
std::cout << response.documents()[0]->toString(2) << std::endl;
}
}