Classes | Static Public Member Functions | Static Private Member Functions | List of all members
FilterGroupBy Class Reference

The implementation of the "groupBy" filter. More...

Classes

struct  ListElem
 
class  SortList
 

Static Public Member Functions

static TemplateVariant apply (const TemplateVariant &v, const TemplateVariant &args)
 

Static Private Member Functions

static QCString determineSortKey (TemplateStructIntf *s, const QCString &attribName)
 

Detailed Description

The implementation of the "groupBy" filter.

Definition at line 950 of file template.cpp.

Member Function Documentation

static TemplateVariant FilterGroupBy::apply ( const TemplateVariant v,
const TemplateVariant args 
)
inlinestatic

Definition at line 969 of file template.cpp.

970  {
972  {
973  //printf("FilterListSort::apply: v=%s args=%s\n",v.toString().data(),args.toString().data());
975 
976  TemplateVariant item;
978 
979  // create list of items based on v using the data in args as a sort key
980  SortList sortList;
981  for (it->toFirst();(it->current(item));it->toNext())
982  {
983  TemplateStructIntf *s = item.toStruct();
984  if (s)
985  {
986  QCString sortKey = determineSortKey(s,args.toString());
987  sortList.append(new ListElem(sortKey,item));
988  //printf("sortKey=%s\n",sortKey.data());
989  }
990  }
991  delete it;
992 
993  // sort the list
994  sortList.sort();
995 
996  // add sorted items to the result list
997  QListIterator<ListElem> sit(sortList);
998  ListElem *elem;
999  TemplateList *groupList=0;
1000  QCString prevKey;
1001  for (sit.toFirst();(elem=sit.current());++sit)
1002  {
1003  if (groupList==0 || elem->key!=prevKey)
1004  {
1005  groupList = TemplateList::alloc();
1006  result->append(groupList);
1007  prevKey = elem->key;
1008  }
1009  groupList->append(elem->value);
1010  }
1011  return result;
1012  }
1013  return v;
1014  }
static TemplateList * alloc()
Definition: template.cpp:420
static QCString result
virtual bool current(TemplateVariant &v) const =0
TemplateListIntf * toList() const
Definition: template.h:256
Default implementation of a context value of type list.
Definition: template.h:376
Abstract interface for a context value of type struct.
Definition: template.h:406
virtual void append(const TemplateVariant &v)
Definition: template.cpp:343
QCString toString() const
Definition: template.h:232
Abstract interface for a iterator of a list.
Definition: template.h:333
virtual TemplateListIntf::ConstIterator * createIterator() const =0
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
static QCString determineSortKey(TemplateStructIntf *s, const QCString &attribName)
Definition: template.cpp:1017
static QCString * s
Definition: config.cpp:1042
QCString & append(const char *s)
Definition: qcstring.cpp:383
static QCString FilterGroupBy::determineSortKey ( TemplateStructIntf s,
const QCString attribName 
)
inlinestaticprivate

Definition at line 1017 of file template.cpp.

1018  {
1019  TemplateVariant v = s->get(attribName);
1020  return v.toString();
1021  }
virtual TemplateVariant get(const char *name) const =0
QCString toString() const
Definition: template.h:232
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90

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