Doxygen
TemplateNodeCreate类 参考

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

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

Public 成员函数

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

Private 属性

ExprAstPtr m_templateExpr
 
ExprAstPtr m_fileExpr
 

额外继承的成员函数

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

详细描述

Class representing an 'create' tag in a template

在文件 template.cpp3823 行定义.

构造及析构函数说明

◆ TemplateNodeCreate()

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

在文件 template.cpp3826 行定义.

3828  {
3829  TRACE(("TemplateNodeCreate(%s)\n",qPrint(data)));
3830  if (data.isEmpty())
3831  {
3832  parser->warn(m_templateName,line,"create tag is missing arguments");
3833  }
3834  int i = data.find(" from ");
3835  if (i==-1)
3836  {
3837  if (data.endsWith(" from"))
3838  {
3839  parser->warn(m_templateName,line,"create is missing template name after 'from' keyword");
3840  }
3841  else if (data=="from")
3842  {
3843  parser->warn(m_templateName,line,"create needs a file name and a template name");
3844  }
3845  else
3846  {
3847  parser->warn(m_templateName,line,"create is missing 'from' keyword");
3848  }
3849  }
3850  else
3851  {
3852  ExpressionParser ep(parser,line);
3853  m_fileExpr = ep.parse(data.left(i).stripWhiteSpace());
3854  m_templateExpr = ep.parse(data.mid(i+6).stripWhiteSpace());
3855  }
3856  }

引用了 QCString::endsWith(), QCString::find(), QCString::isEmpty(), QCString::left(), m_fileExpr, m_templateExpr, TemplateNodeCreator< TemplateNodeCreate >::m_templateName, QCString::mid(), ExpressionParser::parse(), qPrint(), QCString::stripWhiteSpace(), TRACE , 以及 TemplateParser::warn().

成员函数说明

◆ render()

void TemplateNodeCreate::render ( TextStream ,
TemplateContext c 
)
inlinevirtual

实现了 TemplateNode.

在文件 template.cpp3857 行定义.

3858  {
3859  TRACE(("{TemplateNodeCreate::render\n"));
3860  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3861  if (ci==0) return; // should not happen
3863  if (m_templateExpr && m_fileExpr)
3864  {
3865  QCString templateFile = m_templateExpr->resolve(c).toString();
3866  QCString outputFile = m_fileExpr->resolve(c).toString();
3867  if (templateFile.isEmpty())
3868  {
3869  ci->warn(m_templateName,m_line,"empty template name parameter for create command\n");
3870  }
3871  else if (outputFile.isEmpty())
3872  {
3873  ci->warn(m_templateName,m_line,"empty file name parameter for create command\n");
3874  }
3875  else
3876  {
3877  TemplateImpl *t = getTemplate();
3878  if (t)
3879  {
3880  QCString extension=outputFile;
3881  int i=extension.findRev('.');
3882  if (i!=-1)
3883  {
3884  extension=extension.right(extension.length()-i-1);
3885  }
3886  t->engine()->setOutputExtension(extension);
3887  Template *ct = t->engine()->loadByName(templateFile,m_line);
3888  TemplateImpl *createTemplate = ct ? dynamic_cast<TemplateImpl*>(ct) : 0;
3889  if (createTemplate)
3890  {
3891  mkpath(ci,outputFile.str());
3892  if (!ci->outputDirectory().isEmpty())
3893  {
3894  outputFile.prepend(ci->outputDirectory()+"/");
3895  }
3896  //printf("NoteCreate(%s)\n",qPrint(outputFile));
3897  std::ofstream f(outputFile.str(),std::ofstream::out | std::ofstream::binary);
3898  if (f.is_open())
3899  {
3900  TextStream ts(&f);
3901  TemplateEscapeIntf *escIntf = ci->escapeIntf();
3902  ci->selectEscapeIntf(extension);
3903  TextStream os;
3904  createTemplate->render(os,c);
3905  QCString out = os.str();
3907  ts << out;
3908  t->engine()->unload(t);
3909  ci->setActiveEscapeIntf(escIntf);
3910  }
3911  else
3912  {
3913  ci->warn(m_templateName,m_line,"failed to open output file '%s' for create command",qPrint(outputFile));
3914  }
3915  }
3916  else
3917  {
3918  ci->warn(m_templateName,m_line,"failed to load template '%s' for include",qPrint(templateFile));
3919  }
3920  t->engine()->setOutputExtension("");
3921  }
3922  }
3923  }
3924  TRACE(("}TemplateNodeCreate::render\n"));
3925  }

