My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
template.cpp File Reference
#include "template.h"
#include <stdio.h>
#include <stdarg.h>
#include <qlist.h>
#include <qarray.h>
#include <qdict.h>
#include <qstrlist.h>
#include <qvaluelist.h>
#include <qstack.h>
#include <qfile.h>
#include <qregexp.h>
#include <qcstring.h>
#include <qdir.h>
#include "sortdict.h"
#include "ftextstream.h"
#include "message.h"
#include "util.h"
#include "resourcemgr.h"
#include "portable.h"

Go to the source code of this file.

Classes

class  TemplateStruct::Private
 Private data of a template struct object. More...
 
class  TemplateList::Private
 Private data of a template list object. More...
 
class  TemplateListConstIterator
 
class  Operator
 Class representing operators that can appear in template expressions. More...
 
class  TemplateBlockContext
 Class holding stacks of blocks available in the context. More...
 
struct  TemplateKeyValue
 A container to store a key-value pair. More...
 
class  TemplateContextImpl
 Internal class representing the implementation of a template context. More...
 
class  FilterAdd
 The implementation of the "add" filter. More...
 
class  FilterGet
 The implementation of the "get" filter. More...
 
class  FilterRaw
 The implementation of the "raw" filter. More...
 
class  FilterList
 The implementation of the "list" filter. More...
 
class  FilterTexLabel
 The implementation of the "texlabel" filter. More...
 
class  FilterTexIndex
 The implementation of the "texindex" filter. More...
 
class  FilterAppend
 The implementation of the "append" filter. More...
 
class  FilterPrepend
 The implementation of the "prepend" filter. More...
 
class  FilterLength
 The implementation of the "length" filter. More...
 
class  FilterDefault
 The implementation of the "default" filter. More...
 
class  FilterFlatten
 The implementation of the "flatten" filter. More...
 
class  FilterListSort
 The implementation of the "listsort" filter. More...
 
struct  FilterListSort::ListElem
 
class  FilterListSort::SortList
 
class  FilterGroupBy
 The implementation of the "groupBy" filter. More...
 
struct  FilterGroupBy::ListElem
 
class  FilterGroupBy::SortList
 
class  FilterRelative
 The implementation of the "relative" filter. More...
 
class  FilterPaginate
 The implementation of the "paginate" filter. More...
 
class  FilterAlphaIndex
 The implementation of the "alphaIndex" filter. More...
 
struct  FilterAlphaIndex::ListElem
 
class  FilterAlphaIndex::SortList
 
class  FilterStripPath
 The implementation of the "default" filter. More...
 
class  FilterNoWrap
 The implementation of the "default" filter. More...
 
class  FilterDivisibleBy
 The implementation of the "divisibleby" filter. More...
 
class  FilterIsRelativeURL
 The implementation of the "isRelativeURL" filter. More...
 
class  FilterIsAbsoluteURL
 The implementation of the "isRelativeURL" filter. More...
 
class  FilterDecodeURL
 The implementation of the "decodeURL" filter The leading character is removed from the value in case it is a ^ or !. More...
 
class  TemplateFilterFactory
 Factory singleton for registering and creating filters. More...
 
class  TemplateFilterFactory::AutoRegister< T >
 Helper class for registering a filter function. More...
 
class  ExprAst
 Base class for all nodes in the abstract syntax tree of an expression. More...
 
class  ExprAstNumber
 Class representing a number in the AST. More...
 
class  ExprAstVariable
 Class representing a variable in the AST. More...
 
class  ExprAstFunctionVariable
 
class  ExprAstFilter
 Class representing a filter in the AST. More...
 
class  ExprAstFilterAppl
 Class representing a filter applied to an expression in the AST. More...
 
class  ExprAstLiteral
 Class representing a string literal in the AST. More...
 
class  ExprAstNegate
 Class representing a negation (not) operator in the AST. More...
 
class  ExprAstUnary
 
class  ExprAstBinary
 Class representing a binary operator in the AST. More...
 
class  TemplateNode
 Base class of all nodes in a template's AST. More...
 
class  TemplateParser
 Parser for templates. More...
 
class  ExpressionParser
 Recursive decent parser for Django style template expressions. More...
 
class  ExpressionParser::ExprToken
 Class representing a token within an expression. More...
 
