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

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

Inheritance diagram for TemplateNodeWith:
TemplateNodeCreator< TemplateNodeWith > TemplateNode

Classes

struct  Mapping
 

Public Member Functions

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

Private Attributes

TemplateNodeList m_nodes
 
QList< Mappingm_args
 

Additional Inherited Members

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

Detailed Description

Class representing an 'with' tag in a template.

Definition at line 3994 of file template.cpp.

Constructor & Destructor Documentation

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

Definition at line 4004 of file template.cpp.

References m_args, m_nodes, TemplateParser::parse(), ExpressionParser::parse(), TemplateParser::removeNextToken(), removeSpacesAroundEquals(), split(), TemplateParser::templateName(), TRACE, and TemplateParser::warn().

{
TRACE(("{TemplateNodeWith(%s)\n",data.data()));
m_args.setAutoDelete(TRUE);
ExpressionParser expParser(parser,line);
QCString filteredData = removeSpacesAroundEquals(data);
QValueList<QCString> args = split(filteredData," ");
QValueListIterator<QCString> it = args.begin();
while (it!=args.end())
{
QCString arg = *it;
int j=arg.find('=');
if (j>0)
{
ExprAst *expr = expParser.parse(arg.mid(j+1));
if (expr)
{
m_args.append(new Mapping(arg.left(j),expr));
}
}
else
{
parser->warn(parser->templateName(),line,"invalid argument '%s' for 'with' tag",arg.data());
}
++it;
}
QStrList stopAt;
stopAt.append("endwith");
parser->parse(this,line,stopAt,m_nodes);
parser->removeNextToken(); // skip over endwith
TRACE(("}TemplateNodeWith(%s)\n",data.data()));
}
TemplateNodeWith::~TemplateNodeWith ( )
inline

Definition at line 4037 of file template.cpp.

{
}

Member Function Documentation

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

Implements TemplateNode.

Definition at line 4040 of file template.cpp.

References m_args, TemplateNodeCreator< TemplateNodeWith >::m_line, m_nodes, TemplateNodeCreator< TemplateNodeWith >::m_templateName, TemplateNodeWith::Mapping::name, TemplateContext::pop(), TemplateContext::push(), TemplateNodeList::render(), ExprAst::resolve(), TemplateContextImpl::set(), TemplateContextImpl::setLocation(), and TemplateNodeWith::Mapping::value.

{
TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c);
if (ci==0) return; // should not happen
c->push();
QListIterator<Mapping> it(m_args);
Mapping *mapping;
for (it.toFirst();(mapping=it.current());++it)
{
TemplateVariant value = mapping->value->resolve(c);
ci->set(mapping->name,value);
}
m_nodes.render(ts,c);
c->pop();
}

Member Data Documentation

QList<Mapping> TemplateNodeWith::m_args
private

Definition at line 4058 of file template.cpp.

Referenced by render(), and TemplateNodeWith().

TemplateNodeList TemplateNodeWith::m_nodes
private

Definition at line 4057 of file template.cpp.

Referenced by render(), and TemplateNodeWith().


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