Public Member Functions | Private Attributes | List of all members
TemplateNodeInclude Class Reference

Class representing an 'include' tag in a template. More...

Inheritance diagram for TemplateNodeInclude:
TemplateNodeCreator< TemplateNodeInclude > TemplateNode

Public Member Functions

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

Private Attributes

ExprAstm_includeExpr
 

Additional Inherited Members

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

Detailed Description

Class representing an 'include' tag in a template.

Definition at line 3402 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 3405 of file template.cpp.

3407  {
3408  TRACE(("TemplateNodeInclude(%s)\n",data.data()));
3409  ExpressionParser ep(parser,line);
3410  if (data.isEmpty())
3411  {
3412  parser->warn(m_templateName,line,"include tag is missing template file argument");
3413  }
3414  m_includeExpr = ep.parse(data);
3415  }
bool isEmpty() const
Definition: qcstring.h:189
ExprAst * m_includeExpr
Definition: template.cpp:3454
TemplateNode * parent()
Definition: template.cpp:1647
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
TemplateNodeInclude::~TemplateNodeInclude ( )
inline

Definition at line 3416 of file template.cpp.

3417  {
3418  delete m_includeExpr;
3419  }
ExprAst * m_includeExpr
Definition: template.cpp:3454

Member Function Documentation

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

Implements TemplateNode.

Definition at line 3420 of file template.cpp.

3421  {
3422  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3423  if (ci==0) return; // should not happen
3425  if (m_includeExpr)
3426  {
3427  QCString includeFile = m_includeExpr->resolve(c).toString();
3428  if (includeFile.isEmpty())
3429  {
3430  ci->warn(m_templateName,m_line,"invalid parameter for include command\n");
3431  }
3432  else
3433  {
3434  TemplateImpl *t = getTemplate();
3435  if (t)
3436  {
3437  Template *it = t->engine()->loadByName(includeFile,m_line);
3438  TemplateImpl *incTemplate = it ? dynamic_cast<TemplateImpl*>(it) : 0;
3439  if (incTemplate)
3440  {
3441  incTemplate->render(ts,c);
3442  t->engine()->unload(t);
3443  }
3444  else
3445  {
3446  ci->warn(m_templateName,m_line,"failed to load template '%s' for include",includeFile.data()?includeFile.data():"");
3447  }
3448  }
3449  }
3450  }
3451  }
Abstract interface for a template.
Definition: template.h:542
bool isEmpty() const
Definition: qcstring.h:189
Internal class representing the implementation of a template.
Definition: template.cpp:2262
Internal class representing the implementation of a template context.
Definition: template.cpp:511
void render(FTextStream &ts, TemplateContext *c)
Definition: template.cpp:4809
ExprAst * m_includeExpr
Definition: template.cpp:3454
QCString toString() const
Definition: template.h:232
virtual TemplateVariant resolve(TemplateContext *)
Definition: template.cpp:1368
void unload(Template *t)
Definition: template.cpp:4976
const char * data() const
Definition: qcstring.h:207
TemplateEngine * engine() const
Definition: template.cpp:2270
Template * loadByName(const QCString &fileName, int fromLine)
Definition: template.cpp:4971
void warn(const char *fileName, int line, const char *fmt,...) const
Definition: template.cpp:2431
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540

Member Data Documentation

ExprAst* TemplateNodeInclude::m_includeExpr
private

Definition at line 3454 of file template.cpp.


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