class  TemplateToken
 Class representing a lexical token in a template. More...
 
class  TemplateNodeList
 Class representing a list of AST nodes in a template. More...
 
class  TemplateImpl
 Internal class representing the implementation of a template. More...
 
class  TemplateStructWeakRef
 Weak reference wrapper for TemplateStructIntf that provides access to the wrapped struct without holding a reference. More...
 
class  TemplateNodeText
 Class representing a piece of plain text in a template. More...
 
class  TemplateNodeVariable
 Class representing a variable in a template. More...
 
class  TemplateNodeCreator< T >
 Helper class for creating template AST tag nodes and returning the template for a given node. More...
 
class  TemplateNodeIf
 Class representing an 'if' tag in a template. More...
 
struct  TemplateNodeIf::GuardedNodes
 
class  TemplateNodeRepeat
 Class representing a 'for' tag in a template. More...
 
class  TemplateNodeRange
 Class representing a 'range' tag in a template. More...
 
class  TemplateNodeFor
 Class representing a 'for' tag in a template. More...
 
class  TemplateNodeMsg
 Class representing an 'markers' tag in a template. More...
 
class  TemplateNodeBlock
 Class representing a 'block' tag in a template. More...
 
class  TemplateNodeExtend
 Class representing a 'extend' tag in a template. More...
 
class  TemplateNodeInclude
 Class representing an 'include' tag in a template. More...
 
class  TemplateNodeCreate
 Class representing an 'create' tag in a template. More...
 
class  TemplateNodeTree
 Class representing an 'tree' tag in a template. More...
 
struct  TemplateNodeTree::TreeContext
 
class  TemplateNodeIndexEntry
 Class representing an 'indexentry' tag in a template. More...
 
struct  TemplateNodeIndexEntry::Mapping
 
class  TemplateNodeOpenSubIndex
 Class representing an 'opensubindex' tag in a template. More...
 
class  TemplateNodeCloseSubIndex
 Class representing an 'closesubindex' tag in a template. More...
 
class  TemplateNodeWith
 Class representing an 'with' tag in a template. More...
 
struct  TemplateNodeWith::Mapping
 
class  TemplateNodeCycle
 Class representing an 'cycle' tag in a template. More...
 
class  TemplateNodeSet
 Class representing an 'set' tag in a template. More...
 
struct  TemplateNodeSet::Mapping
 
class  TemplateNodeSpaceless
 Class representing an 'spaceless' tag in a template. More...
 
class  TemplateNodeMarkers
 Class representing an 'markers' tag in a template. More...
 
class  TemplateNodeTabbing
 Class representing an 'tabbing' tag in a template. More...
 
class  TemplateNodeResource
 Class representing an 'markers' tag in a template. More...
 
class  TemplateNodeEncoding
 Class representing the 'encoding' tag in a template. More...
 
class  TemplateNodeFactory
 Factory class for creating tag AST nodes found in a template. More...
 
class  TemplateNodeFactory::AutoRegister< T >
 Helper class for registering a template AST node. More...
 
class  TemplateLexer
 Lexer class for turning a template into a list of tokens. More...
 
class  TemplateEngine::Private
 Private data of the template engine. More...
 
class  TemplateEngine::Private::IncludeEntry
 

Macros

#define ENABLE_TRACING   0
 
#define TRACE(x)
 

Functions

static QValueList< QCString > split (const QCString &str, const QCString &sep, bool allowEmptyEntries=FALSE, bool cleanup=TRUE)
 
static QCString removeSpacesAroundEquals (const char *s)
 
static void getPathListFunc (TemplateStructIntf *entry, TemplateList *list)
 
static TemplateVariant getPathFunc (const void *ctx, const QValueList< TemplateVariant > &)
 
static void stripLeadingWhiteSpace (QGString &s)
 

Variables

static
TemplateFilterFactory::AutoRegister
< FilterAdd
fAdd ("add")
 
static
TemplateFilterFactory::AutoRegister
< FilterGet
fGet ("get")
 
static
TemplateFilterFactory::AutoRegister
< FilterRaw
fRaw ("raw")
 
static
TemplateFilterFactory::AutoRegister
< FilterList
fList ("list")
 
