Classes | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
TemplateNodeTree Class Reference

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

Inheritance diagram for TemplateNodeTree:
TemplateNodeCreator< TemplateNodeTree > TemplateNode

Classes

struct  TreeContext
 

Public Member Functions

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

Static Public Member Functions

static TemplateVariant renderChildrenStub (const void *ctx, const QValueList< TemplateVariant > &)
 
- Static Public Member Functions inherited from TemplateNodeCreator< TemplateNodeTree >
static TemplateNodecreateInstance (TemplateParser *parser, TemplateNode *parent, int line, const QCString &data)
 

Private Attributes

ExprAstm_treeExpr
 
TemplateNodeList m_treeNodes
 

Additional Inherited Members

- Protected Member Functions inherited from TemplateNodeCreator< TemplateNodeTree >
void mkpath (TemplateContextImpl *ci, const QCString &fileName)
 
- Protected Attributes inherited from TemplateNodeCreator< TemplateNodeTree >
QCString m_templateName
 
int m_line
 

Detailed Description

Class representing an 'tree' tag in a template.

Definition at line 3594 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 3605 of file template.cpp.

3607  {
3608  TRACE(("{TemplateNodeTree(%s)\n",data.data()));
3609  ExpressionParser ep(parser,line);
3610  if (data.isEmpty())
3611  {
3612  parser->warn(m_templateName,line,"recursetree tag is missing data argument");
3613  }
3614  m_treeExpr = ep.parse(data);
3615  QStrList stopAt;
3616  stopAt.append("endrecursetree");
3617  parser->parse(this,line,stopAt,m_treeNodes);
3618  parser->removeNextToken(); // skip over endrecursetree
3619  TRACE(("}TemplateNodeTree(%s)\n",data.data()));
3620  }
bool isEmpty() const
Definition: qcstring.h:189
TemplateNode * parent()
Definition: template.cpp:1647
TemplateNodeList m_treeNodes
Definition: template.cpp:3703
void append(const type *d)
Definition: qinternallist.h:61
const char * data() const
Definition: qcstring.h:207
ExprAst * m_treeExpr
Definition: template.cpp:3702
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
TemplateNodeTree::~TemplateNodeTree ( )
inline

Definition at line 3621 of file template.cpp.

3622  {
3623  delete m_treeExpr;
3624  }
ExprAst * m_treeExpr
Definition: template.cpp:3702

Member Function Documentation

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

Implements TemplateNode.

Definition at line 3682 of file template.cpp.

3683  {
3684  //printf("TemplateNodeTree::render()\n");
3685  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3686  if (ci==0) return; // should not happen
3689  const TemplateListIntf *list = v.toList();
3690  if (list)
3691  {
3692  TreeContext ctx(this,list,c);
3693  ts << renderChildren(&ctx);
3694  }
3695  else
3696  {
3697  ci->warn(m_templateName,m_line,"recursetree's argument should be a list type");
3698  }
3699  }
Internal class representing the implementation of a template context.
Definition: template.cpp:511
TemplateListIntf * toList() const
Definition: template.h:256
virtual TemplateVariant resolve(TemplateContext *)
Definition: template.cpp:1368
ExprAst * m_treeExpr
Definition: template.cpp:3702
QCString renderChildren(const TreeContext *ctx)
Definition: template.cpp:3630
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
void warn(const char *fileName, int line, const char *fmt,...) const
Definition: template.cpp:2431
void setLocation(const QCString &templateName, int line)
Definition: template.cpp:540
Abstract read-only interface for a context value of type list.
Definition: template.h:329
QCString TemplateNodeTree::renderChildren ( const TreeContext ctx)
inline

Definition at line 3630 of file template.cpp.

