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


C++ Tokeniser::remainingTokens方法代码示例

本文整理汇总了C++中Tokeniser::remainingTokens方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokeniser::remainingTokens方法的具体用法?C++ Tokeniser::remainingTokens怎么用?C++ Tokeniser::remainingTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tokeniser的用法示例。


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

示例1: if

  void
  AccountAvailableState::runCommand(const std::string &command,
      const std::string &args)
  {
    if (CreateAcc == command)
      {

        Tokeniser tokeniser = Tokeniser();
        tokeniser.initTokens(args);
        std::string uname = tokeniser.nextToken();
        std::string password = tokeniser.nextToken();
        std::string realname = tokeniser.remainingTokens();

        std::string msg;
        msg = "Creating account: Name: [" + uname + "], Password: [" + password
            + "], Real Name: [" + realname + "]";

        try
          {
            mAccount.createAccount(uname, realname, password);
          }
        catch (const std::exception& except)
          {
            S_LOG_WARNING("Got error on account creation." << except);
            return;
          }
        catch (...)
          {
            S_LOG_WARNING("Got unknown error on account creation.");
            return;
          }

      }
    else if (Login == command)
      {

        // Split string into userid / password pair
        Tokeniser tokeniser = Tokeniser();
        tokeniser.initTokens(args);
        std::string userid = tokeniser.nextToken();
        std::string password = tokeniser.remainingTokens();

        mAccount.login(userid, password);

        std::string msg;
        msg = "Login: [" + userid + "," + password + "]";
        ConsoleBackend::getSingleton().pushMessage(msg, "info");
      }
  }
开发者ID:,项目名称:,代码行数:49,代码来源:

示例2: runCommand

void LoggedInState::runCommand(const std::string &command, const std::string &args)
{
	if (Logout == command) {
		ConsoleBackend::getSingleton().pushMessage("Logging out...", "important");
		mAccount.logout();

		// Create Character command
	} else if (CreateChar == command) {
		// Split string into name/type/sex/description
		Tokeniser tokeniser = Tokeniser();
		tokeniser.initTokens(args);
		std::string name = tokeniser.nextToken();
		std::string sex = tokeniser.nextToken();
		std::string type = tokeniser.nextToken();
		std::string spawnPoint = tokeniser.nextToken();
		std::string description = tokeniser.remainingTokens();

		createCharacter(name, sex, type, description, spawnPoint, Atlas::Message::MapType());

		// Take Character Command
	} else if (TakeChar == command) {

		takeCharacter(args);

		// List Characters Command
	} else if (ListChars == command) {

		mAccount.refreshCharacterInfo();

		// Say (In-Game chat) Command
	}
}
开发者ID:Chimangoo,项目名称:ember,代码行数:32,代码来源:LoggedInState.cpp

示例3: runCommand

	void ConfigService::runCommand ( const std::string &command, const std::string &args )
	{
		if ( command == SETVALUE )
		{
			Tokeniser tokeniser;
			tokeniser.initTokens ( args );
			std::string section ( tokeniser.nextToken() );
			std::string key ( tokeniser.nextToken() );
			std::string value ( tokeniser.remainingTokens() );

			if ( section == "" || key == "" || value == "" )
			{
				ConsoleBackend::getSingleton().pushMessage ( "Usage: set_value <section> <key> <value>", "help" );
			}
			else
			{
				setValue ( section, key, value );
				ConsoleBackend::getSingleton().pushMessage ( "New value set, section: " +  section + " key: " + key + " value: " + value, "info" );
			}

		}
		else if ( command == GETVALUE )
		{
			Tokeniser tokeniser;
			tokeniser.initTokens ( args );
			std::string section ( tokeniser.nextToken() );
			std::string key ( tokeniser.nextToken() );

			if ( section == "" || key == "" )
			{
				ConsoleBackend::getSingleton().pushMessage ( "Usage: get_value <section> <key>", "help" );
			}
			else
			{
				if ( !hasItem ( section, key ) )
				{
					ConsoleBackend::getSingleton().pushMessage ( "No such value.", "error" );
				}
				else
				{
					varconf::Variable value = getValue ( section, key );
					ConsoleBackend::getSingleton().pushMessage ( std::string ( "Value: " ) + static_cast<std::string> ( value ), "info" );
				}
			}
		}
	}
开发者ID:LawrenceWeng,项目名称:ember,代码行数:46,代码来源:ConfigService.cpp

示例4: runCommand

void NonConnectedState::runCommand(const std::string &command, const std::string &args)
{
	// Connect command
	if (Connect == command) {
		// Split string into server / port pair
		Tokeniser tokeniser = Tokeniser();
		tokeniser.initTokens(args);
		std::string server = tokeniser.nextToken();
		std::string port = tokeniser.remainingTokens();
		std::string msg;
		msg = "Connecting to: [" + server + "]";
		ConsoleBackend::getSingleton().pushMessage(msg, "info");
		if (port == "")
			connect(server);
		else
			connect(server, (short)atoi(port.c_str()));

		// Disonnect command
	}
}
开发者ID:,项目名称:,代码行数:20,代码来源:


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