Commit e0c3517f authored by Dimitri van Heesch's avatar Dimitri van Heesch

Addition of module data to context and alphaIndex filter

parent a7c14ac7
This diff is collapsed.
/******************************************************************************
*
* Copyright (C) 1997-2014 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#ifndef CONTEXT_H #ifndef CONTEXT_H
#define CONTEXT_H #define CONTEXT_H
...@@ -364,10 +379,10 @@ class ModuleContext : public RefCountedContext, public TemplateStructIntf ...@@ -364,10 +379,10 @@ class ModuleContext : public RefCountedContext, public TemplateStructIntf
//---------------------------------------------------- //----------------------------------------------------
class NestedClassListContext : public RefCountedContext, public TemplateListIntf class ClassListContext : public RefCountedContext, public TemplateListIntf
{ {
public: public:
static NestedClassListContext *alloc() { return new NestedClassListContext; } static ClassListContext *alloc() { return new ClassListContext; }
// TemplateListIntf // TemplateListIntf
virtual int count() const; virtual int count() const;
...@@ -376,55 +391,28 @@ class NestedClassListContext : public RefCountedContext, public TemplateListIntf ...@@ -376,55 +391,28 @@ class NestedClassListContext : public RefCountedContext, public TemplateListIntf
virtual int addRef() { return RefCountedContext::addRef(); } virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); } virtual int release() { return RefCountedContext::release(); }
void append(ClassDef *cd);
private: private:
NestedClassListContext(); ClassListContext();
~NestedClassListContext(); ~ClassListContext();
class Private; class Private;
Private *p; Private *p;
}; };
//---------------------------------------------------- //----------------------------------------------------
class NestedNamespaceListContext : public RefCountedContext, public TemplateListIntf class ClassIndexContext : public RefCountedContext, public TemplateStructIntf
{ {
public: public:
static NestedNamespaceListContext *alloc() { return new NestedNamespaceListContext; } static ClassIndexContext *alloc() { return new ClassIndexContext; }
// TemplateListIntf // TemplateStructIntf methods
virtual int count() const; virtual TemplateVariant get(const char *name) const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
virtual int addRef() { return RefCountedContext::addRef(); } virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); } virtual int release() { return RefCountedContext::release(); }
void append(NamespaceDef *cd);
private: private:
NestedNamespaceListContext(); ClassIndexContext();
~NestedNamespaceListContext(); ~ClassIndexContext();
class Private;
Private *p;
};
//----------------------------------------------------
class ClassListContext : public RefCountedContext, public TemplateListIntf
{
public:
static ClassListContext *alloc() { return new ClassListContext; }
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }
private:
ClassListContext();
~ClassListContext();
class Private; class Private;
Private *p; Private *p;
}; };
...@@ -537,6 +525,8 @@ class NestingContext : public RefCountedContext, public TemplateListIntf ...@@ -537,6 +525,8 @@ class NestingContext : public RefCountedContext, public TemplateListIntf
void addFiles(const FileNameList &); void addFiles(const FileNameList &);
void addFiles(const FileList &); void addFiles(const FileList &);
void addPages(const PageSDict &pages,bool rootOnly); void addPages(const PageSDict &pages,bool rootOnly);
void addModules(const GroupSDict &modules);
void addModules(const GroupList &modules);
private: private:
NestingContext(const NestingNodeContext *parent,int level); NestingContext(const NestingNodeContext *parent,int level);
...@@ -667,60 +657,22 @@ class FileTreeContext : public RefCountedContext, public TemplateStructIntf ...@@ -667,60 +657,22 @@ class FileTreeContext : public RefCountedContext, public TemplateStructIntf
//---------------------------------------------------- //----------------------------------------------------
class PageNodeContext : public RefCountedContext, public TemplateStructIntf class PageListContext : public RefCountedContext, public TemplateListIntf
{
public:
static PageNodeContext *alloc(PageDef *pd) { return new PageNodeContext(pd); }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }
private:
PageNodeContext(PageDef *);
~PageNodeContext();
class Private;
Private *p;
};
//----------------------------------------------------
class PageNodeListContext : public RefCountedContext, public TemplateListIntf
{ {
public: public:
static PageNodeListContext *alloc() { return new PageNodeListContext; } static PageListContext *alloc(const PageSDict *pages) { return new PageListContext(pages); }
// TemplateListIntf // TemplateListIntf methods
virtual int count() const; virtual int count() const;
virtual TemplateVariant at(int index) const; virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const; virtual TemplateListIntf::ConstIterator *createIterator() const;
virtual int addRef() { return RefCountedContext::addRef(); } virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); } virtual int release() { return RefCountedContext::release(); }
void addPages(const PageSDict &,bool rootOnly); void addPages(const PageSDict &pages);
private:
PageNodeListContext();
~PageNodeListContext();
class Private;
Private *p;
};
//----------------------------------------------------
class PageListContext : public RefCountedContext, public TemplateStructIntf
{
public:
static PageListContext *alloc() { return new PageListContext; }
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }
private: private:
PageListContext(); PageListContext(const PageSDict *pages);
~PageListContext(); ~PageListContext();
class Private; class Private;
Private *p; Private *p;
......
...@@ -71,6 +71,7 @@ GroupDef::GroupDef(const char *df,int dl,const char *na,const char *t, ...@@ -71,6 +71,7 @@ GroupDef::GroupDef(const char *df,int dl,const char *na,const char *t,
visited = 0; visited = 0;
groupScope = 0; groupScope = 0;
m_subGrouping=Config_getBool("SUBGROUPING");
} }
GroupDef::~GroupDef() GroupDef::~GroupDef()
...@@ -1512,3 +1513,9 @@ void GroupDef::updateLanguage(const Definition *d) ...@@ -1512,3 +1513,9 @@ void GroupDef::updateLanguage(const Definition *d)
} }
} }
bool GroupDef::hasDetailedDescription() const
{
static bool repeatBrief = Config_getBool("REPEAT_BRIEF");
return ((!briefDescription().isEmpty() && repeatBrief) ||
!documentation().isEmpty());
}
...@@ -79,6 +79,7 @@ class GroupDef : public Definition ...@@ -79,6 +79,7 @@ class GroupDef : public Definition
void addListReferences(); void addListReferences();
void sortMemberLists(); void sortMemberLists();
bool subGrouping() const { return m_subGrouping; }
bool visited; // number of times accessed for output - KPW bool visited; // number of times accessed for output - KPW
...@@ -101,6 +102,7 @@ class GroupDef : public Definition ...@@ -101,6 +102,7 @@ class GroupDef : public Definition
PageSDict * getPages() const { return pageDict; } PageSDict * getPages() const { return pageDict; }
DirList * getDirs() const { return dirList; } DirList * getDirs() const { return dirList; }
PageSDict * getExamples() const { return exampleDict; } PageSDict * getExamples() const { return exampleDict; }
bool hasDetailedDescription() const;
//MemberList* getMembers() const { return allMemberList; } //MemberList* getMembers() const { return allMemberList; }
void sortSubGroups(); void sortSubGroups();
...@@ -150,6 +152,7 @@ class GroupDef : public Definition ...@@ -150,6 +152,7 @@ class GroupDef : public Definition
QList<MemberList> m_memberLists; QList<MemberList> m_memberLists;
MemberGroupSDict *memberGroupSDict; MemberGroupSDict *memberGroupSDict;
bool m_subGrouping;
}; };
......
/******************************************************************************
*
* Copyright (C) 1997-2014 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#include "template.h" #include "template.h"
#include <stdio.h> #include <stdio.h>
...@@ -347,6 +362,21 @@ TemplateVariant::Type TemplateVariant::type() const ...@@ -347,6 +362,21 @@ TemplateVariant::Type TemplateVariant::type() const
return p->type; return p->type;
} }
QCString TemplateVariant::typeAsString() const
{
switch (p->type)
{
case None: return "none";
case Bool: return "bool";
case Integer: return "integer";
case String: return "string";
case Struct: return "struct";
case List: return "list";
case Function: return "function";
}
return "invalid";
}
bool TemplateVariant::isValid() const bool TemplateVariant::isValid() const
{ {
return p->type!=None; return p->type!=None;
...@@ -963,7 +993,7 @@ class FilterListSort ...@@ -963,7 +993,7 @@ class FilterListSort
//-------------------------------------------------------------------- //--------------------------------------------------------------------
/** @brief The implementation of the "listsort" filter */ /** @brief The implementation of the "paginate" filter */
class FilterPaginate class FilterPaginate
{ {
public: public:
...@@ -1006,6 +1036,130 @@ class FilterPaginate ...@@ -1006,6 +1036,130 @@ class FilterPaginate
//-------------------------------------------------------------------- //--------------------------------------------------------------------
/** @brief The implementation of the "alphaIndex" filter */
class FilterAlphaIndex
{
private:
struct ListElem
{
ListElem(uint k,const TemplateVariant &v) : key(k), value(v) {}
uint key;
TemplateVariant value;
};
class SortList : public QList<ListElem>
{
public:
SortList() { setAutoDelete(TRUE); }
private:
int compareValues(const ListElem *item1,const ListElem *item2) const
{
return item2->key-item1->key;
}
};
static QCString keyToLetter(uint startLetter)
{
return QString(QChar(startLetter)).utf8();
}
static QCString keyToLabel(uint startLetter)
{
char s[10];
if (startLetter>0x20 && startLetter<=0x7f) // printable ASCII character
{
s[0]=(char)startLetter;
s[1]=0;
}
else
{
const char hex[]="0123456789abcdef";
int i=0;
s[i++]='0';
s[i++]='x';
if (startLetter>(1<<24)) // 4 byte character
{
s[i++]=hex[(startLetter>>28)&0xf];
s[i++]=hex[(startLetter>>24)&0xf];
}
if (startLetter>(1<<16)) // 3 byte character
{
s[i++]=hex[(startLetter>>20)&0xf];
s[i++]=hex[(startLetter>>16)&0xf];
}
if (startLetter>(1<<8)) // 2 byte character
{
s[i++]=hex[(startLetter>>12)&0xf];
s[i++]=hex[(startLetter>>8)&0xf];
}
// one byte character
s[i++]=hex[(startLetter>>4)&0xf];
s[i++]=hex[(startLetter>>0)&0xf];
s[i++]=0;
}
return s;
}
static uint determineSortKey(TemplateStructIntf *s,const QCString &attribName)
{
TemplateVariant v = s->get(attribName);
int index = getPrefixIndex(v.toString());
return getUtf8CodeToUpper(v.toString(),index);
}
public:
static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &args)
{
if (v.type()==TemplateVariant::List && args.type()==TemplateVariant::String)
{
//printf("FilterListSort::apply: v=%s args=%s\n",v.toString().data(),args.toString().data());
TemplateListIntf::ConstIterator *it = v.toList()->createIterator();
TemplateVariant item;
TemplateList *result = TemplateList::alloc();
// create list of items based on v using the data in args as a sort key
SortList sortList;
for (it->toFirst();(it->current(item));it->toNext())
{
TemplateStructIntf *s = item.toStruct();
if (s)
{
uint sortKey = determineSortKey(s,args.toString());
sortList.append(new ListElem(sortKey,item));
//printf("sortKey=%s\n",sortKey.data());
}
}
delete it;
// sort the list
sortList.sort();
// create an index from the sorted list
uint letter=0;
QListIterator<ListElem> sit(sortList);
ListElem *elem;
TemplateStruct *indexNode = 0;
TemplateList *indexList = 0;
for (sit.toFirst();(elem=sit.current());++sit)
{
if (letter!=elem->key || indexNode==0)
{
// create new indexNode
indexNode = TemplateStruct::alloc();
indexList = TemplateList::alloc();
indexNode->set("letter", keyToLetter(elem->key));
indexNode->set("label", keyToLabel(elem->key));
indexNode->set("classes",indexList);
result->append(indexNode);
letter=elem->key;
}
indexList->append(elem->value);
}
return result;
}
return v;
}
};
//--------------------------------------------------------------------
/** @brief The implementation of the "default" filter */ /** @brief The implementation of the "default" filter */
class FilterStripPath class FilterStripPath
{ {
...@@ -1132,6 +1286,7 @@ static TemplateFilterFactory::AutoRegister<FilterPrepend> fPrepend("prepend" ...@@ -1132,6 +1286,7 @@ static TemplateFilterFactory::AutoRegister<FilterPrepend> fPrepend("prepend"
static TemplateFilterFactory::AutoRegister<FilterListSort> fListSort("listsort"); static TemplateFilterFactory::AutoRegister<FilterListSort> fListSort("listsort");
static TemplateFilterFactory::AutoRegister<FilterPaginate> fPaginate("paginate"); static TemplateFilterFactory::AutoRegister<FilterPaginate> fPaginate("paginate");
static TemplateFilterFactory::AutoRegister<FilterStripPath> fStripPath("stripPath"); static TemplateFilterFactory::AutoRegister<FilterStripPath> fStripPath("stripPath");
static TemplateFilterFactory::AutoRegister<FilterAlphaIndex> fAlphaIndex("alphaIndex");
static TemplateFilterFactory::AutoRegister<FilterDivisibleBy> fDivisibleBy("divisibleby"); static TemplateFilterFactory::AutoRegister<FilterDivisibleBy> fDivisibleBy("divisibleby");
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -2898,7 +3053,7 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor> ...@@ -2898,7 +3053,7 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor>
} }
else // simple type... else // simple type...
{ {
ci->warn(m_templateName,m_line,"for requires a variable of list type!"); ci->warn(m_templateName,m_line,"for requires a variable of list type, got type '%s'!",v.typeAsString().data());
} }
} }
} }
...@@ -4499,6 +4654,11 @@ TemplateContext *TemplateEngine::createContext() const ...@@ -4499,6 +4654,11 @@ TemplateContext *TemplateEngine::createContext() const
return new TemplateContextImpl(this); return new TemplateContextImpl(this);
} }
void TemplateEngine::destroyContext(TemplateContext *ctx)
{
delete ctx;
}
Template *TemplateEngine::loadByName(const QCString &fileName,int line) Template *TemplateEngine::loadByName(const QCString &fileName,int line)
{ {
return p->loadByName(fileName,line); return p->loadByName(fileName,line);
......
/******************************************************************************
*
* Copyright (C) 1997-2014 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#ifndef TEMPLATE_H #ifndef TEMPLATE_H
#define TEMPLATE_H #define TEMPLATE_H
...@@ -126,6 +141,9 @@ class TemplateVariant ...@@ -126,6 +141,9 @@ class TemplateVariant
/** Returns the type of the value stored in the variant */ /** Returns the type of the value stored in the variant */
Type type() const; Type type() const;
/** Return a string representation of the type of the value stored in the variant */
QCString typeAsString() const;
/** Returns TRUE if the variant holds a valid value, or FALSE otherwise */ /** Returns TRUE if the variant holds a valid value, or FALSE otherwise */
bool isValid() const; bool isValid() const;
...@@ -485,6 +503,11 @@ class TemplateEngine ...@@ -485,6 +503,11 @@ class TemplateEngine
*/ */
TemplateContext *createContext() const; TemplateContext *createContext() const;
/** Destroys a context created via createContext().
* @param[in] ctx The context.
*/
void destroyContext(TemplateContext *ctx);
/** Creates a new template whole contents are in a file. /** Creates a new template whole contents are in a file.
* @param[in] fileName The name of the file containing the * @param[in] fileName The name of the file containing the
* template data * template data
......
...@@ -1224,7 +1224,7 @@ class TranslatorEnglish : public Translator ...@@ -1224,7 +1224,7 @@ class TranslatorEnglish : public Translator
*/ */
virtual QCString trGroup(bool first_capital, bool singular) virtual QCString trGroup(bool first_capital, bool singular)
{ {
QCString result((first_capital ? "Group" : "group")); QCString result((first_capital ? "Module" : "module"));
if (!singular) result+="s"; if (!singular) result+="s";
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment