Doxygen
TemplateEngine::Private类 参考

Private data of the template engine 更多...

+ TemplateEngine::Private 的协作图:

class  IncludeEntry
 

Public 成员函数

 Private (TemplateEngine *engine)
 
 ~Private ()
 
TemplateloadByName (const QCString &fileName, int line)
 
void unload (Template *)
 
void enterBlock (const QCString &fileName, const QCString &blockName, int line)
 
void leaveBlock ()
 
void printIncludeContext (const QCString &fileName, int line) const
 
void setOutputExtension (const QCString &extension)
 
QCString outputExtension () const
 
void setTemplateDir (const QCString &dirName)
 

Private 属性

std::unordered_map< std::string, std::unique_ptr< Template > > m_templateCache
 
TemplateEnginem_engine = 0
 
std::vector< IncludeEntrym_includeStack
 
QCString m_extension
 
QCString m_templateDirName
 

详细描述

Private data of the template engine

在文件 template.cpp5226 行定义.

构造及析构函数说明

◆ Private()

TemplateEngine::Private::Private ( TemplateEngine engine)
inline

在文件 template.cpp5246 行定义.

5246  : m_engine(engine)
5247  {
5248  //printf("%p:TemplateEngine::Private::Private()\n",(void*)this);
5249  }

◆ ~Private()

TemplateEngine::Private::~Private ( )
inline

在文件 template.cpp5250 行定义.

5251  {
5252  //printf("%p:TemplateEngine::Private::~Private()\n",(void*)this);
5253  }

成员函数说明

◆ enterBlock()

void TemplateEngine::Private::enterBlock ( const QCString fileName,
const QCString blockName,
int  line 
)
inline

在文件 template.cpp5305 行定义.

5306  {
5307  //for (int i=0;i<m_indent;i++) printf(" ");
5308  //m_indent++;
5309  //printf("enterBlock(%s,%s,%d) {\n",qPrint(fileName),qPrint(blockName),line);
5310  m_includeStack.emplace_back(IncludeEntry::Block,fileName,blockName,line);
5311  }

引用了 TemplateEngine::Private::IncludeEntry::Block , 以及 m_includeStack.

◆ leaveBlock()

void TemplateEngine::Private::leaveBlock ( )
inline

在文件 template.cpp5313 行定义.

5314  {
5315  //m_indent--;
5316  //for (int i=0;i<m_indent;i++) printf(" ");
5317  //printf("}\n");
5318  m_includeStack.pop_back();
5319  }

引用了 m_includeStack.

◆ loadByName()

Template* TemplateEngine::Private::loadByName ( const QCString fileName,
int  line 
)
inline

在文件 template.cpp5254 行定义.

5255  {
5256  //for (int i=0;i<m_indent;i++) printf(" ");
5257  //m_indent++;
5258  //printf("loadByName(%s,%d) {\n",qPrint(fileName),line);
5259  m_includeStack.emplace_back(IncludeEntry::Template,fileName,QCString(),line);
5260  auto kv = m_templateCache.find(fileName.str());
5261  if (kv==m_templateCache.end()) // first time template is referenced
5262  {
5263  QCString filePath = m_templateDirName+"/"+fileName;
5264  std::ifstream f(filePath.str(),std::ifstream::in | std::ifstream::binary);
5265  if (f.is_open()) // read template from disk
5266  {
5267  FileInfo fi(filePath.str());
5268  int size=(int)fi.size();
5269  QCString data(size+1);
5270  f.read(data.rawData(),size);
5271  if (!f.fail())
5272  {
5273  kv = m_templateCache.insert(
5274  std::make_pair(fileName.str(),
5275  std::make_unique<TemplateImpl>(m_engine,filePath,data,m_extension))).first;
5276  }
5277  }
5278  else // fallback to default built-in template
5279  {
5280  const QCString data = ResourceMgr::instance().getAsString(fileName);
5281  if (!data.isEmpty())
5282  {
5283  kv = m_templateCache.insert(
5284  std::make_pair(fileName.str(),
5285  std::make_unique<TemplateImpl>(m_engine,fileName,data,m_extension))).first;
5286  }
5287  else
5288  {
5289  err("Could not open template file %s\n",qPrint(fileName));
5290  }
5291  }
5292  }
5293  return kv!=m_templateCache.end() ? kv->second.get() : 0;
5294  }

引用了 err(), ResourceMgr::getAsString(), ResourceMgr::instance(), QCString::isEmpty(), m_engine, m_extension, m_includeStack, m_templateCache, m_templateDirName, qPrint(), QCString::rawData(), FileInfo::size(), QCString::str() , 以及 TemplateEngine::Private::IncludeEntry::Template.

◆ outputExtension()

QCString TemplateEngine::Private::outputExtension ( ) const
inline

