本文整理汇总了C++中CVar::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ CVar::Parse方法的具体用法?C++ CVar::Parse怎么用?C++ CVar::Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVar
的用法示例。
在下文中一共展示了CVar::Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
// --[ Method ]---------------------------------------------------------------
//
// - Class : CEffect
// - prototype : bool Parse(CAdvancedParser* pParser)
//
// - Purpose : Parses an effect. The parser has only the text data of
// the effect, not of the whole script.
//
// -----------------------------------------------------------------------------
bool CEffect::Parse(CAdvancedParser* pParser)
{
assert(pParser);
assert(pParser->Ready());
// General info
pParser->ResetPos();
if(!pParser->ReadKeyFloat("#Begin", '=', &m_fBegin, CParser::SEARCH_WHOLEDATA)) return false;
if(!pParser->ReadKeyFloat("#End", '=', &m_fEnd, CParser::SEARCH_WHOLEDATA)) return false;
if(!pParser->ReadKeyInt ("#Layer", '=', &m_nLayer, CParser::SEARCH_WHOLEDATA)) return false;
// Resources
int nError = 0;
pParser->ResetPos();
while(-1 != pParser->Find("#Resource", CParser::SEARCH_FROMCURPOS))
{
std::string strClass, strName, strValue;
if(!pParser->ReadKeyString("#Name", '=', &strName, CParser::SEARCH_INCURLINE)) nError++;
if(!pParser->ReadKeyString("#Class", '=', &strClass, CParser::SEARCH_INCURLINE)) nError++;
if(!pParser->ReadKeyString("#Value", '=', &strValue, CParser::SEARCH_INCURLINE)) nError++;
if(nError)
{
LOG.Write("\nERROR - CEffect::Parse(): Error parsing resource.");
return false;
}
int i = GetResourceIndex(strName);
if(i == -1)
{
LOG.Write("\nERROR - CEffect::Parse(): Resource \"%s\" doesn't belong to this effect.", strName.data());
return false;
}
std::string strClassAux;
GetResourceClassName(i, &strClassAux);
if(strClassAux != strClass)
{
LOG.Write("\nERROR - CEffect::Parse(): Error parsing resource \"%s\". Class=%s (expected %s)", strName.data(), strClass.data(), strClassAux.data());
return false;
}
if(!SetResourceValue(i, strValue))
{
LOG.Write("\nERROR - CEffect::Parse(): Error setting resource \"%s\" value.", strName.data());
return false;
}
}
// Variables
pParser->ResetPos();
while(-1 != pParser->Find("#Var", CParser::SEARCH_FROMCURPOS))
{
std::string strClass, strName;
if(!pParser->ReadKeyString("#Name", '=', &strName, CParser::SEARCH_INCURLINE)) nError++;
if(!pParser->ReadKeyString("#Class", '=', &strClass, CParser::SEARCH_INCURLINE)) nError++;
if(nError)
{
LOG.Write("\nERROR - CEffect::Parse(): Error parsing var.");
return false;
}
CVar* pVar = GetVar(strName);
if(!pVar)
{
LOG.Write("\nERROR - CEffect::Parse(): Error parsing var. \"%s\" doesn't belong to this effect", strName.data());
return false;
}
if(pVar->GetClassName() != strClass)
{
LOG.Write("\nERROR - CEffect::Parse(): Error parsing var \"%s\". Class=%s (expected %s)", strName.data(), strClass.data(), pVar->GetClassName().data());
return false;
}
if(!pVar->Parse(pParser))
{
LOG.Write("\nERROR - CEffect::Parse(): Error parsing var \"%s\" (CVar::Parse() failed).", strName.data());
//.........这里部分代码省略.........