Doxygen
TemplateNodeWith类 参考

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

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

struct  Mapping
 

Public 成员函数

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

Private 属性

TemplateNodeList m_nodes
 
std::vector< Mappingm_args
 

额外继承的成员函数

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

详细描述

Class representing an 'with' tag in a template

在文件 template.cpp4182 行定义.

构造及析构函数说明

◆ TemplateNodeWith()

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

在文件 template.cpp4191 行定义.

4193  {
4194  TRACE(("{TemplateNodeWith(%s)\n",qPrint(data)));
4195  ExpressionParser expParser(parser,line);
4196  QCString filteredData = data;
4197  removeSpacesAroundEquals(filteredData);
4198  std::vector<QCString> args = split(filteredData," ");
4199  auto it = args.begin();
4200  while (it!=args.end())
4201  {
4202  QCString arg = *it;
4203  int j=arg.find('=');
4204  if (j>0)
4205  {
4206  ExprAstPtr expr = expParser.parse(arg.mid(j+1));
4207  if (expr)
4208  {
4209  m_args.emplace_back(arg.left(j),std::move(expr));
4210  }
4211  }
4212  else
4213  {
4214  parser->warn(parser->templateName(),line,"invalid argument '%s' for 'with' tag",qPrint(arg));
4215  }
4216  ++it;
4217  }
4218  StringVector stopAt = { "endwith" };
4219  parser->parse(this,line,stopAt,m_nodes);
4220  parser->removeNextToken(); // skip over endwith
4221  TRACE(("}TemplateNodeWith(%s)\n",qPrint(data)));
4222  }

引用了 QCString::find(), QCString::left(), m_args, m_nodes, QCString::mid(), TemplateParser::parse(), ExpressionParser::parse(), qPrint(), TemplateParser::removeNextToken(), removeSpacesAroundEquals(), split(), TemplateParser::templateName(), TRACE , 以及 TemplateParser::warn().

◆ ~TemplateNodeWith()

TemplateNodeWith::~TemplateNodeWith ( )
inline

在文件 template.cpp4223 行定义.

4224  {
4225  }

成员函数说明

◆ render()

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

实现了 TemplateNode.

在文件 template.cpp4226 行定义.

4227  {
4228  TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
4229  if (ci==0) return; // should not happen
4231  c->push();
4232  for (const auto &mapping : m_args)
4233  {
4234  TemplateVariant value = mapping.value->resolve(c);
4235  ci->set(mapping.name,value);
4236  }
4237  m_nodes.render(ts,c);
4238  c->pop();
4239  }

引用了 m_args, TemplateNodeCreator< TemplateNodeWith >::m_line, m_nodes, TemplateNodeCreator< TemplateNodeWith >::m_templateName, TemplateContext::pop(), TemplateContext::push(), TemplateNodeList::render(), TemplateContextImpl::set() , 以及 TemplateContextImpl::setLocation().

类成员变量说明

◆ m_args

std::vector<Mapping> TemplateNodeWith::m_args
private

在文件 template.cpp4242 行定义.

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

◆ m_nodes

TemplateNodeList TemplateNodeWith::m_nodes
private

在文件 template.cpp4241 行定义.

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


该类的文档由以下文件生成:
StringVector
std::vector< std::string > StringVector
Definition: containers.h:32
TemplateContextImpl::setLocation
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:682
TemplateNodeCreator< TemplateNodeWith >
split
static std::vector< QCString > split(const QCString &str, const QCString &sep, bool allowEmptyEntries=FALSE, bool cleanup=TRUE)
Definition: template.cpp:47
TemplateParser::templateName
QCString templateName() const
Definition: template.cpp:1998
QCString::find
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:38
ExpressionParser
Recursive decent parser for Django style template expressions.
Definition: template.cpp:2010
TemplateParser::removeNextToken
void removeNextToken()
Definition: template.cpp:5153
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
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
TemplateNodeWith::m_nodes
TemplateNodeList m_nodes
Definition: template.cpp:4241
TRACE
#define TRACE(x)
Definition: template.cpp:40
TemplateNodeList::render
void render(TextStream &ts, TemplateContext *c)
Definition: template.cpp:1971
TemplateNodeCreator< TemplateNodeWith >::m_templateName
QCString m_templateName
Definition: template.cpp:3095
TemplateNode::parent
TemplateNode * parent()
Definition: template.cpp:1941
TemplateNodeWith::m_args
std::vector< Mapping > m_args
Definition: template.cpp:4242
TemplateParser::parse
void parse(TemplateNode *parent, int line, const StringVector &stopAt, TemplateNodeList &nodes)
Definition: template.cpp:5057
ExprAstPtr
std::unique_ptr< ExprAst > ExprAstPtr
Definition: template.cpp:1670
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
removeSpacesAroundEquals
static void removeSpacesAroundEquals(QCString &s)
Strips spaces surrounding = from string in, so ‘foo = 10 bar=5 baz= 'hello’will becomefoo=10 bar=5 ba...
Definition: template.cpp:101
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
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< TemplateNodeWith >::m_line
int m_line
Definition: template.cpp:3096
TemplateContext::pop
virtual void pop()=0
Pop the current scope from the stack.
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108