Doxygen
FilterKeep类 参考

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

静态 Public 成员函数

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

详细描述

The implementation of the "keep" filter

在文件 template.cpp818 行定义.

成员函数说明

◆ apply()

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

在文件 template.cpp821 行定义.

822  {
823  if (v.isValid() && (v.isList()) && args.isString())
824  {
825  TemplateListIntfPtr list = v.toList();
826  if (list)
827  {
828  //printf("FilterKeep::apply: v=%s args=%s\n",qPrint(v.toString()),qPrint(args.toString()));
829  TemplateListIntf::ConstIteratorPtr it = list->createIterator();
830 
832  TemplateVariant item;
833  for (it->toFirst();(it->current(item));it->toNext())
834  {
835  //printf("item type=%s\n",item.typeAsString());
836  TemplateStructIntfPtr s = item.toStruct();
837  if (s)
838  {
839  TemplateVariant value = s->get(args.toString());
840  //printf("value type=%s\n",value.typeAsString());
841  if (value.toBool())
842  {
843  //printf("keeping it\n");
844  result->append(item);
845  }
846  else
847  {
848  //printf("Dropping it\n");
849  }
850  }
851  }
852  return TemplateVariant(std::static_pointer_cast<TemplateListIntf>(result));
853  }
854  }
855  return v;
856  }

引用了 TemplateList::alloc(), TemplateVariant::isList(), TemplateVariant::isString(), TemplateVariant::isValid(), TemplateVariant::toBool(), TemplateVariant::toList(), TemplateVariant::toString() , 以及 TemplateVariant::toStruct().


该类的文档由以下文件生成:
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
TemplateVariant::toString
QCString toString() const
Returns the variant as a string.
Definition: template.cpp:399
TemplateVariant::isValid
constexpr bool isValid() const
Returns TRUE if the variant holds a valid value, or FALSE otherwise
Definition: template.h:203
TemplateVariant::toBool
bool toBool() const
Returns the variant as a boolean.
Definition: template.cpp:367
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