Class representing a 'for' tag in a template.
Definition at line 3188 of file template.cpp.
Definition at line 3191 of file template.cpp.
References TemplateToken::data, m_emptyNodes, m_expr, m_loopNodes, m_reversed, TemplateNodeCreator< TemplateNodeFor >::m_templateName, m_vars, TemplateParser::parse(), ExpressionParser::parse(), TemplateParser::removeNextToken(), split(), TemplateParser::takeNextToken(), TRACE, and TemplateParser::warn().
{
TRACE((
"{TemplateNodeFor(%s)\n",data.data()));
QCString exprStr;
int i = data.find(" in ");
if (i==-1)
{
if (data.right(3)==" in")
{
parser->warn(
m_templateName,line,
"for is missing container after 'in' keyword");
}
else if (data=="in")
{
parser->warn(
m_templateName,line,
"for needs at least one iterator variable");
}
else
{
}
}
else
{
{
parser->warn(
m_templateName,line,
"for needs at least one iterator variable");
}
int j = data.find(" reversed",i);
if (j==-1) j=data.length();
if (j>i+4)
{
exprStr = data.mid(i+4,j-i-4);
}
if (exprStr.isEmpty())
{
parser->warn(
m_templateName,line,
"for is missing container after 'in' keyword");
}
}
m_expr = expParser.parse(exprStr);
QStrList stopAt;
stopAt.append("endfor");
stopAt.append("empty");
if (tok && tok->
data==
"empty")
{
stopAt.removeLast();
parser->removeNextToken();
}
delete tok;
TRACE((
"}TemplateNodeFor(%s)\n",data.data()));
}
Implements TemplateNode.
Definition at line 3256 of file template.cpp.
References TemplateStruct::alloc(), TemplateVariant::call(), TemplateListIntf::count(), TemplateListIntf::createIterator(), TemplateListIntf::ConstIterator::current(), TemplateVariant::Function, TemplateAutoRef< T >::get(), TemplateStructIntf::get(), TemplateContext::getRef(), m_emptyNodes, m_expr, TemplateNodeCreator< TemplateNodeFor >::m_line, m_loopNodes, m_reversed, TemplateNodeCreator< TemplateNodeFor >::m_templateName, m_vars, TemplateContext::pop(), TemplateContext::push(), TemplateNodeList::render(), ExprAst::resolve(), TemplateStruct::set(), TemplateContext::set(), TemplateContextImpl::setLocation(), TemplateVariant::Struct, TemplateListIntf::ConstIterator::toFirst(), TemplateListIntf::ConstIterator::toLast(), TemplateVariant::toList(), TemplateListIntf::ConstIterator::toNext(), TemplateListIntf::ConstIterator::toPrev(), TemplateVariant::toStruct(), TemplateVariant::type(), TemplateVariant::typeAsString(), and TemplateContextImpl::warn().
{
if (ci==0) return;
{
{
v = v.
call(QValueList<TemplateVariant>());
}
if (list)
{
uint listSize = list->
count();
if (listSize==0)
{
return;
}
{
s->set("counter0", (int)index);
s->set("counter", (int)(index+1));
s->set("revcounter", (int)(listSize-index));
s->set("revcounter0", (int)(listSize-index-1));
s->set("first",index==0);
s->set("last", index==listSize-1);
c->
set(
"forloop",s.get());
uint vi=0;
{
}
{
for (uint i=0;i<
m_vars.count();i++,vi++)
{
}
}
{
}
}
delete it;
}
else
{
}
}
}