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

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

Inheritance diagram for TemplateNodeBlock:
TemplateNodeCreator< TemplateNodeBlock > TemplateNode

Public Member Functions

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

Private Attributes

QCString m_blockName
 
TemplateNodeList m_nodes
 

Additional Inherited Members

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

Detailed Description

Class representing a 'block' tag in a template.

Definition at line 3241 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 3244 of file template.cpp.

3246  {
3247  TRACE(("{TemplateNodeBlock(%s)\n",data.data()));
3248  m_blockName = data;
3249  if (m_blockName.isEmpty())
3250  {
3251  parser->warn(parser->templateName(),line,"block tag without name");
3252  }
3253  QStrList stopAt;
3254  stopAt.append("endblock");
3255  parser->parse(this,line,stopAt,m_nodes);
3256  parser->removeNextToken(); // skip over endblock
3257  TRACE(("}TemplateNodeBlock(%s)\n",data.data()));
3258  }
bool isEmpty() const
Definition: qcstring.h:189
QCString m_blockName
Definition: template.cpp:3312
TemplateNode * parent()
Definition: template.cpp:1647
TemplateNodeList m_nodes
Definition: template.cpp:3313
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)
#define TRACE(x)
Definition: template.cpp:43

Member Function Documentation

QCString TemplateNodeBlock::name ( ) const
inline

Definition at line 3306 of file template.cpp.

3307  {
3308  return m_blockName;
3309  }
QCString m_blockName
Definition: template.cpp:3312
void TemplateNodeBlock::render ( FTextStream ts,
TemplateContext c 
)
inlinevirtual

Implements TemplateNode.

Definition at line 3260 of file template.cpp.

3261  {
3262  TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
3263  if (ci==0) return; // should not happen
3265  TemplateImpl *t = getTemplate();
3266  if (t)
3267  {
3268  // remove block from the context, so block.super can work
3270  if (nb) // block is overruled
3271  {
3272  ci->push();
3273  QGString super;
3274  FTextStream ss(&super);
3275  // get super block of block nb
3277  if (sb && sb!=nb && sb!=this) // nb and sb both overrule this block
3278  {
3279  sb->render(ss,c); // render parent of nb to string
3280  }
3281  else if (nb!=this) // only nb overrules this block
3282  {
3283  m_nodes.render(ss,c); // render parent of nb to string
3284  }
3285  // add 'block.super' variable to allow access to parent block content
3287  superBlock->set("super",TemplateVariant(super.data(),TRUE));
3288  ci->set("block",superBlock.get());
3289  // render the overruled block contents
3290  t->engine()->enterBlock(nb->m_templateName,nb->m_blockName,nb->m_line);
3291  nb->m_nodes.render(ts,c);
3292  t->engine()->leaveBlock();
3293  ci->pop();
3294  // re-add block to the context
3295  ci->blockContext()->push(nb);
3296  }
3297  else // block has no overrule
3298  {
3300  m_nodes.render(ts,c);
3301  t->engine()->leaveBlock();
3302  }
3303  }
3304  }
void render(FTextStream &ts, TemplateContext *c)
Definition: template.cpp:2246
char * data() const
Definition: qgstring.h:42
static constexpr double nb
Definition: Units.h:81
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 enterBlock(const QCString &fileName, const QCString &blockName, int line)
Definition: template.cpp:4981
QCString m_blockName
Definition: template.cpp:3312
TemplateNodeBlock * get(const QCString &name) const
Definition: template.cpp:4343
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
Class representing a &#39;block&#39; tag in a template.
Definition: template.cpp:3241
void set(const char *name, const TemplateVariant &v)
Definition: template.cpp:2315
TemplateNodeBlock * pop(const QCString &name) const
Definition: template.cpp:4356
TemplateNodeList m_nodes
Definition: template.cpp:3313
TemplateBlockContext * blockContext()
Definition: template.cpp:2426
TemplateEngine * engine() const
Definition: template.cpp:2270
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
void leaveBlock()
Definition: template.cpp:4986
void push(TemplateNodeBlock *block)
Definition: template.cpp:4400
void render(FTextStream &ts, TemplateContext *c)
Definition: template.cpp:3260
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540
const bool TRUE
Definition: qglobal.h:371
static TemplateStruct * alloc()
Definition: template.cpp:294

Member Data Documentation

QCString TemplateNodeBlock::m_blockName
private

Definition at line 3312 of file template.cpp.

TemplateNodeList TemplateNodeBlock::m_nodes
private

Definition at line 3313 of file template.cpp.


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