引用了 TemplateImpl::engine(), TemplateContextImpl::escapeIntf(), QCString::findRev(), TemplateNodeCreator< TemplateNodeCreate >::getTemplate(), QCString::isEmpty(), QCString::length(), TemplateEngine::loadByName(), m_fileExpr, TemplateNodeCreator< TemplateNodeCreate >::m_line, m_templateExpr, TemplateNodeCreator< TemplateNodeCreate >::m_templateName, TemplateNodeCreator< TemplateNodeCreate >::mkpath(), TemplateContextImpl::outputDirectory(), QCString::prepend(), qPrint(), TemplateImpl::render(), QCString::right(), TemplateContextImpl::selectEscapeIntf(), TemplateContextImpl::setActiveEscapeIntf(), TemplateContextImpl::setLocation(), TemplateEngine::setOutputExtension(), TextStream::str(), QCString::str(), stripLeadingWhiteSpace(), TRACE, TemplateEngine::unload() , 以及 TemplateContextImpl::warn().

类成员变量说明

◆ m_fileExpr

ExprAstPtr TemplateNodeCreate::m_fileExpr
private

在文件 template.cpp3929 行定义.

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

◆ m_templateExpr

ExprAstPtr TemplateNodeCreate::m_templateExpr
private

在文件 template.cpp3928 行定义.

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


该类的文档由以下文件生成:
TemplateContextImpl::warn
void warn(const QCString &fileName, int line, const char *fmt,...) const
Definition: template.cpp:2773
TemplateContextImpl::setActiveEscapeIntf
void setActiveEscapeIntf(TemplateEscapeIntf *intf)
Definition: template.cpp:674
stripLeadingWhiteSpace
static void stripLeadingWhiteSpace(QCString &s)
Definition: template.cpp:3807
TemplateNodeCreator< TemplateNodeCreate >::mkpath
void mkpath(const TemplateContextImpl *ci, const std::string &fileName)
Definition: template.cpp:3061
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
TemplateContextImpl::escapeIntf
TemplateEscapeIntf * escapeIntf()
Definition: template.cpp:675
TemplateContextImpl::setLocation
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:682
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
TemplateNodeCreator< TemplateNodeCreate >
TemplateEngine::loadByName
Template * loadByName(const QCString &fileName, int fromLine)
Creates a new template whose contents are in a file.
Definition: template.cpp:5381
QCString::str
std::string str() const
Definition: qcstring.h:442
Template
Abstract interface for a template.
Definition: template.h:475
TemplateEngine::setOutputExtension
void setOutputExtension(const QCString &extension)
Sets the extension of the output file.
Definition: template.cpp:5406
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
TemplateImpl::engine
TemplateEngine * engine() const
Definition: template.cpp:2562
QCString::find
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:38
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
TemplateParser::warn
void warn(const QCString &fileName, int line, const char *fmt,...) const
Definition: template.cpp:5163
QCString::stripWhiteSpace
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition: qcstring.h:243
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
TRACE
#define TRACE(x)
Definition: template.cpp:40
TemplateContextImpl::outputDirectory
QCString outputDirectory() const
Definition: template.cpp:686
TemplateNodeCreator< TemplateNodeCreate >::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
TemplateNodeCreator< TemplateNodeCreate >::m_templateName
QCString m_templateName
Definition: template.cpp:3095
TemplateNode::parent
TemplateNode * parent()
Definition: template.cpp:1941
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
TemplateNodeCreate::m_templateExpr
ExprAstPtr m_templateExpr
Definition: template.cpp:3928
QCString::endsWith
bool endsWith(const char *s) const
Definition: qcstring.h:420
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
TemplateEscapeIntf
Interface used to escape characters in a string
Definition: template.h:384
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< TemplateNodeCreate >::m_line
int m_line
Definition: template.cpp:3096
TemplateContextImpl::selectEscapeIntf
void selectEscapeIntf(const QCString &ext)
Definition: template.cpp:669
TemplateNodeCreate::m_fileExpr
ExprAstPtr m_fileExpr
Definition: template.cpp:3929
QCString::right
QCString right(size_t len) const
Definition: qcstring.h:217
QCString::prepend
QCString & prepend(const char *s)
Definition: qcstring.h:339
TemplateImpl::render
void render(TextStream &ts, TemplateContext *c)
Definition: template.cpp:5200
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108