在文件 template.cpp5349 行定义.

5350  {
5351  return m_extension;
5352  }

引用了 m_extension.

◆ printIncludeContext()

void TemplateEngine::Private::printIncludeContext ( const QCString fileName,
int  line 
) const
inline

在文件 template.cpp5321 行定义.

5322  {
5323  auto it = m_includeStack.rbegin();
5324  while (it!=m_includeStack.rend())
5325  {
5326  const IncludeEntry &ie = *it;
5327  ++it;
5328  const IncludeEntry *next = it!=m_includeStack.rend() ? &(*it) : 0;
5329  if (ie.type()==IncludeEntry::Template)
5330  {
5331  if (next)
5332  {
5333  warn(fileName,line," inside template '%s' included from template '%s' at line %d",qPrint(ie.fileName()),qPrint(next->fileName()),ie.line());
5334  }
5335  }
5336  else // ie.type()==IncludeEntry::Block
5337  {
5338  warn(fileName,line," included by block '%s' inside template '%s' at line %d",qPrint(ie.blockName()),
5339  qPrint(ie.fileName()),ie.line());
5340  }
5341  }
5342  }

引用了 TemplateEngine::Private::IncludeEntry::blockName(), TemplateEngine::Private::IncludeEntry::fileName(), TemplateEngine::Private::IncludeEntry::line(), m_includeStack, qPrint(), TemplateEngine::Private::IncludeEntry::Template, TemplateEngine::Private::IncludeEntry::type() , 以及 warn().

◆ setOutputExtension()

void TemplateEngine::Private::setOutputExtension ( const QCString extension)
inline

在文件 template.cpp5344 行定义.

5345  {
5346  m_extension = extension;
5347  }

引用了 m_extension.

◆ setTemplateDir()

void TemplateEngine::Private::setTemplateDir ( const QCString dirName)
inline

在文件 template.cpp5354 行定义.

5355  {
5356  m_templateDirName = dirName;
5357  }

引用了 m_templateDirName.

◆ unload()

void TemplateEngine::Private::unload ( Template )
inline

在文件 template.cpp5296 行定义.

5297  {
5298  //(void)t;
5299  //m_indent--;
5300  //for (int i=0;i<m_indent;i++) printf(" ");
5301  //printf("}\n");
5302  m_includeStack.pop_back();
5303  }

引用了 m_includeStack.

类成员变量说明

◆ m_engine

TemplateEngine* TemplateEngine::Private::m_engine = 0
private

在文件 template.cpp5362 行定义.

被这些函数引用 loadByName().

◆ m_extension

QCString TemplateEngine::Private::m_extension
private

在文件 template.cpp5364 行定义.

被这些函数引用 loadByName(), outputExtension() , 以及 setOutputExtension().

◆ m_includeStack

std::vector<IncludeEntry> TemplateEngine::Private::m_includeStack
private

在文件 template.cpp5363 行定义.

被这些函数引用 enterBlock(), leaveBlock(), loadByName(), printIncludeContext() , 以及 unload().

◆ m_templateCache

std::unordered_map< std::string, std::unique_ptr<Template> > TemplateEngine::Private::m_templateCache
private

在文件 template.cpp5360 行定义.

被这些函数引用 loadByName().

◆ m_templateDirName

QCString TemplateEngine::Private::m_templateDirName
private

在文件 template.cpp5365 行定义.

被这些函数引用 loadByName() , 以及 setTemplateDir().


该类的文档由以下文件生成:
TemplateEngine::Private::IncludeEntry::Block
@ Block
Definition: template.cpp:5231
ResourceMgr::instance
static ResourceMgr & instance()
Returns the one and only instance of this class
Definition: resourcemgr.cpp:32
ResourceMgr::getAsString
QCString getAsString(const QCString &name) const
Gets the resource data as a C string
Definition: resourcemgr.cpp:192
TemplateEngine::Private::m_extension
QCString m_extension
Definition: template.cpp:5364
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
warn
void warn(const QCString &file, int line, const char *fmt,...)
Definition: message.cpp:151
TemplateEngine::Private::m_engine
TemplateEngine * m_engine
Definition: template.cpp:5362
TemplateEngine::Private::m_templateCache
std::unordered_map< std::string, std::unique_ptr< Template > > m_templateCache
Definition: template.cpp:5360
TemplateEngine::Private::m_includeStack
std::vector< IncludeEntry > m_includeStack
Definition: template.cpp:5363
TemplateEngine::Private::m_templateDirName
QCString m_templateDirName
Definition: template.cpp:5365
FileInfo
Minimal replacement for QFileInfo.
Definition: fileinfo.h:22
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
TemplateEngine::Private::IncludeEntry::Template
@ Template
Definition: template.cpp:5231
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108