当前位置: 首页>>代码示例>>C++>>正文


C++ QUERY函数代码示例

本文整理汇总了C++中QUERY函数的典型用法代码示例。如果您正苦于以下问题:C++ QUERY函数的具体用法?C++ QUERY怎么用?C++ QUERY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QUERY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: uid

void MethodGetRecentContacts::onCall(const sg::rpc::Uri& target)
{
	common::UserID uid(common::UserPointID(this->getFrom()));

	mongo::BSONObj returnfield = BSON(COLL_RECENTCONTACTS_CONTACT << 1);

	mongo::ScopedDbConnection conn(
			MongoDBManagerSingleton::instance().host());

	auto_ptr<mongo::DBClientCursor> cursor = conn->query(
			COLL_RECENTCONTACTS,
			QUERY(COLL_RECENTCONTACTS_UID << uid.toString()).sort(COLL_RECENTCONTACTS_CONTACT"."COLL_RECENTCONTACTS_CONTACT_TIME, -1),
			getRequestData().max_count(),
			0,
			&returnfield);

	methods::rpc::GetRecentContactsResponse resp;
	while (cursor->more())
	{
		mongo::BSONObj p = cursor->nextSafe();

		methods::rpc::GetRecentContactsResponse_Contact* contact = resp.add_contacts();

		common::UserID contact_uid;
		contact_uid.parseFromString(p[COLL_RECENTCONTACTS_CONTACT_UID].String());
		contact_uid.get(contact->mutable_user_id());

		bool flag = p[COLL_CHATMSGS_DATA_FLAG].Int();
		if (contact_uid.uid < uid.uid)
			flag = !flag;

		methods::rpc::ChatMsgData* pdata = contact->mutable_last_msg();
		pdata->set_flag(flag ? methods::rpc::ChatMsgData_Flag_FLAG_RECV : methods::rpc::ChatMsgData_Flag_FLAG_SEND);
		pdata->set_msg_id(p[COLL_CHATMSGS_DATA_MSGID].Long());
		pdata->set_msg_time(p[COLL_CHATMSGS_DATA_TIME].Date().toTimeT());
		p[COLL_CHATMSGS_DATA_CONTENT_TYPE].Val(*pdata->mutable_content_type());
		p[COLL_CHATMSGS_DATA_CONTENT].Val(*pdata->mutable_content());
	}

	conn.done();

	reply(target, resp);
}
开发者ID:haoustc,项目名称:server1,代码行数:43,代码来源:method_get_recent_contacts.cpp

示例2: cmd_window_server

static void cmd_window_server(const char *data)
{
	SERVER_REC *server;
        QUERY_REC *query;

	g_return_if_fail(data != NULL);

	server = server_find_tag(data);
        query = QUERY(active_win->active);
	if (server == NULL || query == NULL)
		return;

	/* /WINDOW SERVER used in a query window */
	query_change_server(query, server);
	printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
		    TXT_QUERY_SERVER_CHANGED,
		    query->name, server->tag);
	signal_stop();
}
开发者ID:svn2github,项目名称:irssi,代码行数:19,代码来源:fe-queries.c

示例3: QUERY

    Status AuthzManagerExternalStateMongod::updatePrivilegeDocument(
            const UserName& user, const BSONObj& updateObj, const BSONObj& writeConcern) {
        try {
            const std::string userNS = "admin.system.users";
            DBDirectClient client;
            {
                Client::GodScope gs;
                // TODO(spencer): Once we're no longer fully rebuilding the user cache on every
                // change to user data we should remove the global lock and uncomment the
                // WriteContext below
                Lock::GlobalWrite w;
                // Client::WriteContext ctx(userNS);
                client.update(userNS,
                              QUERY(AuthorizationManager::USER_NAME_FIELD_NAME << user.getUser() <<
                                    AuthorizationManager::USER_SOURCE_FIELD_NAME << user.getDB()),
                              updateObj);
            }

            // Handle write concern
            BSONObjBuilder gleBuilder;
            gleBuilder.append("getLastError", 1);
            gleBuilder.appendElements(writeConcern);
            BSONObj res;
            client.runCommand("admin", gleBuilder.done(), res);
            string err = client.getLastErrorString(res);
            if (!err.empty()) {
                return Status(ErrorCodes::UserModificationFailed, err);
            }

            int numUpdated = res["n"].numberInt();
            dassert(numUpdated <= 1 && numUpdated >= 0);
            if (numUpdated == 0) {
                return Status(ErrorCodes::UserNotFound,
                              mongoutils::str::stream() << "User " << user.getFullName() <<
                                      " not found");
            }

            return Status::OK();
        } catch (const DBException& e) {
            return e.toStatus();
        }
    }
