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 4195 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 4198 of file template.cpp.

4200  {
4201  TRACE(("{TemplateNodeResource(%s)\n",data.data()));
4202  ExpressionParser ep(parser,line);
4203  int i;
4204  if (data.isEmpty())
4205  {
4206  parser->warn(m_templateName,line,"resource tag is missing resource file argument");
4207  m_resExpr=0;
4208  m_asExpr=0;
4209  }
4210  else if ((i=data.find(" as "))!=-1) // resource a as b
4211  {
4212  m_resExpr = ep.parse(data.left(i)); // part before as
4213  m_asExpr = ep.parse(data.mid(i+4)); // part after as
4214  }
4215  else // resource a
4216  {
4217  m_resExpr = ep.parse(data);
4218  m_asExpr = 0;
4219  }
4220  TRACE(("}TemplateNodeResource(%s)\n",data.data()));
4221  }
bool isEmpty() const
Definition: qcstring.h:189
QCString left(uint len) const
Definition: qcstring.cpp:213
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
TemplateNode * parent()
Definition: template.cpp:1647
const char * data() const
Definition: qcstring.h:207
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
void line(double t, double *p, double &x, double &y, double &z)
Recursive decent parser for Django style template expressions.
Definition: template.cpp:1680
#define TRACE(x)
Definition: template.cpp:43
TemplateNodeResource::~TemplateNodeResource ( )
inline

Definition at line 4222 of file template.cpp.

4223  {
4224  delete m_resExpr;
4225  delete m_asExpr;
4226  }

Member Function Documentation

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

Implements TemplateNode.

Definition at line 4227 of file template.cpp.

4228  {
4229  TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
4230  if (ci==0) return; // should not happen
4232  if (m_resExpr)
4233  {
4234  QCString resourceFile = m_resExpr->resolve(c).toString();
4235  if (resourceFile.isEmpty())
4236  {
4237  ci->warn(m_templateName,m_line,"invalid parameter for resource command\n");
4238  }
4239  else
4240  {
4241  QCString outputDirectory = ci->outputDirectory();
4242  if (m_asExpr)
4243  {
4244  QCString targetFile = m_asExpr->resolve(c).toString();
4245  mkpath(ci,targetFile);
4246  if (targetFile.isEmpty())
4247  {
4248  ci->warn(m_templateName,m_line,"invalid parameter at right side of 'as' for resource command\n");
4249  }
4250  else
4251  {
4252  ResourceMgr::instance().copyResourceAs(resourceFile,outputDirectory,targetFile);
4253  }
4254  }
4255  else
4256  {
4257  ResourceMgr::instance().copyResource(resourceFile,outputDirectory);
4258  }
4259  }
4260  }
4261  }
QCString outputDirectory() const
Definition: template.cpp:544
bool isEmpty() const
Definition: qcstring.h:189
Internal class representing the implementation of a template context.
Definition: template.cpp:511
bool copyResource(const char *name, const char *targetDir) const
static ResourceMgr & instance()
Definition: resourcemgr.cpp:35
QCString toString() const
Definition: template.h:232
virtual TemplateVariant resolve(TemplateContext *)
Definition: template.cpp:1368
void mkpath(TemplateContextImpl *ci, const QCString &fileName)
Definition: template.cpp:2684
void warn(const char *fileName, int line, const char *fmt,...) const
Definition: template.cpp:2431
bool copyResourceAs(const char *name, const char *targetDir, const char *targetName) const
Definition: resourcemgr.cpp:76
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540

Member Data Documentation

ExprAst* TemplateNodeResource::m_asExpr
private

Definition at line 4264 of file template.cpp.

ExprAst* TemplateNodeResource::m_resExpr
private

Definition at line 4263 of file template.cpp.


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