Public Member Functions | Private Attributes | List of all members
TemplateNodeVariable Class Reference

Class representing a variable in a template. More...

Inheritance diagram for TemplateNodeVariable:
TemplateNode

Public Member Functions

 TemplateNodeVariable (TemplateParser *parser, TemplateNode *parent, int line, const QCString &var)
 
 ~TemplateNodeVariable ()
 
void render (FTextStream &ts, TemplateContext *c)
 
- Public Member Functions inherited from TemplateNode
 TemplateNode (TemplateNode *parent)
 
virtual ~TemplateNode ()
 
TemplateNodeparent ()
 

Private Attributes

QCString m_templateName
 
int m_line
 
ExprAstm_var
 
QList< ExprAstm_args
 

Detailed Description

Class representing a variable in a template.

Definition at line 2608 of file template.cpp.

Constructor & Destructor Documentation

TemplateNodeVariable::TemplateNodeVariable ( TemplateParser parser,
TemplateNode parent,
int  line,
const QCString var 
)
inline

Definition at line 2611 of file template.cpp.

2612  : TemplateNode(parent), m_templateName(parser->templateName()), m_line(line)
2613  {
2614  TRACE(("TemplateNodeVariable(%s)\n",var.data()));
2615  ExpressionParser expParser(parser,line);
2616  m_var = expParser.parse(var);
2617  if (m_var==0)
2618  {
2619  parser->warn(m_templateName,line,"invalid expression '%s' for variable",var.data());
2620  }
2621  }
TemplateNode(TemplateNode *parent)
Definition: template.cpp:1642
void warn(const char *fileName, int line, const char *fmt,...) const
Definition: template.cpp:4772
QCString templateName() const
Definition: template.cpp:1668
const char * data() const
Definition: qcstring.h:207
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
TemplateNodeVariable::~TemplateNodeVariable ( )
inline

Definition at line 2622 of file template.cpp.

2623  {
2624  delete m_var;
2625  }

Member Function Documentation

void TemplateNodeVariable::render ( FTextStream ts,
TemplateContext c 
)
inlinevirtual

Implements TemplateNode.

Definition at line 2627 of file template.cpp.

2628  {
2629  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
2630  if (ci==0) return; // should not happen
2632  if (m_var)
2633  {
2634  TemplateVariant v = m_var->resolve(c);
2636  {
2638  }
2639  if (ci->escapeIntf() && !v.raw())
2640  {
2641  ts << ci->escapeIntf()->escape(v.toString());
2642  }
2643  else
2644  {
2645  ts << v.toString();
2646  }
2647  }
2648  }
Internal class representing the implementation of a template context.
Definition: template.cpp:511
virtual QCString escape(const QCString &input)=0
TemplateVariant call(const QValueList< TemplateVariant > &args)
Definition: template.h:272
TemplateEscapeIntf * escapeIntf() const
Definition: template.cpp:545
QCString toString() const
Definition: template.h:232
virtual TemplateVariant resolve(TemplateContext *)
Definition: template.cpp:1368
bool raw() const
Definition: template.h:287
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
Type type() const
Definition: template.h:142
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540

Member Data Documentation

QList<ExprAst> TemplateNodeVariable::m_args
private

Definition at line 2654 of file template.cpp.

int TemplateNodeVariable::m_line
private

Definition at line 2652 of file template.cpp.

QCString TemplateNodeVariable::m_templateName
private

Definition at line 2651 of file template.cpp.

ExprAst* TemplateNodeVariable::m_var
private

Definition at line 2653 of file template.cpp.


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