本文整理汇总了C++中CTokenizer::GetTokens方法的典型用法代码示例。如果您正苦于以下问题:C++ CTokenizer::GetTokens方法的具体用法?C++ CTokenizer::GetTokens怎么用?C++ CTokenizer::GetTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTokenizer
的用法示例。
在下文中一共展示了CTokenizer::GetTokens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadParticleBehaviour
CParticleBehaviour CParticleSystemManager::ReadParticleBehaviour( std::string szEmitterScript, std::string szParticleBehaviourName )
{
FILE *pFile = fopen( szEmitterScript.c_str(), "rt" );
if ( !pFile )
return CParticleBehaviour( "NULL", 0.0f, 0.0f );
CTokenizer tokenizer;
std::vector<std::string> tokens;
std::string in = ReadLine( pFile );
bool bInBehaviour = false;
float fEffect, fVelocity;
fEffect = fVelocity = 0.0f;
while ( in != "<<<EOF>>>" )
{
tokens = tokenizer.GetTokens( in, " ,;:\"" );
if ( tokens.size() == 0 )
{
in = ReadLine( pFile );
bInBehaviour = false;
continue;
}
if ( tokens[0] == "[emitter]" )
bInBehaviour = false;
else if ( tokens[0] == "[particle]" )
bInBehaviour = false;
else if ( tokens[0] == "[behaviour]" )
bInBehaviour = true;
if ( bInBehaviour )
{
if ( tokens[0] == "name" && tokens[2] == szParticleBehaviourName )
{
// Read until the next blank line
in = ReadLine( pFile );
while ( in != "" && in != "<<<EOF>>>" )
{
tokens = tokenizer.GetTokens(in);
if ( tokens[0] == "velocity" )
fVelocity = (float)atof( tokens[2].c_str() );
else if ( tokens[0] == "move" )
fEffect = (float)atof( tokens[2].c_str() );
in = ReadLine( pFile );
}
fclose( pFile );
return CParticleBehaviour( szParticleBehaviourName, fEffect, fVelocity );
}
}
in = ReadLine( pFile );
}
fclose( pFile );
return CParticleBehaviour( "NULL", 0.0f, 0.0f );
}
示例2: if
CParticleEmitter *CParticleSystemManager::LoadEmitter( std::string szEmitterScript )
{
if ( !SETS->PARTICLES_ON )
return NULL;
FILE *pFile = fopen( szEmitterScript.c_str(), "rt" );
if ( !pFile )
return NULL;
std::string in = ReadLine( pFile );
while ( in != "<<<EOF>>>" && in != "[emitter]" )
in = ReadLine( pFile );
EmitterType eType = NONE;
float fTypeParameter = 0.0f;
unsigned int iMaxParticles = 50;
unsigned int iLifespan = 6000;
unsigned int iSpawnrate = 10;
float fRadius = 0.0f;
CTokenizer tokenizer;
std::vector<std::string> tokens;
std::map<std::string, int> vParticles;
std::map<std::string,int>::iterator particleIt;
while ( in != "<<<EOF>>>" && in != "" )
{
tokens = tokenizer.GetTokens( in, " ,;:\"" );
if ( tokens.size() > 0 )
{
if ( tokens[0] == "direction" )
{
if ( tokens[2] == "arc" )
{
eType = ARC;
fTypeParameter = (float)atof(tokens[3].c_str());
}
else if ( tokens[2] == "line" )
{
eType = LINE;
fTypeParameter = (float)atof(tokens[3].c_str());
}
else
{
eType = NONE;
fTypeParameter = 0.0f;
}
}
else if ( tokens[0] == "maxparticles" )
iMaxParticles = atoi(tokens[2].c_str());
else if ( tokens[0] == "lifespan" )
iLifespan = atoi(tokens[2].c_str());
else if ( tokens[0] == "spawnrate" )
iSpawnrate = atoi(tokens[2].c_str());
else if ( tokens[0] == "radius" )
fRadius = (float)atof(tokens[2].c_str());
else if ( tokens[0] == "particles" )
{
int particles = (tokens.size() - 2) / 2;
for ( int i = 0; i<particles * 2; i+=2 )
{
std::string name = tokens[i + 2];
int chance = atoi(tokens[i + 3].c_str());
vParticles[name] = chance;
}
}
}
in = ReadLine( pFile );
}
fclose( pFile );
CParticleEmitter *pEmitter = new CParticleEmitter( eType, fTypeParameter, iMaxParticles, iLifespan, iSpawnrate, fRadius );
for ( particleIt = vParticles.begin(); particleIt != vParticles.end(); particleIt++ )
{
std::string name = (*particleIt).first;
int chance = (*particleIt).second;
CParticle *pParticle = ReadParticle( szEmitterScript, name, pEmitter );
pEmitter->AddToFactory( pParticle, chance );
}
m_vEmitters.push_back( pEmitter );
return pEmitter;
}