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

Performs arithmetics between two AbstractDateTime values. More...

#include <qatomicmathematicians_p.h>

Inheritance diagram for QPatternist::AbstractDateTimeMathematician:
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 two AbstractDateTime values.

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

Definition at line 235 of file qatomicmathematicians_p.h.

Functions

◆ calculate()

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

Implements QPatternist::AtomicMathematician.

Definition at line 338 of file qatomicmathematicians.cpp.

342 {
343  Q_ASSERT(op == Substract || op == Add);
344  QDateTime dt1(o1.as<AbstractDateTime>()->toDateTime());
345  QDateTime dt2(o2.as<AbstractDateTime>()->toDateTime());
346 
347  const int diff = op == Add ? dt1.secsTo(dt2) : dt2.secsTo(dt1);
348 
349  return toItem(DayTimeDuration::fromSeconds(diff));
350 }
Base class for classes implementing values related to time, date or both.
Item toItem(const QExplicitlySharedDataPointer< T > atomicValue)
Definition: qitem_p.h:431
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static DayTimeDuration::Ptr fromSeconds(const SecondCountProperty secs, const MSecondProperty msecs=0)
static Bigint * diff(Bigint *a, Bigint *b)
const QDateTime & toDateTime() const
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
TCastTarget * as() const
Definition: qitem_p.h:278

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