Doxygen
FilterGroupBy类 参考

The implementation of the "groupBy" filter 更多...

struct  ListElem
 

静态 Public 成员函数

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

静态 Private 成员函数

static QCString determineSortKey (const TemplateStructIntfPtr s, const QCString &attribName)
 

详细描述

The implementation of the "groupBy" filter

在文件 template.cpp1148 行定义.

成员函数说明

◆ apply()

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

在文件 template.cpp1157 行定义.

1158  {
1159  if (v.isList() && args.isString())
1160  {
1161  TemplateListIntfPtr list = v.toList();
1162  if (list)
1163  {
1164  //printf("FilterListSort::apply: v=%s args=%s\n",qPrint(v.toString()),qPrint(args.toString()));
1165  TemplateListIntf::ConstIteratorPtr it = list->createIterator();
1166 
1167  TemplateVariant item;
1169 
1170  // create list of items based on v using the data in args as a sort key
1171  using SortList = std::vector<ListElem>;
1172  SortList sortList;
1173  sortList.reserve(v.toList()->count());
1174  for (it->toFirst();(it->current(item));it->toNext())
1175  {
1176  TemplateStructIntfPtr s = item.toStruct();
1177  if (s)
1178  {
1179  QCString sortKey = determineSortKey(s,args.toString());
1180  sortList.emplace_back(sortKey,item);
1181  //printf("sortKey=%s\n",qPrint(sortKey));
1182  }
1183  }
1184 
1185  // sort the list
1186  std::sort(sortList.begin(),
1187  sortList.end(),
1188  [](const auto &lhs,const auto &rhs) { return lhs.key < rhs.key; });
1189 
1190  // add sorted items to the result list
1191  TemplateListPtr groupList;
1192  QCString prevKey;
1193  for (const auto &elem : sortList)
1194  {
1195  if (groupList==0 || elem.key!=prevKey)
1196  {
1197  groupList = TemplateList::alloc();
1198  result->append(std::static_pointer_cast<TemplateListIntf>(groupList));
1199  prevKey = elem.key;
1200  }
1201  groupList->append(elem.value);
1202  }
1203  return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
1204  }
1205  }
1206  return v;
1207  }

引用了 TemplateList::alloc(), QCString::append(), determineSortKey(), TemplateVariant::isList(), TemplateVariant::isString(), TemplateVariant::toList(), TemplateVariant::toString() , 以及 TemplateVariant::toStruct().

◆ determineSortKey()

static QCString FilterGroupBy::determineSortKey ( const TemplateStructIntfPtr  s,
const QCString attribName 
)
inlinestaticprivate

在文件 template.cpp1210 行定义.

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

引用了 TemplateVariant::toString().

被这些函数引用 apply().


该类的文档由以下文件生成:
TemplateVariant::toStruct
TemplateStructIntfPtr toStruct()
Returns the pointer to struct referenced by this variant or 0 if this variant does not have struct ty...
Definition: template.cpp:441
TemplateVariant::isList
constexpr bool isList() const
Returns TRUE if the variant holds a list value
Definition: template.h:213
TemplateListPtr
std::shared_ptr< TemplateList > TemplateListPtr
Definition: template.cpp:224
TemplateStructIntfPtr
std::shared_ptr< TemplateStructIntf > TemplateStructIntfPtr
Definition: template.h:33
TemplateListIntf::ConstIteratorPtr
std::unique_ptr< ConstIterator > ConstIteratorPtr
Definition: template.h:292
TemplateVariant
Variant type which can hold one value of a fixed set of types.
Definition: template.h:98
TemplateList::alloc
static TemplateListPtr alloc()
Creates an instance and returns a shared pointer to it
Definition: template.cpp:291
TemplateListIntfPtr
std::shared_ptr< TemplateListIntf > TemplateListIntfPtr
Definition: template.h:32
QCString::append
QCString & append(char c)
Definition: qcstring.h:318
TemplateVariant::toString
QCString toString() const
Returns the variant as a string.
Definition: template.cpp:399
TemplateVariant::toList
TemplateListIntfPtr toList()
Returns the pointer to list referenced by this variant or 0 if this variant does not have list type.
Definition: template.cpp:432
TemplateVariant::isString
constexpr bool isString() const
Returns TRUE if the variant holds a string value
Definition: template.h:209
FilterGroupBy::determineSortKey
static QCString determineSortKey(const TemplateStructIntfPtr s, const QCString &attribName)
Definition: template.cpp:1210
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108