static
TemplateFilterFactory::AutoRegister
< FilterAppend
fAppend ("append")
 
static
TemplateFilterFactory::AutoRegister
< FilterLength
fLength ("length")
 
static
TemplateFilterFactory::AutoRegister
< FilterNoWrap
fNoWrap ("nowrap")
 
static
TemplateFilterFactory::AutoRegister
< FilterFlatten
fFlatten ("flatten")
 
static
TemplateFilterFactory::AutoRegister
< FilterDefault
fDefault ("default")
 
static
TemplateFilterFactory::AutoRegister
< FilterPrepend
fPrepend ("prepend")
 
static
TemplateFilterFactory::AutoRegister
< FilterGroupBy
fGroupBy ("groupBy")
 
static
TemplateFilterFactory::AutoRegister
< FilterRelative
fRelative ("relative")
 
static
TemplateFilterFactory::AutoRegister
< FilterListSort
fListSort ("listsort")
 
static
TemplateFilterFactory::AutoRegister
< FilterTexLabel
fTexLabel ("texLabel")
 
static
TemplateFilterFactory::AutoRegister
< FilterTexIndex
fTexIndex ("texIndex")
 
static
TemplateFilterFactory::AutoRegister
< FilterPaginate
fPaginate ("paginate")
 
static
TemplateFilterFactory::AutoRegister
< FilterStripPath
fStripPath ("stripPath")
 
static
TemplateFilterFactory::AutoRegister
< FilterDecodeURL
fDecodeURL ("decodeURL")
 
static
TemplateFilterFactory::AutoRegister
< FilterAlphaIndex
fAlphaIndex ("alphaIndex")
 
static
TemplateFilterFactory::AutoRegister
< FilterDivisibleBy
fDivisibleBy ("divisibleby")
 
static
TemplateFilterFactory::AutoRegister
< FilterIsRelativeURL
fIsRelativeURL ("isRelativeURL")
 
static
TemplateFilterFactory::AutoRegister
< FilterIsAbsoluteURL
fIsAbsoluteURL ("isAbsoluteURL")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeIf
autoRefIf ("if")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeFor
autoRefFor ("for")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeMsg
autoRefMsg ("msg")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeSet
autoRefSet ("set")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeTree
autoRefTree ("recursetree")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeWith
autoRefWith ("with")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeBlock
autoRefBlock ("block")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeCycle
autoRefCycle ("cycle")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeRange
autoRefRange ("range")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeExtend
autoRefExtend ("extend")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeCreate
autoRefCreate ("create")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeRepeat
autoRefRepeat ("repeat")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeInclude
autoRefInclude ("include")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeMarkers
autoRefMarkers ("markers")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeTabbing
autoRefTabbing ("tabbing")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeResource
autoRefResource ("resource")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeEncoding
autoRefEncoding ("encoding")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeSpaceless
autoRefSpaceless ("spaceless")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeIndexEntry
autoRefIndexEntry ("indexentry")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeOpenSubIndex
autoRefOpenSubIndex ("opensubindex")
 
static
TemplateNodeFactory::AutoRegister
< TemplateNodeCloseSubIndex
autoRefCloseSubIndex ("closesubindex")
 

Macro Definition Documentation

#define ENABLE_TRACING   0

Definition at line 39 of file template.cpp.

#define TRACE (   x)

Definition at line 44 of file template.cpp.

