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

The implementation of the "listsort" 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 &arg)
 

Detailed Description

The implementation of the "listsort" filter.

Definition at line 862 of file template.cpp.

Member Function Documentation

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

Definition at line 881 of file template.cpp.

882  {
884  {
885  //printf("FilterListSort::apply: v=%s args=%s\n",v.toString().data(),args.toString().data());
887 
888  TemplateVariant item;
890 
891  // create list of items based on v using the data in args as a sort key
892  SortList sortList;
893  for (it->toFirst();(it->current(item));it->toNext())
894  {
895  TemplateStructIntf *s = item.toStruct();
896  if (s)
897  {
898  QCString sortKey = determineSortKey(s,args.toString());
899  sortList.append(new ListElem(sortKey,item));
900  //printf("sortKey=%s\n",sortKey.data());
901  }
902  }
903  delete it;
904 
905  // sort the list
906  sortList.sort();
907 
908  // add sorted items to the result list
909  QListIterator<ListElem> sit(sortList);
910  ListElem *elem;
911  for (sit.toFirst();(elem=sit.current());++sit)
912  {
913  result->append(elem->value);
914  }
915  return result;
916  }
917  return v;
918  }
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 * s
Definition: config.cpp:1042
QCString & append(const char *s)
Definition: qcstring.cpp:383
static QCString determineSortKey(TemplateStructIntf *s, const QCString &arg)
Definition: template.cpp:921
static QCString FilterListSort::determineSortKey ( TemplateStructIntf s,
const QCString arg 
)
inlinestaticprivate

Definition at line 921 of file template.cpp.

922  {
923  int i,p=0;
925  while ((i=arg.find("{{",p))!=-1)
926  {
927  result+=arg.mid(p,i-p);
928  int j=arg.find("}}",i+2);
929  if (j!=-1)
930  {
931  QCString var = arg.mid(i+2,j-i-2);
932  TemplateVariant val=s->get(var);
933  //printf("found argument %s value=%s\n",var.data(),val.toString().data());
934  result+=val.toString();
935  p=j+2;
936  }
937  else
938  {
939  p=i+1;
940  }
941  }
942  result+=arg.right(arg.length()-p);
943  return result;
944  }
static QCString result
uint length() const
Definition: qcstring.h:195
virtual TemplateVariant get(const char *name) const =0
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
QCString toString() const
Definition: template.h:232
QCString right(uint len) const
Definition: qcstring.cpp:231
p
Definition: test.py:223
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
int var
Definition: 018_def.c:9

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