• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FOREACH_MOD

void ModuleManager::DoSafeUnload(Module* mod)
{
	// First, notify all modules that a module is about to be unloaded, so in case
	// they pass execution to the soon to be unloaded module, it will happen now,
	// i.e. before we unregister the services of the module being unloaded
	FOREACH_MOD(OnUnloadModule, (mod));

	std::map<std::string, Module*>::iterator modfind = Modules.find(mod->ModuleSourceFile);

	std::vector<reference<ExtensionItem> > items;
	ServerInstance->Extensions.BeginUnregister(modfind->second, items);
	/* Give the module a chance to tidy out all its metadata */
	const chan_hash& chans = ServerInstance->GetChans();
	for (chan_hash::const_iterator c = chans.begin(); c != chans.end(); )
	{
		Channel* chan = c->second;
		++c;
		mod->OnCleanup(TYPE_CHANNEL, chan);
		chan->doUnhookExtensions(items);
		const Channel::MemberMap& users = chan->GetUsers();
		for (Channel::MemberMap::const_iterator mi = users.begin(); mi != users.end(); ++mi)
			mi->second->doUnhookExtensions(items);
	}

	const user_hash& users = ServerInstance->Users->GetUsers();
	for (user_hash::const_iterator u = users.begin(); u != users.end(); )
	{
		User* user = u->second;
		// The module may quit the user (e.g. SSL mod unloading) and that will remove it from the container
		++u;
		mod->OnCleanup(TYPE_USER, user);
		user->doUnhookExtensions(items);
	}

	const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes->GetModes(MODETYPE_USER);
	for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); )
	{
		ModeHandler* mh = i->second;
		++i;
		if (mh->creator == mod)
			this->DelService(*mh);
	}

	const ModeParser::ModeHandlerMap& chanmodes = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL);
	for (ModeParser::ModeHandlerMap::const_iterator i = chanmodes.begin(); i != chanmodes.end(); )
	{
		ModeHandler* mh = i->second;
		++i;
		if (mh->creator == mod)
			this->DelService(*mh);
	}

	for(std::multimap<std::string, ServiceProvider*>::iterator i = DataProviders.begin(); i != DataProviders.end(); )
	{
		std::multimap<std::string, ServiceProvider*>::iterator curr = i++;
		if (curr->second->creator == mod)
			DataProviders.erase(curr);
	}

	dynamic_reference_base::reset_all();

	DetachAll(mod);

	Modules.erase(modfind);
	ServerInstance->GlobalCulls.AddItem(mod);

	ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Module %s unloaded",mod->ModuleSourceFile.c_str());
	ServerInstance->ISupport.Build();
}
开发者ID:DeadSix27,项目名称:inspircd,代码行数:69,代码来源:modules.cpp


示例2: main