Referenced by ExprAstFilter::apply(), ExprAstBinary::ExprAstBinary(), ExprAstFilter::ExprAstFilter(), ExprAstFilterAppl::ExprAstFilterAppl(), ExprAstFunctionVariable::ExprAstFunctionVariable(), ExprAstLiteral::ExprAstLiteral(), ExprAstNegate::ExprAstNegate(), ExprAstNumber::ExprAstNumber(), ExprAstUnary::ExprAstUnary(), ExprAstVariable::ExprAstVariable(), TemplateParser::parse(), ExpressionParser::parseAdditiveExpression(), ExpressionParser::parseAndExpression(), ExpressionParser::parseCompareExpression(), ExpressionParser::parseExpression(), ExpressionParser::parseFilter(), ExpressionParser::parseFilteredVariable(), ExpressionParser::parseIdentifier(), ExpressionParser::parseIdentifierOptionalArgs(), ExpressionParser::parseLiteral(), ExpressionParser::parseMultiplicativeExpression(), ExpressionParser::parseNotExpression(), ExpressionParser::parseNumber(), ExpressionParser::parseOrExpression(), ExpressionParser::parsePrimaryExpression(), ExpressionParser::parseUnaryExpression(), TemplateNodeList::render(), TemplateNodeBlock::TemplateNodeBlock(), TemplateNodeCloseSubIndex::TemplateNodeCloseSubIndex(), TemplateNodeCreate::TemplateNodeCreate(), TemplateNodeCycle::TemplateNodeCycle(), TemplateNodeEncoding::TemplateNodeEncoding(), TemplateNodeExtend::TemplateNodeExtend(), TemplateNodeFor::TemplateNodeFor(), TemplateNodeIf::TemplateNodeIf(), TemplateNodeInclude::TemplateNodeInclude(), TemplateNodeIndexEntry::TemplateNodeIndexEntry(), TemplateNodeMarkers::TemplateNodeMarkers(), TemplateNodeMsg::TemplateNodeMsg(), TemplateNodeOpenSubIndex::TemplateNodeOpenSubIndex(), TemplateNodeRange::TemplateNodeRange(), TemplateNodeRepeat::TemplateNodeRepeat(), TemplateNodeResource::TemplateNodeResource(), TemplateNodeSet::TemplateNodeSet(), TemplateNodeSpaceless::TemplateNodeSpaceless(), TemplateNodeTabbing::TemplateNodeTabbing(), TemplateNodeText::TemplateNodeText(), TemplateNodeTree::TemplateNodeTree(), TemplateNodeVariable::TemplateNodeVariable(), and TemplateNodeWith::TemplateNodeWith().

Function Documentation

static TemplateVariant getPathFunc ( const void *  ctx,
const QValueList< TemplateVariant > &   
)
static

Definition at line 2611 of file template.cpp.

References TemplateList::alloc(), and getPathListFunc().

Referenced by TemplateContextImpl::addIndexEntry().

{
getPathListFunc(entry,result);
return result;
}
static void getPathListFunc ( TemplateStructIntf entry,
TemplateList list 
)
static

Definition at line 2601 of file template.cpp.

References TemplateList::append(), TemplateStructIntf::get(), TemplateVariant::Struct, TemplateVariant::toStruct(), and TemplateVariant::type().

Referenced by getPathFunc().

{
TemplateVariant parent = entry->get("parent");
{
getPathListFunc(parent.toStruct(),list);
}
list->append(entry);
}
static QCString removeSpacesAroundEquals ( const char *  s)
static

Strips spaces surrounding = from string in, so foo = 10 bar=5 baz= 'hello' will become foo=10 bar=5 baz='hello'

Definition at line 105 of file template.cpp.

Referenced by TemplateNodeWith::TemplateNodeWith().

{
QCString result(s);
const char *p=result.data();
char *q = result.rawData();
char c;
while ((c=*p++))
{
if (c==' ') // found a space, see if there is a = as well
{
const char *t = p;
bool found=FALSE;
while (*t==' ' || *t=='=') { if (*t++=='=') found=TRUE; }
if (found)
{
c='=';
p=t; // move p to end of '\s*=\s*' sequence
}
}
*q++=c;
}
if (q<p) result.resize(q-result.data()+1);
return result;
}
static QValueList<QCString> split ( const QCString &  str,
const QCString &  sep,
bool  allowEmptyEntries = FALSE,
bool  cleanup = TRUE 
)
static

Definition at line 51 of file template.cpp.

Referenced by FlowChart::alignCommentNode(), assignBinding(), res2cc_cmd.File::convertToBytes(), VhdlDocGen::findAllArchitectures(), VhdlDocGen::findArchitecture(), formatBriefNote(), VhdlDocGen::getIndexWord(), Qhp::initialize(), VhdlDocGen::parseForBinding(), VhdlDocGen::parseForConfig(), TemplateNodeCycle::TemplateNodeCycle(), TemplateNodeFor::TemplateNodeFor(), TemplateNodeIndexEntry::TemplateNodeIndexEntry(), TemplateNodeWith::TemplateNodeWith(), VhdlDocGen::writeInlineClassLink(), VhdlDocGen::writeRecorUnit(), and VhdlDocGen::writeRecUnitDocu().

