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


C++ Tokeniser类代码示例

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


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

示例1: readList

static void readList(Tokeniser& tokeniser, malValueVec* items,
                      const String& end)
{
    while (1) {
        MAL_CHECK(!tokeniser.eof(), "expected '%s', got EOF", end.c_str());
        if (tokeniser.peek() == end) {
            tokeniser.next();
            return;
        }
        items->push_back(readForm(tokeniser));
    }
}
开发者ID:kanaka,项目名称:mal,代码行数:12,代码来源:Reader.cpp

示例2: runCommand

void CaelumEnvironment::runCommand(const std::string &command, const std::string &args)
{
	if (SetCaelumTime == command) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string hourString = tokeniser.nextToken();
		std::string minuteString = tokeniser.nextToken();

		int hour = ::Ogre::StringConverter::parseInt(hourString);
		int minute = ::Ogre::StringConverter::parseInt(minuteString);
		setTime(hour, minute);
	}
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例3: 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);
		}
	}
}
开发者ID:angkorcn,项目名称:ember,代码行数:15,代码来源:EmberEntityFactory.cpp

示例4: Map_Read

void Map_Read (scene::Node& root, Tokeniser& tokeniser, EntityCreator& entityTable, const PrimitiveParser& parser)
{
	// Create an info display panel to track load progress
	gtkutil::ModalProgressDialog dialog(GlobalRadiant().getMainWindow(), _("Loading map"));

	// Read each entity in the map, until EOF is reached
	for (int entCount = 0; ; entCount++) {
		// Update the dialog text
		dialog.setText("Loading entity " + string::toString(entCount));

		// Check for end of file
		if (tokeniser.getToken().empty())
			break;

		// Create an entity node by parsing from the stream
		NodeSmartReference entity(Entity_parseTokens(tokeniser, entityTable, parser, entCount));

		if (entity == g_nullNode) {
			globalErrorStream() << "entity " << entCount << ": parse error\n";
			return;
		}

		// Insert the new entity into the scene graph
		Node_getTraversable(root)->insert(entity);
	}
}
开发者ID:AresAndy,项目名称:ufoai,代码行数:26,代码来源:parse.cpp

示例5: if

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

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

示例7: Tokeniser

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

示例8: section

	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

示例9: parse

void UMPFile::parse (Tokeniser &tokeniser)
{
    std::string token = tokeniser.getToken();
    while (token.length()) {
        if (token == "base") {
            _base = tokeniser.getToken();
            if (_base.empty()) {
                globalErrorStream() << _fileName << ": base without parameter given\n";
                return;
            }
        } else if (token == "tile") {
            try {
                parseTile(tokeniser);
            } catch (UMPException &e) {
                globalErrorStream() << _fileName << ": " << e.getMessage() << "\n";
                return;
            }
        }
        token = tokeniser.getToken();
    }
}
开发者ID:AresAndy,项目名称:ufoai,代码行数:21,代码来源:UMPFile.cpp

示例10: f

bool ConfigFile::Load(const std::string& filename)
{
  // Ctor args: arg 1 (true) => has version info
  // arg2 (false) => don't use Glue File implementation.
  File f(true, File::STD);

  if (!f.OpenRead(filename))
  {
#ifdef _DEBUG
    // This is ok for a clean install, so don't complain in a release build.
    f.ReportError("Couldn't open config file.");
#endif
    return false;
  }
  // This config file simply consists of pairs of tokens. The first of each 
  // pair is the key; the second is the value.
  Tokeniser toker;

  string configLine;
  while (f.GetDataLine(&configLine))
  {
    string key;
    string value;

    if (!toker.Tokenise(&configLine, &key))
    {
      string error = "No value for " + key + " in config file."; 
      f.ReportError(error);
      return false;
    }
    // Tokeniser chops head (the key) off configLine, leaving the value tail.
    value = configLine;

    // Set value in map.
    Set(key, value);

  }
  // No more tokens. This is ok, we have finished.
  return true;
}
开发者ID:jason-amju,项目名称:amju-scp,代码行数:40,代码来源:ConfigFile.cpp

