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

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

Inheritance diagram for TemplateNodeExtend:
TemplateNodeCreator< TemplateNodeExtend > TemplateNode

Public Member Functions

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

Private Attributes

ExprAstm_extendExpr
 
TemplateNodeList m_nodes
 

Additional Inherited Members

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

Detailed Description

Class representing a 'extend' tag in a template.

Definition at line 3319 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 3322 of file template.cpp.

3324  {
3325  TRACE(("{TemplateNodeExtend(%s)\n",data.data()));
3326  ExpressionParser ep(parser,line);
3327  if (data.isEmpty())
3328  {
3329  parser->warn(m_templateName,line,"extend tag is missing template file argument");
3330  }
3331  m_extendExpr = ep.parse(data);
3332  QStrList stopAt;
3333  parser->parse(this,line,stopAt,m_nodes);
3334  TRACE(("}TemplateNodeExtend(%s)\n",data.data()));
3335  }
bool isEmpty() const
Definition: qcstring.h:189
ExprAst * m_extendExpr
Definition: template.cpp:3397
TemplateNode * parent()
Definition: template.cpp:1647
const char * data() const
Definition: qcstring.h:207
TemplateNodeList m_nodes
Definition: template.cpp:3398
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
TemplateNodeExtend::~TemplateNodeExtend ( )
inline

Definition at line 3336 of file template.cpp.

3337  {
3338  delete m_extendExpr;
3339  }
ExprAst * m_extendExpr
Definition: template.cpp:3397

Member Function Documentation

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

Implements TemplateNode.

Definition at line 3341 of file template.cpp.

3342  {
3343  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3344  if (ci==0) return; // should not happen
3346  if (m_extendExpr==0) return;
3347 
3348  QCString extendFile = m_extendExpr->resolve(c).toString();
3349  if (extendFile.isEmpty())
3350  {
3351  ci->warn(m_templateName,m_line,"invalid parameter for extend command");
3352  }
3353 
3354  // goto root of tree (template node)
3355  TemplateImpl *t = getTemplate();
3356  if (t)
3357  {
3358  Template *bt = t->engine()->loadByName(extendFile,m_line);
3359  TemplateImpl *baseTemplate = bt ? dynamic_cast<TemplateImpl*>(bt) : 0;
3360  if (baseTemplate)
3361  {
3362  // fill block context
3363  TemplateBlockContext *bc = ci->blockContext();
3364 
3365  // add overruling blocks to the context
3367  TemplateNode *n;
3368  for (li.toFirst();(n=li.current());++li)
3369  {
3370  TemplateNodeBlock *nb = dynamic_cast<TemplateNodeBlock*>(n);
3371  if (nb)
3372  {
3373  bc->add(nb);
3374  }
3375  TemplateNodeMsg *msg = dynamic_cast<TemplateNodeMsg*>(n);
3376  if (msg)
3377  {
3378  msg->render(ts,c);
3379  }
3380  }
3381 
3382  // render the base template with the given context
3383  baseTemplate->render(ts,c);
3384 
3385  // clean up
3386  bc->clear();
3387  t->engine()->unload(t);
3388  }
3389  else
3390  {
3391  ci->warn(m_templateName,m_line,"failed to load template %s for extend",extendFile.data());
3392  }
3393  }
3394  }
static constexpr double nb
Definition: Units.h:81
Abstract interface for a template.
Definition: template.h:542
bool isEmpty() const
Definition: qcstring.h:189
void msg(const char *fmt,...)
Definition: message.cpp:107
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
ExprAst * m_extendExpr
Definition: template.cpp:3397
Class representing a &#39;block&#39; tag in a template.
Definition: template.cpp:3241
void render(FTextStream &ts, TemplateContext *c)
Definition: template.cpp:4809
QCString toString() const
Definition: template.h:232
bt
Definition: tracks.py:83
virtual TemplateVariant resolve(TemplateContext *)
Definition: template.cpp:1368
std::void_t< T > n
void unload(Template *t)
Definition: template.cpp:4976
const char * data() const
Definition: qcstring.h:207
TemplateBlockContext * blockContext()
Definition: template.cpp:2426
Class holding stacks of blocks available in the context.
Definition: template.cpp:486
TemplateEngine * engine() const
Definition: template.cpp:2270
void render(FTextStream &, TemplateContext *c)
Definition: template.cpp:3218
void add(TemplateNodeBlock *block)
Definition: template.cpp:4369
TemplateNodeList m_nodes
Definition: template.cpp:3398
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
Base class of all nodes in a template&#39;s AST.
Definition: template.cpp:1639
Class representing an &#39;markers&#39; tag in a template.
Definition: template.cpp:3205
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540

Member Data Documentation

ExprAst* TemplateNodeExtend::m_extendExpr
private

Definition at line 3397 of file template.cpp.

TemplateNodeList TemplateNodeExtend::m_nodes
private

Definition at line 3398 of file template.cpp.


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