Doxygen
TemplateNodeTree类 参考

Class representing an 'tree' tag in a template 更多...

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

struct  TreeContext
 

Public 成员函数

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

Private 属性

ExprAstPtr m_treeExpr
 
TemplateNodeList m_treeNodes
 

额外继承的成员函数

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

详细描述

Class representing an 'tree' tag in a template

在文件 template.cpp3935 行定义.

构造及析构函数说明

◆ TemplateNodeTree()

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

在文件 template.cpp3946 行定义.

3948  {
3949  TRACE(("{TemplateNodeTree(%s)\n",qPrint(data)));
3950  ExpressionParser ep(parser,line);
3951  if (data.isEmpty())
3952  {
3953  parser->warn(m_templateName,line,"recursetree tag is missing data argument");
3954  }
3955  m_treeExpr = ep.parse(data);
3956  StringVector stopAt = { "endrecursetree" };
3957  parser->parse(this,line,stopAt,m_treeNodes);
3958  parser->removeNextToken(); // skip over endrecursetree
3959  TRACE(("}TemplateNodeTree(%s)\n",qPrint(data)));
3960  }

引用了 QCString::isEmpty(), TemplateNodeCreator< TemplateNodeTree >::m_templateName, m_treeExpr, m_treeNodes, TemplateParser::parse(), ExpressionParser::parse(), qPrint(), TemplateParser::removeNextToken(), TRACE , 以及 TemplateParser::warn().

成员函数说明

◆ render()

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

实现了 TemplateNode.

在文件 template.cpp4014 行定义.

4015  {
4016  //printf("TemplateNodeTree::render()\n");
4017  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
4018  if (ci==0) return; // should not happen
4020  TemplateVariant v = m_treeExpr->resolve(c);
4021  const TemplateListIntfPtr list = v.toList();
4022  if (list)
4023  {
4024  TreeContext ctx(this,list,c);
4025  ts << renderChildren(&ctx);
4026  }
4027  else
4028  {
4029  ci->warn(m_templateName,m_line,"recursetree's argument should be a list type");
4030  }
4031  }

引用了 TemplateNodeCreator< TemplateNodeTree >::m_line, TemplateNodeCreator< TemplateNodeTree >::m_templateName, m_treeExpr, renderChildren(), TemplateContextImpl::setLocation(), TemplateVariant::toList() , 以及 TemplateContextImpl::warn().

◆ renderChildren()

QCString TemplateNodeTree::renderChildren ( const TreeContext ctx)
inline

在文件 template.cpp3961 行定义.

3962  {
3963  //printf("TemplateNodeTree::renderChildren(%d)\n",ctx->list->count());
3964  // render all children of node to a string and return it
3965  TemplateContext *c = ctx->templateCtx;
3966  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3967  if (ci==0) return QCString(); // should not happen
3968  TextStream ss;
3969  c->push();
3970  TemplateVariant node;
3971  TemplateListIntf::ConstIteratorPtr it = ctx->list->createIterator();
3972  for (it->toFirst();(it->current(node));it->toNext())
3973  {
3974  c->set("node",node);
3975  bool hasChildren=FALSE;
3976  const TemplateStructIntfPtr ns = node.toStruct();
3977  if (ns) // node is a struct
3978  {
3979  TemplateVariant v = ns->get("children");
3980  if (v.isValid()) // with a field 'children'
3981  {
3982  const TemplateListIntfPtr list = v.toList();
3983  if (list && list->count()>0) // non-empty list
3984  {
3985  TreeContext childCtx(this,list,ctx->templateCtx);
3986  TemplateVariant children(
3987  [childCtx](const TemplateVariantList &) {
3988  return TemplateVariant(childCtx.object->renderChildren(&childCtx),TRUE);
3989  });
3990  children.setRaw(TRUE);
3991  c->set("children",children);
3992  m_treeNodes.render(ss,c);
3993  hasChildren=TRUE;
3994  }
3995  else if (list==0)
3996  {
3997  ci->warn(m_templateName,m_line,"recursetree: children attribute has type '%s' instead of list\n",qPrint(v.typeAsString()));
3998  }
3999  }
4000  //else
4001  //{
4002  // ci->warn(m_templateName,m_line,"recursetree: children attribute is not valid");
4003  //}
4004  }
4005  if (!hasChildren)
4006  {
4007  c->set("children",TemplateVariant("")); // provide default
4008  m_treeNodes.render(ss,c);
4009  }
4010  }
4011  c->pop();
4012  return ss.str();
4013  }

