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


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

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


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

示例1: runCommand

void Input::runCommand(const std::string &command, const std::string &args)
{
	if (command == BINDCOMMAND) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string state("general");
		std::string key = tokeniser.nextToken();
		if (key != "") {
			std::string command(tokeniser.nextToken());
			if (command != "") {
				if (tokeniser.nextToken() != "") {
					state = tokeniser.nextToken();
				}
				InputCommandMapperStore::iterator I = mInputCommandMappers.find(state);
				if (I != mInputCommandMappers.end()) {
					I->second->bindCommand(key, command);
				}
			}
		}
	} else if (command == UNBINDCOMMAND) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string state("general");
		std::string key(tokeniser.nextToken());
		if (key != "") {
			if (tokeniser.nextToken() != "") {
				state = tokeniser.nextToken();
			}
			InputCommandMapperStore::iterator I = mInputCommandMappers.find(state);
			if (I != mInputCommandMappers.end()) {
				I->second->unbindCommand(key);
			}
		}
	}
}
开发者ID:mpreisler,项目名称:ember,代码行数:35,代码来源:Input.cpp

示例2: 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,代码来源:

示例3: 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

示例4: 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

示例5: runCommand

void ShaderManager::runCommand(const std::string &command, const std::string &args)
{
  if (SetLevel == command) {
    Tokeniser tokeniser;
    tokeniser.initTokens(args);
    std::string levelString = tokeniser.nextToken();
    EmberServices::getSingleton().getConfigService().setValue("graphics", "level", levelString);
  }
}
开发者ID:junrw,项目名称:ember-gsoc2012,代码行数:9,代码来源:ShaderManager.cpp

示例6: runCommand

void ThirdPersonCameraMount::runCommand(const std::string& command, const std::string& args) {
	if (SetCameraDistance == command) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string distance = tokeniser.nextToken();
		if (!distance.empty()) {
			float fDistance = Ogre::StringConverter::parseReal(distance);
			setCameraDistance(fDistance);
		}
	}
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例7: runCommand

void EmberEntityFactory::runCommand(const std::string &command, const std::string &args)
{
	if (command == ShowModels.getCommand()) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string value = tokeniser.nextToken();
		if (value == "true") {
			S_LOG_INFO("Showing models.");
			Model::ModelDefinitionManager::getSingleton().setShowModels(true);
		} else if (value == "false") {
			S_LOG_INFO("Hiding models.");
			Model::ModelDefinitionManager::getSingleton().setShowModels(false);
		}
	} else if (DumpAttributes == command) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string value = tokeniser.nextToken();
		if (value == "") {
			dumpAttributesOfEntity(value);
		}
	}
}
开发者ID:Arsakes,项目名称:ember,代码行数:22,代码来源:EmberEntityFactory.cpp

示例8: runCommand

void EntityMoveManager::runCommand(const std::string &command, const std::string &args)
{
	if (Move == command) {
		//the first argument must be a valid entity id
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string entityId = tokeniser.nextToken();
		if (entityId != "") {
			EmberEntity* entity = mWorld.getEmberEntity(entityId);
			if (entity != 0) {
				startMove(*entity);
			}
		} else {
			ConsoleBackend::getSingletonPtr()->pushMessage("You must specify a valid entity id to move.", "error");
		}

	}
}
开发者ID:Chimangoo,项目名称:ember,代码行数:18,代码来源:EntityMoveManager.cpp

示例9: while

      void
      MaterialEditor::runCommand(const std::string &command,
          const std::string &args)
      {

        if (AlterMaterial == command)
          {
            try
              {
                Tokeniser tokeniser;
                tokeniser.initTokens(args);

                std::vector<std::string> tokens;
                std::string token;
                while ((token = tokeniser.nextToken()) != "")
                  {
                    tokens.push_back(token);
                  }

                std::string materialName = tokens[0];

                Ogre::MaterialPtr materialPtr =
                    static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(
                        materialName));
                if (!materialPtr.isNull())
                  {
                    std::string techniqueIndexString = tokens[1];
                    if (techniqueIndexString != "")
                      {
                        int techniqueIndex = Ogre::StringConverter::parseInt(
                            techniqueIndexString);
                        Ogre::Technique* technique = materialPtr->getTechnique(
                            techniqueIndex);
                        if (technique)
                          {
                            std::string passIndexString = tokens[2];
                            if (passIndexString != "")
                              {
                                int passIndex = Ogre::StringConverter::parseInt(
                                    passIndexString);
                                Ogre::Pass* pass = technique->getPass(
                                    passIndex);
                                //is texture unit specified
                                if (tokens.size() == 6)
                                  {
                                    std::string textureUnitIndexString =
                                        tokens[3];
                                    std::string property = tokens[4];
                                    std::string value = tokens[5];

                                    int textureUnitIndex =
                                        Ogre::StringConverter::parseInt(
                                            textureUnitIndexString);

                                    Ogre::TextureUnitState* textureUnit =
                                        pass->getTextureUnitState(
                                            textureUnitIndex);
                                    if (textureUnit)
                                      {

                                      }
                                  }
                                else
                                  {
                                    std::string property = tokens[3];
                                    std::string value = tokens[4];
                                    if (property == "alpha_rejection")
                                      {
                                        pass->setAlphaRejectValue(
                                            Ogre::StringConverter::parseInt(
                                                value));
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
            catch (const std::exception& ex)
              {
                S_LOG_WARNING("Error when altering material." << ex);
              }
            catch (...)
              {
                S_LOG_WARNING("Error when altering material.");
              }
          }
      }
开发者ID:PlumInTheLateAfternoonShade,项目名称:ember_gsoc_2013_test,代码行数:88,代码来源:MaterialEditor.cpp


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