Doxygen
TemplateNodeBlock类 参考

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

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

Public 成员函数

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

Private 属性

QCString m_blockName
 
TemplateNodeList m_nodes
 

额外继承的成员函数

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

详细描述

Class representing a 'block' tag in a template

在文件 template.cpp3600 行定义.

构造及析构函数说明

◆ TemplateNodeBlock()

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

在文件 template.cpp3603 行定义.

3605  {
3606  TRACE(("{TemplateNodeBlock(%s)\n",qPrint(data)));
3607  m_blockName = data;
3608  if (m_blockName.isEmpty())
3609  {
3610  parser->warn(parser->templateName(),line,"block tag without name");
3611  }
3612  StringVector stopAt = { "endblock" };
3613  parser->parse(this,line,stopAt,m_nodes);
3614  parser->removeNextToken(); // skip over endblock
3615  TRACE(("}TemplateNodeBlock(%s)\n",qPrint(data)));
3616  }

引用了 QCString::isEmpty(), m_blockName, m_nodes, TemplateParser::parse(), qPrint(), TemplateParser::removeNextToken(), TemplateParser::templateName(), TRACE , 以及 TemplateParser::warn().

成员函数说明

◆ name()

QCString TemplateNodeBlock::name ( ) const
inline

在文件 template.cpp3664 行定义.

3665  {
3666  return m_blockName;
3667  }

引用了 m_blockName.

被这些函数引用 TemplateBlockContext::add() , 以及 TemplateBlockContext::push().

◆ render()

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

实现了 TemplateNode.

在文件 template.cpp3618 行定义.

3619  {
3620  TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
3621  if (ci==0) return; // should not happen
3623  TemplateImpl *t = getTemplate();
3624  if (t)
3625  {
3626  // remove block from the context, so block.super can work
3628  if (nb) // block is overruled
3629  {
3630  ci->push();
3631  TextStream ss;
3632  // get super block of block nb
3634  if (sb && sb!=nb && sb!=this) // nb and sb both overrule this block
3635  {
3636  sb->render(ss,c); // render parent of nb to string
3637  }
3638  else if (nb!=this) // only nb overrules this block
3639  {
3640  m_nodes.render(ss,c); // render parent of nb to string
3641  }
3642  QCString super = ss.str();
3643  // add 'block.super' variable to allow access to parent block content
3645  superBlock->set("super",TemplateVariant(super.data(),TRUE));
3646  ci->set("block",std::static_pointer_cast<TemplateStructIntf>(superBlock));
3647  // render the overruled block contents
3648  t->engine()->enterBlock(nb->m_templateName,nb->m_blockName,nb->m_line);
3649  nb->m_nodes.render(ts,c);
3650  t->engine()->leaveBlock();
3651  ci->pop();
3652  // re-add block to the context
3653  ci->blockContext()->push(nb);
3654  }
3655  else // block has no overrule
3656  {
3658  m_nodes.render(ts,c);
3659  t->engine()->leaveBlock();
3660  }
3661  }
3662  }

引用了 TemplateStruct::alloc(), TemplateContextImpl::blockContext(), QCString::data(), TemplateImpl::engine(), TemplateEngine::enterBlock(), TemplateBlockContext::get(), TemplateNodeCreator< TemplateNodeBlock >::getTemplate(), TemplateEngine::leaveBlock(), m_blockName, TemplateNodeCreator< T >::m_line, TemplateNodeCreator< TemplateNodeBlock >::m_line, m_nodes, TemplateNodeCreator< T >::m_templateName, TemplateNodeCreator< TemplateNodeBlock >::m_templateName, TemplateBlockContext::pop(), TemplateContextImpl::pop(), TemplateBlockContext::push(), TemplateContextImpl::push(), TemplateNodeList::render(), render(), TemplateContextImpl::set(), TemplateContextImpl::setLocation(), TextStream::str() , 以及 TRUE.

