Doxygen
TemplateNodeExtend类 参考

Class representing a 'extend' tag in a template 更多...

+ 类 TemplateNodeExtend 继承关系图:
+ TemplateNodeExtend 的协作图:

Public 成员函数

 TemplateNodeExtend (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
void render (TextStream &ts, TemplateContext *c)
 
- Public 成员函数 继承自 TemplateNodeCreator< TemplateNodeExtend >
 TemplateNodeCreator (TemplateParser *parser, TemplateNode *parent, int line)
 
TemplateImplgetTemplate ()
 
- Public 成员函数 继承自 TemplateNode
 TemplateNode (TemplateNode *parent)
 
virtual ~TemplateNode ()
 
TemplateNodeparent ()
 

Private 属性

ExprAstPtr m_extendExpr
 
TemplateNodeList m_nodes
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 TemplateNodeCreator< TemplateNodeExtend >
static TemplateNodePtr createInstance (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
- Protected 成员函数 继承自 TemplateNodeCreator< TemplateNodeExtend >
void mkpath (const TemplateContextImpl *ci, const std::string &fileName)
 
- Protected 属性 继承自 TemplateNodeCreator< TemplateNodeExtend >
QCString m_templateName
 
int m_line
 

详细描述

Class representing a 'extend' tag in a template

在文件 template.cpp3677 行定义.

构造及析构函数说明

◆ TemplateNodeExtend()

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

在文件 template.cpp3680 行定义.

3682  {
3683  TRACE(("{TemplateNodeExtend(%s)\n",qPrint(data)));
3684  ExpressionParser ep(parser,line);
3685  if (data.isEmpty())
3686  {
3687  parser->warn(m_templateName,line,"extend tag is missing template file argument");
3688  }
3689  m_extendExpr = ep.parse(data);
3690  StringVector stopAt;
3691  parser->parse(this,line,stopAt,m_nodes);
3692  TRACE(("}TemplateNodeExtend(%s)\n",qPrint(data)));
3693  }

引用了 QCString::isEmpty(), m_extendExpr, m_nodes, TemplateNodeCreator< TemplateNodeExtend >::m_templateName, TemplateParser::parse(), ExpressionParser::parse(), qPrint(), TRACE , 以及 TemplateParser::warn().

成员函数说明

◆ render()

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

实现了 TemplateNode.

在文件 template.cpp3695 行定义.

3696  {
3697  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3698  if (ci==0) return; // should not happen
3700  if (m_extendExpr==0) return;
3701 
3702  QCString extendFile = m_extendExpr->resolve(c).toString();
3703  if (extendFile.isEmpty())
3704  {
3705  ci->warn(m_templateName,m_line,"invalid parameter for extend command");
3706  }
3707 
3708  // goto root of tree (template node)
3709  TemplateImpl *t = getTemplate();
3710  if (t)
3711  {
3712  Template *bt = t->engine()->loadByName(extendFile,m_line);
3713  TemplateImpl *baseTemplate = bt ? dynamic_cast<TemplateImpl*>(bt) : 0;
3714  if (baseTemplate)
3715  {
3716  // fill block context
3717  TemplateBlockContext *bc = ci->blockContext();
3718 
3719  // add overruling blocks to the context
3720  for (const auto &n : m_nodes)
3721  {
3722  TemplateNodeBlock *nb = dynamic_cast<TemplateNodeBlock*>(n.get());
3723  if (nb)
3724  {
3725  bc->add(nb);
3726  }
3727  TemplateNodeMsg *msg = dynamic_cast<TemplateNodeMsg*>(n.get());
3728  if (msg)
3729  {
3730  msg->render(ts,c);
3731  }
3732  }
3733 
3734  // render the base template with the given context
3735  baseTemplate->render(ts,c);
3736 
3737  // clean up
3738  bc->clear();
3739  }
3740  else
3741  {
3742  ci->warn(m_templateName,m_line,"failed to load template %s for extend",qPrint(extendFile));
3743  }
3744  t->engine()->unload(bt);
3745  }
3746  }

引用了 TemplateBlockContext::add(), TemplateContextImpl::blockContext(), TemplateBlockContext::clear(), TemplateImpl::engine(), TemplateNodeCreator< TemplateNodeExtend >::getTemplate(), QCString::isEmpty(), TemplateEngine::loadByName(), m_extendExpr, TemplateNodeCreator< TemplateNodeExtend >::m_line, m_nodes, TemplateNodeCreator< TemplateNodeExtend >::m_templateName, msg(), qPrint(), TemplateImpl::render(), TemplateContextImpl::setLocation(), TemplateEngine::unload() , 以及 TemplateContextImpl::warn().

类成员变量说明

◆ m_extendExpr

ExprAstPtr TemplateNodeExtend::m_extendExpr
private

在文件 template.cpp3749 行定义.

被这些函数引用 render() , 以及 TemplateNodeExtend().

◆ m_nodes

TemplateNodeList TemplateNodeExtend::m_nodes
private

在文件 template.cpp3750 行定义.

被这些函数引用 render() , 以及 TemplateNodeExtend().


该类的文档由以下文件生成:
StringVector
std::vector< std::string > StringVector
Definition: containers.h:32
TemplateContextImpl::warn
void warn(const QCString &fileName, int line, const char *fmt,...) const
Definition: template.cpp:2773
TemplateNodeMsg
Class representing an 'markers' tag in a template
Definition: template.cpp:3562
TemplateContextImpl::setLocation
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:682
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
TemplateNodeBlock
Class representing a 'block' tag in a template
Definition: template.cpp:3600
TemplateNodeCreator< TemplateNodeExtend >
TemplateEngine::loadByName
Template * loadByName(const QCString &fileName, int fromLine)
Creates a new template whose contents are in a file.
Definition: template.cpp:5381
Template
Abstract interface for a template.
Definition: template.h:475
TemplateImpl::engine
TemplateEngine * engine() const
Definition: template.cpp:2562
TemplateImpl
Internal class representing the implementation of a template
Definition: template.cpp:2554
ExpressionParser
Recursive decent parser for Django style template expressions.
Definition: template.cpp:2010
TemplateBlockContext
Class holding stacks of blocks available in the context
Definition: template.cpp:614
TemplateParser::warn
void warn(const QCString &fileName, int line, const char *fmt,...) const
Definition: template.cpp:5163
TemplateNodeExtend::m_nodes
TemplateNodeList m_nodes
Definition: template.cpp:3750
TRACE
#define TRACE(x)
Definition: template.cpp:40
TemplateNodeCreator< TemplateNodeExtend >::getTemplate
TemplateImpl * getTemplate()
Definition: template.cpp:3051
TemplateNodeExtend::m_extendExpr
ExprAstPtr m_extendExpr
Definition: template.cpp:3749
TemplateNodeCreator< TemplateNodeExtend >::m_templateName
QCString m_templateName
Definition: template.cpp:3095
TemplateNode::parent
TemplateNode * parent()
Definition: template.cpp:1941
TemplateBlockContext::add
void add(TemplateNodeBlock *block)
Definition: template.cpp:4765
TemplateParser::parse
void parse(TemplateNode *parent, int line, const StringVector &stopAt, TemplateNodeList &nodes)
Definition: template.cpp:5057
msg
void msg(const char *fmt,...)
Definition: message.cpp:53
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
TemplateBlockContext::clear
void clear()
Definition: template.cpp:4786
TemplateContextImpl
Internal class representing the implementation of a template context
Definition: template.cpp:640
TemplateEngine::unload
void unload(Template *t)
Indicates that template t is no longer needed.
Definition: template.cpp:5386
TemplateNodeCreator< TemplateNodeExtend >::m_line
int m_line
Definition: template.cpp:3096
TemplateContextImpl::blockContext
TemplateBlockContext * blockContext()
Definition: template.cpp:2768
TemplateImpl::render
void render(TextStream &ts, TemplateContext *c)
Definition: template.cpp:5200
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108