Doxygen
TemplateNodeCycle类 参考

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

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

Public 成员函数

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

Private 属性

size_t m_index = 0
 
ExprAstList m_args
 

额外继承的成员函数

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

详细描述

Class representing an 'cycle' tag in a template

在文件 template.cpp4248 行定义.

构造及析构函数说明

◆ TemplateNodeCycle()

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

在文件 template.cpp4251 行定义.

4253  {
4254  TRACE(("{TemplateNodeCycle(%s)\n",qPrint(data)));
4255  m_index=0;
4256  ExpressionParser expParser(parser,line);
4257  std::vector<QCString> args = split(data," ");
4258  auto it = args.begin();
4259  while (it!=args.end())
4260  {
4261  ExprAstPtr expr = expParser.parse(*it);
4262  if (expr)
4263  {
4264  m_args.emplace_back(std::move(expr));
4265  }
4266  ++it;
4267  }
4268  if (m_args.size()<2)
4269  {
4270  parser->warn(parser->templateName(),line,"expected at least two arguments for cycle command, got %zu",m_args.size());
4271  }
4272  TRACE(("}TemplateNodeCycle(%s)\n",qPrint(data)));
4273  }

引用了 m_args, m_index, ExpressionParser::parse(), qPrint(), split(), TemplateParser::templateName(), TRACE , 以及 TemplateParser::warn().

成员函数说明

◆ render()

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

实现了 TemplateNode.

在文件 template.cpp4274 行定义.

4275  {
4276  TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
4277  if (ci==0) return; // should not happen
4279  if (m_index<m_args.size())
4280  {
4281  TemplateVariant v = m_args[m_index]->resolve(c);
4282  if (v.isFunction())
4283  {
4284  v = v.call();
4285  }
4286  if (ci->escapeIntf() && !v.raw())
4287  {
4288  if (ci->needsRecoding())
4289  {
4290  ts << ci->recode(ci->escapeIntf()->escape(v.toString()));
4291  }
4292  else
4293  {
4294  ts << ci->escapeIntf()->escape(v.toString());
4295  }
4296  }
4297  else
4298  {
4299  if (ci->needsRecoding())
4300  {
4301  ts << ci->recode(v.toString());
4302  }
4303  else
4304  {
4305  ts << v.toString();
4306  }
4307  }
4308  }
4309  if (++m_index==m_args.size()) // wrap around
4310  {
4311  m_index=0;
4312  }
4313  }

引用了 TemplateVariant::call(), TemplateEscapeIntf::escape(), TemplateContextImpl::escapeIntf(), TemplateVariant::isFunction(), m_args, m_index, TemplateNodeCreator< TemplateNodeCycle >::m_line, TemplateNodeCreator< TemplateNodeCycle >::m_templateName, TemplateContextImpl::needsRecoding(), TemplateVariant::raw(), TemplateContextImpl::recode(), TemplateContextImpl::setLocation() , 以及 TemplateVariant::toString().

类成员变量说明

◆ m_args

ExprAstList TemplateNodeCycle::m_args
private

在文件 template.cpp4316 行定义.

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

◆ m_index

size_t TemplateNodeCycle::m_index = 0
private

在文件 template.cpp4315 行定义.

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


该类的文档由以下文件生成:
TemplateVariant::isFunction
constexpr bool isFunction() const
Returns TRUE if the variant holds a function value
Definition: template.h:215
TemplateContextImpl::escapeIntf
TemplateEscapeIntf * escapeIntf()
Definition: template.cpp:675
TemplateContextImpl::setLocation
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:682
TemplateVariant::call
TemplateVariant call(const std::vector< TemplateVariant > &args=std::vector< TemplateVariant >())
Return the result of apply this function with args.
Definition: template.cpp:454
TemplateNodeCreator< TemplateNodeCycle >
split
static std::vector< QCString > split(const QCString &str, const QCString &sep, bool allowEmptyEntries=FALSE, bool cleanup=TRUE)
Definition: template.cpp:47
TemplateEscapeIntf::escape
virtual QCString escape(const QCString &input)=0
Returns the input after escaping certain characters
TemplateParser::templateName
QCString templateName() const
Definition: template.cpp:1998
TemplateNodeCycle::m_args
ExprAstList m_args
Definition: template.cpp:4316
ExpressionParser
Recursive decent parser for Django style template expressions.
Definition: template.cpp:2010
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
TemplateContextImpl::recode
QCString recode(const QCString &s)
Definition: template.cpp:2609
TemplateNodeCycle::m_index
size_t m_index
Definition: template.cpp:4315
TemplateNodeCreator< TemplateNodeCycle >::m_templateName
QCString m_templateName
Definition: template.cpp:3095
TemplateNode::parent
TemplateNode * parent()
Definition: template.cpp:1941
TemplateVariant::raw
constexpr bool raw() const
Returns whether or not the value of the Value is raw.
Definition: template.h:245
ExprAstPtr
std::unique_ptr< ExprAst > ExprAstPtr
Definition: template.cpp:1670
TemplateContextImpl::needsRecoding
bool needsRecoding() const
Definition: template.cpp:697
TemplateVariant::toString
QCString toString() const
Returns the variant as a string.
Definition: template.cpp:399
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
TemplateContextImpl
Internal class representing the implementation of a template context
Definition: template.cpp:640
TemplateNodeCreator< TemplateNodeCycle >::m_line
int m_line
Definition: template.cpp:3096