20 #include <qvaluelist.h> 100 Delegate() : m_objectPtr(0) , m_stubPtr(0) {}
103 template <
class T, TemplateVariant (T::*TMethod)(const QValueList<TemplateVariant> &) const>
107 d.m_objectPtr = objectPtr;
108 d.m_stubPtr = &methodStub<T, TMethod>;
123 return (*m_stubPtr)(m_objectPtr, args);
127 const void* m_objectPtr;
130 template <
class T, TemplateVariant (T::*TMethod)(const QValueList<TemplateVariant> &) const>
133 T* p = (T*)(objectPtr);
134 return (p->*TMethod)(args);
139 enum Type { None, Bool, Integer, String, Struct, List, Function };
149 case None:
return "none";
150 case Bool:
return "bool";
151 case Integer:
return "integer";
152 case String:
return "string";
153 case Struct:
return "struct";
154 case List:
return "list";
155 case Function:
return "function";
217 if (m_type==TemplateVariant::List && other.m_type==TemplateVariant::List)
219 return m_list==other.m_list;
221 else if (m_type==TemplateVariant::Struct && other.m_type==TemplateVariant::Struct)
223 return m_strukt==other.m_strukt;
237 case Bool:
return m_boolVal ?
"true" :
"false";
238 case Integer:
return QCString().setNum(m_intVal);
239 case String:
return m_strVal;
240 case Struct:
return "[struct]";
241 case List:
return "[list]";
242 case Function:
return "[function]";
258 return m_type==List ? m_list : 0;
266 return m_type==Struct ? m_strukt : 0;
274 if (m_type==Function)
return m_delegate(args);
287 bool raw()
const {
return m_raw; }
316 T &operator*()
const {
return *m_obj; }
317 T *operator->()
const {
return m_obj; }
318 T *
get()
const {
return m_obj; }
339 virtual void toFirst() = 0;
341 virtual void toLast() = 0;
343 virtual void toNext() = 0;
345 virtual void toPrev() = 0;
358 virtual int count()
const = 0;
369 virtual int addRef() = 0;
372 virtual int release() = 0;
380 virtual int count()
const;
383 virtual int addRef();
384 virtual int release();
418 virtual int addRef() = 0;
421 virtual int release() = 0;
431 virtual int addRef();
432 virtual int release();
463 virtual void enableTabbing(
bool b) = 0;
475 virtual void reset() = 0;
495 virtual void push() = 0;
498 virtual void pop() = 0;
524 virtual void setOutputDirectory(
const QCString &dir) = 0;
591 void printIncludeContext(
const char *fileName,
int line)
const;
594 void setTemplateDir(
const char *dirName);
600 void enterBlock(
const QCString &fileName,
const QCString &blockName,
int line);
606 void setOutputExtension(
const char *extension);
Abstract interface for a template context.
Definition: template.h:489
Class representing an 'create' tag in a template.
Definition: template.cpp:3618
TemplateListIntf * toList() const
Returns the pointer to list referenced by this variant or 0 if this variant does not have list type...
Definition: template.h:256
Abstract interface for a template.
Definition: template.h:542
TemplateVariant operator()(const QValueList< TemplateVariant > &args) const
Invokes the function/method stored in the delegate.
Definition: template.h:121
~TemplateVariant()
Destroys the Variant object.
Definition: template.cpp:159
TemplateVariant(* StubType)(const void *obj, const QValueList< TemplateVariant > &args)
Callback type to use when creating a delegate from a function.
Definition: template.h:98
TemplateVariant(int v)
Constructs a new variant with a integer value v.
Definition: template.h:170
static Delegate fromMethod(const T *objectPtr)
Creates a delegate given an object.
Definition: template.h:104
TemplateStructIntf * toStruct() const
Returns the pointer to struct referenced by this variant or 0 if this variant does not have struct ty...
Definition: template.h:264
bool raw() const
Returns whether or not the value of the Value is raw.
Definition: template.h:287
Default implementation of a context value of type list.
Definition: template.h:376
TemplateVariant call(const QValueList< TemplateVariant > &args)
Return the result of apply this function with args.
Definition: template.h:272
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)
Creates a delegate given an object, and a plain function.
Definition: template.h:112
Private data of the template engine.
Definition: template.cpp:5059
Class representing a 'block' tag in a template.
Definition: template.cpp:3381
TemplateVariant & operator=(const TemplateVariant &v)
Assigns the value of the variant v to this variant.
Definition: template.cpp:181
bool operator==(TemplateVariant &other)
Compares this QVariant with v and returns true if they are equal; otherwise returns false...
Definition: template.h:211
Definition: template.h:305
Helper class to create a delegate that can store a function/method call.
Definition: template.h:94
Private data of a template list object.
Definition: template.cpp:304
QCString toString() const
Returns the variant as a string.
Definition: template.h:232
virtual ~ConstIterator()
Destructor for the iterator.
Definition: template.h:337
virtual ~TemplateListIntf()
Destroys the list.
Definition: template.h:355
virtual ~TemplateStructIntf()
Destroys the struct.
Definition: template.h:410
TemplateVariant(const Delegate &delegate)
Constructs a new variant which represents a method call.
Definition: template.h:195
Abstract interface for a iterator of a list.
Definition: template.h:333
Interface used to escape characters in a string.
Definition: template.h:457
TemplateVariant()
Constructs an invalid variant.
Definition: template.h:164
bool toBool() const
Returns the variant as a boolean.
Definition: template.cpp:208
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
Private data of a template struct object.
Definition: template.cpp:242
Engine to create templates and template contexts.
Definition: template.h:559
void setRaw(bool b)
Sets whether or not the value of the Variant should be escaped or written as-is (raw).
Definition: template.h:282
int toInt() const
Returns the variant as an integer.
Definition: template.cpp:223
QCString typeAsString() const
Return a string representation of the type of the value stored in the variant.
Definition: template.h:145
TemplateVariant(bool b)
Constructs a new variant with a boolean value b.
Definition: template.h:167
virtual ~Template()
Destructor.
Definition: template.h:546
TemplateVariant(const char *s, bool raw=FALSE)
Constructs a new variant with a string value s.
Definition: template.h:173
Type
Types of data that can be stored in a TemplateVariant.
Definition: template.h:139
Type type() const
Returns the type of the value stored in the variant.
Definition: template.h:142
Abstract read-only interface for a context value of type list.
Definition: template.h:329
bool isValid() const
Returns TRUE if the variant holds a valid value, or FALSE otherwise.
Definition: template.h:161
This is an alternative implementation of QCString.
Definition: qcstring.h:131
Default implementation of a context value of type struct.
Definition: template.h:426
Definition: template.cpp:350
TemplateVariant(const QCString &s, bool raw=FALSE)
Constructs a new variant with a string value s.
Definition: template.h:176
Interface used to remove redundant spaces inside a spaceless block.
Definition: template.h:469