本文整理汇总了C++中idParser::CheckTokenString方法的典型用法代码示例。如果您正苦于以下问题:C++ idParser::CheckTokenString方法的具体用法?C++ idParser::CheckTokenString怎么用?C++ idParser::CheckTokenString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idParser
的用法示例。
在下文中一共展示了idParser::CheckTokenString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseConstantValue
/*
================
idTypeInfoGen::ParseConstantValue
================
*/
void idTypeInfoGen::ParseConstantValue( const char *scope, idParser &src, idStr &value ) {
idToken token;
idStr constantString;
int indent = 0;
while( src.ReadToken( &token ) ) {
if ( token == "(" ) {
indent++;
} else if ( token == ")" ) {
indent--;
} else if ( indent == 0 && ( token == ";" || token == "," || token == "}" ) ) {
src.UnreadToken( &token );
break;
} else if ( token.type == TT_NAME ) {
constantString = token;
while( src.CheckTokenString( "::" ) ) {
src.ExpectTokenType( TT_NAME, 0, &token );
constantString += "::" + token;
}
value += va( "%d", GetIntegerConstant( scope, constantString, src ) );
continue;
}
value += token;
}
}
示例2: ParseArraySize
/*
================
idTypeInfoGen::ParseArraySize
================
*/
int idTypeInfoGen::ParseArraySize( const char *scope, idParser &src ) {
idToken token;
idStr sizeString, constantString;
int size, totalSize;
if ( !src.CheckTokenString( "[" ) ) {
return 0;
}
totalSize = 1;
sizeString = "";
while( src.ReadToken( &token ) ) {
if ( token == "]" ) {
if ( sizeString.Length() ) {
size = EvaluateIntegerString( sizeString );
if ( size ) {
totalSize *= size;
}
sizeString = "";
}
if ( !src.CheckTokenString( "[" ) ) {
break;
}
} else if ( token.type == TT_NAME ) {
constantString = token;
while( src.CheckTokenString( "::" ) ) {
src.ExpectTokenType( TT_NAME, 0, &token );
constantString += "::" + token;
}
sizeString += va( "%d", GetIntegerConstant( scope, constantString, src ) );
} else {
sizeString += token;
}
}
return totalSize;
}
示例3: ParseScope
/*
================
idTypeInfoGen::ParseScope
================
*/
void idTypeInfoGen::ParseScope( const char *scope, bool isTemplate, idParser &src, idClassTypeInfo *typeInfo ) {
int indent;
idToken token;
idClassTypeInfo *classInfo;
idEnumTypeInfo *enumInfo;
idStr varType;
bool isConst = false;
bool isStatic = false;
indent = 1;
while( indent ) {
if ( !src.ReadToken( &token ) ) {
break;
}
if ( token == "{" ) {
do {
if ( token == "{" ) {
indent++;
} else if ( token == "}" ) {
indent--;
}
varType += token + " ";
} while( indent > 1 && src.ReadToken( &token ) );
} else if ( token == "}" ) {
assert( indent == 1 );
indent--;
} else if ( token == "<" ) {
do {
if ( token == "<" ) {
indent++;
} else if ( token == ">" ) {
indent--;
}
varType += token + " ";
} while( indent > 1 && src.ReadToken( &token ) );
} else if ( token == ";" ) {
varType = "";
isConst = false;
isStatic = false;
} else if ( token == "public" || token == "protected" || token == "private" ) {
if ( !src.ExpectTokenString( ":" ) ) {
break;
}
varType = "";
isConst = false;
isStatic = false;
} else if ( token == "friend" ) {
// skip friend classes/methods
while( src.ReadToken( &token ) ) {
if ( token == "{" ) {
indent++;
} else if ( token == "}" ) {
indent--;
if ( indent == 1 ) {
break;
}
} else if ( token == ";" && indent == 1 ) {
break;
}
}
varType = "";
isConst = false;
isStatic = false;
} else if ( token == "template" ) {
varType = "";
if ( src.CheckTokenString( "<" ) ) {
int indent = 1;
varType += "< ";
while( src.ReadToken( &token ) ) {
if ( token == "<" ) {
indent++;
} else if ( token == ">" ) {
indent--;
if ( indent == 0 ) {
break;
}
}
varType += token + " ";
//.........这里部分代码省略.........
示例4: ParseExportSection
/*
====================
idModelExport::ParseExportSection
====================
*/
int idModelExport::ParseExportSection( idParser &parser ) {
idToken command;
idToken token;
idStr defaultCommands;
idLexer lex;
idStr temp;
idStr parms;
int count;
// only export sections that match our export mask
if( g_exportMask.GetString()[ 0 ] ) {
if( parser.CheckTokenString( "{" ) ) {
parser.SkipBracedSection( false );
return 0;
}
parser.ReadToken( &token );
if( token.Icmp( g_exportMask.GetString() ) ) {
parser.SkipBracedSection();
return 0;
}
parser.ExpectTokenString( "{" );
} else if( !parser.CheckTokenString( "{" ) ) {
// skip the export mask
parser.ReadToken( &token );
parser.ExpectTokenString( "{" );
}
count = 0;
lex.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
while( 1 ) {
if( !parser.ReadToken( &command ) ) {
parser.Error( "Unexpoected end-of-file" );
break;
}
if( command == "}" ) {
break;
}
if( command == "options" ) {
parser.ParseRestOfLine( defaultCommands );
} else if( command == "addoptions" ) {
parser.ParseRestOfLine( temp );
defaultCommands += " ";
defaultCommands += temp;
} else if( ( command == "mesh" ) || ( command == "anim" ) || ( command == "camera" ) ) {
if( !parser.ReadToken( &token ) ) {
parser.Error( "Expected filename" );
}
temp = token;
parser.ParseRestOfLine( parms );
if( defaultCommands.Length() ) {
sprintf( temp, "%s %s", temp.c_str(), defaultCommands.c_str() );
}
if( parms.Length() ) {
sprintf( temp, "%s %s", temp.c_str(), parms.c_str() );
}
lex.LoadMemory( temp, temp.Length(), parser.GetFileName() );
Reset();
if( ParseOptions( lex ) ) {
const char *game = cvarSystem->GetCVarString( "fs_game" );
if( strlen( game ) == 0 ) {
game = BASE_GAMEDIR;
}
if( command == "mesh" ) {
dest.SetFileExtension( MD5_MESH_EXT );
} else if( command == "anim" ) {
dest.SetFileExtension( MD5_ANIM_EXT );
} else if( command == "camera" ) {
dest.SetFileExtension( MD5_CAMERA_EXT );
} else {
dest.SetFileExtension( command );
}
idStr back = commandLine;
sprintf( commandLine, "%s %s -dest %s -game %s%s", command.c_str(), src.c_str(), dest.c_str(), game, commandLine.c_str() );
if( ConvertMayaToMD5() ) {
count++;
} else {
parser.Warning( "Failed to export '%s' : %s", src.c_str(), Maya_Error.c_str() );
}
}
lex.FreeSource();
} else {
parser.Error( "Unknown token: %s", command.c_str() );
parser.SkipBracedSection( false );
break;
}
}
return count;
}