本文整理汇总了C++中client::Context::ns方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::ns方法的具体用法?C++ Context::ns怎么用?C++ Context::ns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类client::Context
的用法示例。
在下文中一共展示了Context::ns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const char *ourgetns() {
Client *c = currentClient.get();
if ( ! c )
return "";
Client::Context* cc = c->getContext();
return cc ? cc->ns() : "";
}
示例2: expressionParserWhereCallbackReal
StatusWithMatchExpression expressionParserWhereCallbackReal(const BSONElement& where) {
if ( !haveClient() )
return StatusWithMatchExpression( ErrorCodes::BadValue, "no current client needed for $where" );
Client::Context* context = cc().getContext();
if ( !context )
return StatusWithMatchExpression( ErrorCodes::BadValue, "no context in $where parsing" );
const char* ns = context->ns();
if ( !ns )
return StatusWithMatchExpression( ErrorCodes::BadValue, "no ns in $where parsing" );
if ( !globalScriptEngine )
return StatusWithMatchExpression( ErrorCodes::BadValue, "no globalScriptEngine in $where parsing" );
auto_ptr<WhereMatchExpression> exp( new WhereMatchExpression() );
if ( where.type() == String || where.type() == Code ) {
Status s = exp->init( ns, where.valuestr(), BSONObj() );
if ( !s.isOK() )
return StatusWithMatchExpression( s );
return StatusWithMatchExpression( exp.release() );
}
if ( where.type() == CodeWScope ) {
Status s = exp->init( ns,
where.codeWScopeCode(),
BSONObj( where.codeWScopeScopeDataUnsafe() ) );
if ( !s.isOK() )
return StatusWithMatchExpression( s );
return StatusWithMatchExpression( exp.release() );
}
return StatusWithMatchExpression( ErrorCodes::BadValue, "$where got bad type" );
}
示例3: getDbContext
string getDbContext() {
stringstream ss;
Client * c = currentClient.get();
if ( c ) {
Client::Context * cx = c->getContext();
if ( cx ) {
Database *database = cx->db();
if ( database ) {
ss << database->name() << ' ';
ss << cx->ns() << ' ';
}
}
}
return ss.str();
}