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

Class representing an 'markers' tag in a template. More...

Inheritance diagram for TemplateNodeResource:
TemplateNodeCreator< TemplateNodeResource > TemplateNode

Public Member Functions

 TemplateNodeResource (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
 ~TemplateNodeResource ()
 
void render (FTextStream &, TemplateContext *c)
 
- Public Member Functions inherited from TemplateNodeCreator< TemplateNodeResource >
 TemplateNodeCreator (TemplateParser *parser, TemplateNode *parent, int line)
 
TemplateImplgetTemplate ()
 
- Public Member Functions inherited from TemplateNode
 TemplateNode (TemplateNode *parent)
 
virtual ~TemplateNode ()
 
TemplateNodeparent ()
 

Private Attributes

ExprAstm_resExpr
 
ExprAstm_asExpr
 

Additional Inherited Members

- Static Public Member Functions inherited from TemplateNodeCreator< TemplateNodeResource >
static TemplateNodecreateInstance (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 
- Protected Member Functions inherited from TemplateNodeCreator< TemplateNodeResource >
void mkpath (TemplateContextImpl *ci, const QCString &fileName)
 
- Protected Attributes inherited from TemplateNodeCreator< TemplateNodeResource >
QCString m_templateName
 
int m_line
 

Detailed Description

Class representing an 'markers' tag in a template.

Definition at line 4363 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 4366 of file template.cpp.

References m_asExpr, m_resExpr, TemplateNodeCreator< TemplateNodeResource >::m_templateName, ExpressionParser::parse(), TRACE, and TemplateParser::warn().

{
TRACE(("{TemplateNodeResource(%s)\n",data.data()));
ExpressionParser ep(parser,line);
int i;
if (data.isEmpty())
{
parser->warn(m_templateName,line,"resource tag is missing resource file argument");
}
else if ((i=data.find(" as "))!=-1) // resource a as b
{
m_resExpr = ep.parse(data.left(i)); // part before as
m_asExpr = ep.parse(data.mid(i+4)); // part after as
}
else // resource a
{
m_resExpr = ep.parse(data);
m_asExpr = 0;
}
TRACE(("}TemplateNodeResource(%s)\n",data.data()));
}
TemplateNodeResource::~TemplateNodeResource ( )
inline

Definition at line 4390 of file template.cpp.

References m_asExpr, and m_resExpr.

{
delete m_resExpr;
delete m_asExpr;
}

Member Function Documentation

void TemplateNodeResource::render ( FTextStream ,
TemplateContext c 
)
inlinevirtual

Implements TemplateNode.

Definition at line 4395 of file template.cpp.

References ResourceMgr::copyResource(), ResourceMgr::copyResourceAs(), ResourceMgr::instance(), m_asExpr, TemplateNodeCreator< TemplateNodeResource >::m_line, m_resExpr, TemplateNodeCreator< TemplateNodeResource >::m_templateName, TemplateNodeCreator< TemplateNodeResource >::mkpath(), TemplateContextImpl::outputDirectory(), ExprAst::resolve(), TemplateContextImpl::setLocation(), TemplateVariant::toString(), and TemplateContextImpl::warn().

{
TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return; // should not happen
if (m_resExpr)
{
QCString resourceFile = m_resExpr->resolve(c).toString();
if (resourceFile.isEmpty())
{
ci->warn(m_templateName,m_line,"invalid parameter for resource command\n");
}
else
{
QCString outputDirectory = ci->outputDirectory();
if (m_asExpr)
{
QCString targetFile = m_asExpr->resolve(c).toString();
mkpath(ci,targetFile);
if (targetFile.isEmpty())
{ ci->warn(m_templateName,m_line,"invalid parameter at right side of 'as' for resource command\n");
}
else
{
ResourceMgr::instance().copyResourceAs(resourceFile,outputDirectory,targetFile);
}
}
else
{
ResourceMgr::instance().copyResource(resourceFile,outputDirectory);
}
}
}
}

Member Data Documentation

ExprAst* TemplateNodeResource::m_asExpr
private

Definition at line 4431 of file template.cpp.

Referenced by render(), TemplateNodeResource(), and ~TemplateNodeResource().

ExprAst* TemplateNodeResource::m_resExpr
private

Definition at line 4430 of file template.cpp.

Referenced by render(), TemplateNodeResource(), and ~TemplateNodeResource().


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