本文整理汇总了C++中Tokeniser类的典型用法代码示例。如果您正苦于以下问题:C++ Tokeniser类的具体用法?C++ Tokeniser怎么用?C++ Tokeniser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tokeniser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 ¯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);
}
开发者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: parseLicensesFile
void LicenseParser::parseLicensesFile (Tokeniser& tokeniser, const std::string& filename)
{
for (;;) {
std::string token = tokeniser.getToken();
if (token.empty())
break;
if (tokeniser.getLine() > 1) {
tokeniser.ungetToken();
break;
}
}
std::size_t lastLine = 1;
for (;;) {
std::string token = tokeniser.getToken();
if (token.empty())
break;
if (string::contains(token, "base/textures/") && lastLine != tokeniser.getLine()) {
_licensesMap[os::stripExtension(token.substr(5))] = true;
lastLine = tokeniser.getLine();
}
}
}
开发者ID:AresAndy,项目名称:ufoai,代码行数:23,代码来源:LicenseParser.cpp
示例15: EntityClassDoom3_parseString
bool EntityClassDoom3_parseString( Tokeniser& tokeniser, CopiedString& s ){
const char* token = tokeniser.getToken();
PARSE_RETURN_FALSE_IF_FAIL( token != 0 );
s = token;
return true;
}
开发者ID:xonotic,项目名称:netradient,代码行数:6,代码来源:eclass_doom3.cpp
示例16: EntityClassDoom3_parseToken
bool EntityClassDoom3_parseToken( Tokeniser& tokeniser, const char* string ){
const char* token = tokeniser.getToken();
PARSE_RETURN_FALSE_IF_FAIL( token != 0 );
return string_equal( token, string );
}
开发者ID:xonotic,项目名称:netradient,代码行数:5,代码来源:eclass_doom3.cpp
示例17: EntityClass_parse
static bool EntityClass_parse( EntityClass& entityClass, Tokeniser& tokeniser ){
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, entityClass.m_name ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "{" ) );
tokeniser.nextLine();
StringOutputStream usage( 256 );
StringOutputStream description( 256 );
CopiedString* currentDescription = 0;
StringOutputStream* currentString = 0;
for (;; )
{
const char* key;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, key ) );
const char* last = string_findFirstSpaceOrTab( key );
CopiedString first( StringRange( key, last ) );
if ( !string_empty( last ) ) {
last = string_findFirstNonSpaceOrTab( last );
}
if ( currentString != 0 && string_equal( key, "\\" ) ) {
tokeniser.nextLine();
*currentString << " ";
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, *currentString ) );
continue;
}
if ( currentDescription != 0 ) {
*currentDescription = description.c_str();
description.clear();
currentDescription = 0;
}
currentString = 0;
if ( string_equal( key, "}" ) ) {
tokeniser.nextLine();
break;
}
else if ( string_equal( key, "model" ) ) {
const char* token;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) );
entityClass.fixedsize = true;
StringOutputStream buffer( 256 );
buffer << PathCleaned( token );
entityClass.m_modelpath = buffer.c_str();
}
else if ( string_equal( key, "editor_color" ) ) {
const char* value;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) );
if ( !string_empty( value ) ) {
entityClass.colorSpecified = true;
bool success = string_parse_vector3( value, entityClass.color );
ASSERT_MESSAGE( success, "editor_color: parse error" );
}
}
else if ( string_equal( key, "editor_ragdoll" ) ) {
//bool ragdoll = atoi(tokeniser.getToken()) != 0;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
}
else if ( string_equal( key, "editor_mins" ) ) {
entityClass.sizeSpecified = true;
const char* value;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) );
if ( !string_empty( value ) && !string_equal( value, "?" ) ) {
entityClass.fixedsize = true;
bool success = string_parse_vector3( value, entityClass.mins );
ASSERT_MESSAGE( success, "editor_mins: parse error" );
}
}
else if ( string_equal( key, "editor_maxs" ) ) {
entityClass.sizeSpecified = true;
const char* value;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) );
if ( !string_empty( value ) && !string_equal( value, "?" ) ) {
entityClass.fixedsize = true;
bool success = string_parse_vector3( value, entityClass.maxs );
ASSERT_MESSAGE( success, "editor_maxs: parse error" );
}
}
else if ( string_equal( key, "editor_usage" ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, usage ) );
currentString = &usage;
}
else if ( string_equal_n( key, "editor_usage", 12 ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, usage ) );
currentString = &usage;
}
else if ( string_equal( key, "editor_rotatable" )
|| string_equal( key, "editor_showangle" )
|| string_equal( key, "editor_showangles" ) // typo? in prey movables.def
|| string_equal( key, "editor_mover" )
|| string_equal( key, "editor_model" )
|| string_equal( key, "editor_material" )
|| string_equal( key, "editor_combatnode" )
|| ( !string_empty( last ) && string_equal( first.c_str(), "editor_gui" ) )
|| string_equal_n( key, "editor_copy", 11 ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
//.........这里部分代码省略.........
开发者ID:xonotic,项目名称:netradient,代码行数:101,代码来源:eclass_doom3.cpp
示例18: EntityClassDoom3_parseModel
bool EntityClassDoom3_parseModel( Tokeniser& tokeniser ){
const char* name;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, name ) );
Model& model = g_models[name];
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "{" ) );
tokeniser.nextLine();
for (;; )
{
const char* parameter;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, parameter ) );
if ( string_equal( parameter, "}" ) ) {
tokeniser.nextLine();
break;
}
else if ( string_equal( parameter, "inherit" ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_parent ) );
tokeniser.nextLine();
}
else if ( string_equal( parameter, "remove" ) ) {
//const char* remove =
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
tokeniser.nextLine();
}
else if ( string_equal( parameter, "mesh" ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_mesh ) );
tokeniser.nextLine();
}
else if ( string_equal( parameter, "skin" ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_skin ) );
tokeniser.nextLine();
}
else if ( string_equal( parameter, "offset" ) ) {
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "(" ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, ")" ) );
tokeniser.nextLine();
}
else if ( string_equal( parameter, "channel" ) ) {
//const char* channelName =
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "(" ) );
for (;; )
{
const char* end;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, end ) );
if ( string_equal( end, ")" ) ) {
tokeniser.nextLine();
break;
}
}
}
else if ( string_equal( parameter, "anim" ) ) {
CopiedString animName;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animName ) );
const char* animFile;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animFile ) );
model.m_anims.insert( Model::Anims::value_type( animName, animFile ) );
const char* token;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) );
while ( string_equal( token, "," ) )
{
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animFile ) );
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) );
}
if ( string_equal( token, "{" ) ) {
for (;; )
{
const char* end;
PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, end ) );
if ( string_equal( end, "}" ) ) {
tokeniser.nextLine();
break;
}
tokeniser.nextLine();
}
}
else
{
tokeniser.ungetToken();
}
}
else
{
globalErrorStream() << "unknown model parameter: " << makeQuoted( parameter ) << "\n";
return false;
}
tokeniser.nextLine();
}
return true;
}
开发者ID:xonotic,项目名称:netradient,代码行数:98,代码来源:eclass_doom3.cpp
示例19: 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,代码来源:
示例20: 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;未经允许,请勿转载。 |
请发表评论