{
QValueList<QCString> lst;
int j = 0;
int i = str.find( sep, j );
while (i!=-1)
{
if ( str.mid(j,i-j).length() > 0 )
{
if (cleanup)
{
lst.append(str.mid(j,i-j).stripWhiteSpace());
}
else
{
lst.append(str.mid(j,i-j));
}
}
else if (allowEmptyEntries)
{
lst.append("");
}
j = i + sep.length();
i = str.find(sep,j);
}
int l = str.length() - 1;
if (str.mid(j,l-j+1).length()>0)
{
if (cleanup)
{
lst.append(str.mid(j,l-j+1).stripWhiteSpace());
}
else
{
lst.append(str.mid(j,l-j+1));
}
}
else if (allowEmptyEntries)
{
lst.append("");
}
return lst;
}
static void stripLeadingWhiteSpace ( QGString &  s)
static

Definition at line 3599 of file template.cpp.

Referenced by TemplateNodeCreate::render().

{
const char *src = s.data();
if (src)
{
char *dst = s.data();
char c;
bool skipSpaces=TRUE;
while ((c=*src++))
{
if (c=='\n') { *dst++=c; skipSpaces=TRUE; }
else if (c==' ' && skipSpaces) {}
else { *dst++=c; skipSpaces=FALSE; }
}
*dst='\0';
}
}

Variable Documentation

TemplateNodeFactory::AutoRegister<TemplateNodeCloseSubIndex> autoRefCloseSubIndex("closesubindex")
static
TemplateNodeFactory::AutoRegister<TemplateNodeCreate> autoRefCreate("create")
static
TemplateNodeFactory::AutoRegister<TemplateNodeEncoding> autoRefEncoding("encoding")
static
TemplateNodeFactory::AutoRegister<TemplateNodeExtend> autoRefExtend("extend")
static
TemplateNodeFactory::AutoRegister<TemplateNodeInclude> autoRefInclude("include")
static
TemplateNodeFactory::AutoRegister<TemplateNodeIndexEntry> autoRefIndexEntry("indexentry")
static
TemplateNodeFactory::AutoRegister<TemplateNodeMarkers> autoRefMarkers("markers")
static
TemplateNodeFactory::AutoRegister<TemplateNodeOpenSubIndex> autoRefOpenSubIndex("opensubindex")
static
TemplateNodeFactory::AutoRegister<TemplateNodeRepeat> autoRefRepeat("repeat")
static
TemplateNodeFactory::AutoRegister<TemplateNodeResource> autoRefResource("resource")
static
TemplateNodeFactory::AutoRegister<TemplateNodeSpaceless> autoRefSpaceless("spaceless")
static
TemplateNodeFactory::AutoRegister<TemplateNodeTabbing> autoRefTabbing("tabbing")
static
TemplateNodeFactory::AutoRegister<TemplateNodeTree> autoRefTree("recursetree")
static
TemplateFilterFactory::AutoRegister<FilterAlphaIndex> fAlphaIndex("alphaIndex")
static
TemplateFilterFactory::AutoRegister<FilterDecodeURL> fDecodeURL("decodeURL")
static
TemplateFilterFactory::AutoRegister<FilterDivisibleBy> fDivisibleBy("divisibleby")
static
TemplateFilterFactory::AutoRegister<FilterIsAbsoluteURL> fIsAbsoluteURL("isAbsoluteURL")
static
TemplateFilterFactory::AutoRegister<FilterIsRelativeURL> fIsRelativeURL("isRelativeURL")
static
TemplateFilterFactory::AutoRegister<FilterListSort> fListSort("listsort")
static
TemplateFilterFactory::AutoRegister<FilterPaginate> fPaginate("paginate")
static
TemplateFilterFactory::AutoRegister<FilterRelative> fRelative("relative")
static
TemplateFilterFactory::AutoRegister<FilterStripPath> fStripPath("stripPath")
static
TemplateFilterFactory::AutoRegister<FilterTexIndex> fTexIndex("texIndex")
static
TemplateFilterFactory::AutoRegister<FilterTexLabel> fTexLabel("texLabel")
static