My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 957 of file template.cpp.

Member Function Documentation

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

Definition at line 976 of file template.cpp.

References TemplateList::alloc(), TemplateList::append(), TemplateListIntf::createIterator(), TemplateListIntf::ConstIterator::current(), determineSortKey(), FilterGroupBy::ListElem::key, TemplateVariant::List, TemplateVariant::String, TemplateListIntf::ConstIterator::toFirst(), TemplateVariant::toList(), TemplateListIntf::ConstIterator::toNext(), TemplateVariant::toString(), TemplateVariant::toStruct(), TemplateVariant::type(), and FilterGroupBy::ListElem::value.

{
{
//printf("FilterListSort::apply: v=%s args=%s\n",v.toString().data(),args.toString().data());
// 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())
{
if (s)
{
QCString sortKey = determineSortKey(s,args.toString());
sortList.append(new ListElem(sortKey,item));
//printf("sortKey=%s\n",sortKey.data());
}
}
delete it;
// sort the list
sortList.sort();
// add sorted items to the result list
QListIterator<ListElem> sit(sortList);
ListElem *elem;
TemplateList *groupList=0;
QCString prevKey;
for (sit.toFirst();(elem=sit.current());++sit)
{
if (groupList==0 || elem->key!=prevKey)
{
groupList = TemplateList::alloc();
result->append(groupList);
prevKey = elem->key;
}
groupList->append(elem->value);
}
return result;
}
return v;
}
static QCString FilterGroupBy::determineSortKey ( TemplateStructIntf s,
const QCString &  attribName 
)
inlinestaticprivate

Definition at line 1024 of file template.cpp.

References TemplateStructIntf::get(), and TemplateVariant::toString().

Referenced by apply().

{
TemplateVariant v = s->get(attribName);
return v.toString();
}

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