被这些函数引用 render().

类成员变量说明

◆ m_blockName

QCString TemplateNodeBlock::m_blockName
private

在文件 template.cpp3670 行定义.

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

◆ m_nodes

TemplateNodeList TemplateNodeBlock::m_nodes
private

在文件 template.cpp3671 行定义.

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


该类的文档由以下文件生成:
StringVector
std::vector< std::string > StringVector
Definition: containers.h:32
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
TemplateBlockContext::push
void push(TemplateNodeBlock *block)
Definition: template.cpp:4791
TemplateNodeCreator< TemplateNodeBlock >
TemplateParser::templateName
QCString templateName() const
Definition: template.cpp:1998
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
TemplateImpl::engine
TemplateEngine * engine() const
Definition: template.cpp:2562
TemplateNodeBlock::m_nodes
TemplateNodeList m_nodes
Definition: template.cpp:3671
TemplateImpl
Internal class representing the implementation of a template
Definition: template.cpp:2554
TemplateParser::removeNextToken
void removeNextToken()
Definition: template.cpp:5153
TemplateNodeBlock::render
void render(TextStream &ts, TemplateContext *c)
Definition: template.cpp:3618
TemplateParser::warn
void warn(const QCString &fileName, int line, const char *fmt,...) const
Definition: template.cpp:5163
TemplateVariant
Variant type which can hold one value of a fixed set of types.
Definition: template.h:98
TRACE
#define TRACE(x)
Definition: template.cpp:40
TRUE
#define TRUE
Definition: qcstring.h:36
TemplateContextImpl::push
void push()
Push a new scope on the stack.
Definition: template.cpp:2749
TemplateNodeCreator< TemplateNodeBlock >::getTemplate
TemplateImpl * getTemplate()
Definition: template.cpp:3051
TextStream::str
std::string str() const
Return the contents of the buffer as a std::string object
Definition: textstream.h:208
TemplateNodeList::render
void render(TextStream &ts, TemplateContext *c)
Definition: template.cpp:1971
TemplateNodeCreator< TemplateNodeBlock >::m_templateName
QCString m_templateName
Definition: template.cpp:3095
TemplateNode::parent
TemplateNode * parent()
Definition: template.cpp:1941
TemplateParser::parse
void parse(TemplateNode *parent, int line, const StringVector &stopAt, TemplateNodeList &nodes)
Definition: template.cpp:5057
TemplateBlockContext::get
TemplateNodeBlock * get(const QCString &name) const
Definition: template.cpp:4737
TemplateContextImpl::set
void set(const QCString &name, const TemplateVariant &v)
Sets a value in the current scope.
Definition: template.cpp:2632
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
TemplateBlockContext::pop
TemplateNodeBlock * pop(const QCString &name)
Definition: template.cpp:4750
TemplateContextImpl::pop
void pop()
Pop the current scope from the stack.
Definition: template.cpp:2755
QCString::data
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Definition: qcstring.h:153
TemplateEngine::enterBlock
void enterBlock(const QCString &fileName, const QCString &blockName, int line)
Definition: template.cpp:5391
TemplateContextImpl
Internal class representing the implementation of a template context
Definition: template.cpp:640
TemplateNodeCreator< TemplateNodeBlock >::m_line
int m_line
Definition: template.cpp:3096
TemplateContextImpl::blockContext
TemplateBlockContext * blockContext()
Definition: template.cpp:2768
TemplateEngine::leaveBlock
void leaveBlock()
Definition: template.cpp:5396
TemplateStructPtr
std::shared_ptr< TemplateStruct > TemplateStructPtr
Definition: template.cpp:147
TemplateStruct::alloc
static TemplateStructPtr alloc()
Creates an instance and returns a shared pointer to it
Definition: template.cpp:218
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108
TemplateNodeBlock::m_blockName
QCString m_blockName
Definition: template.cpp:3670