本文整理汇总了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));
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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
}
}
示例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");
}
}
}
示例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");
}
}
示例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" );
}
}
}
}
示例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();
}
}
示例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;
}
示例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 ¯o : macroTable) {
if (token == macro.token) {
return processMacro(tokeniser, macro.symbol);
}
}
if (std::regex_match(token, intRegex)) {
return mal::integer(token);
}
return mal::symbol(token);
}
示例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;
}
}
示例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;
}
示例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\"");
}
}
示例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);
}