开发者ID:barayuda,项目名称:mongo,代码行数:42,代码来源:authz_manager_external_state_d.cpp

示例4: process_cmd

static int process_cmd (const char *line)
{
    RESULT[0] = '\0';
    if      (matchstr (&line, "EJECT"))        return EJECT (line);
    else if (matchstr (&line, "INSERT"))       return INSERT (line);
    else if (matchstr (&line, "QUERY"))        return QUERY (line);
    else if (matchstr (&line, "FEEDBACK"))     return FEEDBACK (line);
    else if (matchstr (&line, "VERSION"))      return GET_VERSION (line);
    else if (matchstr (&line, "BYE"))          QUIT ();
    else if (matchstr (&line, "QUIT"))         QUIT ();
    else if (matchstr (&line, "DEBUG"))        return DEBUG ();
    else if (matchstr (&line, "RESET"))        m68k_reset (0);
    else if (matchstr (&line, "DISPLAY"))      return DISPLAY (line);
    else if (matchstr (&line, "FRAMERATE"))    return FRAMERATE( line);
    else if (matchstr (&line, "FAKEJOYSTICK")) return FAKEJOYSTICK (line);
    else if (matchstr (&line, "SOUND"))        return SOUND (line);
    else if (matchstr (&line, "UAEEXE"))       return UAEEXE (line);
    else return RC_ERROR;
    return RC_OK;
}
开发者ID:diablodiab,项目名称:libretro-uae,代码行数:20,代码来源:ami-rexx.c

示例5: QUERY

void UpdateGoogleData::doInBackground(const mongo::OID & user_id,CompletionHandler handler){
	std::cout << "do" << boost::this_thread::get_id() << std::endl;

	Log * log = Log::Instance();
	Config * config = Config::Instance();

	log->write("Update user google info: " + user_id.toString());

	bool ok = false;
	char *req_url = NULL;
	char *reply   = NULL;
	DB * db = DB::Instance();
	std::string mail,
		name,
		profile,
		thumbnail;

	if(db){
		mongo::BSONObj user = db->findOne("yquest.users", QUERY("_id" << user_id));
		if(user.valid()){
		req_url = oauth_sign_url2(config->OAUTH_PROFILE_REQUEST_URL.c_str(),
	    		NULL,
	    		OA_HMAC,
	    		NULL,
	    		config->OAUTH_KEY.c_str(),
	    		config->OAUTH_SECRET.c_str(),
	    		user["oauth_token"].String().c_str(),
	    		user["oauth_token_secret"].String().c_str());
	    reply = oauth_http_get(req_url,NULL);
	    log->write(reply);

	     std::stringstream stream(reply);
	     boost::property_tree::ptree ptree;
	      boost::property_tree::json_parser::read_json(stream, ptree);
	      std::cout << ptree.get<std::string>("entry.displayName")<< std::endl;
		}
	}
	io_service.post(boost::bind(handler,ok));

	delete this;
}
开发者ID:Chudovishee,项目名称:yquest,代码行数:41,代码来源:UpdateGoogleData.cpp

示例6: msg

/**
 * (re)connect to database
 */
int IpfixDbWriterMongo::connectToDB()
{
	dbError = true;
	
	// If a connection exists don't reconnect
	if (con.isFailed()) return 0;
  
  // Connect
  string err;
  mongo::HostAndPort dbLogon;
  dbLogon = mongo::HostAndPort(dbHost, dbPort);
  msg(MSG_INFO,"IpfixDbWriterMongo: Connection details: %s", dbLogon.toString().c_str());
  if(!con.connect(dbLogon, err))
	{
		msg(MSG_FATAL,"IpfixDbWriterMongo: Mongo connect failed. Error: %s", err.c_str());
		return 1;
	}
    
  if(!dbUser.empty() && !dbPassword.empty()) 
  {
    // we need to authenticate
    if(!con.auth(dbName, dbUser, dbPassword, err))
	  {
		  msg(MSG_FATAL,"IpfixDbWriterMongo: Mongo authentication failed. Error: %s", err.c_str());
		  return 1;
	  }
  }

  // create couter to support incrementing Exporter IDs
  if(con.findOne(dbCollectionCounters, QUERY("_id" << "exporterCounter")).isEmpty())
  {
    mongo::BSONObjBuilder b;
    b << "_id" << "exporterCounter" << "c" << 0;
    mongo::BSONObj obj = b.obj();
    con.insert(dbCollectionCounters, obj);
  }

	msg(MSG_DEBUG,"IpfixDbWriterMongo: Mongo connection successful");
	dbError = false;
	return 0;
}
开发者ID:JammyStuff,项目名称:vermont,代码行数:44,代码来源:IpfixDbWriterMongo.cpp

示例7: getConfig

