本文整理汇总了C++中KviKvsVariant::type方法的典型用法代码示例。如果您正苦于以下问题:C++ KviKvsVariant::type方法的具体用法?C++ KviKvsVariant::type怎么用?C++ KviKvsVariant::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KviKvsVariant
的用法示例。
在下文中一共展示了KviKvsVariant::type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
bool KviKvsTreeNodeSpecialCommandForeach::execute(KviKvsRunTimeContext * c)
{
KviKvsVariantList l;
l.setAutoDelete(true);
if(!m_pIterationData->evaluate(c,&l))
return false;
KviKvsSwitchList swl;
if(m_pSwitches)
{
if(!(m_pSwitches->evaluate(c,&swl)))
return false;
}
bool bIncludeEmptyScalars = swl.find('a',"all") != 0;
for(KviKvsVariant * pArg = l.first(); pArg; pArg = l.next())
{
switch(pArg->type())
{
case KviKvsVariantData::Array:
{
unsigned int uCnt = pArg->array()->size();
unsigned int idx = 0;
while(idx < uCnt)
{
// we evaluate this each time (as it may actually be killed at each iteration)
// FIXME: maybe some kind of reference counting or a observer pattern might be a bit more efficient here
// (but might be far less efficient everywhere else...)
KviKvsRWEvaluationResult * v = m_pIterationVariable->evaluateReadWrite(c);
if(!v)
return false;
KviKvsVariant * pOne = pArg->array()->at(idx);
if(pOne)
{
if(bIncludeEmptyScalars || (!pOne->isEmpty()))
{
v->result()->copyFrom(*pOne);
} else {
delete v; // we're done with it for this iteration
idx++;
continue;
}
} else {
if(bIncludeEmptyScalars)
{
v->result()->setNothing();
} else {
delete v; // we're done with it for this iteration
idx++;
continue;
}
}
delete v; // we're done with it for this iteration
if(!m_pLoop->execute(c))
{
if(c->error())
return false;
// break allowed!
if(c->breakPending())
{
c->handleBreak();
return true;
}
if(c->continuePending())
{
c->handleContinue();
idx++;
continue;
}
return false; // propagate the false return value
}
idx++;
}
}
break;
case KviKvsVariantData::Hash:
{
KviKvsHashIterator it(*(pArg->hash()->dict()));
while(KviKvsVariant * pOne = it.current())
{
// we evaluate this each time (as it may actually be killed at each iteration)
// FIXME: maybe some kind of reference counting or a observer pattern might be a bit more efficient here
// (but might be far less efficient everywhere else...)
KviKvsRWEvaluationResult * v = m_pIterationVariable->evaluateReadWrite(c);
if(!v)
return false;
if(bIncludeEmptyScalars || (!pOne->isEmpty()))
{
v->result()->copyFrom(*pOne);
} else {
delete v; // we're done with it for this iteration
++it;
//.........这里部分代码省略.........