int main() {
	// Declarations
	char choice = '0';
	BinarySearchTree<User,string> UserTree;
	User temp, maximum, minimum;
	User* ptr;
	string username, password, firstName, lastName;

	// Read in from file
	ifstream infile("users.txt");
		while (infile >> temp) {
			UserTree.insert(temp);
		}
	infile.close();

	// Menu
	while(choice != 'Q') {
		cout << "Enter the corresponding number for what you want to do:" << endl << "1:  Attempt to log in" << endl << "2:  Register a new user" << endl << "3:  Delete an existing user" << endl << "4:  View total number of users" << endl << "5:  View min and max username" << endl << "6:  View tree height" << endl << "Q:  Quit the program" << endl;
		cin >> choice;
		switch(choice) {
		case '1':
			// Authenticate User
			cout << endl << "Log in:" << endl << "   Username: ";
			cin >> username;
			cout << endl << "   Password: ";
			cin >> password;
			ptr = UserTree.search(username);
			if (ptr == NULL) {
				cout << endl << "Invalid username/password combination." << endl;
			} else if (ptr->authenticate(password)){
				cout << endl << "Welcome " << ptr->getFirstName() << ", " << ptr->getLastName() << "." << endl << endl << endl;
			} else {
				cout << endl << "Invalid username/password combination." << endl << endl << endl;
			}
			break;
		case '2':
			// Register User
			cout << endl << "Enter the unique username of the user you want to create: ";
			cin >> username;
			if (!UserTree.search(username)) {
				cout << "   Password: ";
				cin >> password;
				cout << "   First Name: ";
				cin >> firstName;
				cout << "   Last Name: ";
				cin >> lastName;
				User newuser(username, password, firstName, lastName);
				UserTree.insert(newuser);
				cout << endl << "User successfully created!" << endl << endl << endl;
			} else {
				cout << endl << "User already exists!" << endl << endl << endl;
			}
			break;
		case '3':
			cout << endl << "Enter the user name of the user you want to remove:";
			cin >> username;
			if (UserTree.remove(username)) {
				cout << endl << username << " was successfully removed!" << endl << endl << endl;
			} else {
				cout << endl << "No such user exists." << endl << endl << endl;
			}
			break;
		case '4':
			cout << endl << "   There are " << UserTree.size() << " users in this tree." << endl;
			break;
		case '5':
			maximum = UserTree.max();
			minimum = UserTree.min();
			cout << endl << "   Minimum Username: " << minimum.getUsername() << endl << "   Maximum Username: " << maximum.getUsername() << endl << endl << endl;
			break;
		case '6':
			cout << endl << "The User Tree is " << UserTree.height() << " users in height." << endl << endl << endl;
			break;
		}
开发者ID:DArtagan,项目名称:csci262,代码行数:74,代码来源:main.cpp


示例3: output_User

void output_User(const User& u) {
	string str(u.getUsername() + " " + u.getUsername() + " " + u.getFirstName() + " " + u.getLastName());
	outfile << str << endl;
}
开发者ID:DArtagan,项目名称:csci262,代码行数:4,代码来源:main.cpp


示例4: menu

void menu(int choice, bool &goBackToFirstMenu, UserList &dataList)
{
	while(choice != 1 && choice != 2 && choice != 3 && choice != 4) //if user enters something other than 1,2,3
	{
		cout << "Please enter a correct number." << endl;
		cin >> choice;
	}

	if(choice == 1)
	{
		checkUsername(dataList);
	}
	else if(choice == 2)
	{
		bool checkIfExists;
		User newuser;
		cout << "Hi! You are about to create a new user." << endl;
		cout << endl;
		cout << "What is the user's name?" << endl;
		string newName;
		getline(cin, newName);
		getline(cin, newName);
		newuser.setName(newName);
		cout << "Make a username for yourself! (Remember, no spaces in usernames)" << endl;
		string newUserName;
		cin >> newUserName;
		newuser.setUsername(newUserName);
		checkIfExists = dataList.checkIfSame(newUserName);
		while(checkIfExists == true)
		{
			cout << "Try entering another username" << endl;
			string enterNewName;
			cin >> enterNewName;
			newuser.setUsername(enterNewName);
			checkIfExists = dataList.checkIfSame(enterNewName);
		}
		//cout << endl;
		cout << "Make your own password! (remember, no spaces!)" << endl;
		string newPassword;
		cin >> newPassword;
		cout << "For security purposes, please enter your password again." << endl;
		string checkNewPassword;
		cin >> checkNewPassword;
		while(newPassword != checkNewPassword)
		{
			cout << "Please enter your password again!" << endl;
			cin >> checkNewPassword;
		}
		newuser.setPassword(newPassword);
		//cout << endl;
		cout << "Now for the third element, please type which university you go to!" << endl;
		string newUniversity;
		getline(cin,newUniversity);
		getline(cin,newUniversity);
		cout << endl;
		newuser.setUniversity(newUniversity);
		cout << "Your university is " << newUniversity << "!" << endl;
		cout << endl;

		dataList.addUser(newuser);
		User addANewUser;
		string university = "USC";
		string password = "password";
		string username = "username";
		string comment = "COMMENT";
		string comment1 = "HEY WHATS UP";
		string randomizing;
		for(int i = 0; i < 10000; i++)
		{
			randomizing = generatingRandom();
			addANewUser.setUsername(randomizing);
			addANewUser.setPassword(password);
			addANewUser.setUniversity(university);
			//addANewUser.addPostAutomatic(username, comment);
			addANewUser.addPostAutomatic(username, comment1);
			//dataList.addUser(addANewUser);
			//addANewUser.
			for(int j = 0; j < 100; j++)
			{
				//addANewUser.addFriends()
			}
			//dataList.writeFile();
		}

	}
开发者ID:shawwshank,项目名称:projects,代码行数:85,代码来源:asd.cpp


示例5: safe_atoll

void RceQueryCheckAndLockAccountIfPossibleHandle::handle_selfload(Event* e)
{
	int64 uid = e->uid();
	GameDataHandler* pUserManager = eh_->getDataHandler();
	if(!pUserManager)
	{
		return;
	}
	User *pUser = pUserManager->getUser(uid);
	if ( !pUser)
	{
		return;
	}

	Player* pPlayer = pUser->GetPlayer();
	if ( !pPlayer || !pPlayer->CanUse())
	{
		return ;
	}

	RceQueryCheckAndLockAccountIfPossible* req = e->mutable_ce_rcequerycheckandlockaccountifpossible();
	if( !req )
	{
		return;
	}

	RseQueryCheckAndLockAccountIfPossible *pRsp = e->mutable_se_rsequerycheckandlockaccountifpossible();
	pRsp->set_lockapplied(req->applylock());
	pRsp->set_lockrequested(1);
	pRsp->set_locktype(0);
	pRsp->set_locksuccess(1);
	string text;
	pRsp->SerializeToString(&text);
	eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text);
	return;

	DB_Planet *pDBPlanet = pPlayer->GetPlanet(pPlayer->GetCurPlanetId());
	if(!pDBPlanet){
		pRsp->set_locksuccess(0);
		pRsp->set_locktype(7);
		string text;
		pRsp->SerializeToString(&text);
		eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text);
		return;
	}
	/*for(int i = 0; i < req->hangarsunitsinfo_size(); i++){
		HangarsUnitsInfo *pMsgUnit = req->mutable_hangarsunitsinfo(i);
		if(pMsgUnit){
			for (int k = 0; k < pDBPlanet->hangars_size(); k++){
				DB_Hangar *pDBUnit = pDBPlanet->hangars(k);
				if(pDBUnit && pDBUnit->sid() == pMsgUnit->sid()){
					
				}
			}
		}
	}*/

	int64 TID;
	safe_atoll(req->targetaccountid(), TID);
	LoadStatus state = LOAD_INVALID;
	User *pTUser = pUserManager->getUser(TID, &state, true);
	if (pTUser == NULL)
	{
		if (state == LOAD_WAITING)
		{
			eh_->postBackEvent(e);
		}
		else if (state == LOAD_MISS)
		{	
			e->mutable_forwardinfo()->set_uid(TID);
			e->set_state(Status_Normal_To_World);
			eh_->sendEventToWorld(e);
		}
		return;
	}
	else
	{
		if(0 == req->applylock()){
			if(pTUser->Online()){
				pRsp->set_locksuccess(0);
				pRsp->set_locktype(1);
				string text;
				pRsp->SerializeToString(&text);
				eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text);
				return;
			}else if(pTUser->GetLastAttackedTime()){
				pRsp->set_locksuccess(0);
				pRsp->set_locktype(2);
				string text;
				pRsp->SerializeToString(&text);
				eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text);
				return;
			}
		}else{
			int nPlanetId = req->planetid();
			Player *pTPlayer = pUser->GetPlayer();
			
		}
	}
}
开发者ID:CrazyPro,项目名称:ape,代码行数:100,代码来源:RceQueryCheckAndLockAccountIfPossibleHandle.cpp


