My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | List of all members
FilterPaginate Class Reference

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

Static Public Member Functions

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

Detailed Description

The implementation of the "paginate" filter.

Definition at line 1053 of file template.cpp.

Member Function Documentation

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

Definition at line 1056 of file template.cpp.

References TemplateList::alloc(), TemplateList::append(), TemplateListIntf::createIterator(), TemplateListIntf::ConstIterator::current(), TemplateVariant::Integer, TemplateVariant::isValid(), TemplateVariant::List, TemplateListIntf::ConstIterator::toFirst(), TemplateVariant::toInt(), TemplateVariant::toList(), TemplateListIntf::ConstIterator::toNext(), and TemplateVariant::type().

{
if (v.isValid() && v.type()==TemplateVariant::List &&
{
int pageSize = args.toInt();
TemplateListIntf *list = v.toList();
TemplateList *pageList=0;
int i = 0;
for (it->toFirst();(it->current(item));it->toNext())
{
if (pageList==0)
{
pageList = TemplateList::alloc();
result->append(pageList);
}
pageList->append(item);
i++;
if (i==pageSize) // page is full start a new one
{
pageList=0;
i=0;
}
}
delete it;
return result;
}
else // wrong arguments
{
return v;
}
}

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