My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 3459 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 3462 of file template.cpp.

References m_extendExpr, m_nodes, TemplateNodeCreator< TemplateNodeExtend >::m_templateName, TemplateParser::parse(), ExpressionParser::parse(), TRACE, and TemplateParser::warn().

{
TRACE(("{TemplateNodeExtend(%s)\n",data.data()));
ExpressionParser ep(parser,line);
if (data.isEmpty())
{
parser->warn(m_templateName,line,"extend tag is missing template file argument");
}
m_extendExpr = ep.parse(data);
QStrList stopAt;
parser->parse(this,line,stopAt,m_nodes);
TRACE(("}TemplateNodeExtend(%s)\n",data.data()));
}
TemplateNodeExtend::~TemplateNodeExtend ( )
inline

Definition at line 3476 of file template.cpp.

References m_extendExpr.

{
delete m_extendExpr;
}

Member Function Documentation

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

Implements TemplateNode.

Definition at line 3481 of file template.cpp.

References TemplateBlockContext::add(), TemplateContextImpl::blockContext(), TemplateBlockContext::clear(), TemplateImpl::engine(), TemplateNodeCreator< TemplateNodeExtend >::getTemplate(), TemplateEngine::loadByName(), m_extendExpr, TemplateNodeCreator< TemplateNodeExtend >::m_line, m_nodes, TemplateNodeCreator< TemplateNodeExtend >::m_templateName, msg(), TemplateImpl::render(), TemplateNodeMsg::render(), ExprAst::resolve(), TemplateContextImpl::setLocation(), TemplateVariant::toString(), TemplateEngine::unload(), and TemplateContextImpl::warn().

{
TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return; // should not happen
if (m_extendExpr==0) return;
QCString extendFile = m_extendExpr->resolve(c).toString();
if (extendFile.isEmpty())
{
ci->warn(m_templateName,m_line,"invalid parameter for extend command");
}
// goto root of tree (template node)
if (t)
{
Template *bt = t->engine()->loadByName(extendFile,m_line);
TemplateImpl *baseTemplate = bt ? dynamic_cast<TemplateImpl*>(bt) : 0;
if (baseTemplate)
{
// fill block context
// add overruling blocks to the context
QListIterator<TemplateNode> li(m_nodes);
for (li.toFirst();(n=li.current());++li)
{
TemplateNodeBlock *nb = dynamic_cast<TemplateNodeBlock*>(n);
if (nb)
{
bc->add(nb);
}
TemplateNodeMsg *msg = dynamic_cast<TemplateNodeMsg*>(n);
if (msg)
{
msg->render(ts,c);
}
}
// render the base template with the given context
baseTemplate->render(ts,c);
// clean up
bc->clear();
t->engine()->unload(t);
}
else
{
ci->warn(m_templateName,m_line,"failed to load template %s for extend",extendFile.data());
}
}
}

Member Data Documentation

ExprAst* TemplateNodeExtend::m_extendExpr
private

Definition at line 3537 of file template.cpp.

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

TemplateNodeList TemplateNodeExtend::m_nodes
private

Definition at line 3538 of file template.cpp.

Referenced by render(), and TemplateNodeExtend().


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