示例6: slotReadAllYouMessageNotify

void ChatClient::slotReadAllYouMessageNotify(int dialog) {
    User *us = userlist->userByDialog(dialog);
    us->setWroteMessage(0);
}
开发者ID:pva701,项目名称:codes,代码行数:4,代码来源:chatclient.cpp


示例7: slotNotifyOnOff

void ChatClient::slotNotifyOnOff(quint16 userId, bool stat) {
    User *us = userlist->userById(userId);
    us->setOnline(stat);
    userlist->updateStatus(us);
}
开发者ID:pva701,项目名称:codes,代码行数:5,代码来源:chatclient.cpp


示例8: Status

    Status CmdAuthenticate::_authenticateCR(const UserName& user, const BSONObj& cmdObj) {

        if (user == internalSecurity.user->getName() &&
            serverGlobalParams.clusterAuthMode.load() == 
            ServerGlobalParams::ClusterAuthMode_x509) {
            return Status(ErrorCodes::AuthenticationFailed,
                          "Mechanism x509 is required for internal cluster authentication");
        }

        if (_isCRAuthDisabled) {
            // SERVER-8461, MONGODB-CR must be enabled for authenticating the internal user, so that
            // cluster members may communicate with each other.
            if (user != internalSecurity.user->getName()) {
                return Status(ErrorCodes::BadValue, _nonceAuthenticationDisabledMessage);
            }
        }

        string key = cmdObj.getStringField("key");
        string received_nonce = cmdObj.getStringField("nonce");

        if( user.getUser().empty() || key.empty() || received_nonce.empty() ) {
            sleepmillis(10);
            return Status(ErrorCodes::ProtocolError,
                          "field missing/wrong type in received authenticate command");
        }

        stringstream digestBuilder;

        {
            ClientBasic *client = ClientBasic::getCurrent();
            boost::scoped_ptr<AuthenticationSession> session;
            client->swapAuthenticationSession(session);
            if (!session || session->getType() != AuthenticationSession::SESSION_TYPE_MONGO) {
                sleepmillis(30);
                return Status(ErrorCodes::ProtocolError, "No pending nonce");
            }
            else {
                nonce64 nonce = static_cast<MongoAuthenticationSession*>(session.get())->getNonce();
                digestBuilder << hex << nonce;
                if (digestBuilder.str() != received_nonce) {
                    sleepmillis(30);
                    return Status(ErrorCodes::AuthenticationFailed, "Received wrong nonce.");
                }
            }
        }

        User* userObj;
        Status status = getGlobalAuthorizationManager()->acquireUser(user, &userObj);
        if (!status.isOK()) {
            // Failure to find the privilege document indicates no-such-user, a fact that we do not
            // wish to reveal to the client.  So, we return AuthenticationFailed rather than passing
            // through the returned status.
            return Status(ErrorCodes::AuthenticationFailed, status.toString());
        }
        string pwd = userObj->getCredentials().password;
        getGlobalAuthorizationManager()->releaseUser(userObj);

        md5digest d;
        {
            digestBuilder << user.getUser() << pwd;
            string done = digestBuilder.str();

            md5_state_t st;
            md5_init(&st);
            md5_append(&st, (const md5_byte_t *) done.c_str(), done.size());
            md5_finish(&st, d);
        }

        string computed = digestToString( d );

        if ( key != computed ) {
            return Status(ErrorCodes::AuthenticationFailed, "key mismatch");
        }

        AuthorizationSession* authorizationSession =
            ClientBasic::getCurrent()->getAuthorizationSession();
        status = authorizationSession->addAndAuthorizeUser(user);
        if (!status.isOK()) {
            return status;
        }

        return Status::OK();
    }
开发者ID:hshinde,项目名称:mongo,代码行数:83,代码来源:authentication_commands.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UserClass类代码示例发布时间:2022-05-31
下一篇:
C++ UseVector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap