My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
TemplateNodeRepeat Class Reference

Class representing a 'for' tag in a template. More...

Inheritance diagram for TemplateNodeRepeat:
TemplateNodeCreator< TemplateNodeRepeat > TemplateNode

Public Member Functions

 TemplateNodeRepeat (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
 ~TemplateNodeRepeat ()
 
void render (FTextStream &ts, TemplateContext *c)
 
- Public Member Functions inherited from TemplateNodeCreator< TemplateNodeRepeat >
 TemplateNodeCreator (TemplateParser *parser, TemplateNode *parent, int line)
 
TemplateImplgetTemplate ()
 
- Public Member Functions inherited from TemplateNode
 TemplateNode (TemplateNode *parent)
 
virtual ~TemplateNode ()
 
TemplateNodeparent ()
 

Private Attributes

TemplateNodeList m_repeatNodes
 
ExprAstm_expr
 

Additional Inherited Members

- Static Public Member Functions inherited from TemplateNodeCreator< TemplateNodeRepeat >
static TemplateNodecreateInstance (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
- Protected Member Functions inherited from TemplateNodeCreator< TemplateNodeRepeat >
void mkpath (TemplateContextImpl *ci, const QCString &fileName)
 
- Protected Attributes inherited from TemplateNodeCreator< TemplateNodeRepeat >
QCString m_templateName
 
int m_line
 

Detailed Description

Class representing a 'for' tag in a template.

Definition at line 2963 of file template.cpp.

Constructor & Destructor Documentation

TemplateNodeRepeat::TemplateNodeRepeat ( TemplateParser parser,
TemplateNode parent,
int  line,
const QCString &  data 
)
inline

Definition at line 2966 of file template.cpp.

References m_expr, m_repeatNodes, TemplateParser::parse(), ExpressionParser::parse(), TemplateParser::removeNextToken(), and TRACE.

{
TRACE(("{TemplateNodeRepeat(%s)\n",data.data()));
ExpressionParser expParser(parser,line);
m_expr = expParser.parse(data);
QStrList stopAt;
stopAt.append("endrepeat");
parser->parse(this,line,stopAt,m_repeatNodes);
parser->removeNextToken(); // skip over endrepeat
TRACE(("}TemplateNodeRepeat(%s)\n",data.data()));
}
TemplateNodeRepeat::~TemplateNodeRepeat ( )
inline

Definition at line 2978 of file template.cpp.

References m_expr.

{
delete m_expr;
}

Member Function Documentation

void TemplateNodeRepeat::render ( FTextStream ts,
TemplateContext c 
)
inlinevirtual

Implements TemplateNode.

Definition at line 2982 of file template.cpp.

References TemplateStruct::alloc(), TemplateAutoRef< T >::get(), TemplateVariant::Integer, m_expr, TemplateNodeCreator< TemplateNodeRepeat >::m_line, m_repeatNodes, TemplateNodeCreator< TemplateNodeRepeat >::m_templateName, TemplateNodeList::render(), ExprAst::resolve(), TemplateStruct::set(), TemplateContext::set(), TemplateContextImpl::setLocation(), TemplateVariant::toInt(), and TemplateContextImpl::warn().

{
TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return; // should not happen
{
int i, n = v.toInt();
for (i=0;i<n;i++)
{
s->set("counter0", (int)i);
s->set("counter", (int)(i+1));
s->set("revcounter", (int)(n-i));
s->set("revcounter0", (int)(n-i-1));
s->set("first",i==0);
s->set("last", i==n-1);
c->set("repeatloop",s.get());
// render all items for this iteration of the loop
}
}
else // simple type...
{
ci->warn(m_templateName,m_line,"for requires a variable of list type!");
}
}

Member Data Documentation

ExprAst* TemplateNodeRepeat::m_expr
private

Definition at line 3012 of file template.cpp.

Referenced by render(), TemplateNodeRepeat(), and ~TemplateNodeRepeat().

TemplateNodeList TemplateNodeRepeat::m_repeatNodes
private

Definition at line 3011 of file template.cpp.

Referenced by render(), and TemplateNodeRepeat().


The documentation for this class was generated from the following file: