My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 3734 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 3745 of file template.cpp.

References TemplateNodeCreator< TemplateNodeTree >::m_templateName, m_treeExpr, m_treeNodes, TemplateParser::parse(), ExpressionParser::parse(), TemplateParser::removeNextToken(), TRACE, and TemplateParser::warn().

{
TRACE(("{TemplateNodeTree(%s)\n",data.data()));
ExpressionParser ep(parser,line);
if (data.isEmpty())
{
parser->warn(m_templateName,line,"recursetree tag is missing data argument");
}
m_treeExpr = ep.parse(data);
QStrList stopAt;
stopAt.append("endrecursetree");
parser->parse(this,line,stopAt,m_treeNodes);
parser->removeNextToken(); // skip over endrecursetree
TRACE(("}TemplateNodeTree(%s)\n",data.data()));
}
TemplateNodeTree::~TemplateNodeTree ( )
inline

Definition at line 3761 of file template.cpp.

References m_treeExpr.

{
delete m_treeExpr;
}

Member Function Documentation

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

Implements TemplateNode.

Definition at line 3822 of file template.cpp.

References TemplateNodeCreator< TemplateNodeTree >::m_line, TemplateNodeCreator< TemplateNodeTree >::m_templateName, m_treeExpr, renderChildren(), ExprAst::resolve(), TemplateContextImpl::setLocation(), TemplateVariant::toList(), and TemplateContextImpl::warn().

{
//printf("TemplateNodeTree::render()\n");
TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return; // should not happen
const TemplateListIntf *list = v.toList();
if (list)
{
TreeContext ctx(this,list,c);
ts << renderChildren(&ctx);
}
else
{
ci->warn(m_templateName,m_line,"recursetree's argument should be a list type");
}
}
QCString TemplateNodeTree::renderChildren ( const TreeContext ctx)
inline

Definition at line 3770 of file template.cpp.

References TemplateListIntf::count(), TemplateListIntf::createIterator(), TemplateListIntf::ConstIterator::current(), TemplateVariant::Delegate::fromFunction(), TemplateStructIntf::get(), TemplateVariant::isValid(), TemplateNodeTree::TreeContext::list, TemplateNodeCreator< TemplateNodeTree >::m_line, TemplateNodeCreator< TemplateNodeTree >::m_templateName, m_treeNodes, TemplateContext::pop(), TemplateContext::push(), TemplateNodeList::render(), renderChildrenStub(), TemplateContext::set(), TemplateVariant::setRaw(), TemplateNodeTree::TreeContext::templateCtx, TemplateListIntf::ConstIterator::toFirst(), TemplateVariant::toList(), TemplateListIntf::ConstIterator::toNext(), TemplateVariant::toStruct(), TemplateVariant::typeAsString(), and TemplateContextImpl::warn().

Referenced by render(), and renderChildrenStub().

{
//printf("TemplateNodeTree::renderChildren(%d)\n",ctx->list->count());
// render all children of node to a string and return it
TemplateContext *c = ctx->templateCtx;
TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return QCString(); // should not happen
QGString result;
FTextStream ss(&result);
c->push();
TemplateListIntf::ConstIterator *it = ctx->list->createIterator();
for (it->toFirst();(it->current(node));it->toNext())
{
c->set("node",node);
bool hasChildren=FALSE;
const TemplateStructIntf *ns = node.toStruct();
if (ns) // node is a struct
{
TemplateVariant v = ns->get("children");
if (v.isValid()) // with a field 'children'
{
const TemplateListIntf *list = v.toList();
if (list && list->count()>0) // non-empty list
{
TreeContext childCtx(this,list,ctx->templateCtx);
children.setRaw(TRUE);
c->set("children",children);
hasChildren=TRUE;
}
else if (list==0)
{
ci->warn(m_templateName,m_line,"recursetree: children attribute has type '%s' instead of list\n",v.typeAsString().data());
}
}
//else
//{
// ci->warn(m_templateName,m_line,"recursetree: children attribute is not valid");
//}
}
if (!hasChildren)
{
c->set("children",TemplateVariant("")); // provide default
}
}
c->pop();
delete it;
return result.data();
}
static TemplateVariant TemplateNodeTree::renderChildrenStub ( const void *  ctx,
const QValueList< TemplateVariant > &   
)
inlinestatic

Definition at line 3765 of file template.cpp.

References renderChildren().

Referenced by renderChildren().

{
return TemplateVariant(((TreeContext*)ctx)->object->
renderChildren((const TreeContext*)ctx),TRUE);
}

Member Data Documentation

ExprAst* TemplateNodeTree::m_treeExpr
private

Definition at line 3842 of file template.cpp.

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

TemplateNodeList TemplateNodeTree::m_treeNodes
private

Definition at line 3843 of file template.cpp.

Referenced by renderChildren(), and TemplateNodeTree().


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