示例11: readAtom

static malValuePtr readAtom(Tokeniser& tokeniser)
{
    struct ReaderMacro {
        const char* token;
        const char* symbol;
    };
    ReaderMacro macroTable[] = {
        { "@",   "deref" },
        { "`",   "quasiquote" },
        { "'",   "quote" },
        { "[email protected]",  "splice-unquote" },
        { "~",   "unquote" },
    };

    struct Constant {
        const char* token;
        malValuePtr value;
    };
    Constant constantTable[] = {
        { "false",  mal::falseValue()  },
        { "nil",    mal::nilValue()          },
        { "true",   mal::trueValue()   },
    };

    String token = tokeniser.next();
    if (token[0] == '"') {
        return mal::string(unescape(token));
    }
    if (token[0] == ':') {
        return mal::keyword(token);
    }
    if (token == "^") {
        malValuePtr meta = readForm(tokeniser);
        malValuePtr value = readForm(tokeniser);
        // Note that meta and value switch places
        return mal::list(mal::symbol("with-meta"), value, meta);
    }
    for (auto &constant : constantTable) {
        if (token == constant.token) {
            return constant.value;
        }
    }
    for (auto &macro : macroTable) {
        if (token == macro.token) {
            return processMacro(tokeniser, macro.symbol);
        }
    }
    if (std::regex_match(token, intRegex)) {
        return mal::integer(token);
    }
    return mal::symbol(token);
}
开发者ID:kanaka,项目名称:mal,代码行数:52,代码来源:Reader.cpp

示例12: Map_Read

void Map_Read(scene::Node& root, Tokeniser& tokeniser, EntityCreator& entityTable, const PrimitiveParser& parser)
{
  int count_entities = 0;
  for(;;)
  {
    tokeniser.nextLine();
    if (!tokeniser.getToken()) // { or 0
		  break;

    NodeSmartReference entity(Entity_parseTokens(tokeniser, entityTable, parser, count_entities));

    if(entity == g_nullNode)
    {
      globalErrorStream() << "entity " << count_entities << ": parse error\n";
      return;
    }

    Node_getTraversable(root)->insert(entity);

    ++count_entities;
  }
}
开发者ID:ChunHungLiu,项目名称:GtkRadiant,代码行数:22,代码来源:parse.cpp

示例13: Tokeniser_unexpectedError

bool UFOFaceTokenImporter::importTextureName (FaceShader& faceShader, Tokeniser& tokeniser)
{
	const std::string texture = tokeniser.getToken();
	if (texture.empty()) {
		Tokeniser_unexpectedError(tokeniser, texture, "#texture-name");
		return false;
	}
	if (texture == "NULL" || texture.empty()) {
		faceShader.setShader("");
	} else {
		faceShader.setShader(GlobalTexturePrefix_get() + texture);
	}
	return true;
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:14,代码来源:BrushTokens.cpp

示例14: parseColour

QColor ConfigManager::parseColour(QColor deflt){
    QColor c;
    switch(tok.getnext()){
    case T_IDENT:
    case T_STRING:
        c = QColor(tok.getstring());
        return c;
        break;
    case T_DEFAULT:
        return deflt;
    default:
        throw UnexpException(&tok,"colour name or \"#rgb\"");
    }
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例15: parseAudio

static void parseAudio(){
    char warning[1024];
    bool speech;
    
    DataBuffer<float> *buf = ConfigManager::parseFloatSource();
    
    switch(tok.getnext()){
    case T_SAMPLE:speech=false;break;
    case T_SPEECH:speech=true;break;
    default:
        throw UnexpException(&tok,"'speech' or 'sample'");
    }
    
    tok.getnextstring(warning);
    
    getApp()->addAudio(warning,buf,speech);
}
开发者ID:,项目名称:,代码行数:17,代码来源:


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