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"

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  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  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< QCStringsplit (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< FilterAddfAdd ("add")
 
static TemplateFilterFactory::AutoRegister< FilterGetfGet ("get")
 
static TemplateFilterFactory::AutoRegister< FilterRawfRaw ("raw")
 
static TemplateFilterFactory::AutoRegister< FilterListfList ("list")
 
static TemplateFilterFactory::AutoRegister< FilterAppendfAppend ("append")
 
static TemplateFilterFactory::AutoRegister< FilterLengthfLength ("length")
 
static TemplateFilterFactory::AutoRegister< FilterNoWrapfNoWrap ("nowrap")
 
static TemplateFilterFactory::AutoRegister< FilterFlattenfFlatten ("flatten")
 
static TemplateFilterFactory::AutoRegister< FilterDefaultfDefault ("default")
 
static TemplateFilterFactory::AutoRegister< FilterPrependfPrepend ("prepend")
 
static TemplateFilterFactory::AutoRegister< FilterGroupByfGroupBy ("groupBy")
 
static TemplateFilterFactory::AutoRegister< FilterRelativefRelative ("relative")
 
static TemplateFilterFactory::AutoRegister< FilterListSortfListSort ("listsort")
 
static TemplateFilterFactory::AutoRegister< FilterTexLabelfTexLabel ("texLabel")
 
static TemplateFilterFactory::AutoRegister< FilterTexIndexfTexIndex ("texIndex")
 
static TemplateFilterFactory::AutoRegister< FilterPaginatefPaginate ("paginate")
 
static TemplateFilterFactory::AutoRegister< FilterStripPathfStripPath ("stripPath")
 
static TemplateFilterFactory::AutoRegister< FilterAlphaIndexfAlphaIndex ("alphaIndex")
 
static TemplateFilterFactory::AutoRegister< FilterDivisibleByfDivisibleBy ("divisibleby")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeIfautoRefIf ("if")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeForautoRefFor ("for")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeMsgautoRefMsg ("msg")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeSetautoRefSet ("set")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeTreeautoRefTree ("recursetree")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeWithautoRefWith ("with")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeBlockautoRefBlock ("block")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeCycleautoRefCycle ("cycle")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeRangeautoRefRange ("range")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeExtendautoRefExtend ("extend")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeCreateautoRefCreate ("create")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeRepeatautoRefRepeat ("repeat")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeIncludeautoRefInclude ("include")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeMarkersautoRefMarkers ("markers")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeTabbingautoRefTabbing ("tabbing")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeResourceautoRefResource ("resource")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeSpacelessautoRefSpaceless ("spaceless")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeIndexEntryautoRefIndexEntry ("indexentry")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeOpenSubIndexautoRefOpenSubIndex ("opensubindex")
 
static TemplateNodeFactory::AutoRegister< TemplateNodeCloseSubIndexautoRefCloseSubIndex ("closesubindex")
 

Macro Definition Documentation

#define ENABLE_TRACING   0

Definition at line 38 of file template.cpp.

#define TRACE (   x)

Definition at line 43 of file template.cpp.

Function Documentation

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

Definition at line 2499 of file template.cpp.

2500 {
2503  getPathListFunc(entry,result);
2504  return result;
2505 }
static TemplateList * alloc()
Definition: template.cpp:420
QList< Entry > entry
static QCString result
Default implementation of a context value of type list.
Definition: template.h:376
static void getPathListFunc(TemplateStructIntf *entry, TemplateList *list)
Definition: template.cpp:2489
Default implementation of a context value of type struct.
Definition: template.h:426
static void getPathListFunc ( TemplateStructIntf entry,
TemplateList list 
)
static

Definition at line 2489 of file template.cpp.

2490 {
2491  TemplateVariant parent = entry->get("parent");
2492  if (parent.type()==TemplateVariant::Struct)
2493  {
2494  getPathListFunc(parent.toStruct(),list);
2495  }
2496  list->append(entry);
2497 }
virtual TemplateVariant get(const char *name) const =0
static void getPathListFunc(TemplateStructIntf *entry, TemplateList *list)
Definition: template.cpp:2489
virtual void append(const TemplateVariant &v)
Definition: template.cpp:343
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
TemplateStructIntf * toStruct() const
Definition: template.h:264
Type type() const
Definition: template.h:142
def parent(G, child, parent_type)
Definition: graph.py:67
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 104 of file template.cpp.

105 {
106  QCString result(s);
107  const char *p=result.data();
108  char *q = result.rawData();
109  char c;
110  while ((c=*p++))
111  {
112  if (c==' ') // found a space, see if there is a = as well
113  {
114  const char *t = p;
115  bool found=FALSE;
116  while (*t==' ' || *t=='=') { if (*t++=='=') found=TRUE; }
117  if (found)
118  {
119  c='=';
120  p=t; // move p to end of '\s*=\s*' sequence
121  }
122  }
123  *q++=c;
124  }
125  if (q<p) result.resize(q-result.data()+1);
126  return result;
127 }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
static QCString result
const bool FALSE
Definition: qglobal.h:370
p
Definition: test.py:223
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
static QValueList<QCString> split ( const QCString str,
const QCString sep,
bool  allowEmptyEntries = FALSE,
bool  cleanup = TRUE 
)
static

Definition at line 50 of file template.cpp.

52 {
54 
55  int j = 0;
56  int i = str.find( sep, j );
57 
58  while (i!=-1)
59  {
60  if ( str.mid(j,i-j).length() > 0 )
61  {
62  if (cleanup)
63  {
64  lst.append(str.mid(j,i-j).stripWhiteSpace());
65  }
66  else
67  {
68  lst.append(str.mid(j,i-j));
69  }
70  }
71  else if (allowEmptyEntries)
72  {
73  lst.append("");
74  }
75  j = i + sep.length();
76  i = str.find(sep,j);
77  }
78 
79  int l = str.length() - 1;
80  if (str.mid(j,l-j+1).length()>0)
81  {
82  if (cleanup)
83  {
84  lst.append(str.mid(j,l-j+1).stripWhiteSpace());
85  }
86  else
87  {
88  lst.append(str.mid(j,l-j+1));
89  }
90  }
91  else if (allowEmptyEntries)
92  {
93  lst.append("");
94  }
95 
96  return lst;
97 }
QCString stripWhiteSpace() const
Definition: qcstring.cpp:295
Iterator append(const T &x)
Definition: qvaluelist.h:372
uint length() const
Definition: qcstring.h:195
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
static QStrList * l
Definition: config.cpp:1044
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
static void stripLeadingWhiteSpace ( QGString s)
static

Definition at line 3459 of file template.cpp.

3460 {
3461  const char *src = s.data();
3462  if (src)
3463  {
3464  char *dst = s.data();
3465  char c;
3466  bool skipSpaces=TRUE;
3467  while ((c=*src++))
3468  {
3469  if (c=='\n') { *dst++=c; skipSpaces=TRUE; }
3470  else if (c==' ' && skipSpaces) {}
3471  else { *dst++=c; skipSpaces=FALSE; }
3472  }
3473  *dst='\0';
3474  }
3475 }
char * data() const
Definition: qgstring.h:42
const bool FALSE
Definition: qglobal.h:370
const bool TRUE
Definition: qglobal.h:371

Variable Documentation

TemplateNodeFactory::AutoRegister<TemplateNodeCloseSubIndex> autoRefCloseSubIndex("closesubindex")
static
TemplateNodeFactory::AutoRegister<TemplateNodeCreate> autoRefCreate("create")
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<FilterDivisibleBy> fDivisibleBy("divisibleby")
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