3631  {
3632  //printf("TemplateNodeTree::renderChildren(%d)\n",ctx->list->count());
3633  // render all children of node to a string and return it
3634  TemplateContext *c = ctx->templateCtx;
3635  TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
3636  if (ci==0) return QCString(); // should not happen
3637  QGString result;
3638  FTextStream ss(&result);
3639  c->push();
3640  TemplateVariant node;
3641  TemplateListIntf::ConstIterator *it = ctx->list->createIterator();
3642  for (it->toFirst();(it->current(node));it->toNext())
3643  {
3644  c->set("node",node);
3645  bool hasChildren=FALSE;
3646  const TemplateStructIntf *ns = node.toStruct();
3647  if (ns) // node is a struct
3648  {
3649  TemplateVariant v = ns->get("children");
3650  if (v.isValid()) // with a field 'children'
3651  {
3652  const TemplateListIntf *list = v.toList();
3653  if (list && list->count()>0) // non-empty list
3654  {
3655  TreeContext childCtx(this,list,ctx->templateCtx);
3657  children.setRaw(TRUE);
3658  c->set("children",children);
3659  m_treeNodes.render(ss,c);
3660  hasChildren=TRUE;
3661  }
3662  else if (list==0)
3663  {
3664  ci->warn(m_templateName,m_line,"recursetree: children attribute has type '%s' instead of list\n",v.typeAsString().data());
3665  }
3666  }
3667  //else
3668  //{
3669  // ci->warn(m_templateName,m_line,"recursetree: children attribute is not valid");
3670  //}
3671  }
3672  if (!hasChildren)
3673  {
3674  c->set("children",TemplateVariant("")); // provide default
3675  m_treeNodes.render(ss,c);
3676  }
3677  }
3678  c->pop();
3679  delete it;
3680  return result.data();
3681  }
void render(FTextStream &ts, TemplateContext *c)
Definition: template.cpp:2246
virtual void pop()=0
Abstract interface for a template context.
Definition: template.h:489
virtual void push()=0
char * data() const
Definition: qgstring.h:42
static QCString result
Internal class representing the implementation of a template context.
Definition: template.cpp:511
virtual bool current(TemplateVariant &v) const =0
virtual TemplateVariant get(const char *name) const =0
TemplateListIntf * toList() const
Definition: template.h:256
const bool FALSE
Definition: qglobal.h:370
QCString typeAsString() const
Definition: template.h:145
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
Abstract interface for a context value of type struct.
Definition: template.h:406
static Delegate fromFunction(const void *obj, StubType func)
Definition: template.h:112
virtual void set(const char *name, const TemplateVariant &v)=0
TemplateNodeList m_treeNodes
Definition: template.cpp:3703
static TemplateVariant renderChildrenStub(const void *ctx, const QValueList< TemplateVariant > &)
Definition: template.cpp:3625
virtual int count() const =0
Abstract interface for a iterator of a list.
Definition: template.h:333
const char * data() const
Definition: qcstring.h:207
bool isValid() const
Definition: template.h:161
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
void warn(const char *fileName, int line, const char *fmt,...) const
Definition: template.cpp:2431
TemplateStructIntf * toStruct() const
Definition: template.h:264
Abstract read-only interface for a context value of type list.
Definition: template.h:329
QAsciiDict< Entry > ns
const bool TRUE
Definition: qglobal.h:371
static TemplateVariant TemplateNodeTree::renderChildrenStub ( const void *  ctx,
const QValueList< TemplateVariant > &   
)
inlinestatic

Definition at line 3625 of file template.cpp.

3626  {
3627  return TemplateVariant(((TreeContext*)ctx)->object->
3628  renderChildren((const TreeContext*)ctx),TRUE);
3629  }
QCString renderChildren(const TreeContext *ctx)
Definition: template.cpp:3630
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
const bool TRUE
Definition: qglobal.h:371

Member Data Documentation

ExprAst* TemplateNodeTree::m_treeExpr
private

Definition at line 3702 of file template.cpp.

TemplateNodeList TemplateNodeTree::m_treeNodes
private

Definition at line 3703 of file template.cpp.


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