引用了 FALSE, TemplateVariant::isValid(), TemplateNodeTree::TreeContext::list, TemplateNodeCreator< TemplateNodeTree >::m_line, TemplateNodeCreator< TemplateNodeTree >::m_templateName, m_treeNodes, TemplateNodeTree::TreeContext::object, TemplateContext::pop(), TemplateContext::push(), qPrint(), TemplateNodeList::render(), renderChildren(), TemplateContext::set(), TemplateVariant::setRaw(), TextStream::str(), TemplateNodeTree::TreeContext::templateCtx, TemplateVariant::toList(), TemplateVariant::toStruct(), TRUE, TemplateVariant::typeAsString() , 以及 TemplateContextImpl::warn().

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

类成员变量说明

◆ m_treeExpr

ExprAstPtr TemplateNodeTree::m_treeExpr
private

在文件 template.cpp4034 行定义.

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

◆ m_treeNodes

TemplateNodeList TemplateNodeTree::m_treeNodes
private

在文件 template.cpp4035 行定义.

被这些函数引用 renderChildren() , 以及 TemplateNodeTree().


该类的文档由以下文件生成:
TemplateVariant::toStruct
TemplateStructIntfPtr toStruct()
Returns the pointer to struct referenced by this variant or 0 if this variant does not have struct ty...
Definition: template.cpp:441
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
TemplateVariantList
std::vector< TemplateVariant > TemplateVariantList
Definition: template.h:261
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
TemplateNodeCreator< TemplateNodeTree >
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
TemplateStructIntfPtr
std::shared_ptr< TemplateStructIntf > TemplateStructIntfPtr
Definition: template.h:33
TemplateListIntf::ConstIteratorPtr
std::unique_ptr< ConstIterator > ConstIteratorPtr
Definition: template.h:292
ExpressionParser
Recursive decent parser for Django style template expressions.
Definition: template.cpp:2010
TemplateParser::removeNextToken
void removeNextToken()
Definition: template.cpp:5153
TemplateNodeTree::m_treeNodes
TemplateNodeList m_treeNodes
Definition: template.cpp:4035
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
TemplateContext::set
virtual void set(const QCString &name, const TemplateVariant &v)=0
Sets a value in the current scope.
TRUE
#define TRUE
Definition: qcstring.h:36
TemplateContext
Abstract interface for a template context.
Definition: template.h:422
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< TemplateNodeTree >::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
TemplateListIntfPtr
std::shared_ptr< TemplateListIntf > TemplateListIntfPtr
Definition: template.h:32
TemplateNodeTree::renderChildren
QCString renderChildren(const TreeContext *ctx)
Definition: template.cpp:3961
TemplateNodeTree::m_treeExpr
ExprAstPtr m_treeExpr
Definition: template.cpp:4034
TemplateVariant::isValid
constexpr bool isValid() const
Returns TRUE if the variant holds a valid value, or FALSE otherwise
Definition: template.h:203
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
TemplateVariant::typeAsString
const char * typeAsString() const
Returns a string representation of this variant's type
Definition: template.cpp:416
TemplateVariant::setRaw
void setRaw(bool b)
Sets whether or not the value of the Variant should be escaped or written as-is (raw).
Definition: template.h:240
TemplateContext::push
virtual void push()=0
Push a new scope on the stack.
TemplateContextImpl
Internal class representing the implementation of a template context
Definition: template.cpp:640
TemplateNodeCreator< TemplateNodeTree >::m_line
int m_line
Definition: template.cpp:3096
TemplateVariant::toList
TemplateListIntfPtr toList()
Returns the pointer to list referenced by this variant or 0 if this variant does not have list type.
Definition: template.cpp:432
TemplateContext::pop
virtual void pop()=0
Pop the current scope from the stack.
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108