diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2016-02-28 15:18:55 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2016-05-28 14:20:01 (GMT) |
commit | d38d33cef2241cd8d29c99f519d21ae225453357 (patch) | |
tree | cec801d4e012ca1b245d48cfd6b854d8b6530842 /src/template.cpp | |
parent | f7a05140593d854955151e4286205ef1f908e07b (diff) | |
download | Doxygen-d38d33cef2241cd8d29c99f519d21ae225453357.zip Doxygen-d38d33cef2241cd8d29c99f519d21ae225453357.tar.gz Doxygen-d38d33cef2241cd8d29c99f519d21ae225453357.tar.bz2 |
Added generating template files and reading templates from disk if present
Diffstat (limited to 'src/template.cpp')
-rw-r--r-- | src/template.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/template.cpp b/src/template.cpp index 3e354c3..9e814d7 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -5027,8 +5027,23 @@ class TemplateEngine::Private //printf("loadByName(%s,%d) {\n",fileName.data(),line); m_includeStack.append(new IncludeEntry(IncludeEntry::Template,fileName,QCString(),line)); Template *templ = m_templateCache.find(fileName); - if (templ==0) + if (templ==0) // first time template is referenced { + QCString filePath = m_templateDirName+"/"+fileName; + QFile f(filePath); + if (f.open(IO_ReadOnly)) + { + QFileInfo fi(filePath); + int size=fi.size(); + QCString data(size+1); + if (f.readBlock(data.rawData(),size)==size) + { + templ = new TemplateImpl(m_engine,filePath,data,m_extension); + m_templateCache.insert(fileName,templ); + return templ; + } + } + // fallback to default built-in template const QCString data = ResourceMgr::instance().getAsString(fileName); if (!data.isEmpty()) { @@ -5101,12 +5116,18 @@ class TemplateEngine::Private return m_extension; } + void setTemplateDir(const char *dirName) + { + m_templateDirName = dirName; + } + private: QDict<Template> m_templateCache; //mutable int m_indent; TemplateEngine *m_engine; QList<IncludeEntry> m_includeStack; QCString m_extension; + QCString m_templateDirName; }; TemplateEngine::TemplateEngine() @@ -5164,5 +5185,9 @@ QCString TemplateEngine::outputExtension() const return p->outputExtension(); } +void TemplateEngine::setTemplateDir(const char *dirName) +{ + p->setTemplateDir(dirName); +} |