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 2823 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 2826 of file template.cpp.

2828  {
2829  TRACE(("{TemplateNodeRepeat(%s)\n",data.data()));
2830  ExpressionParser expParser(parser,line);
2831  m_expr = expParser.parse(data);
2832  QStrList stopAt;
2833  stopAt.append("endrepeat");
2834  parser->parse(this,line,stopAt,m_repeatNodes);
2835  parser->removeNextToken(); // skip over endrepeat
2836  TRACE(("}TemplateNodeRepeat(%s)\n",data.data()));
2837  }
TemplateNode * parent()
Definition: template.cpp:1647
TemplateNodeList m_repeatNodes
Definition: template.cpp:2871
void append(const type *d)
Definition: qinternallist.h:61
const char * data() const
Definition: qcstring.h:207
void line(double t, double *p, double &x, double &y, double &z)
Recursive decent parser for Django style template expressions.
Definition: template.cpp:1680
#define TRACE(x)
Definition: template.cpp:43
TemplateNodeRepeat::~TemplateNodeRepeat ( )
inline

Definition at line 2838 of file template.cpp.

2839  {
2840  delete m_expr;
2841  }

Member Function Documentation

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

Implements TemplateNode.

Definition at line 2842 of file template.cpp.

2843  {
2844  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
2845  if (ci==0) return; // should not happen
2847  TemplateVariant v;
2849  {
2850  int i, n = v.toInt();
2851  for (i=0;i<n;i++)
2852  {
2854  s->set("counter0", (int)i);
2855  s->set("counter", (int)(i+1));
2856  s->set("revcounter", (int)(n-i));
2857  s->set("revcounter0", (int)(n-i-1));
2858  s->set("first",i==0);
2859  s->set("last", i==n-1);
2860  c->set("repeatloop",s.get());
2861  // render all items for this iteration of the loop
2862  m_repeatNodes.render(ts,c);
2863  }
2864  }
2865  else // simple type...
2866  {
2867  ci->warn(m_templateName,m_line,"for requires a variable of list type!");
2868  }
2869  }
void render(FTextStream &ts, TemplateContext *c)
Definition: template.cpp:2246
Internal class representing the implementation of a template context.
Definition: template.cpp:511
int toInt() const
Definition: template.cpp:222
virtual void set(const char *name, const TemplateVariant &v)=0
virtual TemplateVariant resolve(TemplateContext *)
Definition: template.cpp:1368
std::void_t< T > n
TemplateNodeList m_repeatNodes
Definition: template.cpp:2871
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
void warn(const char *fileName, int line, const char *fmt,...) const
Definition: template.cpp:2431
static QCString type
Definition: declinfo.cpp:672
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540
static QCString * s
Definition: config.cpp:1042
static TemplateStruct * alloc()
Definition: template.cpp:294

Member Data Documentation

ExprAst* TemplateNodeRepeat::m_expr
private

Definition at line 2872 of file template.cpp.

TemplateNodeList TemplateNodeRepeat::m_repeatNodes
private

Definition at line 2871 of file template.cpp.


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