Eina_Bool getConfig(DB *db, Zentific_Ctx *ctx, const char *key, const char *subsystem,
	int mid, int uid, int gid, int vgid, int ngid, int vm,
	int node, int platform, int role){

	if (!key || !subsystem || !key[0] || !subsystem[0]){
		ctx->error = AZY_ERR(INVALID_PARAMETER);
		return EINA_FALSE;
	}

	DB_VARS;
	QUERY(KEYVALUE_esql,
		"SELECT * FROM `config` WHERE `key`='%s'"
		" AND `subsystem`='%s' AND `mid`='%d'"
		" AND `uid`='%d' AND `gid`='%d' AND `vgid`='%d'"
		" AND `ngid`='%d' AND `vm`='%d' AND `node`='%d'"
		" AND `platform`='%d' AND `role`='%d'",
		key, subsystem, mid, uid, gid,
		vgid, ngid, vm, node, platform, role);
	ctx->free_func = (Ecore_Cb)KEYVALUE_free;
	QID_RETURN;
}
开发者ID:zmike,项目名称:ezrpc,代码行数:21,代码来源:zrpcdb_zentific.c

示例8: e_data_cal_view_get_property

static void
e_data_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
	EDataCalView *query;
	EDataCalViewPrivate *priv;

	query = QUERY (object);
	priv = query->priv;

	switch (property_id) {
	case PROP_BACKEND:
		g_value_set_object (value, priv->backend);
		break;
	case PROP_SEXP:
		g_value_set_object (value, priv->sexp);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
开发者ID:nobled,项目名称:evolution-data-server,代码行数:21,代码来源:e-data-cal-view.c

示例9: cmd_unquery

/* SYNTAX: UNQUERY [<nick>] */
static void cmd_unquery(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
	QUERY_REC *query;

	g_return_if_fail(data != NULL);

	if (*data == '\0') {
		/* remove current query */
		query = QUERY(item);
		if (query == NULL) return;
	} else {
		query = query_find(server, data);
		if (query == NULL) {
			printformat(server, NULL, MSGLEVEL_CLIENTERROR,
				    TXT_NO_QUERY, data);
			return;
		}
	}

	query_destroy(query);
}
开发者ID:svn2github,项目名称:irssi,代码行数:22,代码来源:fe-queries.c

示例10: BSON

void User::IncrCredits(const std::string& section, long long kBytes)
{
  auto doIncrement = [section, kBytes](acl::UserID uid)
    {
      NoErrorConnection conn;
      auto updateExisting = [&]() -> bool
        {
          auto query = BSON("uid" << uid << 
                            "credits" << BSON("$elemMatch" << BSON("section" << section)));
                            
          auto update = BSON("$inc" << BSON("credits.$.value" << kBytes));
                            
          auto cmd = BSON("findandmodify" << "users" <<
                          "query" << query <<
                          "update" << update);
                          
          mongo::BSONObj result;
          return conn.RunCommand(cmd, result) && 
                 result["value"].type() != mongo::jstNULL;
        };

      auto doInsert = [&]() -> bool
      {
        auto query = QUERY("uid" << uid << "credits" << BSON("$not" << 
                           BSON("$elemMatch" << BSON("section" << section))));
        auto update = BSON("$push" << BSON("credits" << BSON("section" << section << "value" << kBytes)));
        return conn.Update("users", query, update, false) > 0;
      };
      
      if (updateExisting()) return;
      if (doInsert()) return;
      if (updateExisting()) return;

      logs::Database("Unable to increment credits for UID %1%%2%", uid,
                     !section.empty() ? " in section " + section : 
                     std::string(""));
    };
  
  asyncTasks.Assign(std::async(std::launch::async, doIncrement, user.id));
}
开发者ID:arrrrrrr,项目名称:ebftpd,代码行数:40,代码来源:user.cpp

示例11: while

void CComputeRowDataProcessor::ComputeData()
{
	bool bResult = false;
	BSONObj boRowRecord, boVLanInfo;
	Query queryRackInRow;
	CRackModel *pRackModel;
	CRowModel *pRowModel;
	auto_ptr<DBClientCursor> ptrRackCursor = auto_ptr<DBClientCursor>();
	while (m_ptrCursor->more())
	{
		boRowRecord = m_ptrCursor->nextSafe();
		if (pRowModel->GetRackQuery(queryRackInRow, boRowRecord))
		{
			if (m_pRackController->Find(ptrRackCursor, queryRackInRow))
			{
				boVLanInfo = pRackModel->GetVLanInfo(ptrRackCursor);
				m_pCIController->Update(boVLanInfo, QUERY("_id" << boRowRecord["_id"]));
			}
		}
		ptrRackCursor.reset();
	}
}
开发者ID:fr34k8,项目名称:CMDBv2,代码行数:22,代码来源:ComputeRowDataProcessor.cpp

示例12: QUERY

//-----------------------------------------------------------------------------
bool solution_c::fetch( Reveal::Core::solution_ptr& solution, Reveal::DB::database_ptr db, std::string experiment_id, std::string scenario_id, double t, double epsilon ) {
  std::auto_ptr<mongo::DBClientCursor> cursor;
  Reveal::Core::scenario_ptr ptr;
  std::string table = "solution";

  mongo_ptr mongo = mongo_c::service( db );
  if( !mongo ) return false;

  double lbound = t - epsilon;
  double ubound = t + epsilon;

  mongo->fetch( cursor, table, QUERY( "experiment_id" << experiment_id << "scenario_id" << scenario_id << "t" << mongo::GTE << lbound << mongo::LTE << ubound ) );

  if( !cursor->more() ) return false;

  // TODO: add error handling
  mongo::BSONObj record = cursor->next();

  map( solution, record, Reveal::Core::solution_c::CLIENT );

  return true;
}
开发者ID:jacquelinekay,项目名称:reveal,代码行数:23,代码来源:solution.cpp

示例13: uid

void MethodRemoveRecentContacts::onCall(const sg::rpc::Uri& target)
{
	if (getRequestData().user_ids_size())
	{
		common::UserID uid(common::UserPointID(this->getFrom()));

		mongo::ScopedDbConnection conn(
				MongoDBManagerSingleton::instance().host());

		mongo::BSONArrayBuilder contactsBuilder;
		for (int i=0; i<getRequestData().user_ids_size(); ++i)
		{
			contactsBuilder << common::UserID(getRequestData().user_ids(i)).toString();
		}

		conn->remove(COLL_RECENTCONTACTS,
				QUERY(COLL_RECENTCONTACTS_UID << uid.toString() << "$or" << BSON(COLL_RECENTCONTACTS_CONTACT << contactsBuilder.arr())));

		conn.done();
	}
	reply(target);
}
开发者ID:haoustc,项目名称:server1,代码行数:22,代码来源:method_remove_recent_contacts.cpp

示例14: conn

    Status AuthzManagerExternalStateMongos::updatePrivilegeDocument(
            const UserName& user, const BSONObj& updateObj, const BSONObj& writeConcern) {
        try {
            const std::string userNS = "admin.system.users";
            scoped_ptr<ScopedDbConnection> conn(getConnectionForAuthzCollection(userNS));

            conn->get()->update(
                    userNS,
                    QUERY(AuthorizationManager::USER_NAME_FIELD_NAME << user.getUser() <<
                          AuthorizationManager::USER_SOURCE_FIELD_NAME << user.getDB()),
                    updateObj);

            // Handle write concern
            BSONObjBuilder gleBuilder;
            gleBuilder.append("getLastError", 1);
            gleBuilder.appendElements(writeConcern);
            BSONObj res;
            conn->get()->runCommand("admin", gleBuilder.done(), res);
            string err = conn->get()->getLastErrorString(res);
            conn->done();

            if (!err.empty()) {
                return Status(ErrorCodes::UserModificationFailed, err);
            }

            int numUpdated = res["n"].numberInt();
            dassert(numUpdated <= 1 && numUpdated >= 0);
            if (numUpdated == 0) {
                return Status(ErrorCodes::UserNotFound,
                              mongoutils::str::stream() << "User " << user.getFullName() <<
                                      " not found");
            }

            return Status::OK();
        } catch (const DBException& e) {
            return e.toStatus();
        }
    }
开发者ID:barayuda,项目名称:mongo,代码行数:38,代码来源:authz_manager_external_state_s.cpp

示例15: id

  void
  FilesystemEntry::updateContentType(mongo::GridFile& gridfile, 
                                     mode_t mode, 
                                     uid_t uid, 
                                     gid_t gid,
                                     time_t time)
  {
    std::stringstream lContentType;    
    lContentType << "m:" << mode << "|u:" << uid << "|g:" << gid << "|t:" << time;

    // create update filter and query
    mongo::OID id(gridfile.getFileField("_id").OID().str());
    mongo::Query filter = QUERY("_id" << id);
    mongo::BSONObj update = BSON( "$set" 
                               << BSON ( "contentType" << lContentType.str() ));

    // update it
    // TODO DK this is not multi process safe because it doesn't store a new file 
    //         entry, but don't see a better solution yet.
    theConnection->update(filesCollection(), filter, update);

    synchonizeUpdate();
  }
开发者ID:28msec,项目名称:gridfs-fuse,代码行数:23,代码来源:filesystem_entry.cpp


注:本文中的QUERY函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。