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

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

Static Public Member Functions

static int variantIntValue (const TemplateVariant &v, bool &isInt)
 
static TemplateVariant apply (const TemplateVariant &v, const TemplateVariant &arg)
 

Detailed Description

The implementation of the "add" filter.

Definition at line 588 of file template.cpp.

Member Function Documentation

static TemplateVariant FilterAdd::apply ( const TemplateVariant v,
const TemplateVariant arg 
)
inlinestatic

Definition at line 600 of file template.cpp.

References TemplateVariant::isValid(), TemplateVariant::String, TemplateVariant::toString(), TemplateVariant::type(), and variantIntValue().

{
if (!v.isValid())
{
return arg;
}
bool lhsIsInt;
int lhsValue = variantIntValue(v,lhsIsInt);
bool rhsIsInt;
int rhsValue = variantIntValue(arg,rhsIsInt);
if (lhsIsInt && rhsIsInt)
{
return lhsValue+rhsValue;
}
{
return TemplateVariant(v.toString() + arg.toString());
}
else
{
return v;
}
}
static int FilterAdd::variantIntValue ( const TemplateVariant v,
bool &  isInt 
)
inlinestatic

Definition at line 591 of file template.cpp.

References TemplateVariant::Integer, TemplateVariant::String, TemplateVariant::toInt(), TemplateVariant::toString(), and TemplateVariant::type().

Referenced by apply().

{
if (!isInt && v.type()==TemplateVariant::String)
{
return v.toString().toInt(&isInt);
}
return isInt ? v.toInt() : 0;
}

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