Qt 4.8
Public Functions | List of all members
QPatternist::DurationDurationMathematician Class Reference

Performs arithmetics between DayTimeDuration and DayTimeDuration, or YearMonthDuration and YearMonthDuration. More...

#include <qatomicmathematicians_p.h>

Inheritance diagram for QPatternist::DurationDurationMathematician:
QPatternist::AtomicMathematician QPatternist::AtomicTypeVisitorResult QSharedData

Public Functions

virtual Item calculate (const Item &o1, const Operator op, const Item &o2, const QExplicitlySharedDataPointer< DynamicContext > &context) const
 
- Public Functions inherited from QPatternist::AtomicMathematician
virtual ~AtomicMathematician ()
 
- Public Functions inherited from QPatternist::AtomicTypeVisitorResult
 AtomicTypeVisitorResult ()
 
virtual ~AtomicTypeVisitorResult ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Additional Inherited Members

- Public Types inherited from QPatternist::AtomicMathematician
enum  Operator {
  Div = 1, IDiv = 2, Substract = 4, Mod = 8,
  Multiply = 16, Add = 32
}
 
typedef QFlags< OperatorOperators
 
typedef QExplicitlySharedDataPointer< AtomicMathematicianPtr
 
- Public Types inherited from QPatternist::AtomicTypeVisitorResult
typedef QExplicitlySharedDataPointer< AtomicTypeVisitorResultPtr
 
- Static Public Functions inherited from QPatternist::AtomicMathematician
static QString displayName (const AtomicMathematician::Operator op)
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Performs arithmetics between DayTimeDuration and DayTimeDuration, or YearMonthDuration and YearMonthDuration.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 153 of file qatomicmathematicians_p.h.

Functions

◆ calculate()

Item DurationDurationMathematician::calculate ( const Item o1,
const Operator  op,
const Item o2,
const QExplicitlySharedDataPointer< DynamicContext > &  context 
) const
virtual

Implements QPatternist::AtomicMathematician.

Definition at line 267 of file qatomicmathematicians.cpp.

271 {
272  const AbstractDuration::Ptr duration(o1.as<AbstractDuration>());
273  const AbstractDuration::Value op2 = o2.as<AbstractDuration>()->value();
274 
275  switch(op)
276  {
277  case Div:
278  return toItem(Decimal::fromValue(static_cast<xsDecimal>(duration->value()) / op2));
279  case Substract:
280  return duration->fromValue(duration->value() - op2);
281  case Add:
282  return duration->fromValue(duration->value() + op2);
283  default:
284  {
285  Q_ASSERT(false);
286  return Item(); /* Silence warning. */
287  }
288  }
289 }
Base class for classes implementing durations.
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
Item toItem(const QExplicitlySharedDataPointer< T > atomicValue)
Definition: qitem_p.h:431
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static Decimal::Ptr fromValue(const xsDecimal num)
Definition: qdecimal.cpp:59
qint64 Value
The amount in milli seconds.
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
TCastTarget * as() const
Definition: qitem_p.h:278

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