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 581 of file template.cpp.

Member Function Documentation

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

Definition at line 593 of file template.cpp.

594  {
595  if (!v.isValid())
596  {
597  return arg;
598  }
599  bool lhsIsInt;
600  int lhsValue = variantIntValue(v,lhsIsInt);
601  bool rhsIsInt;
602  int rhsValue = variantIntValue(arg,rhsIsInt);
603  if (lhsIsInt && rhsIsInt)
604  {
605  return lhsValue+rhsValue;
606  }
608  {
609  return TemplateVariant(v.toString() + arg.toString());
610  }
611  else
612  {
613  return v;
614  }
615  }
QCString toString() const
Definition: template.h:232
bool isValid() const
Definition: template.h:161
Variant type which can hold one value of a fixed set of types.
Definition: template.h:90
static int variantIntValue(const TemplateVariant &v, bool &isInt)
Definition: template.cpp:584
Type type() const
Definition: template.h:142
static int FilterAdd::variantIntValue ( const TemplateVariant v,
bool isInt 
)
inlinestatic

Definition at line 584 of file template.cpp.

585  {
586  isInt = v.type()==TemplateVariant::Integer;
587  if (!isInt && v.type()==TemplateVariant::String)
588  {
589  return v.toString().toInt(&isInt);
590  }
591  return isInt ? v.toInt() : 0;
592  }
int toInt() const
Definition: template.cpp:222
QCString toString() const
Definition: template.h:232
int toInt(bool *ok=0) const
Definition: qcstring.cpp:439
Type type() const
Definition: template.h:142

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