Doxygen
FilterPaginate类 参考

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

静态 Public 成员函数

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

详细描述

The implementation of the "paginate" filter

在文件 template.cpp1239 行定义.

成员函数说明

◆ apply()

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

在文件 template.cpp1242 行定义.

1243  {
1244  if (v.isValid() && v.isList() &&
1245  args.isValid() && args.isInt())
1246  {
1247  int pageSize = args.toInt();
1248  const TemplateListIntfPtr list = v.toList();
1250  TemplateListIntf::ConstIteratorPtr it = list->createIterator();
1251  TemplateVariant item;
1252  TemplateListPtr pageList;
1253  int i = 0;
1254  for (it->toFirst();(it->current(item));it->toNext())
1255  {
1256  if (pageList==0)
1257  {
1258  pageList = TemplateList::alloc();
1259  result->append(std::static_pointer_cast<TemplateListIntf>(pageList));
1260  }
1261  pageList->append(item);
1262  i++;
1263  if (i==pageSize) // page is full start a new one
1264  {
1265  pageList=0;
1266  i=0;
1267  }
1268  }
1269  return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
1270  }
1271  else // wrong arguments
1272  {
1273  return v;
1274  }
1275  }

引用了 TemplateList::alloc(), TemplateVariant::isInt(), TemplateVariant::isList(), TemplateVariant::isValid(), TemplateVariant::toInt() , 以及 TemplateVariant::toList().


该类的文档由以下文件生成:
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
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
TemplateVariant::isInt
constexpr bool isInt() const
Returns TRUE if the variant holds an integer value
Definition: template.h:207
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
TemplateVariant::isValid
constexpr bool isValid() const
Returns TRUE if the variant holds a valid value, or FALSE otherwise
Definition: template.h:203
TemplateVariant::toInt
int toInt() const
Returns the variant as an integer.
Definition: template.cpp:383
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