My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Attributes | List of all members
TemplateEngine::Private Class Reference

Private data of the template engine. More...

Classes

class  IncludeEntry
 

Public Member Functions

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

Private Attributes

QDict< Templatem_templateCache
 
TemplateEnginem_engine
 
QList< IncludeEntrym_includeStack
 
QCString m_extension
 
QCString m_templateDirName
 

Detailed Description

Private data of the template engine.

Definition at line 5059 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 5079 of file template.cpp.

References m_includeStack, and m_templateCache.

: m_templateCache(17) /*, m_indent(0)*/, m_engine(engine)
{
m_templateCache.setAutoDelete(TRUE);
m_includeStack.setAutoDelete(TRUE);
}

Member Function Documentation

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

Definition at line 5130 of file template.cpp.

References TemplateEngine::Private::IncludeEntry::Block, and m_includeStack.

Referenced by TemplateEngine::enterBlock().

{
//for (int i=0;i<m_indent;i++) printf(" ");
//m_indent++;
//printf("enterBlock(%s,%s,%d) {\n",fileName.data(),blockName.data(),line);
m_includeStack.append(new IncludeEntry(IncludeEntry::Block,fileName,blockName,line));
}
void TemplateEngine::Private::leaveBlock ( )
inline

Definition at line 5138 of file template.cpp.

References m_includeStack.

Referenced by TemplateEngine::leaveBlock().

{
//m_indent--;
//for (int i=0;i<m_indent;i++) printf(" ");
//printf("}\n");
m_includeStack.removeLast();
}
Template* TemplateEngine::Private::loadByName ( const QCString &  fileName,
int  line 
)
inline

Definition at line 5084 of file template.cpp.

References err(), ResourceMgr::getAsString(), ResourceMgr::instance(), m_engine, m_extension, m_includeStack, m_templateCache, m_templateDirName, and TemplateEngine::Private::IncludeEntry::Template.

Referenced by TemplateEngine::loadByName().

{
//for (int i=0;i<m_indent;i++) printf(" ");
//m_indent++;
//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) // 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())
{
templ = new TemplateImpl(m_engine,fileName,data,m_extension);
m_templateCache.insert(fileName,templ);
}
else
{
err("Cound not open template file %s\n",fileName.data());
}
}
return templ;
}
QCString TemplateEngine::Private::outputExtension ( ) const
inline

Definition at line 5175 of file template.cpp.

References m_extension.

Referenced by TemplateEngine::outputExtension().

{
return m_extension;
}
void TemplateEngine::Private::printIncludeContext ( const char *  fileName,
int  line 
) const
inline

Definition at line 5146 of file template.cpp.

References TemplateEngine::Private::IncludeEntry::blockName(), TemplateEngine::Private::IncludeEntry::fileName(), TemplateEngine::Private::IncludeEntry::line(), m_includeStack, TemplateEngine::Private::IncludeEntry::Template, TemplateEngine::Private::IncludeEntry::type(), and warn().

Referenced by TemplateEngine::printIncludeContext().

{
QListIterator<IncludeEntry> li(m_includeStack);
li.toLast();
IncludeEntry *ie=li.current();
while ((ie=li.current()))
{
--li;
IncludeEntry *next=li.current();
if (ie->type()==IncludeEntry::Template)
{
if (next)
{
warn(fileName,line," inside template '%s' included from template '%s' at line %d",ie->fileName().data(),next->fileName().data(),ie->line());
}
}
else // ie->type()==IncludeEntry::Block
{
warn(fileName,line," included by block '%s' inside template '%s' at line %d",ie->blockName().data(),
ie->fileName().data(),ie->line());
}
}
}
void TemplateEngine::Private::setOutputExtension ( const char *  extension)
inline

Definition at line 5170 of file template.cpp.

References m_extension.

Referenced by TemplateEngine::setOutputExtension().

{
m_extension = extension;
}
void TemplateEngine::Private::setTemplateDir ( const char *  dirName)
inline

Definition at line 5180 of file template.cpp.

References m_templateDirName.

Referenced by TemplateEngine::setTemplateDir().

{
m_templateDirName = dirName;
}
void TemplateEngine::Private::unload ( Template )
inline

Definition at line 5121 of file template.cpp.

References m_includeStack.

Referenced by TemplateEngine::unload().

{
//(void)t;
//m_indent--;
//for (int i=0;i<m_indent;i++) printf(" ");
//printf("}\n");
m_includeStack.removeLast();
}

Member Data Documentation

TemplateEngine* TemplateEngine::Private::m_engine
private

Definition at line 5188 of file template.cpp.

Referenced by loadByName().

QCString TemplateEngine::Private::m_extension
private

Definition at line 5190 of file template.cpp.

Referenced by loadByName(), outputExtension(), and setOutputExtension().

QList<IncludeEntry> TemplateEngine::Private::m_includeStack
private

Definition at line 5189 of file template.cpp.

Referenced by enterBlock(), leaveBlock(), loadByName(), printIncludeContext(), Private(), and unload().

QDict<Template> TemplateEngine::Private::m_templateCache
private

Definition at line 5186 of file template.cpp.

Referenced by loadByName(), and Private().

QCString TemplateEngine::Private::m_templateDirName
private

Definition at line 5191 of file template.cpp.

Referenced by loadByName(), and setTemplateDir().


The documentation for this class was generated from the following file: